use of org.opensmartgridplatform.core.db.api.iec61850valueobjects.RelayType in project open-smart-grid-platform by OSGP.
the class Iec61850SetScheduleCommand method createScheduleEntries.
/**
* Returns a map of schedule entries, grouped by the internal index.
*/
private Map<Integer, List<ScheduleEntry>> createScheduleEntries(final List<ScheduleEntryDto> scheduleList, final Ssld ssld, final RelayTypeDto relayTypeDto) throws FunctionalException {
final Map<Integer, List<ScheduleEntry>> relaySchedulesEntries = new HashMap<>();
final RelayType relayType = RelayType.valueOf(relayTypeDto.name());
final List<DeviceOutputSetting> settings = this.ssldDataService.findByRelayType(ssld, relayType);
for (final ScheduleEntryDto schedule : scheduleList) {
for (final LightValueDto lightValue : schedule.getLightValue()) {
this.setScheduleEntry(ssld, relaySchedulesEntries, relayType, settings, schedule, lightValue);
}
}
return relaySchedulesEntries;
}
use of org.opensmartgridplatform.core.db.api.iec61850valueobjects.RelayType in project open-smart-grid-platform 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));
}
Aggregations