Search in sources :

Example 6 with EmptyDeviceResponse

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

the class DeviceRequestMessageProcessor method handleScheduledEmptyDeviceResponse.

protected void handleScheduledEmptyDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final boolean isScheduled, final int retryCount) {
    ResponseMessageResultType result = ResponseMessageResultType.OK;
    TechnicalException ex = null;
    try {
        final EmptyDeviceResponse response = (EmptyDeviceResponse) deviceResponse;
        this.deviceResponseService.handleDeviceMessageStatus(response.getStatus());
    } catch (final TechnicalException 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, MessagePriorityEnum.DEFAULT.getPriority());
    final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(ex).scheduled(isScheduled).retryCount(retryCount).build();
    responseMessageSender.send(responseMessage);
}
Also used : 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) EmptyDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)

Example 7 with EmptyDeviceResponse

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

the class DeviceRequestMessageProcessor method handleEmptyDeviceResponse.

protected void handleEmptyDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
    ResponseMessageResultType result = ResponseMessageResultType.OK;
    TechnicalException ex = null;
    try {
        final EmptyDeviceResponse response = (EmptyDeviceResponse) deviceResponse;
        this.deviceResponseService.handleDeviceMessageStatus(response.getStatus());
    } catch (final TechnicalException 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, MessagePriorityEnum.DEFAULT.getPriority());
    final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(ex).retryCount(retryCount).build();
    responseMessageSender.send(responseMessage);
}
Also used : 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) EmptyDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)

Example 8 with EmptyDeviceResponse

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

the class PublicLightingSetLightRequestMessageProcessor method processSignedOslpEnvelope.

@Override
public void processSignedOslpEnvelope(final String deviceIdentification, final SignedOslpEnvelopeDto signedOslpEnvelopeDto) {
    final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = signedOslpEnvelopeDto.getUnsignedOslpEnvelopeDto();
    final OslpEnvelope oslpEnvelope = signedOslpEnvelopeDto.getOslpEnvelope();
    final String correlationUid = unsignedOslpEnvelopeDto.getCorrelationUid();
    final String organisationIdentification = unsignedOslpEnvelopeDto.getOrganisationIdentification();
    final String domain = unsignedOslpEnvelopeDto.getDomain();
    final String domainVersion = unsignedOslpEnvelopeDto.getDomainVersion();
    final String messageType = unsignedOslpEnvelopeDto.getMessageType();
    final String ipAddress = unsignedOslpEnvelopeDto.getIpAddress();
    final int retryCount = unsignedOslpEnvelopeDto.getRetryCount();
    final boolean isScheduled = unsignedOslpEnvelopeDto.isScheduled();
    final DeviceResponseHandler setLightDeviceResponseHandler = new DeviceResponseHandler() {

        @Override
        public void handleResponse(final DeviceResponse deviceResponse) {
            if (((EmptyDeviceResponse) deviceResponse).getStatus().equals(DeviceMessageStatus.OK)) {
                // If the response is OK, just log it. The resumeSchedule()
                // function will be called next.
                LOGGER.info("setLight() successful for device : {}", deviceResponse.getDeviceIdentification());
            } else {
                // If the response is not OK, send a response message to the
                // responses queue.
                PublicLightingSetLightRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, PublicLightingSetLightRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
            }
        }

        @Override
        public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
            PublicLightingSetLightRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, unsignedOslpEnvelopeDto.getExtraData(), PublicLightingSetLightRequestMessageProcessor.this.responseMessageSender, deviceResponse, domain, domainVersion, messageType, isScheduled, retryCount);
        }
    };
    final DeviceRequest setLightdeviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
    // Execute a ResumeSchedule call with 'immediate = false' and 'index
    // = 0' as arguments.
    final ResumeScheduleMessageDataContainerDto resumeScheduleMessageDataContainer = new ResumeScheduleMessageDataContainerDto(0, false);
    final DeviceResponseHandler resumeScheduleDeviceResponseHandler = this.publicLightingResumeScheduleRequestMessageProcessor.createResumeScheduleDeviceResponseHandler(domain, domainVersion, DeviceRequestMessageType.RESUME_SCHEDULE.name(), retryCount, resumeScheduleMessageDataContainer, isScheduled);
    // The data of the setLightdeviceRequest can be reused
    final ResumeScheduleDeviceRequest resumeScheduleDeviceRequest = new ResumeScheduleDeviceRequest(setLightdeviceRequest.getOrganisationIdentification(), setLightdeviceRequest.getDeviceIdentification(), setLightdeviceRequest.getCorrelationUid(), resumeScheduleMessageDataContainer, setLightdeviceRequest.getDomain(), setLightdeviceRequest.getDomainVersion(), DeviceRequestMessageType.RESUME_SCHEDULE.name(), setLightdeviceRequest.getIpAddress(), setLightdeviceRequest.getRetryCount(), setLightdeviceRequest.isScheduled());
    try {
        this.deviceService.doSetLight(oslpEnvelope, setLightdeviceRequest, resumeScheduleDeviceRequest, setLightDeviceResponseHandler, resumeScheduleDeviceResponseHandler, ipAddress);
    } catch (final IOException e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, retryCount);
    }
}
Also used : UnsignedOslpEnvelopeDto(com.alliander.osgp.oslp.UnsignedOslpEnvelopeDto) EmptyDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse) DeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse) DeviceResponseHandler(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponseHandler) SetLightDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.SetLightDeviceRequest) DeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest) ResumeScheduleDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.ResumeScheduleDeviceRequest) IOException(java.io.IOException) ResumeScheduleMessageDataContainerDto(com.alliander.osgp.dto.valueobjects.ResumeScheduleMessageDataContainerDto) ResumeScheduleDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.ResumeScheduleDeviceRequest) OslpEnvelope(com.alliander.osgp.oslp.OslpEnvelope)

Example 9 with EmptyDeviceResponse

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

the class OslpDeviceService method handleOslpResponseSetScheduleSingle.

private void handleOslpResponseSetScheduleSingle(final SetScheduleDeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
    this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
    DeviceMessageStatus status;
    if (oslpResponse.getPayloadMessage().hasSetScheduleResponse()) {
        final Oslp.Status oslpStatus = oslpResponse.getPayloadMessage().getSetScheduleResponse().getStatus();
        status = this.mapper.map(oslpStatus, DeviceMessageStatus.class);
    } else {
        status = DeviceMessageStatus.FAILURE;
    }
    this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
    final DeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), status);
    deviceResponseHandler.handleResponse(deviceResponse);
}
Also used : DeviceMessageStatus(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceMessageStatus) 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) EmptyDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)

Example 10 with EmptyDeviceResponse

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

the class OslpDeviceService method handleOslpResponseSetReboot.

private void handleOslpResponseSetReboot(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
    this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
    this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
    DeviceMessageStatus status;
    if (oslpResponse.getPayloadMessage().hasSetRebootResponse()) {
        final Oslp.Status oslpStatus = oslpResponse.getPayloadMessage().getSetRebootResponse().getStatus();
        status = this.mapper.map(oslpStatus, DeviceMessageStatus.class);
    } else {
        status = DeviceMessageStatus.FAILURE;
    }
    final DeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), status);
    deviceResponseHandler.handleResponse(deviceResponse);
}
Also used : DeviceMessageStatus(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceMessageStatus) 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) EmptyDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)

Aggregations

EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)18 DeviceMessageStatus (com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceMessageStatus)15 Oslp (com.alliander.osgp.oslp.Oslp)15 DeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse)12 GetActualPowerUsageDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetActualPowerUsageDeviceResponse)11 GetConfigurationDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse)11 GetFirmwareVersionDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse)11 GetPowerUsageHistoryDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetPowerUsageHistoryDeviceResponse)11 GetStatusDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse)11 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)2 DeviceMessageMetadata (com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)2 ProtocolResponseMessage (com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage)2 ResponseMessageResultType (com.alliander.osgp.shared.infra.jms.ResponseMessageResultType)2 DeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest)1 DeviceResponseHandler (com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponseHandler)1 ResumeScheduleDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.ResumeScheduleDeviceRequest)1 SetLightDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.SetLightDeviceRequest)1 ResumeScheduleMessageDataContainerDto (com.alliander.osgp.dto.valueobjects.ResumeScheduleMessageDataContainerDto)1 OslpEnvelope (com.alliander.osgp.oslp.OslpEnvelope)1 UnsignedOslpEnvelopeDto (com.alliander.osgp.oslp.UnsignedOslpEnvelopeDto)1