Search in sources :

Example 1 with NodeWriteException

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

the class Iec61850DisableRegistrationCommand method disableRegistration.

public void disableRegistration(final DeviceConnection deviceConnection) throws NodeWriteException {
    final NodeContainer deviceRegistration = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.REGISTRATION, Fc.CF);
    deviceRegistration.writeBoolean(SubDataAttribute.DEVICE_REGISTRATION_ENABLED, false);
    LOGGER.info("Registration disabled for device: {}", deviceConnection.getDeviceIdentification());
}
Also used : NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)

Example 2 with NodeWriteException

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

the class Iec61850EnableReportingCommand method enableReportingOnDeviceWithoutUsingSequenceNumber.

/**
     * Enable reporting so the device can send reports. This version of the
     * function does not use the 'sequence number' to filter incoming reports.
     * When using the {@link Iec61850ClearReportCommand} the 'sequence number'
     * will always be reset to 0.
     *
     * @throws NodeWriteException
     *             In case writing of data-attributes fails.
     */
public void enableReportingOnDeviceWithoutUsingSequenceNumber(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection) throws NodeWriteException {
    final NodeContainer reporting = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.LOGICAL_NODE_ZERO, DataAttribute.REPORTING, Fc.BR);
    final Iec61850ClientBaseEventListener reportListener = deviceConnection.getConnection().getIec61850ClientAssociation().getReportListener();
    reportListener.setSqNum(0);
    reporting.writeBoolean(SubDataAttribute.ENABLE_REPORTING, true);
    LOGGER.info("Allowing device {} to send reports containing events", deviceConnection.getDeviceIdentification());
}
Also used : NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer) Iec61850ClientBaseEventListener(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.reporting.Iec61850ClientBaseEventListener)

Example 3 with NodeWriteException

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

the class Iec61850ClearReportCommand method clearReportOnDevice.

public void clearReportOnDevice(final DeviceConnection deviceConnection) throws NodeWriteException {
    final NodeContainer reporting = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.LOGICAL_NODE_ZERO, DataAttribute.REPORTING, Fc.BR);
    reporting.writeBoolean(SubDataAttribute.ENABLE_REPORTING, false);
    reporting.writeBoolean(SubDataAttribute.PURGE_BUF, true);
    LOGGER.info("Cleared event buffer for device: {}", deviceConnection.getDeviceIdentification());
}
Also used : NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)

Example 4 with NodeWriteException

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

the class Iec61850Client method sendCommandWithRetry.

/**
     * Executes the apply method of the given {@link Function} with retries and
     * message logging.
     *
     * @return The given T.
     */
public <T> T sendCommandWithRetry(final Function<T> function, final String functionName, final String deviceIdentification) throws ProtocolAdapterException {
    T output = null;
    final DeviceMessageLog deviceMessageLog = new DeviceMessageLog(IED.FLEX_OVL, LogicalDevice.LIGHTING, functionName);
    try {
        output = function.apply(deviceMessageLog);
    } catch (final NodeWriteException | NodeReadException e) {
        if (ConnectionState.OK.equals(e.getConnectionState())) {
            // ServiceError means we have to retry.
            LOGGER.error("Caught ServiceError, retrying", e);
            this.sendCommandWithRetry(function, deviceIdentification, 1, deviceMessageLog);
        } else {
            LOGGER.error("Caught IOException, connection with device is broken.", e);
        }
    } catch (final ConnectionFailureException e) {
        throw e;
    } catch (final Exception e) {
        throw new ProtocolAdapterException(e == null ? "Could not execute command" : e.getMessage(), e);
    }
    return output;
}
Also used : DeviceMessageLog(com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) NodeWriteException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException) ConnectionFailureException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException) NodeReadException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) SclParseException(org.openmuc.openiec61850.SclParseException) NodeWriteException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException) NodeReadException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException) ConnectionFailureException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException) IOException(java.io.IOException) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)

Example 5 with NodeWriteException

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

the class Iec61850RtuDeviceReportingService method enableMeasurementReportingOnDevice.

private void enableMeasurementReportingOnDevice(final DeviceConnection deviceConnection, final String deviceIdentification, final LogicalDevice logicalDevice, final int logicalDeviceIndex, final DataAttribute reportName) {
    LOGGER.info("Allowing device {} to send events", deviceIdentification);
    try {
        final NodeContainer reportingNode = deviceConnection.getFcModelNode(logicalDevice, logicalDeviceIndex, LogicalNode.LOGICAL_NODE_ZERO, reportName, Fc.BR);
        reportingNode.writeBoolean(SubDataAttribute.ENABLE_REPORTING, true);
    } catch (final NullPointerException e) {
        LOGGER.debug("NullPointerException", e);
        LOGGER.warn("Skip enable reporting for device {}{}, report {}.", logicalDevice, logicalDeviceIndex, reportName.getDescription());
    } catch (final NodeWriteException e) {
        LOGGER.debug("NodeWriteException", e);
        LOGGER.error("Enable reporting for device {}{}, report {}, failed with exception: {}", logicalDevice, logicalDeviceIndex, reportName.getDescription(), e.getMessage());
    }
}
Also used : NodeWriteException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException) NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)

Aggregations

NodeContainer (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)10 NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)7 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)2 Iec61850EnableReportingCommand (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850EnableReportingCommand)2 Array (org.openmuc.openiec61850.Array)2 DeviceMessageLog (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)1 ProfilePair (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.ProfilePair)1 ConnectionFailureException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException)1 NodeReadException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException)1 Iec61850ClientBaseEventListener (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.reporting.Iec61850ClientBaseEventListener)1 Iec61850ClearReportCommand (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850ClearReportCommand)1 Iec61850SetGpsCoordinatesCommand (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850SetGpsCoordinatesCommand)1 Ssld (com.alliander.osgp.core.db.api.iec61850.entities.Ssld)1 IOException (java.io.IOException)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 BdaFloat32 (org.openmuc.openiec61850.BdaFloat32)1 BdaTimestamp (org.openmuc.openiec61850.BdaTimestamp)1 SclParseException (org.openmuc.openiec61850.SclParseException)1