Search in sources :

Example 16 with NodeReadException

use of com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850UpdateFirmwareCommand method determineFirmwareUpdateDateTime.

private Date determineFirmwareUpdateDateTime(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection) throws NodeReadException {
    final NodeContainer clock = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF);
    iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), clock.getFcmodelNode());
    final DateTime deviceTime = new DateTime(clock.getDate(SubDataAttribute.CURRENT_TIME));
    // Creating a DateTime one minute from now.
    return deviceTime.plusMinutes(1).toDate();
}
Also used : NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer) DateTime(org.joda.time.DateTime)

Example 17 with NodeReadException

use of com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850VlmCapCommand method execute.

@Override
public MeasurementDto execute(final Iec61850Client client, final DeviceConnection connection, final LogicalDevice logicalDevice, final int logicalDeviceIndex) throws NodeReadException {
    final NodeContainer containingNode = connection.getFcModelNode(logicalDevice, logicalDeviceIndex, LogicalNode.TANK_CHARACTERISTICS_ONE, DataAttribute.VLMCAP, Fc.SP);
    client.readNodeDataValues(connection.getConnection().getClientAssociation(), containingNode.getFcmodelNode());
    return this.translate(containingNode);
}
Also used : NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)

Example 18 with NodeReadException

use of com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850TotalEnergyCommand method execute.

@Override
public MeasurementDto execute(final Iec61850Client client, final DeviceConnection connection, final LogicalDevice logicalDevice, final int logicalDeviceIndex) throws NodeReadException {
    final NodeContainer containingNode = connection.getFcModelNode(logicalDevice, logicalDeviceIndex, LogicalNode.GENERATOR_ONE, DataAttribute.TOTAL_ENERGY, Fc.MX);
    client.readNodeDataValues(connection.getConnection().getClientAssociation(), containingNode.getFcmodelNode());
    return this.translate(containingNode);
}
Also used : NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)

Example 19 with NodeReadException

use of com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850DeviceConnectionService method readNodeDataValues.

public void readNodeDataValues(final String deviceIdentification, final FcModelNode fcModelNode) throws NodeReadException {
    final Iec61850Connection iec61850Connection = this.fetchIec61850Connection(deviceIdentification);
    if (iec61850Connection == null) {
        return;
    }
    final ClientAssociation clientAssociation = iec61850Connection.getClientAssociation();
    this.iec61850Client.readNodeDataValues(clientAssociation, fcModelNode);
}
Also used : Iec61850Connection(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection) Iec61850ClientAssociation(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation) ClientAssociation(org.openmuc.openiec61850.ClientAssociation)

Example 20 with NodeReadException

use of com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException 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)

Aggregations

NodeContainer (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)31 NodeReadException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException)3 Iec61850Connection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection)3 Iec61850ClientAssociation (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation)2 IOException (java.io.IOException)2 DateTime (org.joda.time.DateTime)2 ClientAssociation (org.openmuc.openiec61850.ClientAssociation)2 DeviceMessageLog (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)1 ConnectionFailureException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException)1 NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)1 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 LogicalNode (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.LogicalNode)1 PowerUsageDataDto (com.alliander.osgp.dto.valueobjects.PowerUsageDataDto)1 RelayDataDto (com.alliander.osgp.dto.valueobjects.RelayDataDto)1 SsldDataDto (com.alliander.osgp.dto.valueobjects.SsldDataDto)1 ArrayList (java.util.ArrayList)1 FcModelNode (org.openmuc.openiec61850.FcModelNode)1 SclParseException (org.openmuc.openiec61850.SclParseException)1 ServiceError (org.openmuc.openiec61850.ServiceError)1