Search in sources :

Example 1 with GetFirmwareVersionDeviceResponse

use of com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse in project Protocol-Adapter-OSLP 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;
    String firmwareVersion = "";
    OsgpException osgpException = null;
    final List<FirmwareVersionDto> firmwareVersions = new ArrayList<>();
    try {
        final GetFirmwareVersionDeviceResponse response = (GetFirmwareVersionDeviceResponse) deviceResponse;
        firmwareVersion = response.getFirmwareVersion();
        firmwareVersions.add(new FirmwareVersionDto(FirmwareModuleType.FUNCTIONAL, firmwareVersion));
    } catch (final Exception e) {
        LOGGER.error("Device Response Exception", e);
        result = ResponseMessageResultType.NOT_OK;
        osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device firmware version", e);
    }
    final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, MessagePriorityEnum.DEFAULT.getPriority());
    final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().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) GetFirmwareVersionDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse) ArrayList(java.util.ArrayList) 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) IOException(java.io.IOException) JMSException(javax.jms.JMSException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException)

Example 2 with GetFirmwareVersionDeviceResponse

use of com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse in project Protocol-Adapter-OSLP by OSGP.

the class OslpDeviceService method handleOslpResponseGetFirmwareVersion.

private void handleOslpResponseGetFirmwareVersion(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
    this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
    this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
    String firmwareVersion = "";
    if (oslpResponse.getPayloadMessage().hasGetFirmwareVersionResponse()) {
        firmwareVersion = oslpResponse.getPayloadMessage().getGetFirmwareVersionResponse().getFirmwareVersion();
    }
    final DeviceResponse deviceResponse = new GetFirmwareVersionDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), firmwareVersion);
    deviceResponseHandler.handleResponse(deviceResponse);
}
Also used : GetFirmwareVersionDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse) EmptyDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse) GetConfigurationDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse) GetStatusDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse) GetFirmwareVersionDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse) GetPowerUsageHistoryDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetPowerUsageHistoryDeviceResponse) GetActualPowerUsageDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetActualPowerUsageDeviceResponse) DeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse) ByteString(com.google.protobuf.ByteString)

Aggregations

GetFirmwareVersionDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse)2 DeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse)1 EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)1 GetActualPowerUsageDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetActualPowerUsageDeviceResponse)1 GetConfigurationDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse)1 GetPowerUsageHistoryDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetPowerUsageHistoryDeviceResponse)1 GetStatusDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse)1 FirmwareVersionDto (com.alliander.osgp.dto.valueobjects.FirmwareVersionDto)1 OsgpException (com.alliander.osgp.shared.exceptionhandling.OsgpException)1 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)1 DeviceMessageMetadata (com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)1 ProtocolResponseMessage (com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage)1 ResponseMessageResultType (com.alliander.osgp.shared.infra.jms.ResponseMessageResultType)1 ByteString (com.google.protobuf.ByteString)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 JMSException (javax.jms.JMSException)1