Search in sources :

Example 1 with TransitionMessageDataContainerDto

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

the class PublicLightingSetTransitionRequestMessageProcessor method processMessage.

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

Example 2 with TransitionMessageDataContainerDto

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

the class PublicLightingSetTransitionRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    LOGGER.debug("Processing public lighting set transition request message");
    MessageMetadata messageMetadata;
    TransitionMessageDataContainerDto transitionMessageDataContainer;
    try {
        messageMetadata = MessageMetadata.fromMessage(message);
        transitionMessageDataContainer = (TransitionMessageDataContainerDto) 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 SetTransitionDeviceRequest deviceRequest = new SetTransitionDeviceRequest(DeviceRequest.newBuilder().messageMetaData(messageMetadata), transitionMessageDataContainer);
        this.deviceService.setTransition(deviceRequest);
    } catch (final RuntimeException e) {
        this.handleError(e, messageMetadata);
    }
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) TransitionMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.TransitionMessageDataContainerDto) SetTransitionDeviceRequest(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetTransitionDeviceRequest) JMSException(javax.jms.JMSException)

Example 3 with TransitionMessageDataContainerDto

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

the class SetTransitionService method setTransitionForDevice.

private void setTransitionForDevice(final MessageMetadata metadata, final String ipAddress, @NotNull final TransitionType transitionType, final DateTime transitionTime) {
    final String organisationIdentification = metadata.getOrganisationIdentification();
    final String deviceIdentification = metadata.getDeviceIdentification();
    LOGGER.debug("Private setTransitionForDevice called for device {} with organisation {}", deviceIdentification, organisationIdentification);
    final TransitionMessageDataContainerDto transitionMessageDataContainerDto = new TransitionMessageDataContainerDto(this.domainCoreMapper.map(transitionType, org.opensmartgridplatform.dto.valueobjects.TransitionTypeDto.class), transitionTime);
    this.osgpCoreRequestMessageSender.send(new RequestMessage(metadata.getCorrelationUid(), organisationIdentification, deviceIdentification, transitionMessageDataContainerDto), metadata.getMessageType(), metadata.getMessagePriority(), ipAddress);
}
Also used : TransitionMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.TransitionMessageDataContainerDto) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage)

Aggregations

TransitionMessageDataContainerDto (org.opensmartgridplatform.dto.valueobjects.TransitionMessageDataContainerDto)3 JMSException (javax.jms.JMSException)2 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)2 DeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest)1 SetTransitionDeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.SetTransitionDeviceRequest)1 RequestMessageData (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)1 Iec61850DeviceResponseHandler (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler)1 SetTransitionDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetTransitionDeviceRequest)1 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)1