Search in sources :

Example 1 with LightValueMessageDataContainerDto

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());
}
Also used : LightMeasurementDevice(org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice) CdmaDevice(org.opensmartgridplatform.domain.core.valueobjects.CdmaDevice) RtuDevice(org.opensmartgridplatform.domain.core.entities.RtuDevice) Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) LightValueMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.LightValueMessageDataContainerDto)

Example 2 with LightValueMessageDataContainerDto

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);
    }
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) SetLightDeviceRequest(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetLightDeviceRequest) LightValueMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.LightValueMessageDataContainerDto) JMSException(javax.jms.JMSException)

Example 3 with LightValueMessageDataContainerDto

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);
}
Also used : Iec61850DeviceResponseHandler(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) SetLightDeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.SetLightDeviceRequest) LightValueMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.LightValueMessageDataContainerDto) JMSException(javax.jms.JMSException) DeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest) SetLightDeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.SetLightDeviceRequest) RequestMessageData(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)

Aggregations

LightValueMessageDataContainerDto (org.opensmartgridplatform.dto.valueobjects.LightValueMessageDataContainerDto)3 JMSException (javax.jms.JMSException)2 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)2 DeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest)1 SetLightDeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.SetLightDeviceRequest)1 RequestMessageData (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)1 Iec61850DeviceResponseHandler (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler)1 SetLightDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetLightDeviceRequest)1 Device (org.opensmartgridplatform.domain.core.entities.Device)1 LightMeasurementDevice (org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice)1 RtuDevice (org.opensmartgridplatform.domain.core.entities.RtuDevice)1 CdmaDevice (org.opensmartgridplatform.domain.core.valueobjects.CdmaDevice)1 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)1