Search in sources :

Example 6 with ProtocolResponseMessage

use of com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage 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)

Example 7 with ProtocolResponseMessage

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

the class DeviceManagementService method sendMeasurements.

public void sendMeasurements(final String deviceIdentification, final GetDataResponseDto response) throws ProtocolAdapterException {
    // Correlation ID is generated @ WS adapter, domain+version is
    // hard-coded
    // for now
    final ProtocolResponseMessage responseMessage = new ProtocolResponseMessage.Builder().dataObject(response).deviceMessageMetadata(new DeviceMessageMetadata(deviceIdentification, "no-organisation", "no-correlationUid", DeviceFunctionDto.GET_DATA.name(), 0)).result(ResponseMessageResultType.OK).domain("MICROGRIDS").domainVersion("1.0").build();
    this.responseSender.send(responseMessage);
}
Also used : ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)

Example 8 with ProtocolResponseMessage

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

the class BaseMessageProcessor method handleExpectedError.

public void handleExpectedError(final OsgpException e, final String correlationUid, final String organisationIdentification, final String deviceIdentification, final String domain, final String domainVersion, final String messageType) {
    LOGGER.error("Expected error while processing message", e);
    final int retryCount = Integer.MAX_VALUE;
    final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceIdentification, organisationIdentification, correlationUid, messageType, 0);
    final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(ResponseMessageResultType.NOT_OK).osgpException(e).retryCount(retryCount).build();
    this.responseMessageSender.send(protocolResponseMessage);
}
Also used : ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)

Example 9 with ProtocolResponseMessage

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

the class SsldDeviceRequestMessageProcessor method handleGetStatusDeviceResponse.

// This function is used in 3 domains.
protected void handleGetStatusDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
    LOGGER.info("Handling getStatusDeviceResponse for device: {}", deviceResponse.getDeviceIdentification());
    if (StringUtils.isEmpty(deviceResponse.getCorrelationUid())) {
        LOGGER.warn("CorrelationUID is null or empty, not sending GetStatusResponse message for GetStatusRequest message for device: {}", deviceResponse.getDeviceIdentification());
        return;
    }
    final GetStatusDeviceResponse response = (GetStatusDeviceResponse) deviceResponse;
    final DeviceStatusDto status = response.getDeviceStatus();
    final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, 0);
    final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(ResponseMessageResultType.OK).osgpException(null).retryCount(retryCount).dataObject(status).build();
    responseMessageSender.send(protocolResponseMessage);
}
Also used : GetStatusDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetStatusDeviceResponse) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceStatusDto(com.alliander.osgp.dto.valueobjects.DeviceStatusDto) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)

Example 10 with ProtocolResponseMessage

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

the class BaseMessageProcessor method handleUnExpectedError.

public void handleUnExpectedError(final DeviceResponse deviceResponse, final Throwable t, final Serializable messageData, final String domain, final String domainVersion, final String messageType, final boolean isScheduled, final int retryCount) {
    final OsgpException ex = this.ensureOsgpException(t);
    final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, 0);
    final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(ResponseMessageResultType.NOT_OK).osgpException(ex).retryCount(retryCount).dataObject(messageData).scheduled(isScheduled).build();
    this.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)

Aggregations

ProtocolResponseMessage (com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage)12 DeviceMessageMetadata (com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)11 OsgpException (com.alliander.osgp.shared.exceptionhandling.OsgpException)7 ResponseMessageResultType (com.alliander.osgp.shared.infra.jms.ResponseMessageResultType)7 JMSException (javax.jms.JMSException)5 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)4 Serializable (java.io.Serializable)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 GetPowerUsageHistoryDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetPowerUsageHistoryDeviceResponse)1 GetStatusDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetStatusDeviceResponse)1 ConfigurationDto (com.alliander.osgp.dto.valueobjects.ConfigurationDto)1 DeviceStatusDto (com.alliander.osgp.dto.valueobjects.DeviceStatusDto)1 FirmwareVersionDto (com.alliander.osgp.dto.valueobjects.FirmwareVersionDto)1 PowerUsageHistoryResponseMessageDataContainerDto (com.alliander.osgp.dto.valueobjects.PowerUsageHistoryResponseMessageDataContainerDto)1 GetDataResponseDto (com.alliander.osgp.dto.valueobjects.microgrids.GetDataResponseDto)1 FunctionalException (com.alliander.osgp.shared.exceptionhandling.FunctionalException)1 NotSupportedException (com.alliander.osgp.shared.exceptionhandling.NotSupportedException)1