Search in sources :

Example 1 with GetLightSensorStatusResponse

use of org.opensmartgridplatform.adapter.domain.shared.GetLightSensorStatusResponse in project open-smart-grid-platform by OSGP.

the class AdHocManagementService method handleGetLightSensorStatusResponse.

// === GET LIGHT SENSOR STATUS ===
public void handleGetLightSensorStatusResponse(final LightSensorStatusDto lightSensorStatusDto, final CorrelationIds ids, final String messageType, final int messagePriority, final ResponseMessageResultType deviceResult, final OsgpException exception) {
    LOGGER.info("handleResponse for MessageType: {}", messageType);
    final GetLightSensorStatusResponse response = new GetLightSensorStatusResponse();
    response.setOsgpException(exception);
    response.setResult(deviceResult);
    if (lightSensorStatusDto != null) {
        response.setLightSensorStatus(new LightSensorStatus(LightSensorStatusType.valueOf(lightSensorStatusDto.getStatus().name())));
        this.updateLastCommunicationTime(ids.getDeviceIdentification());
    }
    if (deviceResult == ResponseMessageResultType.NOT_OK || exception != null) {
        LOGGER.error("Device Response not ok.", exception);
    }
    final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withIds(ids).withResult(response.getResult()).withOsgpException(response.getOsgpException()).withDataObject(response.getLightSensorStatus()).withMessagePriority(messagePriority).build();
    if (!OsgpSystemCorrelationUid.CORRELATION_UID.equals(ids.getCorrelationUid())) {
        this.webServiceResponseMessageSender.send(responseMessage);
    } else {
        LOGGER.info("We used sensor status to keep 104 LMDs connected, ignore response: {}", responseMessage);
    }
}
Also used : GetLightSensorStatusResponse(org.opensmartgridplatform.adapter.domain.shared.GetLightSensorStatusResponse) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) LightSensorStatus(org.opensmartgridplatform.domain.core.valueobjects.LightSensorStatus)

Aggregations

GetLightSensorStatusResponse (org.opensmartgridplatform.adapter.domain.shared.GetLightSensorStatusResponse)1 LightSensorStatus (org.opensmartgridplatform.domain.core.valueobjects.LightSensorStatus)1 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)1