use of org.opensmartgridplatform.dto.valueobjects.DeviceStatusDto in project open-smart-grid-platform by OSGP.
the class TariffSwitchingGetStatusRequestMessageProcessor method handleGetStatusDeviceResponse.
private void handleGetStatusDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
DeviceStatusDto status = null;
try {
final GetStatusDeviceResponse response = (GetStatusDeviceResponse) deviceResponse;
status = response.getDeviceStatus();
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device status", e);
}
final MessageMetadata messageMetadata = MessageMetadataFactory.from(deviceResponse, messageType).builder().withDomain(domain).withDomainVersion(domainVersion).withRetryCount(retryCount).build();
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).result(result).osgpException(osgpException).dataObject(status).build();
responseMessageSender.send(responseMessage);
}
use of org.opensmartgridplatform.dto.valueobjects.DeviceStatusDto in project open-smart-grid-platform by OSGP.
the class CommonGetStatusRequestMessageProcessor method handleGetStatusDeviceResponse.
private void handleGetStatusDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
DeviceStatusDto status = null;
try {
final GetStatusDeviceResponse response = (GetStatusDeviceResponse) deviceResponse;
status = response.getDeviceStatus();
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device status", e);
}
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(MessageMetadataFactory.from(deviceResponse, messageType).builder().withDomain(domain).withDomainVersion(domainVersion).withRetryCount(retryCount).build()).result(result).osgpException(osgpException).dataObject(status).build();
responseMessageSender.send(responseMessage);
}
use of org.opensmartgridplatform.dto.valueobjects.DeviceStatusDto in project open-smart-grid-platform by OSGP.
the class PublicLightingGetStatusRequestMessageProcessor method handleGetStatusDeviceResponse.
private void handleGetStatusDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
DeviceStatusDto status = null;
try {
final GetStatusDeviceResponse response = (GetStatusDeviceResponse) deviceResponse;
status = response.getDeviceStatus();
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device status", e);
}
final MessageMetadata messageMetadata = MessageMetadataFactory.from(deviceResponse, messageType).builder().withDomain(domain).withDomainVersion(domainVersion).withRetryCount(retryCount).build();
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).result(result).osgpException(osgpException).dataObject(status).build();
responseMessageSender.send(responseMessage);
}
use of org.opensmartgridplatform.dto.valueobjects.DeviceStatusDto in project open-smart-grid-platform by OSGP.
the class OslpDeviceService method handleOslpResponseGetStatus.
private void handleOslpResponseGetStatus(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
DeviceStatusDto deviceStatus = null;
if (oslpResponse.getPayloadMessage().hasGetStatusResponse()) {
final Oslp.GetStatusResponse getStatusResponse = oslpResponse.getPayloadMessage().getGetStatusResponse();
final Oslp.Status oslpStatus = getStatusResponse.getStatus();
if (oslpStatus == Oslp.Status.OK) {
// Required properties.
final List<LightValueDto> lightValues = this.mapper.mapAsList(getStatusResponse.getValueList(), LightValueDto.class);
final LinkTypeDto preferredType = this.getPreferredLinktype(getStatusResponse);
final LinkTypeDto actualLinkType = this.getActualLinktype(getStatusResponse);
final LightTypeDto lightType = this.getLightType(getStatusResponse);
final int eventNotificationMask = getStatusResponse.getEventNotificationMask();
deviceStatus = new DeviceStatusDto(lightValues, preferredType, actualLinkType, lightType, eventNotificationMask);
// Optional properties.
this.setBootLoaderVersion(deviceStatus, getStatusResponse);
this.setCurrentConfigurationBankUsed(deviceStatus, getStatusResponse);
this.setCurrentIp(deviceStatus, getStatusResponse);
this.setCurrentTime(deviceStatus, getStatusResponse);
this.setDcOutputVoltageCurrent(deviceStatus, getStatusResponse);
this.setDcOutputVoltageMaximum(deviceStatus, getStatusResponse);
this.setEventNotificationsMask(deviceStatus, getStatusResponse);
this.setExternalFlashMemSize(deviceStatus, getStatusResponse);
this.setFirmwareVersion(deviceStatus, getStatusResponse);
this.setHardwareId(deviceStatus, getStatusResponse);
this.setInternalFlashMemSize(deviceStatus, getStatusResponse);
this.setLastInternalTestResultCode(deviceStatus, getStatusResponse);
this.setMacAddress(deviceStatus, getStatusResponse);
this.setMaximumOutputPowerOnDcOutput(deviceStatus, getStatusResponse);
this.setName(deviceStatus, getStatusResponse);
this.setNumberOfOutputs(deviceStatus, getStatusResponse);
this.setSerialNumber(deviceStatus, getStatusResponse);
this.setStartupCounter(deviceStatus, getStatusResponse);
} else {
// handle failure by throwing exceptions if needed
LOGGER.error("Unable to convert Oslp.GetStatusResponse");
}
}
final DeviceResponse deviceResponse = new GetStatusDeviceResponse(deviceRequest, deviceStatus);
deviceResponseHandler.handleResponse(deviceResponse);
}
use of org.opensmartgridplatform.dto.valueobjects.DeviceStatusDto in project open-smart-grid-platform by OSGP.
the class PublicLightingGetStatusResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing public lighting get status response message");
String correlationUid = null;
String messageType = null;
int messagePriority = MessagePriorityEnum.DEFAULT.getPriority();
String organisationIdentification = null;
String deviceIdentification = null;
ResponseMessage responseMessage;
ResponseMessageResultType responseMessageResultType = null;
OsgpException osgpException = null;
Object dataObject;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
messagePriority = message.getJMSPriority();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
responseMessage = (ResponseMessage) message.getObject();
responseMessageResultType = responseMessage.getResult();
osgpException = responseMessage.getOsgpException();
dataObject = responseMessage.getDataObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("messagePriority: {}", messagePriority);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("responseMessageResultType: {}", responseMessageResultType);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("osgpException", osgpException);
return;
}
if (OsgpSystemCorrelationUid.CORRELATION_UID.equals(correlationUid)) {
LOGGER.info("Received message for device: {} of type: {} with correlation UID: {} and result: {}.", deviceIdentification, messageType, correlationUid, responseMessageResultType.name());
this.adHocManagementService.updateLastCommunicationTime(deviceIdentification);
return;
}
try {
LOGGER.info("Calling application service function to handle response: {}", messageType);
final DeviceStatusDto deviceLightStatus = (DeviceStatusDto) dataObject;
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.adHocManagementService.handleGetStatusResponse(deviceLightStatus, ids, messageType, messagePriority, responseMessageResultType, osgpException);
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType, messagePriority);
}
}
Aggregations