Search in sources :

Example 1 with GetStatusDeviceResponse

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

the class OslpDeviceService method handleOslpResponseGetStatus.

private void handleOslpResponseGetStatus(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
    this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
    this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
    DeviceStatusDto deviceStatus = null;
    if (oslpResponse.getPayloadMessage().hasGetStatusResponse()) {
        final Oslp.GetStatusResponse getStatusResponse = oslpResponse.getPayloadMessage().getGetStatusResponse();
        final Oslp.Status oslpStatus = getStatusResponse.getStatus();
        if (oslpStatus == Oslp.Status.OK) {
            // Required properties.
            final List<LightValueDto> lightValues = this.mapper.mapAsList(getStatusResponse.getValueList(), LightValueDto.class);
            final LinkTypeDto preferredType = getStatusResponse.getPreferredLinktype().equals(Oslp.LinkType.LINK_NOT_SET) ? null : this.mapper.map(getStatusResponse.getPreferredLinktype(), LinkTypeDto.class);
            final LinkTypeDto actualLinkType = getStatusResponse.getActualLinktype().equals(Oslp.LinkType.LINK_NOT_SET) ? null : this.mapper.map(getStatusResponse.getActualLinktype(), LinkTypeDto.class);
            final LightTypeDto lightType = getStatusResponse.getLightType().equals(Oslp.LightType.LT_NOT_SET) ? null : this.mapper.map(getStatusResponse.getLightType(), LightTypeDto.class);
            final int eventNotificationMask = getStatusResponse.getEventNotificationMask();
            deviceStatus = new DeviceStatusDto(lightValues, preferredType, actualLinkType, lightType, eventNotificationMask);
            // Optional properties.
            if (getStatusResponse.hasBootLoaderVersion()) {
                deviceStatus.setBootLoaderVersion(getStatusResponse.getBootLoaderVersion());
            }
            if (getStatusResponse.getCurrentConfigurationBackUsed() != null && getStatusResponse.getCurrentConfigurationBackUsed().toByteArray().length == 1) {
                deviceStatus.setCurrentConfigurationBackUsed(this.convertCurrentConfigurationBankUsed(getStatusResponse.getCurrentConfigurationBackUsed()));
            }
            if (getStatusResponse.hasCurrentIp()) {
                deviceStatus.setCurrentIp(getStatusResponse.getCurrentIp());
            }
            if (getStatusResponse.hasCurrentTime()) {
                deviceStatus.setCurrentTime(getStatusResponse.getCurrentTime());
            }
            if (getStatusResponse.hasDcOutputVoltageCurrent()) {
                deviceStatus.setDcOutputVoltageCurrent(getStatusResponse.getDcOutputVoltageCurrent());
            }
            if (getStatusResponse.hasDcOutputVoltageMaximum()) {
                deviceStatus.setDcOutputVoltageMaximum(getStatusResponse.getDcOutputVoltageMaximum());
            }
            if (getStatusResponse.hasEventNotificationMask()) {
                deviceStatus.setEventNotificationsMask(getStatusResponse.getEventNotificationMask());
            }
            if (getStatusResponse.hasExternalFlashMemSize()) {
                deviceStatus.setExternalFlashMemSize(getStatusResponse.getExternalFlashMemSize());
            }
            if (getStatusResponse.hasFirmwareVersion()) {
                deviceStatus.setFirmwareVersion(getStatusResponse.getFirmwareVersion());
            }
            if (getStatusResponse.hasHardwareId()) {
                deviceStatus.setHardwareId(getStatusResponse.getHardwareId());
            }
            if (getStatusResponse.hasInternalFlashMemSize()) {
                deviceStatus.setInternalFlashMemSize(getStatusResponse.getInternalFlashMemSize());
            }
            if (getStatusResponse.hasLastInternalTestResultCode()) {
                deviceStatus.setLastInternalTestResultCode(getStatusResponse.getLastInternalTestResultCode());
            }
            if (getStatusResponse.getMacAddress() != null && !getStatusResponse.getMacAddress().isEmpty()) {
                deviceStatus.setMacAddress(this.convertMacAddress(getStatusResponse.getMacAddress()));
            }
            if (getStatusResponse.hasMaximumOutputPowerOnDcOutput()) {
                deviceStatus.setMaximumOutputPowerOnDcOutput(getStatusResponse.getMaximumOutputPowerOnDcOutput());
            }
            if (getStatusResponse.hasName()) {
                deviceStatus.setName(getStatusResponse.getName());
            }
            if (getStatusResponse.hasNumberOfOutputs()) {
                deviceStatus.setNumberOfOutputs(getStatusResponse.getNumberOfOutputs());
            }
            if (getStatusResponse.hasSerialNumber()) {
                deviceStatus.setSerialNumber(this.convertSerialNumber(getStatusResponse.getSerialNumber()));
            }
            if (getStatusResponse.hasStartupCounter()) {
                deviceStatus.setStartupCounter(getStatusResponse.getStartupCounter());
            }
        } else {
            // handle failure by throwing exceptions if needed
            LOGGER.error("Unable to convert Oslp.GetStatusResponse");
        }
    }
    final DeviceResponse deviceResponse = new GetStatusDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), deviceStatus);
    deviceResponseHandler.handleResponse(deviceResponse);
}
Also used : GetStatusDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse) LinkTypeDto(com.alliander.osgp.dto.valueobjects.LinkTypeDto) LightTypeDto(com.alliander.osgp.dto.valueobjects.LightTypeDto) DeviceStatusDto(com.alliander.osgp.dto.valueobjects.DeviceStatusDto) 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) Oslp(com.alliander.osgp.oslp.Oslp) LightValueDto(com.alliander.osgp.dto.valueobjects.LightValueDto)

Example 2 with GetStatusDeviceResponse

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

the class CommonGetStatusRequestMessageProcessor method handleGetStatusDeviceResponse.

private void handleGetStatusDeviceResponse(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;
    DeviceStatusDto status = null;
    try {
        final GetStatusDeviceResponse response = (GetStatusDeviceResponse) deviceResponse;
        status = response.getDeviceStatus();
    } catch (final Exception e) {
        LOGGER.error("Device Response Exception", e);
        result = ResponseMessageResultType.NOT_OK;
        osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device status", 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(status).retryCount(retryCount).build();
    responseMessageSender.send(responseMessage);
}
Also used : OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) GetStatusDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceStatusDto(com.alliander.osgp.dto.valueobjects.DeviceStatusDto) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType) OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) IOException(java.io.IOException) JMSException(javax.jms.JMSException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException)

Example 3 with GetStatusDeviceResponse

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

the class PublicLightingGetStatusRequestMessageProcessor method handleGetStatusDeviceResponse.

private void handleGetStatusDeviceResponse(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;
    DeviceStatusDto status = null;
    try {
        final GetStatusDeviceResponse response = (GetStatusDeviceResponse) deviceResponse;
        status = response.getDeviceStatus();
    } catch (final Exception e) {
        LOGGER.error("Device Response Exception", e);
        result = ResponseMessageResultType.NOT_OK;
        osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device status", 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(status).retryCount(retryCount).build();
    responseMessageSender.send(responseMessage);
}
Also used : OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) GetStatusDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceStatusDto(com.alliander.osgp.dto.valueobjects.DeviceStatusDto) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType) OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) IOException(java.io.IOException) JMSException(javax.jms.JMSException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException)

Example 4 with GetStatusDeviceResponse

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

the class TariffSwitchingGetStatusRequestMessageProcessor method handleGetStatusDeviceResponse.

private void handleGetStatusDeviceResponse(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;
    DeviceStatusDto status = null;
    try {
        final GetStatusDeviceResponse response = (GetStatusDeviceResponse) deviceResponse;
        status = response.getDeviceStatus();
    } catch (final Exception e) {
        LOGGER.error("Device Response Exception", e);
        result = ResponseMessageResultType.NOT_OK;
        osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device status", 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(status).retryCount(retryCount).build();
    responseMessageSender.send(responseMessage);
}
Also used : OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) GetStatusDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceStatusDto(com.alliander.osgp.dto.valueobjects.DeviceStatusDto) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType) OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) IOException(java.io.IOException) JMSException(javax.jms.JMSException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException)

Aggregations

GetStatusDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse)4 DeviceStatusDto (com.alliander.osgp.dto.valueobjects.DeviceStatusDto)4 OsgpException (com.alliander.osgp.shared.exceptionhandling.OsgpException)3 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)3 DeviceMessageMetadata (com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)3 ProtocolResponseMessage (com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage)3 ResponseMessageResultType (com.alliander.osgp.shared.infra.jms.ResponseMessageResultType)3 IOException (java.io.IOException)3 JMSException (javax.jms.JMSException)3 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 GetFirmwareVersionDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse)1 GetPowerUsageHistoryDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetPowerUsageHistoryDeviceResponse)1 LightTypeDto (com.alliander.osgp.dto.valueobjects.LightTypeDto)1 LightValueDto (com.alliander.osgp.dto.valueobjects.LightValueDto)1 LinkTypeDto (com.alliander.osgp.dto.valueobjects.LinkTypeDto)1 Oslp (com.alliander.osgp.oslp.Oslp)1