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));
}
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);
}
Aggregations