Search in sources :

Example 1 with Iec61850ClearReportCommand

use of com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850ClearReportCommand 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 2 with Iec61850ClearReportCommand

use of com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850ClearReportCommand 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)

Aggregations

ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 NodeContainer (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)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 Iec61850EnableReportingCommand (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850EnableReportingCommand)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1