use of org.opensmartgridplatform.dto.valueobjects.LightValueMessageDataContainerDto in project open-smart-grid-platform by OSGP.
the class AdHocManagementService method setLight.
// === SET LIGHT ===
public void setLight(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final List<LightValue> lightValues, final String messageType, final int messagePriority) throws FunctionalException {
LOGGER.debug("setLight called for device {} with organisation {}", deviceIdentification, organisationIdentification);
this.findOrganisation(organisationIdentification);
final Device device = this.findActiveDevice(deviceIdentification);
final List<org.opensmartgridplatform.dto.valueobjects.LightValueDto> lightValuesDto = this.domainCoreMapper.mapAsList(lightValues, org.opensmartgridplatform.dto.valueobjects.LightValueDto.class);
final LightValueMessageDataContainerDto lightValueMessageDataContainer = new LightValueMessageDataContainerDto(lightValuesDto);
this.osgpCoreRequestMessageSender.send(new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, lightValueMessageDataContainer), messageType, messagePriority, device.getIpAddress());
}
use of org.opensmartgridplatform.dto.valueobjects.LightValueMessageDataContainerDto in project open-smart-grid-platform by OSGP.
the class PublicLightingSetLightRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) {
LOGGER.debug("Processing public lighting set light request message");
MessageMetadata messageMetadata;
LightValueMessageDataContainerDto lightValueMessageDataContainer;
try {
messageMetadata = MessageMetadata.fromMessage(message);
lightValueMessageDataContainer = (LightValueMessageDataContainerDto) message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
try {
this.printDomainInfo(messageMetadata.getMessageType(), messageMetadata.getDomain(), messageMetadata.getDomainVersion());
final SetLightDeviceRequest deviceRequest = new SetLightDeviceRequest(DeviceRequest.newBuilder().messageMetaData(messageMetadata), lightValueMessageDataContainer);
this.deviceService.setLight(deviceRequest);
} catch (final RuntimeException e) {
this.handleError(e, messageMetadata);
}
}
use of org.opensmartgridplatform.dto.valueobjects.LightValueMessageDataContainerDto in project open-smart-grid-platform by OSGP.
the class PublicLightingSetLightRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing public lighting set light request message");
MessageMetadata messageMetadata;
LightValueMessageDataContainerDto lightValueMessageDataContainer;
try {
messageMetadata = MessageMetadata.fromMessage(message);
lightValueMessageDataContainer = (LightValueMessageDataContainerDto) 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.setLight(new SetLightDeviceRequest(deviceRequestBuilder, lightValueMessageDataContainer), iec61850DeviceResponseHandler);
}
Aggregations