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);
}
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());
}
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);
}
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());
}
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));
}
Aggregations