use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse in project open-smart-grid-platform by OSGP.
the class OslpDeviceService method buildDeviceResponseGetConfiguration.
private DeviceResponse buildDeviceResponseGetConfiguration(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse) {
ConfigurationDto configuration = null;
final DeviceMessageStatus status;
if (oslpResponse.getPayloadMessage().hasGetConfigurationResponse()) {
final Oslp.GetConfigurationResponse getConfigurationResponse = oslpResponse.getPayloadMessage().getGetConfigurationResponse();
configuration = this.mapper.map(getConfigurationResponse, ConfigurationDto.class);
status = this.mapper.map(getConfigurationResponse.getStatus(), DeviceMessageStatus.class);
} else {
status = DeviceMessageStatus.FAILURE;
}
return new GetConfigurationDeviceResponse(deviceRequest, status, configuration);
}
use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse in project open-smart-grid-platform by OSGP.
the class PublicLightingSetScheduleRequestMessageProcessor method handleResponse.
private void handleResponse(final DeviceResponse deviceResponse, final SetScheduleDeviceRequest deviceRequest) {
final ScheduleMessageTypeDto scheduleMessageTypeDto = deviceRequest.getScheduleMessageDataContainer().getScheduleMessageType();
switch(scheduleMessageTypeDto) {
case RETRIEVE_CONFIGURATION:
final GetConfigurationDeviceResponse getConfigurationDeviceResponse = (GetConfigurationDeviceResponse) deviceResponse;
this.handleSetScheduleGetConfigurationResponse(deviceRequest, getConfigurationDeviceResponse);
break;
case SET_ASTRONOMICAL_OFFSETS:
this.handleSetScheduleAstronomicalOffsetsResponse(deviceRequest);
break;
case SET_REBOOT:
this.handleSetScheduleSetRebootResponse(deviceRequest);
break;
case SET_SCHEDULE:
default:
this.handleEmptyDeviceResponse(deviceResponse, this.responseMessageSender, deviceRequest.getDomain(), deviceRequest.getDomainVersion(), deviceRequest.getMessageType(), deviceRequest.getRetryCount());
}
}
use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse in project open-smart-grid-platform by OSGP.
the class CommonGetConfigurationRequestMessageProcessor method handleGetConfigurationDeviceResponse.
private void handleGetConfigurationDeviceResponse(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;
ConfigurationDto configuration = null;
try {
final GetConfigurationDeviceResponse response = (GetConfigurationDeviceResponse) deviceResponse;
this.deviceResponseService.handleDeviceMessageStatus(response.getStatus());
configuration = response.getConfiguration();
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device configuration", e);
}
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(MessageMetadataFactory.from(deviceResponse, messageType).builder().withDomain(domain).withDomainVersion(domainVersion).withRetryCount(retryCount).build()).result(result).osgpException(osgpException).dataObject(configuration).build();
responseMessageSender.send(responseMessage);
}
Aggregations