Search in sources :

Example 6 with NodeWriteException

use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException in project open-smart-grid-platform by OSGP.

the class Iec61850RtuDeviceReportingService method resyncBufferedReport.

private void resyncBufferedReport(final DeviceConnection connection, final String deviceIdentification, final Brcb brcb) {
    final NodeContainer node = new NodeContainer(connection, brcb);
    try {
        this.client.readNodeDataValues(connection.getConnection().getClientAssociation(), node.getFcmodelNode());
    } catch (final NodeReadException e) {
        LOGGER.debug("NodeReadException", e);
        LOGGER.error("Resync reporting failed, could not read report id from device {}, exception: {}", deviceIdentification, e.getMessage());
        return;
    }
    final String reportId = node.getString(SubDataAttribute.REPORT_ID);
    LOGGER.debug("Resync reporting for report {} on device {}", reportId, deviceIdentification);
    final Iec61850ReportEntry reportEntry = this.iec61850ReportEntryRepository.findByDeviceIdentificationAndReportId(deviceIdentification, reportId);
    if (reportEntry == null) {
        LOGGER.info("Resync reporting for report {} on device {} not possible, no last report entry found", reportId, deviceIdentification);
    } else {
        LOGGER.info("Resync reporting for report {} on device {} with last report entry: {}", reportId, deviceIdentification, reportEntry);
        try {
            node.writeOctetString(SubDataAttribute.ENTRY_ID, reportEntry.getEntryId());
        } catch (final NodeWriteException e) {
            LOGGER.debug("NodeWriteException", e);
            LOGGER.error("Resync reporting for report {} on device {} failed with exception: {}", reportId, deviceIdentification, e.getMessage());
        }
    }
}
Also used : NodeWriteException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException) NodeReadException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeReadException) NodeContainer(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer) Iec61850ReportEntry(org.opensmartgridplatform.adapter.protocol.iec61850.domain.entities.Iec61850ReportEntry)

Example 7 with NodeWriteException

use of org.opensmartgridplatform.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 8 with NodeWriteException

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

Example 9 with NodeWriteException

use of org.opensmartgridplatform.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 10 with NodeWriteException

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

Aggregations

NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)7 NodeWriteException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException)5 NodeContainer (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)2 Array (com.beanit.openiec61850.Array)2 IOException (java.io.IOException)2 Array (org.openmuc.openiec61850.Array)2 NodeReadException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeReadException)2 NodeContainer (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)2 DeviceMessageLog (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)1 ConnectionFailureException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException)1 NodeReadException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException)1 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 Iec61850EnableReportingCommand (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850EnableReportingCommand)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 BdaFloat32 (com.beanit.openiec61850.BdaFloat32)1 BdaTimestamp (com.beanit.openiec61850.BdaTimestamp)1 Brcb (com.beanit.openiec61850.Brcb)1 Rcb (com.beanit.openiec61850.Rcb)1 SclParseException (com.beanit.openiec61850.SclParseException)1