use of org.opensmartgridplatform.dto.valueobjects.ScheduleMessageDataContainerDto 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.ScheduleMessageDataContainerDto 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.ScheduleMessageDataContainerDto 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.ScheduleMessageDataContainerDto in project open-smart-grid-platform by OSGP.
the class OslpDeviceService method buildOslpRequestGetConfigurationForSetScheduleAstronomicalOffsets.
private void buildOslpRequestGetConfigurationForSetScheduleAstronomicalOffsets(final SetScheduleDeviceRequest deviceRequest) {
final ScheduleMessageDataContainerDto scheduleMessageDataContainer = deviceRequest.getScheduleMessageDataContainer();
final Oslp.GetConfigurationRequest.Builder request = GetConfigurationRequest.newBuilder();
this.buildAndSignEnvelope(deviceRequest, Oslp.Message.newBuilder().setGetConfigurationRequest(request.build()).build(), scheduleMessageDataContainer);
}
Aggregations