Search in sources :

Example 16 with NodeContainer

use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850MaterialFlowCommand method execute.

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

Example 17 with NodeContainer

use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850ModeCommand method execute.

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

Example 18 with NodeContainer

use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850RtuDeviceReportingService method enableMeasurementReportingOnDevice.

private void enableMeasurementReportingOnDevice(final DeviceConnection deviceConnection, final String deviceIdentification, final LogicalDevice logicalDevice, final int logicalDeviceIndex, final DataAttribute reportName) {
    LOGGER.info("Allowing device {} to send events", deviceIdentification);
    try {
        final NodeContainer reportingNode = deviceConnection.getFcModelNode(logicalDevice, logicalDeviceIndex, LogicalNode.LOGICAL_NODE_ZERO, reportName, Fc.BR);
        reportingNode.writeBoolean(SubDataAttribute.ENABLE_REPORTING, true);
    } catch (final NullPointerException e) {
        LOGGER.debug("NullPointerException", e);
        LOGGER.warn("Skip enable reporting for device {}{}, report {}.", logicalDevice, logicalDeviceIndex, reportName.getDescription());
    } catch (final NodeWriteException e) {
        LOGGER.debug("NodeWriteException", e);
        LOGGER.error("Enable reporting for device {}{}, report {}, failed with exception: {}", logicalDevice, logicalDeviceIndex, reportName.getDescription(), e.getMessage());
    }
}
Also used : NodeWriteException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException) NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)

Example 19 with NodeContainer

use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850SetGpsCoordinatesCommand method setGpsCoordinates.

public void setGpsCoordinates(final DeviceConnection deviceConnection, final Float longitude, final Float latitude) throws NodeWriteException {
    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(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)

Example 20 with NodeContainer

use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850SetLightCommand method switchLightRelay.

public Boolean switchLightRelay(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final int index, final boolean on) throws ProtocolAdapterException {
    // Commands don't return anything, so returnType is Void.
    final Function<Boolean> function = new Function<Boolean>() {

        @Override
        public Boolean apply(final DeviceMessageLog deviceMessageLog) throws Exception {
            try {
                final LogicalNode logicalNode = LogicalNode.getSwitchComponentByIndex(index);
                // Check if CfSt.enbOper [CF] is set to true. If it is not
                // set to true, the relay can not be operated.
                final NodeContainer masterControl = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, logicalNode, DataAttribute.MASTER_CONTROL, Fc.CF);
                iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), masterControl.getFcmodelNode());
                final BdaBoolean enbOper = masterControl.getBoolean(SubDataAttribute.ENABLE_OPERATION);
                if (enbOper.getValue()) {
                    LOGGER.info("masterControl.enbOper is true, switching of relay {} is enabled", index);
                } else {
                    LOGGER.info("masterControl.enbOper is false, switching of relay {} is disabled", index);
                    // Set the value to true.
                    masterControl.writeBoolean(SubDataAttribute.ENABLE_OPERATION, true);
                    LOGGER.info("set masterControl.enbOper to true to enable switching of relay {}", index);
                    deviceMessageLog.addVariable(logicalNode, DataAttribute.MASTER_CONTROL, Fc.CF, SubDataAttribute.ENABLE_OPERATION, Boolean.toString(true));
                }
                // 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));
                DeviceMessageLoggingService.logMessage(deviceMessageLog, deviceConnection.getDeviceIdentification(), deviceConnection.getOrganisationIdentification(), false);
                return true;
            } catch (final Exception e) {
                LOGGER.error("Exception during switchLightRelay()", e);
                return false;
            }
        }
    };
    return iec61850Client.sendCommandWithRetry(function, "SetLight", deviceConnection.getDeviceIdentification());
}
Also used : Function(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.Function) DeviceMessageLog(com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) BdaBoolean(org.openmuc.openiec61850.BdaBoolean) NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer) LogicalNode(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.LogicalNode) BdaBoolean(org.openmuc.openiec61850.BdaBoolean) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)

Aggregations

NodeContainer (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)63 NodeContainer (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)55 DeviceMessageLog (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)10 Function (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.Function)10 DateTime (org.joda.time.DateTime)9 ArrayList (java.util.ArrayList)8 DeviceMessageLog (org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)7 Function (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.Function)7 LogicalNode (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.LogicalNode)6 Date (java.util.Date)6 BdaBoolean (com.beanit.openiec61850.BdaBoolean)5 BdaBoolean (org.openmuc.openiec61850.BdaBoolean)5 Iec61850ClientBaseEventListener (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.reporting.Iec61850ClientBaseEventListener)5 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)3 List (java.util.List)3 LogicalNode (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.LogicalNode)3 DaylightSavingTimeTransition (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DaylightSavingTimeTransition)2 NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)2 Iec61850ClientBaseEventListener (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.reporting.Iec61850ClientBaseEventListener)2 DeviceOutputSetting (com.alliander.osgp.core.db.api.iec61850.entities.DeviceOutputSetting)2