Search in sources :

Example 1 with Iec61850SetScheduleFunction

use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.Iec61850SetScheduleFunction 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);
    }
}
Also used : ScheduleEntryDto(org.opensmartgridplatform.dto.valueobjects.ScheduleEntryDto) Iec61850SetScheduleFunction(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.Iec61850SetScheduleFunction) ArrayList(java.util.ArrayList) List(java.util.List) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) RelayTypeDto(org.opensmartgridplatform.dto.valueobjects.RelayTypeDto) ScheduleDto(org.opensmartgridplatform.dto.valueobjects.ScheduleDto)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 Iec61850SetScheduleFunction (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.Iec61850SetScheduleFunction)1 RelayTypeDto (org.opensmartgridplatform.dto.valueobjects.RelayTypeDto)1 ScheduleDto (org.opensmartgridplatform.dto.valueobjects.ScheduleDto)1 ScheduleEntryDto (org.opensmartgridplatform.dto.valueobjects.ScheduleEntryDto)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1