use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceMessageStatus 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);
}
}
use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceMessageStatus in project open-smart-grid-platform by OSGP.
the class OslpDeviceService method buildDeviceResponseSwitchConfiguration.
private DeviceResponse buildDeviceResponseSwitchConfiguration(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse) {
final DeviceMessageStatus status;
if (oslpResponse.getPayloadMessage().hasSwitchConfigurationResponse()) {
final Oslp.SwitchConfigurationResponse switchConfigurationResponse = oslpResponse.getPayloadMessage().getSwitchConfigurationResponse();
status = this.mapper.map(switchConfigurationResponse.getStatus(), DeviceMessageStatus.class);
} else {
status = DeviceMessageStatus.FAILURE;
}
return new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), deviceRequest.getMessagePriority(), status);
}
use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceMessageStatus 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);
}
Aggregations