use of org.opensmartgridplatform.dto.valueobjects.ScheduleDto in project open-smart-grid-platform by OSGP.
the class OslpDeviceService method buildOslpRequestSetScheduleSingle.
private void buildOslpRequestSetScheduleSingle(final SetScheduleDeviceRequest deviceRequest) {
final List<Oslp.Schedule> oslpSchedules = this.convertToOslpSchedules(deviceRequest.getScheduleMessageDataContainer().getSchedule().getScheduleList());
final Oslp.SetScheduleRequest.Builder request = SetScheduleRequest.newBuilder().addAllSchedules(oslpSchedules).setScheduleType(this.mapper.map(deviceRequest.getRelayType(), org.opensmartgridplatform.oslp.Oslp.RelayType.class));
final ScheduleDto schedule = new ScheduleDto(deviceRequest.getScheduleMessageDataContainer().getSchedule().getScheduleList());
final ScheduleMessageDataContainerDto scheduleMessageDataContainer = new ScheduleMessageDataContainerDto.Builder(schedule).build();
this.buildAndSignEnvelope(deviceRequest, Oslp.Message.newBuilder().setSetScheduleRequest(request.build()).build(), scheduleMessageDataContainer);
}
use of org.opensmartgridplatform.dto.valueobjects.ScheduleDto in project open-smart-grid-platform by OSGP.
the class OslpDeviceService method buildOslpRequestSetSchedulePaged.
private void buildOslpRequestSetSchedulePaged(final SetScheduleDeviceRequest deviceRequest, final Pager pager) {
final List<Oslp.Schedule> oslpSchedules = this.convertToOslpSchedules(deviceRequest.getScheduleMessageDataContainer().getSchedule().getScheduleList().subList(pager.getIndexFrom(), pager.getIndexTo()));
final Oslp.SetScheduleRequest.Builder oslpRequestBuilder = SetScheduleRequest.newBuilder().addAllSchedules(oslpSchedules).setScheduleType(this.mapper.map(deviceRequest.getRelayType(), org.opensmartgridplatform.oslp.Oslp.RelayType.class)).setPageInfo(Oslp.PageInfo.newBuilder().setCurrentPage(pager.getCurrentPage()).setPageSize(pager.getPageSize()).setTotalPages(pager.getNumberOfPages()));
final PageInfoDto pageInfo = new PageInfoDto(pager.getCurrentPage(), pager.getPageSize(), pager.getNumberOfPages());
final ScheduleDto schedule = new ScheduleDto(deviceRequest.getScheduleMessageDataContainer().getSchedule().getScheduleList());
final ScheduleMessageDataContainerDto scheduleMessageDataContainer = new ScheduleMessageDataContainerDto.Builder(schedule).withPageInfo(pageInfo).build();
this.buildAndSignEnvelope(deviceRequest, Oslp.Message.newBuilder().setSetScheduleRequest(oslpRequestBuilder.build()).build(), scheduleMessageDataContainer);
}
use of org.opensmartgridplatform.dto.valueobjects.ScheduleDto in project open-smart-grid-platform by OSGP.
the class OslpDeviceService method buildOslpRequestSetScheduleAstronomicalOffsets.
private void buildOslpRequestSetScheduleAstronomicalOffsets(final SetScheduleDeviceRequest deviceRequest) {
final ScheduleMessageDataContainerDto scheduleMessageDataContainer = deviceRequest.getScheduleMessageDataContainer();
final ScheduleDto schedule = scheduleMessageDataContainer.getSchedule();
final ConfigurationDto configuration = scheduleMessageDataContainer.getConfiguration();
// First, sort the relay mapping on (internal) index number (FLEX-2514)
if (configuration.getRelayConfiguration() != null) {
Collections.sort(configuration.getRelayConfiguration().getRelayMap(), (rm1, rm2) -> rm1.getIndex().compareTo(rm2.getIndex()));
}
int sunriseOffset = 0;
if (schedule.getAstronomicalSunriseOffset() != null) {
sunriseOffset = schedule.getAstronomicalSunriseOffset();
}
int sunsetOffset = 0;
if (schedule.getAstronomicalSunsetOffset() != null) {
sunsetOffset = schedule.getAstronomicalSunsetOffset();
}
configuration.setAstroGateSunRiseOffset(sunriseOffset);
configuration.setAstroGateSunSetOffset(sunsetOffset);
final Oslp.SetConfigurationRequest request = this.mapper.map(configuration, Oslp.SetConfigurationRequest.class);
this.buildAndSignEnvelope(deviceRequest, Oslp.Message.newBuilder().setSetConfigurationRequest(request).build(), scheduleMessageDataContainer);
}
use of org.opensmartgridplatform.dto.valueobjects.ScheduleDto 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);
}
use of org.opensmartgridplatform.dto.valueobjects.ScheduleDto in project open-smart-grid-platform by OSGP.
the class TariffSwitchingSetScheduleRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing tariff switching set schedule request message");
MessageMetadata messageMetadata;
ScheduleDto scheduleDto;
try {
messageMetadata = MessageMetadata.fromMessage(message);
scheduleDto = (ScheduleDto) message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
final RequestMessageData requestMessageData = RequestMessageData.newBuilder().messageMetadata(messageMetadata).build();
this.printDomainInfo(requestMessageData);
final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
final DeviceRequest.Builder deviceRequestBuilder = DeviceRequest.newBuilder().messageMetaData(messageMetadata);
this.deviceService.setSchedule(new SetScheduleDeviceRequest(deviceRequestBuilder, scheduleDto, RelayTypeDto.TARIFF), iec61850DeviceResponseHandler);
}
Aggregations