Search in sources :

Example 11 with Iec60870Device

use of org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device in project open-smart-grid-platform by OSGP.

the class ConnectionSteps method whenIConnectToIEC60870Device.

@When("I connect to IEC60870 device {string}")
public void whenIConnectToIEC60870Device(final String deviceIdentification) throws Exception {
    LOGGER.debug("When I connect to IEC60870 device {}", deviceIdentification);
    final Iec60870Device device = this.iec60870DeviceSteps.getDevice(deviceIdentification).orElseThrow(() -> new Exception("Device not found"));
    final DeviceType deviceType = device.getDeviceType();
    final String connectionDeviceIdentification = device.getConnectionDeviceIdentification();
    this.connectionParameters = this.initConnectionParameters(connectionDeviceIdentification);
    this.connectionEventListener = new ClientConnectionEventListener.Builder().withDeviceIdentification(connectionDeviceIdentification).withClientAsduHandlerRegistry(this.clientAsduHandlerRegistry).withClientConnectionCache(this.connectionCacheSpy).withLoggingService(this.loggingService).withLogItemFactory(this.logItemFactory).withResponseMetadata(this.initResponseMetadata(deviceIdentification, deviceType)).withResponseMetadataFactory(this.responseMetadataFactory).build();
    when(this.clientMock.connect(any(ConnectionParameters.class), any(ConnectionEventListener.class))).thenReturn(new DeviceConnection(this.connection, this.connectionParameters));
}
Also used : DeviceType(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceType) ConnectionParameters(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ConnectionParameters) DeviceConnection(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceConnection) Iec60870Device(org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device) ConnectionFailureException(org.opensmartgridplatform.shared.exceptionhandling.ConnectionFailureException) ClientConnectionAlreadyInCacheException(org.opensmartgridplatform.adapter.protocol.iec60870.domain.exceptions.ClientConnectionAlreadyInCacheException) ClientConnectionEventListener(org.opensmartgridplatform.adapter.protocol.iec60870.domain.services.ClientConnectionEventListener) ClientConnectionEventListener(org.opensmartgridplatform.adapter.protocol.iec60870.domain.services.ClientConnectionEventListener) ConnectionEventListener(org.openmuc.j60870.ConnectionEventListener) When(io.cucumber.java.en.When)

Example 12 with Iec60870Device

use of org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device in project open-smart-grid-platform by OSGP.

the class Iec60870LightMeasurementRtuDeviceCreator method apply.

@Override
public Iec60870Device apply(final Map<String, String> settings) {
    final Iec60870Device device = new Iec60870Device(this.deviceIdentification(settings), this.deviceType());
    device.setPort(this.port(settings));
    device.setCommonAddress(this.commonAddress(settings));
    return device;
}
Also used : Iec60870Device(org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device)

Example 13 with Iec60870Device

use of org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device in project open-smart-grid-platform by OSGP.

the class OsgpCoreResponseSteps method protocolResponseMessage.

private ProtocolResponseMessage protocolResponseMessage(final Map<String, String> map) {
    final String deviceIdentification = map.get("device_identification");
    final Iec60870Device device = this.deviceSteps.getDevice(deviceIdentification).orElse(null);
    final DomainInfo domainInfo = DomainInfoFactory.forDeviceType(device.getDeviceType());
    final MessageMetadata deviceMessageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceIdentification).withMessageType(MessageType.GET_LIGHT_SENSOR_STATUS.name()).withDomain(domainInfo.getDomain()).withDomainVersion(domainInfo.getDomainVersion()).build();
    return ProtocolResponseMessage.newBuilder().messageMetadata(deviceMessageMetadata).dataObject(new LightSensorStatusDto(LightSensorStatusTypeDto.valueOf(map.get("status")))).result(ResponseMessageResultType.OK).build();
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) DomainInfo(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DomainInfo) Iec60870Device(org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device) LightSensorStatusDto(org.opensmartgridplatform.dto.valueobjects.LightSensorStatusDto)

Example 14 with Iec60870Device

use of org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device in project open-smart-grid-platform by OSGP.

the class OsgpCoreResponseSteps method connectResponseMessage.

private ProtocolResponseMessage connectResponseMessage(final Map<String, String> map) {
    final String deviceIdentification = map.get("device_identification");
    final Iec60870Device device = this.deviceSteps.getDevice(deviceIdentification).orElse(null);
    final DomainInfo domainInfo = DomainInfoFactory.forDeviceType(device.getDeviceType());
    final MessageMetadata deviceMessageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceIdentification).withMessageType(MessageType.CONNECT.name()).withDomain(domainInfo.getDomain()).withDomainVersion(domainInfo.getDomainVersion()).build();
    return ProtocolResponseMessage.newBuilder().messageMetadata(deviceMessageMetadata).result(ResponseMessageResultType.OK).build();
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) DomainInfo(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DomainInfo) Iec60870Device(org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device)

Example 15 with Iec60870Device

use of org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device in project open-smart-grid-platform by OSGP.

the class Iec60870DeviceSteps method anIec60870DeviceWithIdentification.

private void anIec60870DeviceWithIdentification(final String deviceIdentification) {
    final Iec60870Device device = Iec60870DeviceFactory.createDefaultWith(deviceIdentification);
    this.deviceIsKnownInTheRepository(device);
}
Also used : Iec60870Device(org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device)

Aggregations

Iec60870Device (org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device)21 Test (org.junit.jupiter.api.Test)6 RequestMetadata (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.RequestMetadata)4 ResponseMetadata (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ResponseMetadata)4 ConnectionEventListener (org.openmuc.j60870.ConnectionEventListener)3 ClientConnectionAlreadyInCacheException (org.opensmartgridplatform.adapter.protocol.iec60870.domain.exceptions.ClientConnectionAlreadyInCacheException)2 ConnectionParameters (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ConnectionParameters)2 DomainInfo (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DomainInfo)2 MeasurementReportDto (org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto)2 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)2 Given (io.cucumber.java.en.Given)1 When (io.cucumber.java.en.When)1 ClientConnectionEventListener (org.opensmartgridplatform.adapter.protocol.iec60870.domain.services.ClientConnectionEventListener)1 DeviceConnection (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceConnection)1 DeviceType (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceType)1 LightSensorStatusDto (org.opensmartgridplatform.dto.valueobjects.LightSensorStatusDto)1 ConnectionFailureException (org.opensmartgridplatform.shared.exceptionhandling.ConnectionFailureException)1