Search in sources :

Example 11 with ModelNode

use of org.openmuc.openiec61850.ModelNode in project Protocol-Adapter-IEC61850 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.removeIec61850Connection(deviceIdentification);
    }
    return false;
}
Also used : Iec61850Connection(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection) NodeReadException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException) FcModelNode(org.openmuc.openiec61850.FcModelNode)

Example 12 with ModelNode

use of org.openmuc.openiec61850.ModelNode in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850RtuDeviceReportingService method enableGasFurnaceReportingOnDevice.

private void enableGasFurnaceReportingOnDevice(final DeviceConnection connection, final String deviceIdentification) {
    final ServerModel serverModel = connection.getConnection().getServerModel();
    final String gasFurnacePrefix = LogicalDevice.GAS_FURNACE.getDescription();
    int i = 1;
    String logicalDeviceName = gasFurnacePrefix + i;
    ModelNode gasFurnaceNode = serverModel.getChild(this.serverName + logicalDeviceName);
    while (gasFurnaceNode != null) {
        this.enableStatusReportingOnDevice(connection, deviceIdentification, LogicalDevice.GAS_FURNACE, i, DataAttribute.REPORT_STATUS_ONE);
        this.enableMeasurementReportingOnDevice(connection, deviceIdentification, LogicalDevice.GAS_FURNACE, i, DataAttribute.REPORT_MEASUREMENTS_ONE);
        i += 1;
        logicalDeviceName = gasFurnacePrefix + i;
        gasFurnaceNode = serverModel.getChild(this.serverName + logicalDeviceName);
    }
}
Also used : ServerModel(org.openmuc.openiec61850.ServerModel) ModelNode(org.openmuc.openiec61850.ModelNode)

Example 13 with ModelNode

use of org.openmuc.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)

Example 14 with ModelNode

use of org.openmuc.openiec61850.ModelNode in project Protocol-Adapter-IEC61850 by OSGP.

the class RtuSimulator method addChpDevices.

private void addChpDevices(final ServerModel serverModel) {
    final String chpPrefix = "CHP";
    int i = 1;
    String logicalDeviceName = chpPrefix + i;
    ModelNode chpNode = serverModel.getChild(this.getDeviceName() + logicalDeviceName);
    while (chpNode != null) {
        this.logicalDevices.add(new Chp(this.getDeviceName(), logicalDeviceName, serverModel));
        i += 1;
        logicalDeviceName = chpPrefix + i;
        chpNode = serverModel.getChild(this.getDeviceName() + logicalDeviceName);
    }
}
Also used : Chp(com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.Chp) ModelNode(org.openmuc.openiec61850.ModelNode)

Example 15 with ModelNode

use of org.openmuc.openiec61850.ModelNode in project Protocol-Adapter-IEC61850 by OSGP.

the class RtuSimulator method addLoadDevices.

private void addLoadDevices(final ServerModel serverModel) {
    final String loadPrefix = "LOAD";
    int i = 1;
    String logicalDeviceName = loadPrefix + i;
    ModelNode loadNode = serverModel.getChild(this.getDeviceName() + logicalDeviceName);
    while (loadNode != null) {
        this.logicalDevices.add(new Load(this.getDeviceName(), logicalDeviceName, serverModel));
        i += 1;
        logicalDeviceName = loadPrefix + i;
        loadNode = serverModel.getChild(this.getDeviceName() + logicalDeviceName);
    }
}
Also used : Load(com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.Load) ModelNode(org.openmuc.openiec61850.ModelNode)

Aggregations

ModelNode (org.openmuc.openiec61850.ModelNode)25 ServerModel (org.openmuc.openiec61850.ServerModel)11 FcModelNode (org.openmuc.openiec61850.FcModelNode)5 ArrayList (java.util.ArrayList)3 DataSampleDto (org.osgpfoundation.osgp.dto.da.iec61850.DataSampleDto)3 NodeReadException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException)1 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 Iec61850Connection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection)1 Battery (com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.Battery)1 Boiler (com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.Boiler)1 Chp (com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.Chp)1 Engine (com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.Engine)1 GasFurnace (com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.GasFurnace)1 HeatBuffer (com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.HeatBuffer)1 HeatPump (com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.HeatPump)1 Load (com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.Load)1 LogicalDevice (com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.LogicalDevice)1 Pv (com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.Pv)1 Rtu (com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.Rtu)1 BigDecimal (java.math.BigDecimal)1