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));
}
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;
}
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();
}
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();
}
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);
}
Aggregations