Search in sources :

Example 11 with ScheduleMessageDataContainerDto

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);
}
Also used : SetScheduleRequest(org.opensmartgridplatform.oslp.Oslp.SetScheduleRequest) ScheduleMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.ScheduleMessageDataContainerDto) ScheduleDto(org.opensmartgridplatform.dto.valueobjects.ScheduleDto)

Example 12 with ScheduleMessageDataContainerDto

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);
}
Also used : SetScheduleRequest(org.opensmartgridplatform.oslp.Oslp.SetScheduleRequest) PageInfoDto(org.opensmartgridplatform.dto.valueobjects.PageInfoDto) ScheduleMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.ScheduleMessageDataContainerDto) Oslp(org.opensmartgridplatform.oslp.Oslp) ScheduleDto(org.opensmartgridplatform.dto.valueobjects.ScheduleDto)

Example 13 with ScheduleMessageDataContainerDto

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);
}
Also used : ConfigurationDto(org.opensmartgridplatform.dto.valueobjects.ConfigurationDto) ScheduleMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.ScheduleMessageDataContainerDto) Oslp(org.opensmartgridplatform.oslp.Oslp) ScheduleDto(org.opensmartgridplatform.dto.valueobjects.ScheduleDto)

Example 14 with ScheduleMessageDataContainerDto

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);
}
Also used : ScheduleMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.ScheduleMessageDataContainerDto) GetConfigurationRequest(org.opensmartgridplatform.oslp.Oslp.GetConfigurationRequest)

Aggregations

ScheduleMessageDataContainerDto (org.opensmartgridplatform.dto.valueobjects.ScheduleMessageDataContainerDto)14 SetScheduleDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetScheduleDeviceRequest)7 ScheduleDto (org.opensmartgridplatform.dto.valueobjects.ScheduleDto)5 DeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceRequest)4 PendingSetScheduleRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.domain.entities.PendingSetScheduleRequest)4 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)3 IOException (java.io.IOException)2 Date (java.util.Date)2 JMSException (javax.jms.JMSException)2 DeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse)2 DeviceResponseHandler (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponseHandler)2 Oslp (org.opensmartgridplatform.oslp.Oslp)2 SetScheduleRequest (org.opensmartgridplatform.oslp.Oslp.SetScheduleRequest)2 OslpEnvelope (org.opensmartgridplatform.oslp.OslpEnvelope)2 UnsignedOslpEnvelopeDto (org.opensmartgridplatform.oslp.UnsignedOslpEnvelopeDto)2 Given (io.cucumber.java.en.Given)1 GetConfigurationDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse)1 OslpDevice (org.opensmartgridplatform.adapter.protocol.oslp.elster.domain.entities.OslpDevice)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1 ConfigurationDto (org.opensmartgridplatform.dto.valueobjects.ConfigurationDto)1