Search in sources :

Example 21 with DeviceConnection

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

the class Iec61850PhaseToNeutralVoltageCommand 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, this.dataAttribute, 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 22 with DeviceConnection

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

the class Iec61850RebootCommand method rebootDevice.

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

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

Example 23 with DeviceConnection

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

the class Iec61850ScheduleTypeCommand 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, DATA_ATTRIBUTE, FC);
    client.readNodeDataValues(connection.getConnection().getClientAssociation(), containingNode.getFcmodelNode());
    return this.translate(containingNode);
}
Also used : NodeContainer(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)

Example 24 with DeviceConnection

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

the class Iec61850SetEventNotificationFilterCommand method setEventNotificationFilterOnDevice.

public void setEventNotificationFilterOnDevice(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final String filter) throws ProtocolAdapterException {
    final Function<Void> function = new Function<Void>() {

        @Override
        public Void apply(final DeviceMessageLog deviceMessageLog) throws ProtocolAdapterException {
            LOGGER.info("Setting the event notification filter");
            final NodeContainer eventBufferConfiguration = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.EVENT_BUFFER, Fc.CF);
            iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), eventBufferConfiguration.getFcmodelNode());
            LOGGER.info("Updating the enabled EventType filter to {}", filter);
            eventBufferConfiguration.writeString(SubDataAttribute.EVENT_BUFFER_FILTER, filter);
            deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.EVENT_BUFFER, Fc.CF, SubDataAttribute.EVENT_BUFFER_FILTER, filter);
            Iec61850SetEventNotificationFilterCommand.this.loggingService.logMessage(deviceMessageLog, deviceConnection.getDeviceIdentification(), deviceConnection.getOrganisationIdentification(), false);
            return null;
        }
    };
    iec61850Client.sendCommandWithRetry(function, "SetEventNoficationFilter", 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)

Example 25 with DeviceConnection

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

the class Iec61850SetLightCommand method switchLightRelay.

private void switchLightRelay(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final DeviceMessageLog deviceMessageLog, final int index, final boolean on) throws NodeException {
    final LogicalNode logicalNode = LogicalNode.getSwitchComponentByIndex(index);
    Iec61850Commands.enableOperationOfRelay(deviceConnection, iec61850Client, deviceMessageLog, logicalNode, index);
    // Switch the relay using Pos.Oper.ctlVal [CO].
    final NodeContainer position = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, logicalNode, DataAttribute.POSITION, Fc.CO);
    iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), position.getFcmodelNode());
    final NodeContainer operation = position.getChild(SubDataAttribute.OPERATION);
    final BdaBoolean controlValue = operation.getBoolean(SubDataAttribute.CONTROL_VALUE);
    LOGGER.info(String.format("Switching relay %d %s", index, on ? "on" : "off"));
    controlValue.setValue(on);
    operation.write();
    deviceMessageLog.addVariable(logicalNode, DataAttribute.POSITION, Fc.CO, SubDataAttribute.OPERATION, SubDataAttribute.CONTROL_VALUE, Boolean.toString(on));
}
Also used : BdaBoolean(com.beanit.openiec61850.BdaBoolean) NodeContainer(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer) LogicalNode(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.LogicalNode)

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