use of com.alliander.osgp.dto.valueobjects.DeviceFixedIpDto in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850GetConfigurationCommand method getConfigurationFromDevice.
public ConfigurationDto getConfigurationFromDevice(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final Ssld ssld, final Iec61850Mapper mapper) throws ProtocolAdapterException {
final Function<ConfigurationDto> function = new Function<ConfigurationDto>() {
@Override
public ConfigurationDto apply(final DeviceMessageLog deviceMessageLog) throws Exception {
// Keeping the hardcoded values and values that aren't fetched
// from the device out of the Function.
// Hardcoded (not supported)
final MeterTypeDto meterType = MeterTypeDto.AUX;
// Hardcoded (not supported)
final Integer shortTermHistoryIntervalMinutes = 15;
// Hardcoded (not supported)
final LinkTypeDto preferredLinkType = LinkTypeDto.ETHERNET;
// Hardcoded (not supported)
final Integer longTermHistoryInterval = 1;
// Hardcoded (not supported)
final LongTermIntervalTypeDto longTermHistoryIntervalType = LongTermIntervalTypeDto.DAYS;
final List<RelayMapDto> relayMaps = new ArrayList<>();
for (final DeviceOutputSetting deviceOutputSetting : ssld.getOutputSettings()) {
Iec61850GetConfigurationCommand.this.checkRelayType(iec61850Client, deviceConnection, deviceOutputSetting, deviceMessageLog);
relayMaps.add(mapper.map(deviceOutputSetting, RelayMapDto.class));
}
final RelayConfigurationDto relayConfiguration = new RelayConfigurationDto(relayMaps);
// PSLD specific => just sending null so it'll be ignored
final DaliConfigurationDto daliConfiguration = null;
// getting the software configuration values
LOGGER.info("Reading the software configuration values");
final NodeContainer softwareConfiguration = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SOFTWARE_CONFIGURATION, Fc.CF);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), softwareConfiguration.getFcmodelNode());
String lightTypeValue = softwareConfiguration.getString(SubDataAttribute.LIGHT_TYPE);
// Fix for Kaifa bug KI-31
if (lightTypeValue == null || lightTypeValue.isEmpty()) {
lightTypeValue = "RELAY";
}
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SOFTWARE_CONFIGURATION, Fc.CF, SubDataAttribute.LIGHT_TYPE, lightTypeValue);
final LightTypeDto lightType = LightTypeDto.valueOf(lightTypeValue);
final short astroGateSunRiseOffset = softwareConfiguration.getShort(SubDataAttribute.ASTRONOMIC_SUNRISE_OFFSET).getValue();
final short astroGateSunSetOffset = softwareConfiguration.getShort(SubDataAttribute.ASTRONOMIC_SUNSET_OFFSET).getValue();
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SOFTWARE_CONFIGURATION, Fc.CF, SubDataAttribute.ASTRONOMIC_SUNRISE_OFFSET, Short.toString(astroGateSunRiseOffset));
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SOFTWARE_CONFIGURATION, Fc.CF, SubDataAttribute.ASTRONOMIC_SUNSET_OFFSET, Short.toString(astroGateSunSetOffset));
final ConfigurationDto configuration = new ConfigurationDto(lightType, daliConfiguration, relayConfiguration, shortTermHistoryIntervalMinutes, preferredLinkType, meterType, longTermHistoryInterval, longTermHistoryIntervalType);
// getting the registration configuration values
LOGGER.info("Reading the registration configuration values");
final NodeContainer registration = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.REGISTRATION, Fc.CF);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), registration.getFcmodelNode());
final String serverAddress = registration.getString(SubDataAttribute.SERVER_ADDRESS);
final int serverPort = registration.getInteger(SubDataAttribute.SERVER_PORT).getValue();
configuration.setOsgpIpAddress(serverAddress);
configuration.setOsgpPortNumber(serverPort);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.REGISTRATION, Fc.CF, SubDataAttribute.SERVER_ADDRESS, serverAddress);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.REGISTRATION, Fc.CF, SubDataAttribute.SERVER_PORT, Integer.toString(serverPort));
// getting the IP configuration values
LOGGER.info("Reading the IP configuration values");
final NodeContainer ipConfiguration = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.IP_CONFIGURATION, Fc.CF);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), ipConfiguration.getFcmodelNode());
final String deviceFixedIpAddress = ipConfiguration.getString(SubDataAttribute.IP_ADDRESS);
final String deviceFixedIpNetmask = ipConfiguration.getString(SubDataAttribute.NETMASK);
final String deviceFixedIpGateway = ipConfiguration.getString(SubDataAttribute.GATEWAY);
final boolean isDhcpEnabled = ipConfiguration.getBoolean(SubDataAttribute.ENABLE_DHCP).getValue();
final DeviceFixedIpDto deviceFixedIp = new DeviceFixedIpDto(deviceFixedIpAddress, deviceFixedIpNetmask, deviceFixedIpGateway);
configuration.setDeviceFixedIp(deviceFixedIp);
configuration.setDhcpEnabled(isDhcpEnabled);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.IP_CONFIGURATION, Fc.CF, SubDataAttribute.IP_ADDRESS, deviceFixedIpAddress);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.IP_CONFIGURATION, Fc.CF, SubDataAttribute.NETMASK, deviceFixedIpNetmask);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.IP_CONFIGURATION, Fc.CF, SubDataAttribute.GATEWAY, deviceFixedIpGateway);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.IP_CONFIGURATION, Fc.CF, SubDataAttribute.ENABLE_DHCP, Boolean.toString(isDhcpEnabled));
// setting the software configuration values
configuration.setAstroGateSunRiseOffset((int) astroGateSunRiseOffset);
configuration.setAstroGateSunSetOffset((int) astroGateSunSetOffset);
// getting the clock configuration values
LOGGER.info("Reading the clock configuration values");
final NodeContainer clock = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), clock.getFcmodelNode());
final int timeSyncFrequency = clock.getUnsignedShort(SubDataAttribute.TIME_SYNC_FREQUENCY).getValue();
final boolean automaticSummerTimingEnabled = clock.getBoolean(SubDataAttribute.AUTOMATIC_SUMMER_TIMING_ENABLED).getValue();
final String summerTimeDetails = clock.getString(SubDataAttribute.SUMMER_TIME_DETAILS);
final String winterTimeDetails = clock.getString(SubDataAttribute.WINTER_TIME_DETAILS);
configuration.setTimeSyncFrequency(timeSyncFrequency);
configuration.setAutomaticSummerTimingEnabled(automaticSummerTimingEnabled);
configuration.setSummerTimeDetails(new DaylightSavingTimeTransition(TIME_ZONE_AMSTERDAM, summerTimeDetails).getDateTimeForNextTransition().toDateTime(DateTimeZone.UTC));
configuration.setWinterTimeDetails(new DaylightSavingTimeTransition(TIME_ZONE_AMSTERDAM, winterTimeDetails).getDateTimeForNextTransition().toDateTime(DateTimeZone.UTC));
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.TIME_SYNC_FREQUENCY, Integer.toString(timeSyncFrequency));
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.AUTOMATIC_SUMMER_TIMING_ENABLED, Boolean.toString(automaticSummerTimingEnabled));
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.SUMMER_TIME_DETAILS, summerTimeDetails);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.WINTER_TIME_DETAILS, winterTimeDetails);
// getting the TLS configuration values
// LOGGER.info("Reading the TLS configuration values");
// final NodeContainer tls =
// deviceConnection.getFcModelNode(LogicalDevice.LIGHTING,
// LogicalNode.STREET_LIGHT_CONFIGURATION,
// DataAttribute.TLS_CONFIGURATION, Fc.CF);
//
// iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(),
// tls.getFcmodelNode());
//
// final int tlsPortNumber = (int)
// tls.getUnsignedInteger(SubDataAttribute.TLS_PORT_NUMBER).getValue();
// final boolean tlsEnabled =
// tls.getBoolean(SubDataAttribute.TLS_ENABLED).getValue();
// final String commonName =
// tls.getString(SubDataAttribute.TLS_COMMON_NAME);
//
// configuration.setTlsPortNumber(tlsPortNumber);
// configuration.setTlsEnabled(tlsEnabled);
// configuration.setCommonNameString(commonName);
DeviceMessageLoggingService.logMessage(deviceMessageLog, deviceConnection.getDeviceIdentification(), deviceConnection.getOrganisationIdentification(), false);
return configuration;
}
};
return iec61850Client.sendCommandWithRetry(function, "GetConfiguration", deviceConnection.getDeviceIdentification());
}
use of com.alliander.osgp.dto.valueobjects.DeviceFixedIpDto in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850SetConfigurationCommand method setConfigurationOnDevice.
public void setConfigurationOnDevice(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final ConfigurationDto configuration) throws ProtocolAdapterException {
final Function<Void> function = new Function<Void>() {
@Override
public Void apply(final DeviceMessageLog deviceMessageLog) throws Exception {
if (configuration.getRelayConfiguration() != null && configuration.getRelayConfiguration().getRelayMap() != null) {
final List<RelayMapDto> relayMaps = configuration.getRelayConfiguration().getRelayMap();
for (final RelayMapDto relayMap : relayMaps) {
final Integer internalIndex = relayMap.getAddress();
final RelayTypeDto relayType = relayMap.getRelayType();
final LogicalNode logicalNode = LogicalNode.getSwitchComponentByIndex(internalIndex);
final NodeContainer switchType = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, logicalNode, DataAttribute.SWITCH_TYPE, Fc.CO);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), switchType.getFcmodelNode());
final NodeContainer operation = switchType.getChild(SubDataAttribute.OPERATION);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), operation.getFcmodelNode());
final BdaInt8 ctlVal = operation.getByte(SubDataAttribute.CONTROL_VALUE);
final byte switchTypeValue = (byte) (RelayTypeDto.LIGHT.equals(relayType) ? SWITCH_TYPE_LIGHT : SWITCH_TYPE_TARIFF);
LOGGER.info("Updating Switch for internal index {} to {} ({})", internalIndex, switchTypeValue, relayType);
ctlVal.setValue(switchTypeValue);
operation.write();
deviceMessageLog.addVariable(logicalNode, DataAttribute.SWITCH_TYPE, Fc.CO, SubDataAttribute.OPERATION, SubDataAttribute.CONTROL_VALUE, Byte.toString(switchTypeValue));
}
}
// don't read the values for no reason.
if (!(configuration.getOsgpIpAddres() == null && configuration.getOsgpPortNumber() == null)) {
final NodeContainer registration = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.REGISTRATION, Fc.CF);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), registration.getFcmodelNode());
if (configuration.getOsgpIpAddres() != null) {
LOGGER.info("Updating OspgIpAddress to {}", configuration.getOsgpIpAddres());
registration.writeString(SubDataAttribute.SERVER_ADDRESS, configuration.getOsgpIpAddres());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.REGISTRATION, Fc.CF, SubDataAttribute.SERVER_ADDRESS, configuration.getOsgpIpAddres());
}
if (configuration.getOsgpPortNumber() != null) {
LOGGER.info("Updating OsgpPortNumber to {}", configuration.getOsgpPortNumber());
registration.writeInteger(SubDataAttribute.SERVER_PORT, configuration.getOsgpPortNumber());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.REGISTRATION, Fc.CF, SubDataAttribute.SERVER_PORT, configuration.getOsgpPortNumber().toString());
}
}
// that we don't read the values for no reason.
if (!(configuration.getAstroGateSunRiseOffset() == null && configuration.getAstroGateSunSetOffset() == null && configuration.getLightType() == null)) {
final NodeContainer softwareConfiguration = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SOFTWARE_CONFIGURATION, Fc.CF);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), softwareConfiguration.getFcmodelNode());
if (configuration.getAstroGateSunRiseOffset() != null) {
LOGGER.info("Updating AstroGateSunRiseOffset to {}", configuration.getAstroGateSunRiseOffset());
softwareConfiguration.writeShort(SubDataAttribute.ASTRONOMIC_SUNRISE_OFFSET, configuration.getAstroGateSunRiseOffset().shortValue());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SOFTWARE_CONFIGURATION, Fc.CF, SubDataAttribute.ASTRONOMIC_SUNRISE_OFFSET, Short.toString(configuration.getAstroGateSunRiseOffset().shortValue()));
}
if (configuration.getAstroGateSunSetOffset() != null) {
LOGGER.info("Updating AstroGateSunSetOffset to {}", configuration.getAstroGateSunSetOffset());
softwareConfiguration.writeShort(SubDataAttribute.ASTRONOMIC_SUNSET_OFFSET, configuration.getAstroGateSunSetOffset().shortValue());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SOFTWARE_CONFIGURATION, Fc.CF, SubDataAttribute.ASTRONOMIC_SUNSET_OFFSET, Short.toString(configuration.getAstroGateSunSetOffset().shortValue()));
}
if (configuration.getLightType() != null) {
LOGGER.info("Updating LightType to {}", configuration.getLightType());
softwareConfiguration.writeString(SubDataAttribute.LIGHT_TYPE, configuration.getLightType().name());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SOFTWARE_CONFIGURATION, Fc.CF, SubDataAttribute.LIGHT_TYPE, configuration.getLightType().name());
}
}
// don't read the values for no reason.
if (!(configuration.getTimeSyncFrequency() == null && configuration.isAutomaticSummerTimingEnabled() == null && configuration.getSummerTimeDetails() == null && configuration.getWinterTimeDetails() == null)) {
final NodeContainer clock = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), clock.getFcmodelNode());
if (configuration.getTimeSyncFrequency() != null) {
LOGGER.info("Updating TimeSyncFrequency to {}", configuration.getTimeSyncFrequency());
clock.writeUnsignedShort(SubDataAttribute.TIME_SYNC_FREQUENCY, configuration.getTimeSyncFrequency());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.TIME_SYNC_FREQUENCY, Integer.toString(configuration.getTimeSyncFrequency()));
}
if (configuration.isAutomaticSummerTimingEnabled() != null) {
LOGGER.info("Updating AutomaticSummerTimingEnabled to {}", configuration.isAutomaticSummerTimingEnabled());
clock.writeBoolean(SubDataAttribute.AUTOMATIC_SUMMER_TIMING_ENABLED, configuration.isAutomaticSummerTimingEnabled());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.AUTOMATIC_SUMMER_TIMING_ENABLED, Boolean.toString(configuration.isAutomaticSummerTimingEnabled()));
}
/*
* Perform some effort to create dstBegT/dstEndt information
* based on provided DateTime values. This will work in a
* number of cases, but to be able to do this accurately in
* an international context, DST transition times will
* probably have to be based on information about the
* time-zone the device is operating in, instead of a
* particular DateTime provided by the caller without
* further information.
*/
final DaylightSavingTimeTransition.DstTransitionFormat dstFormatMwd = DaylightSavingTimeTransition.DstTransitionFormat.DAY_OF_WEEK_OF_MONTH;
final DateTime summerTimeDetails = configuration.getSummerTimeDetails();
final DateTime winterTimeDetails = configuration.getWinterTimeDetails();
if (summerTimeDetails != null) {
final String mwdValueForBeginOfDst = DaylightSavingTimeTransition.forDateTimeAccordingToFormat(summerTimeDetails, dstFormatMwd).getTransition();
LOGGER.info("Updating DstBeginTime to {} based on SummerTimeDetails {}", mwdValueForBeginOfDst, summerTimeDetails);
clock.writeString(SubDataAttribute.SUMMER_TIME_DETAILS, mwdValueForBeginOfDst);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.SUMMER_TIME_DETAILS, mwdValueForBeginOfDst);
}
if (winterTimeDetails != null) {
final String mwdValueForEndOfDst = DaylightSavingTimeTransition.forDateTimeAccordingToFormat(winterTimeDetails, dstFormatMwd).getTransition();
LOGGER.info("Updating DstEndTime to {} based on WinterTimeDetails {}", mwdValueForEndOfDst, winterTimeDetails);
clock.writeString(SubDataAttribute.WINTER_TIME_DETAILS, mwdValueForEndOfDst);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF, SubDataAttribute.WINTER_TIME_DETAILS, mwdValueForEndOfDst);
}
}
// don't read the values for no reason.
if (!(configuration.isDhcpEnabled() == null && configuration.getDeviceFixedIp() == null)) {
final NodeContainer ipConfiguration = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.IP_CONFIGURATION, Fc.CF);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), ipConfiguration.getFcmodelNode());
if (configuration.isDhcpEnabled() != null) {
LOGGER.info("Updating DhcpEnabled to {}", configuration.isDhcpEnabled());
ipConfiguration.writeBoolean(SubDataAttribute.ENABLE_DHCP, configuration.isDhcpEnabled());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.IP_CONFIGURATION, Fc.CF, SubDataAttribute.ENABLE_DHCP, Boolean.toString(configuration.isDhcpEnabled()));
}
// All values in DeviceFixedIpDto are non-nullable, so no
// null-checks are needed.
final DeviceFixedIpDto deviceFixedIp = configuration.getDeviceFixedIp();
LOGGER.info("Updating deviceFixedIpAddress to {}", configuration.getDeviceFixedIp().getIpAddress());
ipConfiguration.writeString(SubDataAttribute.IP_ADDRESS, deviceFixedIp.getIpAddress());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.IP_CONFIGURATION, Fc.CF, SubDataAttribute.IP_ADDRESS, deviceFixedIp.getIpAddress());
LOGGER.info("Updating deviceFixedIpNetmask to {}", configuration.getDeviceFixedIp().getNetMask());
ipConfiguration.writeString(SubDataAttribute.NETMASK, deviceFixedIp.getNetMask());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.IP_CONFIGURATION, Fc.CF, SubDataAttribute.NETMASK, deviceFixedIp.getNetMask());
LOGGER.info("Updating deviceFixIpGateway to {}", configuration.getDeviceFixedIp().getGateWay());
ipConfiguration.writeString(SubDataAttribute.GATEWAY, deviceFixedIp.getGateWay());
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.IP_CONFIGURATION, Fc.CF, SubDataAttribute.GATEWAY, deviceFixedIp.getGateWay());
}
// Checking to see if all TLS values are null, so that we
// don't read the values for no reason.
// if (!(configuration.getCommonNameString() == null &&
// configuration.isTlsEnabled() == null && configuration
// .getTlsPortNumber() == null)) {
//
// final NodeContainer tls =
// deviceConnection.getFcModelNode(LogicalDevice.LIGHTING,
// LogicalNode.STREET_LIGHT_CONFIGURATION,
// DataAttribute.TLS_CONFIGURATION, Fc.CF);
// iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(),
// tls.getFcmodelNode());
//
// if (configuration.getTlsPortNumber() != null) {
// LOGGER.info("Updating tlsPortNumber to {}",
// configuration.getTlsPortNumber());
// tls.writeUnsignedInteger(SubDataAttribute.TLS_PORT_NUMBER,
// configuration.getTlsPortNumber());
// }
//
// if (configuration.isTlsEnabled() != null) {
// LOGGER.info("Updating tlsEnabled to {}",
// configuration.isTlsEnabled());
// tls.writeBoolean(SubDataAttribute.TLS_ENABLED,
// configuration.isTlsEnabled());
// }
//
// if (configuration.getCommonNameString() != null) {
// LOGGER.info("Updating commonNameString to {}",
// configuration.getCommonNameString());
// tls.writeString(SubDataAttribute.TLS_COMMON_NAME,
// configuration.getCommonNameString());
// }
// }
DeviceMessageLoggingService.logMessage(deviceMessageLog, deviceConnection.getDeviceIdentification(), deviceConnection.getOrganisationIdentification(), false);
return null;
}
};
iec61850Client.sendCommandWithRetry(function, "SetConfiguration", deviceConnection.getDeviceIdentification());
}
use of com.alliander.osgp.dto.valueobjects.DeviceFixedIpDto in project Protocol-Adapter-OSLP by OSGP.
the class OslpGetConfigurationResponseToConfigurationConverter method convert.
@Override
public ConfigurationDto convert(final Oslp.GetConfigurationResponse source, final Type<? extends ConfigurationDto> destinationType, final MappingContext context) {
// @formatter:off
// Convert the required values for the constructor of Configuration.
final LightTypeDto lightType = source.hasLightType() ? this.mapperFacade.map(source.getLightType(), LightTypeDto.class) : null;
final DaliConfigurationDto daliConfiguration = source.hasDaliConfiguration() ? this.mapperFacade.map(source.getDaliConfiguration(), DaliConfigurationDto.class) : null;
final Integer shortTermHistoryIntervalMinutes = source.hasShortTermHistoryIntervalMinutes() ? this.mapperFacade.map(source.getShortTermHistoryIntervalMinutes(), Integer.class) : null;
final RelayConfigurationDto relayConfiguration = source.hasRelayConfiguration() ? this.mapperFacade.map(source.getRelayConfiguration(), RelayConfigurationDto.class) : new RelayConfigurationDto(new ArrayList<RelayMapDto>());
final LinkTypeDto preferredLinkType = source.hasPreferredLinkType() && !source.getPreferredLinkType().equals(Oslp.LinkType.LINK_NOT_SET) ? this.mapperFacade.map(source.getPreferredLinkType(), LinkTypeDto.class) : null;
final MeterTypeDto meterType = source.hasMeterType() && !source.getMeterType().equals(Oslp.MeterType.MT_NOT_SET) ? this.mapperFacade.map(source.getMeterType(), MeterTypeDto.class) : null;
final Integer longTermHistoryInterval = source.hasLongTermHistoryInterval() ? this.mapperFacade.map(source.getLongTermHistoryInterval(), Integer.class) : null;
final LongTermIntervalTypeDto longTermHistoryIntervalType = source.hasLongTermHistoryIntervalType() && !source.getLongTermHistoryIntervalType().equals(Oslp.LongTermIntervalType.LT_INT_NOT_SET) ? this.mapperFacade.map(source.getLongTermHistoryIntervalType(), LongTermIntervalTypeDto.class) : null;
final ConfigurationDto configuration = ConfigurationDto.newBuilder().withLightType(lightType).withDaliConfiguration(daliConfiguration).withRelayConfiguration(relayConfiguration).withShortTermHistoryIntervalMinutes(shortTermHistoryIntervalMinutes).withPreferredLinkType(preferredLinkType).withMeterType(meterType).withLongTermHistoryInterval(longTermHistoryInterval).withLongTermHysteryIntervalType(longTermHistoryIntervalType).build();
// Set the optional values using the set() functions.
configuration.setTimeSyncFrequency(source.getTimeSyncFrequency());
if (source.getDeviceFixIpValue() != null && !source.getDeviceFixIpValue().isEmpty()) {
final String ipAddress = this.convertIpAddress(source.getDeviceFixIpValue());
final String netMask = this.convertIpAddress(source.getNetMask());
final String gateWay = this.convertIpAddress(source.getGateWay());
configuration.setDeviceFixedIp(new DeviceFixedIpDto(ipAddress, netMask, gateWay));
}
configuration.setDhcpEnabled(source.getIsDhcpEnabled());
configuration.setCommunicationTimeout(source.getCommunicationTimeout());
configuration.setCommunicationNumberOfRetries(source.getCommunicationNumberOfRetries());
configuration.setCommunicationPauseTimeBetweenConnectionTrials(source.getCommunicationPauseTimeBetweenConnectionTrials());
if (source.getOspgIpAddress() != null && !source.getOspgIpAddress().isEmpty()) {
configuration.setOsgpIpAddress(this.convertIpAddress(source.getOspgIpAddress()));
}
if (source.getOsgpPortNumber() > 0 && source.getOsgpPortNumber() < 65536) {
configuration.setOsgpPortNumber(source.getOsgpPortNumber());
}
configuration.setTestButtonEnabled(source.getIsTestButtonEnabled());
configuration.setAutomaticSummerTimingEnabled(source.getIsAutomaticSummerTimingEnabled());
configuration.setAstroGateSunRiseOffset(source.getAstroGateSunRiseOffset());
configuration.setAstroGateSunSetOffset(source.getAstroGateSunSetOffset());
configuration.setSwitchingDelays(source.getSwitchingDelayList());
if (source.getRelayLinkingList() != null) {
configuration.setRelayLinking(this.mapperFacade.mapAsList(source.getRelayLinkingList(), RelayMatrixDto.class));
}
configuration.setRelayRefreshing(source.getRelayRefreshing());
final DateTime summerTimeDetails = this.convertSummerTimeWinterTimeDetails(source.getSummerTimeDetails());
configuration.setSummerTimeDetails(summerTimeDetails);
final DateTime winterTimeDetails = this.convertSummerTimeWinterTimeDetails(source.getWinterTimeDetails());
configuration.setWinterTimeDetails(winterTimeDetails);
return configuration;
// @formatter:on
}
Aggregations