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);
}
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);
}
}
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);
}
}
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);
}
Aggregations