Search in sources :

Example 1 with ScheduleEntryDto

use of org.opensmartgridplatform.dto.valueobjects.ScheduleEntryDto 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)

Example 2 with ScheduleEntryDto

use of org.opensmartgridplatform.dto.valueobjects.ScheduleEntryDto 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;
}
Also used : RelayType(org.opensmartgridplatform.core.db.api.iec61850valueobjects.RelayType) ScheduleEntryDto(org.opensmartgridplatform.dto.valueobjects.ScheduleEntryDto) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) DeviceOutputSetting(org.opensmartgridplatform.core.db.api.iec61850.entities.DeviceOutputSetting) LightValueDto(org.opensmartgridplatform.dto.valueobjects.LightValueDto)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 ScheduleEntryDto (org.opensmartgridplatform.dto.valueobjects.ScheduleEntryDto)2 HashMap (java.util.HashMap)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 Iec61850SetScheduleFunction (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.Iec61850SetScheduleFunction)1 DeviceOutputSetting (org.opensmartgridplatform.core.db.api.iec61850.entities.DeviceOutputSetting)1 RelayType (org.opensmartgridplatform.core.db.api.iec61850valueobjects.RelayType)1 LightValueDto (org.opensmartgridplatform.dto.valueobjects.LightValueDto)1 RelayTypeDto (org.opensmartgridplatform.dto.valueobjects.RelayTypeDto)1 ScheduleDto (org.opensmartgridplatform.dto.valueobjects.ScheduleDto)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1