Search in sources :

Example 6 with DeviceResponse

use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse in project open-smart-grid-platform by OSGP.

the class OslpDeviceService method handleOslpResponseSwitchConfiguration.

private void handleOslpResponseSwitchConfiguration(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
    this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
    this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
    final DeviceResponse deviceResponse = this.buildDeviceResponseSwitchConfiguration(deviceRequest, oslpResponse);
    deviceResponseHandler.handleResponse(deviceResponse);
}
Also used : EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse) DeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse) GetConfigurationDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse) GetStatusDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse) GetFirmwareVersionDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse)

Example 7 with DeviceResponse

use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse in project open-smart-grid-platform by OSGP.

the class OslpDeviceService method handleOslpResponseUpdateFirmware.

private void handleOslpResponseUpdateFirmware(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
    this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
    this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
    final DeviceMessageStatus status;
    if (oslpResponse.getPayloadMessage().hasUpdateFirmwareResponse()) {
        final Oslp.Status oslpStatus = oslpResponse.getPayloadMessage().getUpdateFirmwareResponse().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);
}
Also used : DeviceMessageStatus(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceMessageStatus) EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse) DeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse) GetConfigurationDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse) GetStatusDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse) GetFirmwareVersionDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse) Oslp(org.opensmartgridplatform.oslp.Oslp) EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)

Example 8 with DeviceResponse

use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse in project open-smart-grid-platform by OSGP.

the class CommonGetFirmwareRequestMessageProcessor method processSignedOslpEnvelope.

@Override
public void processSignedOslpEnvelope(final String deviceIdentification, final SignedOslpEnvelopeDto signedOslpEnvelopeDto) {
    final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = signedOslpEnvelopeDto.getUnsignedOslpEnvelopeDto();
    final OslpEnvelope oslpEnvelope = signedOslpEnvelopeDto.getOslpEnvelope();
    final String correlationUid = unsignedOslpEnvelopeDto.getCorrelationUid();
    final String organisationIdentification = unsignedOslpEnvelopeDto.getOrganisationIdentification();
    final String domain = unsignedOslpEnvelopeDto.getDomain();
    final String domainVersion = unsignedOslpEnvelopeDto.getDomainVersion();
    final String messageType = unsignedOslpEnvelopeDto.getMessageType();
    final int messagePriority = unsignedOslpEnvelopeDto.getMessagePriority();
    final String ipAddress = unsignedOslpEnvelopeDto.getIpAddress();
    final int retryCount = unsignedOslpEnvelopeDto.getRetryCount();
    final boolean isScheduled = unsignedOslpEnvelopeDto.isScheduled();
    final DeviceResponseHandler deviceResponseHandler = new DeviceResponseHandler() {

        @Override
        public void handleResponse(final DeviceResponse deviceResponse) {
            CommonGetFirmwareRequestMessageProcessor.this.handleGetFirmwareVersionDeviceResponse(deviceResponse, CommonGetFirmwareRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
        }

        @Override
        public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
            CommonGetFirmwareRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, domain, domainVersion, messageType, isScheduled, retryCount);
        }
    };
    final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, messagePriority);
    try {
        this.deviceService.doGetFirmwareVersion(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress);
    } catch (final IOException e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, messagePriority, retryCount);
    }
}
Also used : UnsignedOslpEnvelopeDto(org.opensmartgridplatform.oslp.UnsignedOslpEnvelopeDto) DeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse) GetFirmwareVersionDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse) DeviceResponseHandler(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponseHandler) DeviceRequest(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceRequest) IOException(java.io.IOException) OslpEnvelope(org.opensmartgridplatform.oslp.OslpEnvelope)

Example 9 with DeviceResponse

use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse in project open-smart-grid-platform by OSGP.

the class CommonStartDeviceTestRequestMessageProcessor method processSignedOslpEnvelope.

@Override
public void processSignedOslpEnvelope(final String deviceIdentification, final SignedOslpEnvelopeDto signedOslpEnvelopeDto) {
    final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = signedOslpEnvelopeDto.getUnsignedOslpEnvelopeDto();
    final OslpEnvelope oslpEnvelope = signedOslpEnvelopeDto.getOslpEnvelope();
    final String correlationUid = unsignedOslpEnvelopeDto.getCorrelationUid();
    final String organisationIdentification = unsignedOslpEnvelopeDto.getOrganisationIdentification();
    final String domain = unsignedOslpEnvelopeDto.getDomain();
    final String domainVersion = unsignedOslpEnvelopeDto.getDomainVersion();
    final String messageType = unsignedOslpEnvelopeDto.getMessageType();
    final int messagePriority = unsignedOslpEnvelopeDto.getMessagePriority();
    final String ipAddress = unsignedOslpEnvelopeDto.getIpAddress();
    final int retryCount = unsignedOslpEnvelopeDto.getRetryCount();
    final boolean isScheduled = unsignedOslpEnvelopeDto.isScheduled();
    final DeviceResponseHandler deviceResponseHandler = new DeviceResponseHandler() {

        @Override
        public void handleResponse(final DeviceResponse deviceResponse) {
            CommonStartDeviceTestRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, CommonStartDeviceTestRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
        }

        @Override
        public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
            CommonStartDeviceTestRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, domain, domainVersion, messageType, isScheduled, retryCount);
        }
    };
    final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, messagePriority);
    try {
        this.deviceService.doStartSelfTest(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress);
    } catch (final IOException e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, messagePriority, retryCount);
    }
}
Also used : UnsignedOslpEnvelopeDto(org.opensmartgridplatform.oslp.UnsignedOslpEnvelopeDto) DeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse) DeviceResponseHandler(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponseHandler) DeviceRequest(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceRequest) IOException(java.io.IOException) OslpEnvelope(org.opensmartgridplatform.oslp.OslpEnvelope)

Example 10 with DeviceResponse

use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse in project open-smart-grid-platform by OSGP.

the class CommonSwitchConfigurationRequestMessageProcessor method processSignedOslpEnvelope.

@Override
public void processSignedOslpEnvelope(final String deviceIdentification, final SignedOslpEnvelopeDto signedOslpEnvelopeDto) {
    final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = signedOslpEnvelopeDto.getUnsignedOslpEnvelopeDto();
    final OslpEnvelope oslpEnvelope = signedOslpEnvelopeDto.getOslpEnvelope();
    final String correlationUid = unsignedOslpEnvelopeDto.getCorrelationUid();
    final String organisationIdentification = unsignedOslpEnvelopeDto.getOrganisationIdentification();
    final String domain = unsignedOslpEnvelopeDto.getDomain();
    final String domainVersion = unsignedOslpEnvelopeDto.getDomainVersion();
    final String messageType = unsignedOslpEnvelopeDto.getMessageType();
    final int messagePriority = unsignedOslpEnvelopeDto.getMessagePriority();
    final String ipAddress = unsignedOslpEnvelopeDto.getIpAddress();
    final int retryCount = unsignedOslpEnvelopeDto.getRetryCount();
    final boolean isScheduled = unsignedOslpEnvelopeDto.isScheduled();
    final DeviceResponseHandler deviceResponseHandler = new DeviceResponseHandler() {

        @Override
        public void handleResponse(final DeviceResponse deviceResponse) {
            CommonSwitchConfigurationRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, CommonSwitchConfigurationRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
        }

        @Override
        public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
            CommonSwitchConfigurationRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, domain, domainVersion, messageType, isScheduled, retryCount);
        }
    };
    final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, messagePriority);
    try {
        this.deviceService.doSwitchConfiguration(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress);
    } catch (final IOException e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, messagePriority, retryCount);
    }
}
Also used : UnsignedOslpEnvelopeDto(org.opensmartgridplatform.oslp.UnsignedOslpEnvelopeDto) DeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse) DeviceResponseHandler(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponseHandler) DeviceRequest(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceRequest) IOException(java.io.IOException) OslpEnvelope(org.opensmartgridplatform.oslp.OslpEnvelope)

Aggregations

DeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse)39 GetStatusDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse)24 EmptyDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)23 GetConfigurationDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse)23 GetFirmwareVersionDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse)22 IOException (java.io.IOException)19 DeviceResponseHandler (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponseHandler)18 OslpEnvelope (org.opensmartgridplatform.oslp.OslpEnvelope)18 UnsignedOslpEnvelopeDto (org.opensmartgridplatform.oslp.UnsignedOslpEnvelopeDto)18 DeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceRequest)16 Oslp (org.opensmartgridplatform.oslp.Oslp)14 DeviceMessageStatus (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceMessageStatus)13 GetStatusDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.GetStatusDeviceRequest)3 SetScheduleDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetScheduleDeviceRequest)2 ScheduleMessageDataContainerDto (org.opensmartgridplatform.dto.valueobjects.ScheduleMessageDataContainerDto)2 ByteString (com.google.protobuf.ByteString)1 ResumeScheduleDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.ResumeScheduleDeviceRequest)1 SetConfigurationDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetConfigurationDeviceRequest)1 SetDeviceVerificationKeyDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetDeviceVerificationKeyDeviceRequest)1 SetEventNotificationsDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetEventNotificationsDeviceRequest)1