Search in sources :

Example 86 with DeviceConnection

use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project open-smart-grid-platform by OSGP.

the class Iec61850LoadMinimumActualPowerCommand method execute.

@Override
public MeasurementDto execute(final Iec61850Client client, final DeviceConnection connection, final LogicalDevice logicalDevice, final int logicalDeviceIndex) throws NodeException {
    final NodeContainer containingNode = connection.getFcModelNode(logicalDevice, logicalDeviceIndex, this.logicalNode, DataAttribute.MIN_ACTUAL_POWER, Fc.MX);
    client.readNodeDataValues(connection.getConnection().getClientAssociation(), containingNode.getFcmodelNode());
    return this.translate(containingNode);
}
Also used : NodeContainer(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)

Example 87 with DeviceConnection

use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project open-smart-grid-platform by OSGP.

the class Iec61850SetGpsCoordinatesCommand method setGpsCoordinates.

public void setGpsCoordinates(final DeviceConnection deviceConnection, final Float longitude, final Float latitude) throws NodeException {
    final NodeContainer astronomical = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.ASTRONOMICAL, Fc.CF);
    astronomical.writeFloat(SubDataAttribute.GPS_LONGITUDE, longitude);
    astronomical.writeFloat(SubDataAttribute.GPS_LATITUDE, latitude);
    LOGGER.info("longitude: {}, latitude: {} written for device: {}", longitude, latitude, deviceConnection.getDeviceIdentification());
}
Also used : NodeContainer(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)

Example 88 with DeviceConnection

use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project open-smart-grid-platform by OSGP.

the class Iec61850TransitionCommand method transitionDevice.

public void transitionDevice(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final TransitionMessageDataContainerDto transitionMessageDataContainer) throws ProtocolAdapterException {
    final TransitionTypeDto transitionType = transitionMessageDataContainer.getTransitionType();
    LOGGER.info("device: {}, transition: {}", deviceConnection.getDeviceIdentification(), transitionType);
    final boolean controlValueForTransition = transitionType.equals(TransitionTypeDto.DAY_NIGHT);
    final DateTime dateTime = transitionMessageDataContainer.getDateTime();
    if (dateTime != null) {
        LOGGER.warn("device: {}, setting date/time {} for transition {} not supported", deviceConnection.getDeviceIdentification(), dateTime, transitionType);
    }
    final Function<Void> function = new Function<Void>() {

        @Override
        public Void apply(final DeviceMessageLog deviceMessageLog) throws ProtocolAdapterException {
            final NodeContainer sensorNode = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SENSOR, Fc.CO);
            iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), sensorNode.getFcmodelNode());
            LOGGER.info("device: {}, sensorNode: {}", deviceConnection.getDeviceIdentification(), sensorNode);
            final NodeContainer oper = sensorNode.getChild(SubDataAttribute.OPERATION);
            LOGGER.info("device: {}, oper: {}", deviceConnection.getDeviceIdentification(), oper);
            final BdaBoolean ctlVal = oper.getBoolean(SubDataAttribute.CONTROL_VALUE);
            LOGGER.info("device: {}, ctlVal: {}", deviceConnection.getDeviceIdentification(), ctlVal);
            ctlVal.setValue(controlValueForTransition);
            LOGGER.info("device: {}, set ctlVal to {} in order to transition the device", deviceConnection.getDeviceIdentification(), controlValueForTransition);
            oper.write();
            deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SENSOR, Fc.CO, SubDataAttribute.OPERATION, SubDataAttribute.CONTROL_VALUE, Boolean.toString(controlValueForTransition));
            Iec61850TransitionCommand.this.loggingService.logMessage(deviceMessageLog, deviceConnection.getDeviceIdentification(), deviceConnection.getOrganisationIdentification(), false);
            return null;
        }
    };
    iec61850Client.sendCommandWithRetry(function, "SetTransition", deviceConnection.getDeviceIdentification());
}
Also used : Function(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.Function) DeviceMessageLog(org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) TransitionTypeDto(org.opensmartgridplatform.dto.valueobjects.TransitionTypeDto) BdaBoolean(com.beanit.openiec61850.BdaBoolean) NodeContainer(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer) DateTime(org.joda.time.DateTime)

Example 89 with DeviceConnection

use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project open-smart-grid-platform by OSGP.

the class Iec61850UpdateSslCertificateCommand method pushSslCertificateToDevice.

public void pushSslCertificateToDevice(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final CertificationDto certification) throws ProtocolAdapterException {
    final Function<Void> function = new Function<Void>() {

        @Override
        public Void apply(final DeviceMessageLog deviceMessageLog) throws ProtocolAdapterException {
            LOGGER.info("Reading the certificate authority url");
            final NodeContainer sslConfiguration = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CERTIFICATE_AUTHORITY_REPLACE, Fc.CF);
            iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), sslConfiguration.getFcmodelNode());
            // Removing trailing and leading slashes (if present) from the
            // domain and the URL.
            String adjustedDomain = certification.getCertificateDomain();
            if (adjustedDomain.endsWith("/")) {
                adjustedDomain = adjustedDomain.substring(0, adjustedDomain.length() - 1);
            }
            String adjustedUrl = certification.getCertificateUrl();
            if (adjustedUrl.startsWith("/")) {
                adjustedUrl = adjustedUrl.substring(1, adjustedUrl.length());
            }
            final String fullUrl = adjustedDomain.concat("/").concat(adjustedUrl);
            LOGGER.info("Updating the certificate download url to {}", fullUrl);
            sslConfiguration.writeString(SubDataAttribute.URL, fullUrl);
            deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CERTIFICATE_AUTHORITY_REPLACE, Fc.CF, SubDataAttribute.URL, fullUrl);
            final NodeContainer clock = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF);
            iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), clock.getFcmodelNode());
            final DateTime deviceTime = new DateTime(clock.getDate(SubDataAttribute.CURRENT_TIME));
            final Date oneMinuteFromNow = deviceTime.plusMinutes(1).toDate();
            LOGGER.info("Updating the certificate download start time to: {}", oneMinuteFromNow);
            sslConfiguration.writeDate(SubDataAttribute.START_TIME, oneMinuteFromNow);
            deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CERTIFICATE_AUTHORITY_REPLACE, Fc.CF, SubDataAttribute.START_TIME, Iec61850UpdateSslCertificateCommand.this.simpleDateFormat.format(oneMinuteFromNow));
            Iec61850UpdateSslCertificateCommand.this.loggingService.logMessage(deviceMessageLog, deviceConnection.getDeviceIdentification(), deviceConnection.getOrganisationIdentification(), false);
            return null;
        }
    };
    iec61850Client.sendCommandWithRetry(function, "UpdateSslCertificate", deviceConnection.getDeviceIdentification());
}
Also used : Function(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.Function) DeviceMessageLog(org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) NodeContainer(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer) DateTime(org.joda.time.DateTime) Date(java.util.Date)

Example 90 with DeviceConnection

use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project open-smart-grid-platform by OSGP.

the class Iec61850WarningOtherCommand method execute.

@Override
public MeasurementDto execute(final Iec61850Client client, final DeviceConnection connection, final LogicalDevice logicalDevice, final int logicalDeviceIndex) throws NodeException {
    final NodeContainer containingNode = connection.getFcModelNode(logicalDevice, logicalDeviceIndex, LogicalNode.GENERIC_PROCESS_I_O, DataAttribute.WARNING_OTHER, Fc.ST);
    client.readNodeDataValues(connection.getConnection().getClientAssociation(), containingNode.getFcmodelNode());
    return this.translate(containingNode);
}
Also used : NodeContainer(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)

Aggregations

NodeContainer (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)63 JMSException (javax.jms.JMSException)32 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)20 DeviceConnection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)18 DeviceConnection (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)18 ConnectionFailureException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException)17 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)17 ConnectionFailureException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException)17 NodeException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeException)14 NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)13 FunctionalException (com.alliander.osgp.shared.exceptionhandling.FunctionalException)13 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)13 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)13 DeviceMessageLog (org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)12 Function (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.Function)12 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)12 Ssld (com.alliander.osgp.core.db.api.iec61850.entities.Ssld)6 ArrayList (java.util.ArrayList)6 DateTime (org.joda.time.DateTime)6 Iec61850ClientBaseEventListener (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.reporting.Iec61850ClientBaseEventListener)6