use of com.beanit.openiec61850.ModelNode in project open-smart-grid-platform by OSGP.
the class Node method getChangedMagnitudeAttributeForNode.
private BasicDataAttribute getChangedMagnitudeAttributeForNode(final ModelNode node) {
final BdaFloat32 bda = (BdaFloat32) node;
bda.setFloat((float) this.value);
return bda;
}
use of com.beanit.openiec61850.ModelNode in project open-smart-grid-platform by OSGP.
the class Iec61850DeviceConnectionService method testIfConnectionIsCachedAndAlive.
private boolean testIfConnectionIsCachedAndAlive(final String deviceIdentification, final IED ied, final String serverName, final String logicalDevice) throws ProtocolAdapterException {
try {
LOGGER.info("Trying to find connection in cache for deviceIdentification: {}", deviceIdentification);
final Iec61850Connection iec61850Connection = this.fetchIec61850Connection(deviceIdentification);
if (iec61850Connection != null) {
// Already connected, check if connection is still usable.
LOGGER.info("Connection found for deviceIdentification: {}", deviceIdentification);
// requires manual reads of remote data.
if (ied != null && logicalDevice != null) {
final String description = this.getActualServerName(ied, serverName);
LOGGER.info("Testing if connection is alive using {}{}/{}.{} for deviceIdentification: {}", description, logicalDevice, LogicalNode.LOGICAL_NODE_ZERO.getDescription(), DataAttribute.NAME_PLATE.getDescription(), deviceIdentification);
final FcModelNode modelNode = this.getModelNode(logicalDevice, iec61850Connection, description);
this.iec61850Client.readNodeDataValues(iec61850Connection.getClientAssociation(), modelNode);
} else {
// Read all data values, which is much slower, but requires
// no manual reads of remote data.
LOGGER.info("Testing if connection is alive using readAllDataValues() for deviceIdentification: {}", deviceIdentification);
this.iec61850Client.readAllDataValues(iec61850Connection.getClientAssociation());
}
LOGGER.info("Connection is still active for deviceIdentification: {}", deviceIdentification);
return true;
}
} catch (final NodeReadException e) {
LOGGER.error("Connection is no longer active, removing connection from cache for deviceIdentification: " + deviceIdentification, e);
this.disconnect(deviceIdentification);
}
return false;
}
use of com.beanit.openiec61850.ModelNode in project open-smart-grid-platform by OSGP.
the class DistributionAutomationGetPQValuesRequestMessageProcessor method processPQValue.
private DataSampleDto processPQValue(final ModelNode parentNode, final ModelNode node) {
Date ts = null;
String type = null;
BigDecimal value = null;
if (node.getChildren() != null) {
ts = this.findBdaTimestampNodeValue(node);
final ModelNode floatNode = this.findDeeperBdaFloat32NodeInConstructedDataAttributeChildren(node);
if (floatNode != null) {
type = parentNode.getName() + "." + node.getName() + "." + floatNode.getParent().getParent().getName() + "." + floatNode.getParent().getName() + "." + floatNode.getName();
value = this.getNodeBigDecimal(floatNode);
}
}
return new DataSampleDto(type, ts, value);
}
use of com.beanit.openiec61850.ModelNode in project open-smart-grid-platform by OSGP.
the class Iec61850ClientDaRTUEventListener method processSingleMeasurementNode.
private void processSingleMeasurementNode(final FcModelNode member, final LogicalNode logicalNode, final ModelNode childNode) {
final BdaFloat32 singleMeasurement = this.getSingleMeasurementModelNode(childNode);
final BdaTimestamp timestampMeasurement = this.getTimestampModelNode(childNode);
String type = member.getName() + "." + childNode.getName();
type += "." + singleMeasurement.getParent().getParent().getName() + "." + singleMeasurement.getParent().getName() + "." + singleMeasurement.getName();
final BigDecimal value = new BigDecimal(singleMeasurement.getFloat(), new MathContext(3, RoundingMode.HALF_EVEN));
final DataSampleDto sample = new DataSampleDto(type, timestampMeasurement.getDate(), value);
logicalNode.getDataSamples().add(sample);
}
use of com.beanit.openiec61850.ModelNode in project Protocol-Adapter-IEC61850 by OSGP.
the class RtuSimulator method addHeatPumpDevices.
private void addHeatPumpDevices(final ServerModel serverModel) {
final String heatPumpPrefix = "HEAT_PUMP";
int i = 1;
String logicalDeviceName = heatPumpPrefix + i;
ModelNode heatPumpNode = serverModel.getChild(this.getDeviceName() + logicalDeviceName);
while (heatPumpNode != null) {
this.logicalDevices.add(new HeatPump(this.getDeviceName(), logicalDeviceName, serverModel));
i += 1;
logicalDeviceName = heatPumpPrefix + i;
heatPumpNode = serverModel.getChild(this.getDeviceName() + logicalDeviceName);
}
}
Aggregations