use of org.opensmartgridplatform.domain.core.valueobjects.LightValue in project open-smart-grid-platform by OSGP.
the class ScheduleManagementService method setTariffSchedule.
// === SET TARIFF SCHEDULE ===
/**
* Set a tariff schedule.
*/
public void setTariffSchedule(final CorrelationIds ids, final List<ScheduleEntry> schedules, final Long scheduleTime, final String messageType, final int messagePriority) throws FunctionalException {
LOGGER.info("setTariffSchedule called with organisation {} and device {}.", ids.getOrganisationIdentification(), ids.getDeviceIdentification());
this.findOrganisation(ids.getOrganisationIdentification());
final Device device = this.findActiveDevice(ids.getDeviceIdentification());
if (Ssld.PSLD_TYPE.equals(device.getDeviceType())) {
throw new FunctionalException(FunctionalExceptionType.TARIFF_SCHEDULE_NOT_ALLOWED_FOR_PSLD, ComponentType.DOMAIN_TARIFF_SWITCHING, new ValidationException("Set tariff schedule is not allowed for PSLD."));
}
// Reverse schedule switching for TARIFF_REVERSED relays.
for (final DeviceOutputSetting dos : this.getSsldForDevice(device).getOutputSettings()) {
if (dos.getOutputType().equals(RelayType.TARIFF_REVERSED)) {
for (final ScheduleEntry schedule : schedules) {
for (final LightValue lightValue : schedule.getLightValue()) {
lightValue.invertIsOn();
}
}
}
}
LOGGER.info("Mapping to schedule DTO");
final List<org.opensmartgridplatform.dto.valueobjects.ScheduleEntryDto> schedulesDto = this.domainCoreMapper.mapAsList(schedules, org.opensmartgridplatform.dto.valueobjects.ScheduleEntryDto.class);
final ScheduleDto scheduleDto = new ScheduleDto(schedulesDto);
LOGGER.info("Sending message");
this.osgpCoreRequestMessageSender.send(new RequestMessage(ids, scheduleDto), messageType, messagePriority, device.getIpAddress(), scheduleTime);
}
Aggregations