Search in sources :

Example 1 with DeviceMessageMetadata

use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-IEC61850 by OSGP.

the class PublicLightingGetPowerUsageHistoryRequestMessageProcessor method handleGetPowerUsageHistoryDeviceResponse.

private void handleGetPowerUsageHistoryDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount, final int messagePriority, final Long scheduleTime) {
    final GetPowerUsageHistoryDeviceResponse getPowerUsageHistoryDeviceResponse = (GetPowerUsageHistoryDeviceResponse) deviceResponse;
    ResponseMessageResultType result = ResponseMessageResultType.OK;
    OsgpException osgpException = null;
    PowerUsageHistoryResponseMessageDataContainerDto powerUsageHistoryResponseMessageDataContainer = null;
    try {
        powerUsageHistoryResponseMessageDataContainer = new PowerUsageHistoryResponseMessageDataContainerDto(getPowerUsageHistoryDeviceResponse.getPowerUsageHistoryData());
    } catch (final Exception e) {
        LOGGER.error("Device Response Exception", e);
        result = ResponseMessageResultType.NOT_OK;
        osgpException = new TechnicalException(ComponentType.PROTOCOL_IEC61850, "Unexpected exception while retrieving response message", e);
    }
    final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, messagePriority, scheduleTime);
    final ProtocolResponseMessage.Builder builder = new ProtocolResponseMessage.Builder();
    final ProtocolResponseMessage responseMessage = builder.domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(osgpException).dataObject(powerUsageHistoryResponseMessageDataContainer).retryCount(retryCount).build();
    responseMessageSender.send(responseMessage);
}
Also used : OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) PowerUsageHistoryResponseMessageDataContainerDto(com.alliander.osgp.dto.valueobjects.PowerUsageHistoryResponseMessageDataContainerDto) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) GetPowerUsageHistoryDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetPowerUsageHistoryDeviceResponse) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType) OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException)

Example 2 with DeviceMessageMetadata

use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-IEC61850 by OSGP.

the class CommonGetConfigurationRequestMessageProcessor method handleGetConfigurationDeviceResponse.

private void handleGetConfigurationDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
    ResponseMessageResultType result = ResponseMessageResultType.OK;
    OsgpException osgpException = null;
    ConfigurationDto configuration = null;
    try {
        final GetConfigurationDeviceResponse response = (GetConfigurationDeviceResponse) deviceResponse;
        configuration = response.getConfiguration();
    } catch (final Exception e) {
        LOGGER.error("Device Response Exception", e);
        result = ResponseMessageResultType.NOT_OK;
        osgpException = new TechnicalException(ComponentType.PROTOCOL_IEC61850, "Unexpected exception while retrieving response message", e);
    }
    final DeviceMessageMetadata deviceMessageMetaData = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, 0);
    final ProtocolResponseMessage responseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetaData).result(result).osgpException(osgpException).dataObject(configuration).retryCount(retryCount).build();
    responseMessageSender.send(responseMessage);
}
Also used : OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) ConfigurationDto(com.alliander.osgp.dto.valueobjects.ConfigurationDto) GetConfigurationDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetConfigurationDeviceResponse) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType) OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException)

Example 3 with DeviceMessageMetadata

use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-IEC61850 by OSGP.

the class CommonGetFirmwareRequestMessageProcessor method handleGetFirmwareVersionDeviceResponse.

private void handleGetFirmwareVersionDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
    ResponseMessageResultType result = ResponseMessageResultType.OK;
    OsgpException osgpException = null;
    List<FirmwareVersionDto> firmwareVersions = null;
    try {
        firmwareVersions = ((GetFirmwareVersionDeviceResponse) deviceResponse).getFirmwareVersions();
    } catch (final Exception e) {
        LOGGER.error("Device Response Exception", e);
        result = ResponseMessageResultType.NOT_OK;
        osgpException = new TechnicalException(ComponentType.UNKNOWN, "Unexpected exception while retrieving response message", e);
    }
    final DeviceMessageMetadata deviceMessageMetaData = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, 0);
    final ProtocolResponseMessage responseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetaData).result(result).osgpException(osgpException).dataObject((Serializable) firmwareVersions).retryCount(retryCount).build();
    responseMessageSender.send(responseMessage);
}
Also used : OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType) FirmwareVersionDto(com.alliander.osgp.dto.valueobjects.FirmwareVersionDto) OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException)

Example 4 with DeviceMessageMetadata

use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-IEC61850 by OSGP.

the class BaseMessageProcessor method handleDeviceResponse.

/**
     * Handles {@link EmptyDeviceResponse} by default. MessageProcessor
     * implementations can override this function to handle responses containing
     * data.
     */
public void handleDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount, final int messagePriority, final Long scheduleTime) {
    ResponseMessageResultType result = ResponseMessageResultType.OK;
    OsgpException ex = null;
    try {
        final EmptyDeviceResponse response = (EmptyDeviceResponse) deviceResponse;
        this.deviceResponseService.handleDeviceMessageStatus(response.getStatus());
    } catch (final OsgpException e) {
        LOGGER.error("Device Response Exception", e);
        result = ResponseMessageResultType.NOT_OK;
        ex = e;
    }
    final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, messagePriority, scheduleTime);
    final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(ex).retryCount(retryCount).build();
    responseMessageSender.send(protocolResponseMessage);
}
Also used : OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType) EmptyDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)

Example 5 with DeviceMessageMetadata

use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-IEC61850 by OSGP.

the class DaRtuDeviceRequestMessageProcessor method handleDeviceResponse.

/**
     * Override to include the data in the response
     */
@Override
public void handleDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount, final int messagePriority, final Long scheduleTime) {
    ResponseMessageResultType result = ResponseMessageResultType.OK;
    OsgpException ex = null;
    Serializable dataObject = null;
    try {
        final DaDeviceResponse response = (DaDeviceResponse) deviceResponse;
        this.deviceResponseService.handleDeviceMessageStatus(response.getStatus());
        dataObject = response.getDataResponse();
    } catch (final OsgpException e) {
        LOGGER.error("Device Response Exception", e);
        result = ResponseMessageResultType.NOT_OK;
        ex = e;
    }
    final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, messagePriority, scheduleTime);
    final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(ex).dataObject(dataObject).retryCount(retryCount).build();
    responseMessageSender.send(protocolResponseMessage);
}
Also used : DaDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.da.rtu.DaDeviceResponse) OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) Serializable(java.io.Serializable) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType)

Aggregations

DeviceMessageMetadata (com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)26 ProtocolResponseMessage (com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage)26 ResponseMessageResultType (com.alliander.osgp.shared.infra.jms.ResponseMessageResultType)17 OsgpException (com.alliander.osgp.shared.exceptionhandling.OsgpException)15 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)15 JMSException (javax.jms.JMSException)12 IOException (java.io.IOException)6 DeviceStatusDto (com.alliander.osgp.dto.valueobjects.DeviceStatusDto)4 Serializable (java.io.Serializable)4 GetStatusDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse)3 EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)2 ConfigurationDto (com.alliander.osgp.dto.valueobjects.ConfigurationDto)2 FirmwareVersionDto (com.alliander.osgp.dto.valueobjects.FirmwareVersionDto)2 PowerUsageHistoryResponseMessageDataContainerDto (com.alliander.osgp.dto.valueobjects.PowerUsageHistoryResponseMessageDataContainerDto)2 FunctionalException (com.alliander.osgp.shared.exceptionhandling.FunctionalException)2 NotSupportedException (com.alliander.osgp.shared.exceptionhandling.NotSupportedException)2 DaDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.da.rtu.DaDeviceResponse)1 EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)1 GetConfigurationDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetConfigurationDeviceResponse)1 GetDataDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetDataDeviceResponse)1