Search in sources :

Example 36 with DeviceResponse

use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse in project open-smart-grid-platform by OSGP.

the class OslpDeviceService method handleOslpResponseStopSelfTest.

private void handleOslpResponseStopSelfTest(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
    this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
    this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
    final DeviceMessageStatus status;
    if (oslpResponse.getPayloadMessage().hasStopSelfTestResponse()) {
        final Oslp.Status oslpStatus = oslpResponse.getPayloadMessage().getStopSelfTestResponse().getStatus();
        status = this.mapper.map(oslpStatus, DeviceMessageStatus.class);
    } else {
        status = DeviceMessageStatus.FAILURE;
    }
    final DeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), deviceRequest.getMessagePriority(), status);
    deviceResponseHandler.handleResponse(deviceResponse);
}
Also used : DeviceMessageStatus(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceMessageStatus) EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse) DeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse) GetConfigurationDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse) GetStatusDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse) GetFirmwareVersionDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse) Oslp(org.opensmartgridplatform.oslp.Oslp) EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)

Example 37 with DeviceResponse

use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse in project open-smart-grid-platform by OSGP.

the class OslpDeviceService method handleOslpResponseSetConfiguration.

private void handleOslpResponseSetConfiguration(final DeviceRequest setConfigurationDeviceRequest, final DeviceRequest setRebootDeviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler setConfigurationDeviceResponseHandler, final DeviceResponseHandler setRebootDeviceResponseHandler) {
    this.saveOslpResponseLogEntry(setConfigurationDeviceRequest, oslpResponse);
    this.updateSequenceNumber(setConfigurationDeviceRequest.getDeviceIdentification(), oslpResponse);
    final DeviceMessageStatus status;
    if (oslpResponse.getPayloadMessage().hasSetConfigurationResponse()) {
        final Oslp.Status oslpStatus = oslpResponse.getPayloadMessage().getSetConfigurationResponse().getStatus();
        status = this.mapper.map(oslpStatus, DeviceMessageStatus.class);
    } else {
        status = DeviceMessageStatus.FAILURE;
    }
    final DeviceResponse deviceResponse = new EmptyDeviceResponse(setConfigurationDeviceRequest.getOrganisationIdentification(), setConfigurationDeviceRequest.getDeviceIdentification(), setConfigurationDeviceRequest.getCorrelationUid(), setConfigurationDeviceRequest.getMessagePriority(), status);
    setConfigurationDeviceResponseHandler.handleResponse(deviceResponse);
    if (this.executeRebootAfterSetConfiguration && status.equals(DeviceMessageStatus.OK)) {
        LOGGER.info("Sending SetRebootRequest for device: {}", setConfigurationDeviceRequest.getDeviceIdentification());
        this.setReboot(setRebootDeviceRequest);
    } else {
        LOGGER.info("Not sending SetRebootRequest for device: {} because executeRebootAfterSetConfiguration is false or DeviceMessageStatus is not OK", setConfigurationDeviceRequest.getDeviceIdentification());
        final DeviceResponse emptyDeviceResponse = new EmptyDeviceResponse(setConfigurationDeviceRequest.getOrganisationIdentification(), setConfigurationDeviceRequest.getDeviceIdentification(), setConfigurationDeviceRequest.getCorrelationUid(), setConfigurationDeviceRequest.getMessagePriority(), status);
        setRebootDeviceResponseHandler.handleResponse(emptyDeviceResponse);
    }
}
Also used : DeviceMessageStatus(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceMessageStatus) EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse) DeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse) GetConfigurationDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse) GetStatusDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse) GetFirmwareVersionDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse) Oslp(org.opensmartgridplatform.oslp.Oslp) EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)

Example 38 with DeviceResponse

use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse in project open-smart-grid-platform by OSGP.

the class OslpDeviceService method handleOslpResponseSetLight.

private void handleOslpResponseSetLight(final DeviceRequest deviceRequest, final ResumeScheduleDeviceRequest resumeScheduleDeviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler setLightDeviceResponseHandler, final DeviceResponseHandler resumeScheduleDeviceResponseHandler) {
    this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
    this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
    final DeviceMessageStatus status;
    if (oslpResponse.getPayloadMessage().hasSetLightResponse()) {
        final Oslp.Status oslpStatus = oslpResponse.getPayloadMessage().getSetLightResponse().getStatus();
        status = this.mapper.map(oslpStatus, DeviceMessageStatus.class);
    } else {
        status = DeviceMessageStatus.FAILURE;
    }
    // Send response to the message processor's device response handler.
    final DeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), deviceRequest.getMessagePriority(), status);
    setLightDeviceResponseHandler.handleResponse(deviceResponse);
    if (this.executeResumeScheduleAfterSetLight && status.equals(DeviceMessageStatus.OK)) {
        LOGGER.info("Sending ResumeScheduleRequest for device: {}", deviceRequest.getDeviceIdentification());
        this.resumeSchedule(resumeScheduleDeviceRequest);
    } else {
        LOGGER.info("Not sending ResumeScheduleRequest for device: {} because executeResumeScheduleAfterSetLight is false or DeviceMessageStatus is not OK", deviceRequest.getDeviceIdentification());
        final DeviceResponse emptyDeviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), deviceRequest.getMessagePriority(), status);
        resumeScheduleDeviceResponseHandler.handleResponse(emptyDeviceResponse);
    }
}
Also used : DeviceMessageStatus(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceMessageStatus) EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse) DeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse) GetConfigurationDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse) GetStatusDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse) GetFirmwareVersionDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse) Oslp(org.opensmartgridplatform.oslp.Oslp) EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)

Example 39 with DeviceResponse

use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse in project open-smart-grid-platform by OSGP.

the class OslpDeviceService method handleOslpResponseResumeSchedule.

private void handleOslpResponseResumeSchedule(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
    this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
    this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
    final DeviceMessageStatus status;
    if (oslpResponse.getPayloadMessage().hasResumeScheduleResponse()) {
        final Oslp.Status oslpStatus = oslpResponse.getPayloadMessage().getResumeScheduleResponse().getStatus();
        status = this.mapper.map(oslpStatus, DeviceMessageStatus.class);
    } else {
        status = DeviceMessageStatus.FAILURE;
    }
    final DeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), deviceRequest.getMessagePriority(), status);
    deviceResponseHandler.handleResponse(deviceResponse);
}
Also used : DeviceMessageStatus(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceMessageStatus) EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse) DeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse) GetConfigurationDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse) GetStatusDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse) GetFirmwareVersionDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse) Oslp(org.opensmartgridplatform.oslp.Oslp) EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)

Aggregations

DeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse)39 GetStatusDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse)24 EmptyDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)23 GetConfigurationDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse)23 GetFirmwareVersionDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse)22 IOException (java.io.IOException)19 DeviceResponseHandler (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponseHandler)18 OslpEnvelope (org.opensmartgridplatform.oslp.OslpEnvelope)18 UnsignedOslpEnvelopeDto (org.opensmartgridplatform.oslp.UnsignedOslpEnvelopeDto)18 DeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceRequest)16 Oslp (org.opensmartgridplatform.oslp.Oslp)14 DeviceMessageStatus (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceMessageStatus)13 GetStatusDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.GetStatusDeviceRequest)3 SetScheduleDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetScheduleDeviceRequest)2 ScheduleMessageDataContainerDto (org.opensmartgridplatform.dto.valueobjects.ScheduleMessageDataContainerDto)2 ByteString (com.google.protobuf.ByteString)1 ResumeScheduleDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.ResumeScheduleDeviceRequest)1 SetConfigurationDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetConfigurationDeviceRequest)1 SetDeviceVerificationKeyDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetDeviceVerificationKeyDeviceRequest)1 SetEventNotificationsDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetEventNotificationsDeviceRequest)1