Search in sources :

Example 36 with ProtocolAdapterException

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

the class Iec61850GetConfigurationCommand method checkRelayType.

private void checkRelayType(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final DeviceOutputSetting deviceOutputSetting, final DeviceMessageLog deviceMessageLog) throws ProtocolAdapterException {
    final RelayType registeredRelayType = deviceOutputSetting.getRelayType();
    final int expectedSwType;
    if (RelayType.LIGHT.equals(registeredRelayType)) {
        expectedSwType = SWITCH_TYPE_LIGHT;
    } else if (RelayType.TARIFF.equals(registeredRelayType) || RelayType.TARIFF_REVERSED.equals(registeredRelayType)) {
        expectedSwType = SWITCH_TYPE_TARIFF;
    } else {
        throw new ProtocolAdapterException("DeviceOutputSetting (internal index = " + deviceOutputSetting.getInternalId() + ", external index = " + deviceOutputSetting.getExternalId() + ") does not have a known RelayType: " + registeredRelayType);
    }
    final LogicalNode logicalNode = LogicalNode.getSwitchComponentByIndex(deviceOutputSetting.getInternalId());
    final NodeContainer switchType = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, logicalNode, DataAttribute.SWITCH_TYPE, Fc.ST);
    iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), switchType.getFcmodelNode());
    final int switchTypeValue = switchType.getByte(SubDataAttribute.STATE).getValue();
    if (expectedSwType != switchTypeValue) {
        throw new ProtocolAdapterException("DeviceOutputSetting (internal index = " + deviceOutputSetting.getInternalId() + ", external index = " + deviceOutputSetting.getExternalId() + ") has a RelayType (" + registeredRelayType + ") that does not match the SwType on the device: " + (switchTypeValue == SWITCH_TYPE_TARIFF ? "Tariff switch (0)" : (switchTypeValue == SWITCH_TYPE_LIGHT ? "Light switch (1)" : "Unknown value: " + switchTypeValue)));
    }
    deviceMessageLog.addVariable(logicalNode, DataAttribute.SWITCH_TYPE, Fc.ST, SubDataAttribute.STATE, Integer.toString(switchTypeValue));
}
Also used : RelayType(com.alliander.osgp.core.db.api.iec61850valueobjects.RelayType) NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) LogicalNode(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.LogicalNode)

Example 37 with ProtocolAdapterException

use of com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException 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)22 DeviceMessageLog (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)16 Function (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.Function)15 NodeContainer (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)11 ArrayList (java.util.ArrayList)9 DateTime (org.joda.time.DateTime)7 ConnectionFailureException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException)6 DeviceOutputSetting (com.alliander.osgp.core.db.api.iec61850.entities.DeviceOutputSetting)6 NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)5 DeviceConnection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)5 LogicalNode (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.LogicalNode)5 FunctionalException (com.alliander.osgp.shared.exceptionhandling.FunctionalException)5 BdaBoolean (org.openmuc.openiec61850.BdaBoolean)5 Ssld (com.alliander.osgp.core.db.api.iec61850.entities.Ssld)4 LightValueDto (com.alliander.osgp.dto.valueobjects.LightValueDto)4 IOException (java.io.IOException)4 List (java.util.List)4 JMSException (javax.jms.JMSException)4 ScheduleEntry (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.ScheduleEntry)3 NodeReadException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException)3