use of com.alliander.osgp.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);
}
use of com.alliander.osgp.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);
}
use of com.alliander.osgp.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());
}
}
use of com.alliander.osgp.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());
}
use of com.alliander.osgp.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());
}
Aggregations