Search in sources :

Example 11 with ConfigurationDto

use of org.opensmartgridplatform.dto.valueobjects.ConfigurationDto in project open-smart-grid-platform by OSGP.

the class PublicLightingSetScheduleRequestMessageProcessor method determineNextRequest.

private ScheduleMessageTypeDto determineNextRequest(final SetScheduleDeviceRequest deviceRequest, final GetConfigurationDeviceResponse deviceResponse) {
    final int requestedSunriseOffset = deviceRequest.getScheduleMessageDataContainer().getSchedule().getAstronomicalSunriseOffset();
    final int requestedSunsetOffset = deviceRequest.getScheduleMessageDataContainer().getSchedule().getAstronomicalSunsetOffset();
    final ConfigurationDto configurationInDevice = deviceResponse.getConfiguration();
    LOGGER.info("Requested astroGateSunRiseOffset {},  astroGateSunRiseOffset in device {}, Requested astroGateSunSetOffset {},  astroGateSunSetOffset in device {}, ", requestedSunriseOffset, configurationInDevice.getAstroGateSunRiseOffset(), requestedSunsetOffset, configurationInDevice.getAstroGateSunSetOffset());
    if (requestedSunriseOffset != configurationInDevice.getAstroGateSunRiseOffset() || requestedSunsetOffset != configurationInDevice.getAstroGateSunSetOffset()) {
        return ScheduleMessageTypeDto.SET_ASTRONOMICAL_OFFSETS;
    }
    return ScheduleMessageTypeDto.SET_SCHEDULE;
}
Also used : ConfigurationDto(org.opensmartgridplatform.dto.valueobjects.ConfigurationDto)

Example 12 with ConfigurationDto

use of org.opensmartgridplatform.dto.valueobjects.ConfigurationDto in project open-smart-grid-platform by OSGP.

the class OslpGetConfigurationResponseToConfigurationConverter method convert.

@Override
public ConfigurationDto convert(final Oslp.GetConfigurationResponse source, final Type<? extends ConfigurationDto> destinationType, final MappingContext context) {
    // Convert the required values for the constructor of Configuration.
    final LightTypeDto lightType = this.getLightType(source);
    final DaliConfigurationDto daliConfiguration = this.getDaliConfiguration(source);
    final RelayConfigurationDto relayConfiguration = this.getRelayConfiguration(source);
    final LinkTypeDto preferredLinkType = this.getPreferredLinkType(source);
    final ConfigurationDto configuration = ConfigurationDto.newBuilder().withLightType(lightType).withDaliConfiguration(daliConfiguration).withRelayConfiguration(relayConfiguration).withPreferredLinkType(preferredLinkType).build();
    // Set the optional values using the set() functions.
    configuration.setTimeSyncFrequency(source.getTimeSyncFrequency());
    this.setFixedIpConfiguration(source, configuration);
    configuration.setDhcpEnabled(source.getIsDhcpEnabled());
    configuration.setCommunicationTimeout(source.getCommunicationTimeout());
    configuration.setCommunicationNumberOfRetries(source.getCommunicationNumberOfRetries());
    configuration.setCommunicationPauseTimeBetweenConnectionTrials(source.getCommunicationPauseTimeBetweenConnectionTrials());
    this.setOspgIpAddress(source, configuration);
    this.setOsgpPortNumber(source, configuration);
    configuration.setTestButtonEnabled(source.getIsTestButtonEnabled());
    configuration.setAutomaticSummerTimingEnabled(source.getIsAutomaticSummerTimingEnabled());
    configuration.setAstroGateSunRiseOffset(source.getAstroGateSunRiseOffset() / SECONDS_PER_MINUTE);
    configuration.setAstroGateSunSetOffset(source.getAstroGateSunSetOffset() / SECONDS_PER_MINUTE);
    configuration.setSwitchingDelays(source.getSwitchingDelayList());
    this.setRelayLinking(source, configuration);
    configuration.setRelayRefreshing(source.getRelayRefreshing());
    final DateTime summerTimeDetails = this.convertSummerTimeWinterTimeDetails(source.getSummerTimeDetails());
    configuration.setSummerTimeDetails(summerTimeDetails);
    final DateTime winterTimeDetails = this.convertSummerTimeWinterTimeDetails(source.getWinterTimeDetails());
    configuration.setWinterTimeDetails(winterTimeDetails);
    return configuration;
}
Also used : DaliConfigurationDto(org.opensmartgridplatform.dto.valueobjects.DaliConfigurationDto) LinkTypeDto(org.opensmartgridplatform.dto.valueobjects.LinkTypeDto) LightTypeDto(org.opensmartgridplatform.dto.valueobjects.LightTypeDto) DaliConfigurationDto(org.opensmartgridplatform.dto.valueobjects.DaliConfigurationDto) RelayConfigurationDto(org.opensmartgridplatform.dto.valueobjects.RelayConfigurationDto) ConfigurationDto(org.opensmartgridplatform.dto.valueobjects.ConfigurationDto) RelayConfigurationDto(org.opensmartgridplatform.dto.valueobjects.RelayConfigurationDto) DateTime(org.joda.time.DateTime) MutableDateTime(org.joda.time.MutableDateTime)

Example 13 with ConfigurationDto

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

use of org.opensmartgridplatform.dto.valueobjects.ConfigurationDto in project open-smart-grid-platform by OSGP.

the class DomainCoreMapperTest method aConfigurationDto.

private ConfigurationDto aConfigurationDto() {
    final ConfigurationDto source = new ConfigurationDto.Builder().withLightType(this.aLightTypeDto()).withDaliConfiguration(this.aDaliConfigurationDto()).withRelayConfiguration(this.aRelayConfigurationDto()).withPreferredLinkType(LinkTypeDto.CDMA).build();
    source.setTimeSyncFrequency(133);
    source.setDeviceFixedIp(new DeviceFixedIpDto("ipAddress1", "netMask1", "gateWay1"));
    source.setDhcpEnabled(true);
    source.setTlsEnabled(true);
    source.setTlsPortNumber(134);
    source.setCommonNameString("commonNameString1");
    source.setCommunicationTimeout(135);
    source.setCommunicationNumberOfRetries(136);
    source.setCommunicationPauseTimeBetweenConnectionTrials(137);
    source.setOsgpIpAddress("osgpIpAddress1");
    source.setOsgpPortNumber(138);
    source.setNtpHost("ntpHost1");
    source.setNtpEnabled(true);
    source.setNtpSyncInterval(139);
    source.setTestButtonEnabled(true);
    source.setAutomaticSummerTimingEnabled(true);
    source.setAstroGateSunRiseOffset(140);
    source.setAstroGateSunSetOffset(141);
    source.setSwitchingDelays(asList(142, 143));
    source.setRelayLinking(asList(new RelayMatrixDto(144, true), new RelayMatrixDto(145, false)));
    source.setRelayRefreshing(true);
    source.setSummerTimeDetails(new DateTime(146L * 24 * 60 * 60 * 1000));
    source.setWinterTimeDetails(new DateTime(147L * 24 * 60 * 60 * 1000));
    return source;
}
Also used : RelayMatrixDto(org.opensmartgridplatform.dto.valueobjects.RelayMatrixDto) DaliConfigurationDto(org.opensmartgridplatform.dto.valueobjects.DaliConfigurationDto) RelayConfigurationDto(org.opensmartgridplatform.dto.valueobjects.RelayConfigurationDto) ConfigurationDto(org.opensmartgridplatform.dto.valueobjects.ConfigurationDto) DeviceFixedIpDto(org.opensmartgridplatform.dto.valueobjects.DeviceFixedIpDto) DateTime(org.joda.time.DateTime)

Example 15 with ConfigurationDto

use of org.opensmartgridplatform.dto.valueobjects.ConfigurationDto in project open-smart-grid-platform by OSGP.

the class CommonSetConfigurationRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.debug("Processing common set configuration message");
    MessageMetadata messageMetadata;
    ConfigurationDto configuration;
    try {
        messageMetadata = MessageMetadata.fromMessage(message);
        configuration = (ConfigurationDto) 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.setConfiguration(new SetConfigurationDeviceRequest(deviceRequestBuilder, configuration), iec61850DeviceResponseHandler);
}
Also used : Iec61850DeviceResponseHandler(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) ConfigurationDto(org.opensmartgridplatform.dto.valueobjects.ConfigurationDto) JMSException(javax.jms.JMSException) DeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest) SetConfigurationDeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.SetConfigurationDeviceRequest) RequestMessageData(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData) SetConfigurationDeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.SetConfigurationDeviceRequest)

Aggregations

ConfigurationDto (org.opensmartgridplatform.dto.valueobjects.ConfigurationDto)15 JMSException (javax.jms.JMSException)7 DaliConfigurationDto (org.opensmartgridplatform.dto.valueobjects.DaliConfigurationDto)4 RelayConfigurationDto (org.opensmartgridplatform.dto.valueobjects.RelayConfigurationDto)4 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)4 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)3 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)3 DateTime (org.joda.time.DateTime)2 GetConfigurationDeviceResponse (org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.GetConfigurationDeviceResponse)2 ConnectionFailureException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException)2 NodeException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeException)2 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)2 DeviceConnection (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)2 GetConfigurationDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse)2 DeviceFixedIpDto (org.opensmartgridplatform.dto.valueobjects.DeviceFixedIpDto)2 LightTypeDto (org.opensmartgridplatform.dto.valueobjects.LightTypeDto)2 LinkTypeDto (org.opensmartgridplatform.dto.valueobjects.LinkTypeDto)2 Oslp (org.opensmartgridplatform.oslp.Oslp)2 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)2 ProtocolResponseMessage (org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)2