Search in sources :

Example 1 with SetTransitionDeviceRequest

use of org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.SetTransitionDeviceRequest in project Protocol-Adapter-IEC61850 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");
    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;
    TransitionMessageDataContainerDto transitionMessageDataContainer = 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;
        transitionMessageDataContainer = (TransitionMessageDataContainerDto) 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(transitionMessageDataContainer, domain, domainVersion, messageType, retryCount, isScheduled, correlationUid, organisationIdentification, deviceIdentification);
    this.printDomainInfo(messageType, domain, domainVersion);
    final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
    final SetTransitionDeviceRequest deviceRequest = new SetTransitionDeviceRequest(organisationIdentification, deviceIdentification, correlationUid, transitionMessageDataContainer, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
    this.deviceService.setTransition(deviceRequest, iec61850DeviceResponseHandler);
}
Also used : Iec61850DeviceResponseHandler(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler) TransitionMessageDataContainerDto(com.alliander.osgp.dto.valueobjects.TransitionMessageDataContainerDto) SetTransitionDeviceRequest(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.requests.SetTransitionDeviceRequest) JMSException(javax.jms.JMSException) RequestMessageData(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)

Example 2 with SetTransitionDeviceRequest

use of org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.SetTransitionDeviceRequest 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 3 with SetTransitionDeviceRequest

use of org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.SetTransitionDeviceRequest in project open-smart-grid-platform by OSGP.

the class Iec61850SsldDeviceService method setTransition.

@Override
public void setTransition(final SetTransitionDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
    DeviceConnection devCon = null;
    try {
        final DeviceConnection deviceConnection = this.connectToDevice(deviceRequest);
        devCon = deviceConnection;
        new Iec61850TransitionCommand(this.deviceMessageLoggingService).transitionDevice(this.iec61850Client, deviceConnection, deviceRequest.getTransitionTypeContainer());
        this.createSuccessfulDefaultResponse(deviceRequest, deviceResponseHandler);
        this.enableReporting(deviceConnection, deviceRequest);
    } catch (final ConnectionFailureException se) {
        this.handleConnectionFailureException(deviceRequest, deviceResponseHandler, se);
        this.iec61850DeviceConnectionService.disconnect(devCon, deviceRequest);
    } catch (final Exception e) {
        this.handleException(deviceRequest, deviceResponseHandler, e);
        this.iec61850DeviceConnectionService.disconnect(devCon, deviceRequest);
    }
}
Also used : ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException) DeviceConnection(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection) Iec61850TransitionCommand(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850TransitionCommand) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) JMSException(javax.jms.JMSException) NodeException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException)

Aggregations

JMSException (javax.jms.JMSException)3 SetTransitionDeviceRequest (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.requests.SetTransitionDeviceRequest)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 TransitionMessageDataContainerDto (com.alliander.osgp.dto.valueobjects.TransitionMessageDataContainerDto)1 DeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest)1 SetTransitionDeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.SetTransitionDeviceRequest)1 ConnectionFailureException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException)1 NodeException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeException)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 DeviceConnection (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)1 RequestMessageData (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)1 Iec61850DeviceResponseHandler (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler)1 Iec61850TransitionCommand (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850TransitionCommand)1 TransitionMessageDataContainerDto (org.opensmartgridplatform.dto.valueobjects.TransitionMessageDataContainerDto)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)1 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)1