Search in sources :

Example 1 with LightValueMessageDataContainerDto

use of com.alliander.osgp.dto.valueobjects.LightValueMessageDataContainerDto in project Protocol-Adapter-OSLP by OSGP.

the class PublicLightingSetLightRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    LOGGER.debug("Processing public lighting set light request message");
    String correlationUid = null;
    String domain = null;
    String domainVersion = null;
    String messageType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    String ipAddress = null;
    int retryCount = 0;
    boolean isScheduled = false;
    try {
        correlationUid = message.getJMSCorrelationID();
        domain = message.getStringProperty(Constants.DOMAIN);
        domainVersion = message.getStringProperty(Constants.DOMAIN_VERSION);
        messageType = message.getJMSType();
        organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
        deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        ipAddress = message.getStringProperty(Constants.IP_ADDRESS);
        retryCount = message.getIntProperty(Constants.RETRY_COUNT);
        isScheduled = message.propertyExists(Constants.IS_SCHEDULED) ? message.getBooleanProperty(Constants.IS_SCHEDULED) : false;
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        LOGGER.debug("correlationUid: {}", correlationUid);
        LOGGER.debug("domain: {}", domain);
        LOGGER.debug("domainVersion: {}", domainVersion);
        LOGGER.debug("messageType: {}", messageType);
        LOGGER.debug("organisationIdentification: {}", organisationIdentification);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        LOGGER.debug("ipAddress: {}", ipAddress);
        return;
    }
    try {
        final LightValueMessageDataContainerDto lightValueMessageDataContainer = (LightValueMessageDataContainerDto) message.getObject();
        LOGGER.info("Calling DeviceService function: {} for domain: {} {}", messageType, domain, domainVersion);
        final SetLightDeviceRequest deviceRequest = new SetLightDeviceRequest(organisationIdentification, deviceIdentification, correlationUid, lightValueMessageDataContainer, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
        this.deviceService.setLight(deviceRequest);
    } catch (final Exception e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, retryCount);
    }
}
Also used : SetLightDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.SetLightDeviceRequest) LightValueMessageDataContainerDto(com.alliander.osgp.dto.valueobjects.LightValueMessageDataContainerDto) JMSException(javax.jms.JMSException) IOException(java.io.IOException) JMSException(javax.jms.JMSException)

Example 2 with LightValueMessageDataContainerDto

use of com.alliander.osgp.dto.valueobjects.LightValueMessageDataContainerDto in project Protocol-Adapter-IEC61850 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");
    String correlationUid = null;
    String domain = null;
    String domainVersion = null;
    String messageType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    String ipAddress = null;
    int retryCount = 0;
    boolean isScheduled = false;
    LightValueMessageDataContainerDto lightValueMessageDataContainer = null;
    try {
        correlationUid = message.getJMSCorrelationID();
        domain = message.getStringProperty(Constants.DOMAIN);
        domainVersion = message.getStringProperty(Constants.DOMAIN_VERSION);
        messageType = message.getJMSType();
        organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
        deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        ipAddress = message.getStringProperty(Constants.IP_ADDRESS);
        retryCount = message.getIntProperty(Constants.RETRY_COUNT);
        isScheduled = message.propertyExists(Constants.IS_SCHEDULED) ? message.getBooleanProperty(Constants.IS_SCHEDULED) : false;
        lightValueMessageDataContainer = (LightValueMessageDataContainerDto) message.getObject();
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        LOGGER.debug("correlationUid: {}", correlationUid);
        LOGGER.debug("domain: {}", domain);
        LOGGER.debug("domainVersion: {}", domainVersion);
        LOGGER.debug("messageType: {}", messageType);
        LOGGER.debug("organisationIdentification: {}", organisationIdentification);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        LOGGER.debug("ipAddress: {}", ipAddress);
        return;
    }
    final RequestMessageData requestMessageData = new RequestMessageData(lightValueMessageDataContainer, domain, domainVersion, messageType, retryCount, isScheduled, correlationUid, organisationIdentification, deviceIdentification);
    this.printDomainInfo(messageType, domain, domainVersion);
    final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
    final SetLightDeviceRequest deviceRequest = new SetLightDeviceRequest(organisationIdentification, deviceIdentification, correlationUid, lightValueMessageDataContainer, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
    this.deviceService.setLight(deviceRequest, iec61850DeviceResponseHandler);
}
Also used : Iec61850DeviceResponseHandler(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler) SetLightDeviceRequest(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.requests.SetLightDeviceRequest) LightValueMessageDataContainerDto(com.alliander.osgp.dto.valueobjects.LightValueMessageDataContainerDto) JMSException(javax.jms.JMSException) RequestMessageData(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)

Aggregations

LightValueMessageDataContainerDto (com.alliander.osgp.dto.valueobjects.LightValueMessageDataContainerDto)2 JMSException (javax.jms.JMSException)2 SetLightDeviceRequest (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.requests.SetLightDeviceRequest)1 RequestMessageData (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)1 Iec61850DeviceResponseHandler (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler)1 SetLightDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.SetLightDeviceRequest)1 IOException (java.io.IOException)1