Search in sources :

Example 1 with GetConfigurationDeviceResponse

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);
}
Also used : DeviceMessageStatus(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceMessageStatus) ConfigurationDto(org.opensmartgridplatform.dto.valueobjects.ConfigurationDto) GetConfigurationDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse) Oslp(org.opensmartgridplatform.oslp.Oslp)

Example 2 with GetConfigurationDeviceResponse

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());
    }
}
Also used : ScheduleMessageTypeDto(org.opensmartgridplatform.dto.valueobjects.ScheduleMessageTypeDto) GetConfigurationDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse)

Example 3 with GetConfigurationDeviceResponse

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);
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) ProtocolResponseMessage(org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage) ConfigurationDto(org.opensmartgridplatform.dto.valueobjects.ConfigurationDto) GetConfigurationDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) IOException(java.io.IOException) JMSException(javax.jms.JMSException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)

Aggregations

GetConfigurationDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse)3 ConfigurationDto (org.opensmartgridplatform.dto.valueobjects.ConfigurationDto)2 IOException (java.io.IOException)1 JMSException (javax.jms.JMSException)1 DeviceMessageStatus (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceMessageStatus)1 ScheduleMessageTypeDto (org.opensmartgridplatform.dto.valueobjects.ScheduleMessageTypeDto)1 Oslp (org.opensmartgridplatform.oslp.Oslp)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)1 ProtocolResponseMessage (org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)1 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)1