Search in sources :

Example 1 with LightTypeDto

use of com.alliander.osgp.dto.valueobjects.LightTypeDto 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());
}
Also used : LinkTypeDto(com.alliander.osgp.dto.valueobjects.LinkTypeDto) DaliConfigurationDto(com.alliander.osgp.dto.valueobjects.DaliConfigurationDto) LightTypeDto(com.alliander.osgp.dto.valueobjects.LightTypeDto) DeviceFixedIpDto(com.alliander.osgp.dto.valueobjects.DeviceFixedIpDto) ArrayList(java.util.ArrayList) MeterTypeDto(com.alliander.osgp.dto.valueobjects.MeterTypeDto) DeviceOutputSetting(com.alliander.osgp.core.db.api.iec61850.entities.DeviceOutputSetting) NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer) LongTermIntervalTypeDto(com.alliander.osgp.dto.valueobjects.LongTermIntervalTypeDto) Function(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.Function) DaylightSavingTimeTransition(com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DaylightSavingTimeTransition) DeviceMessageLog(com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) ConfigurationDto(com.alliander.osgp.dto.valueobjects.ConfigurationDto) DaliConfigurationDto(com.alliander.osgp.dto.valueobjects.DaliConfigurationDto) RelayConfigurationDto(com.alliander.osgp.dto.valueobjects.RelayConfigurationDto) RelayMapDto(com.alliander.osgp.dto.valueobjects.RelayMapDto) RelayConfigurationDto(com.alliander.osgp.dto.valueobjects.RelayConfigurationDto)

Example 2 with LightTypeDto

use of com.alliander.osgp.dto.valueobjects.LightTypeDto in project Protocol-Adapter-OSLP by OSGP.

the class OslpDeviceService method handleOslpResponseGetStatus.

private void handleOslpResponseGetStatus(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
    this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
    this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
    DeviceStatusDto deviceStatus = null;
    if (oslpResponse.getPayloadMessage().hasGetStatusResponse()) {
        final Oslp.GetStatusResponse getStatusResponse = oslpResponse.getPayloadMessage().getGetStatusResponse();
        final Oslp.Status oslpStatus = getStatusResponse.getStatus();
        if (oslpStatus == Oslp.Status.OK) {
            // Required properties.
            final List<LightValueDto> lightValues = this.mapper.mapAsList(getStatusResponse.getValueList(), LightValueDto.class);
            final LinkTypeDto preferredType = getStatusResponse.getPreferredLinktype().equals(Oslp.LinkType.LINK_NOT_SET) ? null : this.mapper.map(getStatusResponse.getPreferredLinktype(), LinkTypeDto.class);
            final LinkTypeDto actualLinkType = getStatusResponse.getActualLinktype().equals(Oslp.LinkType.LINK_NOT_SET) ? null : this.mapper.map(getStatusResponse.getActualLinktype(), LinkTypeDto.class);
            final LightTypeDto lightType = getStatusResponse.getLightType().equals(Oslp.LightType.LT_NOT_SET) ? null : this.mapper.map(getStatusResponse.getLightType(), LightTypeDto.class);
            final int eventNotificationMask = getStatusResponse.getEventNotificationMask();
            deviceStatus = new DeviceStatusDto(lightValues, preferredType, actualLinkType, lightType, eventNotificationMask);
            // Optional properties.
            if (getStatusResponse.hasBootLoaderVersion()) {
                deviceStatus.setBootLoaderVersion(getStatusResponse.getBootLoaderVersion());
            }
            if (getStatusResponse.getCurrentConfigurationBackUsed() != null && getStatusResponse.getCurrentConfigurationBackUsed().toByteArray().length == 1) {
                deviceStatus.setCurrentConfigurationBackUsed(this.convertCurrentConfigurationBankUsed(getStatusResponse.getCurrentConfigurationBackUsed()));
            }
            if (getStatusResponse.hasCurrentIp()) {
                deviceStatus.setCurrentIp(getStatusResponse.getCurrentIp());
            }
            if (getStatusResponse.hasCurrentTime()) {
                deviceStatus.setCurrentTime(getStatusResponse.getCurrentTime());
            }
            if (getStatusResponse.hasDcOutputVoltageCurrent()) {
                deviceStatus.setDcOutputVoltageCurrent(getStatusResponse.getDcOutputVoltageCurrent());
            }
            if (getStatusResponse.hasDcOutputVoltageMaximum()) {
                deviceStatus.setDcOutputVoltageMaximum(getStatusResponse.getDcOutputVoltageMaximum());
            }
            if (getStatusResponse.hasEventNotificationMask()) {
                deviceStatus.setEventNotificationsMask(getStatusResponse.getEventNotificationMask());
            }
            if (getStatusResponse.hasExternalFlashMemSize()) {
                deviceStatus.setExternalFlashMemSize(getStatusResponse.getExternalFlashMemSize());
            }
            if (getStatusResponse.hasFirmwareVersion()) {
                deviceStatus.setFirmwareVersion(getStatusResponse.getFirmwareVersion());
            }
            if (getStatusResponse.hasHardwareId()) {
                deviceStatus.setHardwareId(getStatusResponse.getHardwareId());
            }
            if (getStatusResponse.hasInternalFlashMemSize()) {
                deviceStatus.setInternalFlashMemSize(getStatusResponse.getInternalFlashMemSize());
            }
            if (getStatusResponse.hasLastInternalTestResultCode()) {
                deviceStatus.setLastInternalTestResultCode(getStatusResponse.getLastInternalTestResultCode());
            }
            if (getStatusResponse.getMacAddress() != null && !getStatusResponse.getMacAddress().isEmpty()) {
                deviceStatus.setMacAddress(this.convertMacAddress(getStatusResponse.getMacAddress()));
            }
            if (getStatusResponse.hasMaximumOutputPowerOnDcOutput()) {
                deviceStatus.setMaximumOutputPowerOnDcOutput(getStatusResponse.getMaximumOutputPowerOnDcOutput());
            }
            if (getStatusResponse.hasName()) {
                deviceStatus.setName(getStatusResponse.getName());
            }
            if (getStatusResponse.hasNumberOfOutputs()) {
                deviceStatus.setNumberOfOutputs(getStatusResponse.getNumberOfOutputs());
            }
            if (getStatusResponse.hasSerialNumber()) {
                deviceStatus.setSerialNumber(this.convertSerialNumber(getStatusResponse.getSerialNumber()));
            }
            if (getStatusResponse.hasStartupCounter()) {
                deviceStatus.setStartupCounter(getStatusResponse.getStartupCounter());
            }
        } else {
            // handle failure by throwing exceptions if needed
            LOGGER.error("Unable to convert Oslp.GetStatusResponse");
        }
    }
    final DeviceResponse deviceResponse = new GetStatusDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), deviceStatus);
    deviceResponseHandler.handleResponse(deviceResponse);
}
Also used : GetStatusDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse) LinkTypeDto(com.alliander.osgp.dto.valueobjects.LinkTypeDto) LightTypeDto(com.alliander.osgp.dto.valueobjects.LightTypeDto) DeviceStatusDto(com.alliander.osgp.dto.valueobjects.DeviceStatusDto) EmptyDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse) GetConfigurationDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse) GetStatusDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse) GetFirmwareVersionDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse) GetPowerUsageHistoryDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetPowerUsageHistoryDeviceResponse) GetActualPowerUsageDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetActualPowerUsageDeviceResponse) DeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse) Oslp(com.alliander.osgp.oslp.Oslp) LightValueDto(com.alliander.osgp.dto.valueobjects.LightValueDto)

Example 3 with LightTypeDto

use of com.alliander.osgp.dto.valueobjects.LightTypeDto 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
}
Also used : DaliConfigurationDto(com.alliander.osgp.dto.valueobjects.DaliConfigurationDto) LinkTypeDto(com.alliander.osgp.dto.valueobjects.LinkTypeDto) RelayMatrixDto(com.alliander.osgp.dto.valueobjects.RelayMatrixDto) LightTypeDto(com.alliander.osgp.dto.valueobjects.LightTypeDto) DeviceFixedIpDto(com.alliander.osgp.dto.valueobjects.DeviceFixedIpDto) ArrayList(java.util.ArrayList) MeterTypeDto(com.alliander.osgp.dto.valueobjects.MeterTypeDto) LongTermIntervalTypeDto(com.alliander.osgp.dto.valueobjects.LongTermIntervalTypeDto) ByteString(com.google.protobuf.ByteString) DateTime(org.joda.time.DateTime) MutableDateTime(org.joda.time.MutableDateTime) ConfigurationDto(com.alliander.osgp.dto.valueobjects.ConfigurationDto) DaliConfigurationDto(com.alliander.osgp.dto.valueobjects.DaliConfigurationDto) RelayConfigurationDto(com.alliander.osgp.dto.valueobjects.RelayConfigurationDto) RelayConfigurationDto(com.alliander.osgp.dto.valueobjects.RelayConfigurationDto)

Example 4 with LightTypeDto

use of com.alliander.osgp.dto.valueobjects.LightTypeDto in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850GetStatusCommand method getStatusFromDevice.

public DeviceStatusDto getStatusFromDevice(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final Ssld ssld) throws ProtocolAdapterException {
    final Function<DeviceStatusDto> function = new Function<DeviceStatusDto>() {

        @Override
        public DeviceStatusDto apply(final DeviceMessageLog deviceMessageLog) throws Exception {
            // getting the light relay values
            final List<LightValueDto> lightValues = new ArrayList<>();
            for (final DeviceOutputSetting deviceOutputSetting : ssld.getOutputSettings()) {
                final LogicalNode logicalNode = LogicalNode.getSwitchComponentByIndex(deviceOutputSetting.getInternalId());
                final NodeContainer position = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, logicalNode, DataAttribute.POSITION, Fc.ST);
                iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), position.getFcmodelNode());
                final BdaBoolean state = position.getBoolean(SubDataAttribute.STATE);
                final boolean on = state.getValue();
                lightValues.add(new LightValueDto(deviceOutputSetting.getExternalId(), on, null));
                LOGGER.info(String.format("Got status of relay %d => %s", deviceOutputSetting.getInternalId(), on ? "on" : "off"));
                deviceMessageLog.addVariable(logicalNode, DataAttribute.POSITION, Fc.ST, Boolean.toString(on));
            }
            final NodeContainer eventBuffer = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.EVENT_BUFFER, Fc.CF);
            iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), eventBuffer.getFcmodelNode());
            final String filter = eventBuffer.getString(SubDataAttribute.EVENT_BUFFER_FILTER);
            LOGGER.info("Got EvnBuf.enbEvnType filter {}", filter);
            deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.EVENT_BUFFER, Fc.CF, filter);
            final Set<EventNotificationTypeDto> notificationTypes = EventType.getNotificationTypesForFilter(filter);
            int eventNotificationsMask = 0;
            for (final EventNotificationTypeDto notificationType : notificationTypes) {
                eventNotificationsMask |= notificationType.getValue();
            }
            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";
            }
            final LightTypeDto lightType = LightTypeDto.valueOf(lightTypeValue);
            deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SOFTWARE_CONFIGURATION, Fc.CF, lightTypeValue);
            DeviceMessageLoggingService.logMessage(deviceMessageLog, deviceConnection.getDeviceIdentification(), deviceConnection.getOrganisationIdentification(), false);
            /*
                 * The preferredLinkType and actualLinkType are hard-coded to
                 * LinkTypeDto.ETHERNET, other link types do not apply to the
                 * device type in use.
                 */
            return new DeviceStatusDto(lightValues, LinkTypeDto.ETHERNET, LinkTypeDto.ETHERNET, lightType, eventNotificationsMask);
        }
    };
    return iec61850Client.sendCommandWithRetry(function, "GetStatus", deviceConnection.getDeviceIdentification());
}
Also used : LightTypeDto(com.alliander.osgp.dto.valueobjects.LightTypeDto) ArrayList(java.util.ArrayList) DeviceOutputSetting(com.alliander.osgp.core.db.api.iec61850.entities.DeviceOutputSetting) NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer) LogicalNode(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.LogicalNode) LightValueDto(com.alliander.osgp.dto.valueobjects.LightValueDto) Function(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.Function) DeviceMessageLog(com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) DeviceStatusDto(com.alliander.osgp.dto.valueobjects.DeviceStatusDto) BdaBoolean(org.openmuc.openiec61850.BdaBoolean) EventNotificationTypeDto(com.alliander.osgp.dto.valueobjects.EventNotificationTypeDto)

Aggregations

LightTypeDto (com.alliander.osgp.dto.valueobjects.LightTypeDto)4 LinkTypeDto (com.alliander.osgp.dto.valueobjects.LinkTypeDto)3 ArrayList (java.util.ArrayList)3 DeviceMessageLog (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)2 Function (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.Function)2 NodeContainer (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)2 DeviceOutputSetting (com.alliander.osgp.core.db.api.iec61850.entities.DeviceOutputSetting)2 ConfigurationDto (com.alliander.osgp.dto.valueobjects.ConfigurationDto)2 DaliConfigurationDto (com.alliander.osgp.dto.valueobjects.DaliConfigurationDto)2 DeviceFixedIpDto (com.alliander.osgp.dto.valueobjects.DeviceFixedIpDto)2 DeviceStatusDto (com.alliander.osgp.dto.valueobjects.DeviceStatusDto)2 LightValueDto (com.alliander.osgp.dto.valueobjects.LightValueDto)2 LongTermIntervalTypeDto (com.alliander.osgp.dto.valueobjects.LongTermIntervalTypeDto)2 MeterTypeDto (com.alliander.osgp.dto.valueobjects.MeterTypeDto)2 RelayConfigurationDto (com.alliander.osgp.dto.valueobjects.RelayConfigurationDto)2 DaylightSavingTimeTransition (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DaylightSavingTimeTransition)1 LogicalNode (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.LogicalNode)1 DeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse)1 EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)1 GetActualPowerUsageDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetActualPowerUsageDeviceResponse)1