use of com.beanit.openiec61850.BdaInt8 in project Protocol-Adapter-IEC61850 by OSGP.
the class LogicalDevice method setRandomByte.
protected BasicDataAttribute setRandomByte(final String node, final Fc fc, final int min, final int max) {
final BdaInt8 value = (BdaInt8) this.serverModel.findModelNode(this.createNodeName(node), fc);
value.setValue((byte) ThreadLocalRandom.current().nextInt(min, max));
return value;
}
use of com.beanit.openiec61850.BdaInt8 in project open-smart-grid-platform by OSGP.
the class Iec61850SetConfigurationFunction method setRelayConfiguration.
private void setRelayConfiguration(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final ConfigurationDto configuration, final DeviceMessageLog deviceMessageLog) throws NodeException {
if (configuration.getRelayConfiguration() != null && configuration.getRelayConfiguration().getRelayMap() != null) {
final List<RelayMapDto> relayMaps = configuration.getRelayConfiguration().getRelayMap();
for (final RelayMapDto relayMap : relayMaps) {
final Integer internalIndex = relayMap.getAddress();
final RelayTypeDto relayType = relayMap.getRelayType();
final LogicalNode logicalNode = LogicalNode.getSwitchComponentByIndex(internalIndex);
final NodeContainer switchType = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, logicalNode, DataAttribute.SWITCH_TYPE, Fc.CO);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), switchType.getFcmodelNode());
final NodeContainer operation = switchType.getChild(SubDataAttribute.OPERATION);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), operation.getFcmodelNode());
final BdaInt8 ctlVal = operation.getByte(SubDataAttribute.CONTROL_VALUE);
final byte switchTypeValue = (byte) (RelayTypeDto.LIGHT.equals(relayType) ? SWITCH_TYPE_LIGHT : SWITCH_TYPE_TARIFF);
LOGGER.info("Updating Switch for internal index {} to {} ({})", internalIndex, switchTypeValue, relayType);
ctlVal.setValue(switchTypeValue);
operation.write();
deviceMessageLog.addVariable(logicalNode, DataAttribute.SWITCH_TYPE, Fc.CO, SubDataAttribute.OPERATION, SubDataAttribute.CONTROL_VALUE, Byte.toString(switchTypeValue));
}
}
}
use of com.beanit.openiec61850.BdaInt8 in project open-smart-grid-platform by OSGP.
the class NodeContainer method writeByte.
public void writeByte(final SubDataAttribute child, final byte value) throws NodeWriteException {
final BdaInt8 bdaByte = (BdaInt8) this.parent.getChild(child.getDescription());
bdaByte.setValue(value);
this.writeNode(bdaByte);
}
use of com.beanit.openiec61850.BdaInt8 in project open-smart-grid-platform by OSGP.
the class LogicalDevice method setByte.
protected BasicDataAttribute setByte(final LogicalDeviceNode node, final byte val) {
final BdaInt8 value = (BdaInt8) this.serverModel.findModelNode(this.createNodeName(node), node.getFc());
value.setValue(val);
return value;
}
Aggregations