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;
}
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;
}
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);
}
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;
}
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);
}
Aggregations