use of org.opensmartgridplatform.dto.valueobjects.RelayTypeDto in project open-smart-grid-platform by OSGP.
the class Iec61850SetScheduleCommand method setScheduleOnDevice.
public void setScheduleOnDevice(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final SetScheduleDeviceRequest deviceRequest, final Ssld ssld) throws ProtocolAdapterException {
final ScheduleDto scheduleDto = deviceRequest.getSchedule();
final RelayTypeDto relayType = deviceRequest.getRelayType();
final List<ScheduleEntryDto> scheduleList = scheduleDto.getScheduleList();
try {
// Creating a list of all Schedule entries, grouped by relay index.
final Map<Integer, List<ScheduleEntry>> relaySchedulesEntries = this.createScheduleEntries(scheduleList, ssld, relayType);
final Function<Void> function = new Iec61850SetScheduleFunction(iec61850Client, deviceConnection, deviceRequest, ssld, relaySchedulesEntries, this.loggingService, this.ssldDataService);
iec61850Client.sendCommandWithRetry(function, "SetSchedule", deviceConnection.getDeviceIdentification());
} catch (final FunctionalException e) {
throw new ProtocolAdapterException(e.getMessage(), e);
}
}
use of org.opensmartgridplatform.dto.valueobjects.RelayTypeDto in project open-smart-grid-platform by OSGP.
the class Iec61850SetConfigurationFunction method setRelayConfiguration.
private void setRelayConfiguration(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final ConfigurationDto configuration, final DeviceMessageLog deviceMessageLog) throws NodeException {
if (configuration.getRelayConfiguration() != null && configuration.getRelayConfiguration().getRelayMap() != null) {
final List<RelayMapDto> relayMaps = configuration.getRelayConfiguration().getRelayMap();
for (final RelayMapDto relayMap : relayMaps) {
final Integer internalIndex = relayMap.getAddress();
final RelayTypeDto relayType = relayMap.getRelayType();
final LogicalNode logicalNode = LogicalNode.getSwitchComponentByIndex(internalIndex);
final NodeContainer switchType = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, logicalNode, DataAttribute.SWITCH_TYPE, Fc.CO);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), switchType.getFcmodelNode());
final NodeContainer operation = switchType.getChild(SubDataAttribute.OPERATION);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), operation.getFcmodelNode());
final BdaInt8 ctlVal = operation.getByte(SubDataAttribute.CONTROL_VALUE);
final byte switchTypeValue = (byte) (RelayTypeDto.LIGHT.equals(relayType) ? SWITCH_TYPE_LIGHT : SWITCH_TYPE_TARIFF);
LOGGER.info("Updating Switch for internal index {} to {} ({})", internalIndex, switchTypeValue, relayType);
ctlVal.setValue(switchTypeValue);
operation.write();
deviceMessageLog.addVariable(logicalNode, DataAttribute.SWITCH_TYPE, Fc.CO, SubDataAttribute.OPERATION, SubDataAttribute.CONTROL_VALUE, Byte.toString(switchTypeValue));
}
}
}
Aggregations