Search in sources :

Example 11 with NodeWriteException

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

the class DeviceRegistrationService method setLocationInformation.

/**
     * Set the location information for this device. If the osgp_core database
     * contains longitude and latitude information for the given device, those
     * values must be saved to the corresponding data-attributes.
     */
protected void setLocationInformation(final DeviceConnection deviceConnection) {
    final Ssld ssld = DeviceRegistrationService.this.ssldDataRepository.findByDeviceIdentification(deviceConnection.getDeviceIdentification());
    if (ssld != null) {
        final Float longitude = ssld.getGpsLongitude();
        final Float latitude = ssld.getGpsLatitude();
        LOGGER.info("Ssld found for device: {} longitude: {}, latitude: {}", deviceConnection.getDeviceIdentification(), longitude, latitude);
        if (longitude != null && latitude != null) {
            try {
                new Iec61850SetGpsCoordinatesCommand().setGpsCoordinates(deviceConnection, longitude, latitude);
            } catch (final NodeWriteException e) {
                LOGGER.error("Unable to set location information for device: " + deviceConnection.getDeviceIdentification(), e);
            }
        }
    }
}
Also used : NodeWriteException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException) Iec61850SetGpsCoordinatesCommand(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850SetGpsCoordinatesCommand) Ssld(com.alliander.osgp.core.db.api.iec61850.entities.Ssld)

Example 12 with NodeWriteException

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

the class Iec61850RtuDeviceReportingService method enableStatusReportingOnDevice.

private void enableStatusReportingOnDevice(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)

Example 13 with NodeWriteException

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

the class Iec61850SsldDeviceService method enableReporting.

private void enableReporting(final DeviceConnection deviceConnection, final DeviceRequest deviceRequest) throws NodeWriteException {
    // Enabling device reporting.
    new Iec61850EnableReportingCommand().enableReportingOnDeviceWithoutUsingSequenceNumber(this.iec61850Client, deviceConnection);
    // Don't disconnect now! The device should be able to send reports.
    new Timer().schedule(new TimerTask() {

        @Override
        public void run() {
            try {
                new Iec61850ClearReportCommand().clearReportOnDevice(deviceConnection);
            } catch (final ProtocolAdapterException e) {
                LOGGER.error("Unable to clear report for device: " + deviceRequest.getDeviceIdentification(), e);
            }
            Iec61850SsldDeviceService.this.iec61850DeviceConnectionService.disconnect(deviceConnection, deviceRequest);
        }
    }, this.disconnectDelay);
}
Also used : Iec61850ClearReportCommand(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850ClearReportCommand) Timer(java.util.Timer) TimerTask(java.util.TimerTask) Iec61850EnableReportingCommand(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850EnableReportingCommand) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)

Example 14 with NodeWriteException

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

the class NodeContainer method writeFloatArray.

public void writeFloatArray(final SubDataAttribute child, final Float[] values) throws NodeWriteException {
    final Array array = (Array) this.parent.getChild(child.getDescription());
    if (array.size() != values.length) {
        throw new NodeWriteException(String.format("Invalid array size %d. Size on device is %d", values.length, array.size()));
    }
    for (int i = 0; i < values.length; i++) {
        final BdaFloat32 bdaFloat = (BdaFloat32) array.getChild(i);
        bdaFloat.setFloat(values[i]);
        this.writeNode(bdaFloat);
    }
// Unfortunately writing an array using "this.writeNode(array);"
// doesn't seem to work...
// Therefore the items are written in individual calls...
}
Also used : Array(org.openmuc.openiec61850.Array) NodeWriteException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException) BdaFloat32(org.openmuc.openiec61850.BdaFloat32)

Example 15 with NodeWriteException

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

the class NodeContainer method writeDateArray.

public void writeDateArray(final SubDataAttribute child, final Date[] values) throws NodeWriteException {
    final Array array = (Array) this.parent.getChild(child.getDescription());
    if (array.size() != values.length) {
        throw new NodeWriteException(String.format("Invalid array size %d. Size on device is %d", values.length, array.size()));
    }
    for (int i = 0; i < values.length; i++) {
        final BdaTimestamp bdaTimestamp = (BdaTimestamp) array.getChild(i);
        bdaTimestamp.setDate(values[i]);
        this.writeNode(bdaTimestamp);
    }
// Unfortunately writing an array using "this.writeNode(array);"
// doesn't seem to work...
// Therefore the items are written in individual calls...
}
Also used : Array(org.openmuc.openiec61850.Array) NodeWriteException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException) BdaTimestamp(org.openmuc.openiec61850.BdaTimestamp)

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