Search in sources :

Example 21 with ModelNode

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;
}
Also used : BdaFloat32(com.beanit.openiec61850.BdaFloat32)

Example 22 with ModelNode

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;
}
Also used : Iec61850Connection(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.Iec61850Connection) NodeReadException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeReadException) FcModelNode(com.beanit.openiec61850.FcModelNode)

Example 23 with ModelNode

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);
}
Also used : DataSampleDto(org.opensmartgridplatform.dto.da.iec61850.DataSampleDto) FcModelNode(com.beanit.openiec61850.FcModelNode) ModelNode(com.beanit.openiec61850.ModelNode) Date(java.util.Date) BigDecimal(java.math.BigDecimal)

Example 24 with ModelNode

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);
}
Also used : DataSampleDto(org.opensmartgridplatform.dto.da.iec61850.DataSampleDto) BdaTimestamp(com.beanit.openiec61850.BdaTimestamp) BdaFloat32(com.beanit.openiec61850.BdaFloat32) BigDecimal(java.math.BigDecimal) MathContext(java.math.MathContext)

Example 25 with ModelNode

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);
    }
}
Also used : HeatPump(com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.HeatPump) ModelNode(org.openmuc.openiec61850.ModelNode)

Aggregations

ModelNode (org.openmuc.openiec61850.ModelNode)25 ModelNode (com.beanit.openiec61850.ModelNode)20 ServerModel (org.openmuc.openiec61850.ServerModel)10 ArrayList (java.util.ArrayList)7 FcModelNode (com.beanit.openiec61850.FcModelNode)5 DataSampleDto (org.opensmartgridplatform.dto.da.iec61850.DataSampleDto)4 BigDecimal (java.math.BigDecimal)3 FcModelNode (org.openmuc.openiec61850.FcModelNode)3 DataSampleDto (org.osgpfoundation.osgp.dto.da.iec61850.DataSampleDto)3 BasicDataAttribute (com.beanit.openiec61850.BasicDataAttribute)2 BdaFloat32 (com.beanit.openiec61850.BdaFloat32)2 BdaTimestamp (com.beanit.openiec61850.BdaTimestamp)2 ServerModel (com.beanit.openiec61850.ServerModel)2 MathContext (java.math.MathContext)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 LightMeasurementRtu (org.opensmartgridplatform.simulator.protocol.iec61850.server.logicaldevices.LightMeasurementRtu)2