use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse in project open-smart-grid-platform by OSGP.
the class OslpDeviceService method handleOslpResponseSetTransition.
private void handleOslpResponseSetTransition(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
final DeviceMessageStatus status;
if (oslpResponse.getPayloadMessage().hasSetTransitionResponse()) {
final Oslp.Status oslpStatus = oslpResponse.getPayloadMessage().getSetTransitionResponse().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);
}
use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse in project open-smart-grid-platform by OSGP.
the class PublicLightingSetScheduleRequestMessageProcessor 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 ScheduleMessageDataContainerDto dataContainer = (ScheduleMessageDataContainerDto) unsignedOslpEnvelopeDto.getExtraData();
final DeviceRequest.Builder builder = DeviceRequest.newBuilder().organisationIdentification(organisationIdentification).deviceIdentification(deviceIdentification).correlationUid(correlationUid).domain(domain).domainVersion(domainVersion).messageType(messageType).messagePriority(messagePriority).ipAddress(ipAddress).retryCount(retryCount).isScheduled(isScheduled);
final SetScheduleDeviceRequest deviceRequest = new SetScheduleDeviceRequest(builder, dataContainer, RelayTypeDto.LIGHT);
final DeviceResponseHandler deviceResponseHandler = new DeviceResponseHandler() {
@Override
public void handleResponse(final DeviceResponse deviceResponse) {
PublicLightingSetScheduleRequestMessageProcessor.this.handleResponse(deviceResponse, deviceRequest);
}
@Override
public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
PublicLightingSetScheduleRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, domain, domainVersion, messageType, isScheduled, retryCount);
}
};
try {
this.deviceService.doSetSchedule(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress, domain, domainVersion, messageType, messagePriority, retryCount, isScheduled, dataContainer.getPageInfo());
} catch (final IOException e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, messagePriority, retryCount);
}
}
use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse in project open-smart-grid-platform by OSGP.
the class TariffSwitchingGetStatusRequestMessageProcessor 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) {
TariffSwitchingGetStatusRequestMessageProcessor.this.handleGetStatusDeviceResponse(deviceResponse, TariffSwitchingGetStatusRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
}
@Override
public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
TariffSwitchingGetStatusRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, domain, domainVersion, messageType, isScheduled, retryCount);
}
};
final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, messagePriority);
try {
this.deviceService.doGetStatus(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress);
} catch (final IOException e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, messagePriority, retryCount);
}
}
use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse in project open-smart-grid-platform by OSGP.
the class CommonSetDeviceVerificationKeyRequestMessageProcessor 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) {
CommonSetDeviceVerificationKeyRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, CommonSetDeviceVerificationKeyRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
}
@Override
public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
CommonSetDeviceVerificationKeyRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, domain, domainVersion, messageType, isScheduled, retryCount);
}
};
final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, messagePriority);
try {
this.deviceService.doSetDeviceVerificationKey(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress);
} catch (final IOException e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, messagePriority, retryCount);
}
}
use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse in project open-smart-grid-platform by OSGP.
the class OslpDeviceService method handleOslpResponseSetSchedulePaged.
private void handleOslpResponseSetSchedulePaged(final SetScheduleDeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final String domain, final String domainVersion, final String messageType, final int retryCount, final boolean isScheduled, final Pager pager, final DeviceResponseHandler deviceResponseHandler) {
this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
// Get response status
final DeviceMessageStatus status;
if (oslpResponse.getPayloadMessage().hasSetScheduleResponse()) {
final Oslp.Status oslpStatus = oslpResponse.getPayloadMessage().getSetScheduleResponse().getStatus();
status = this.mapper.map(oslpStatus, DeviceMessageStatus.class);
} else {
status = DeviceMessageStatus.FAILURE;
}
if (pager.isLastPage() || status != DeviceMessageStatus.OK) {
// Stop processing pages and handle device response.
this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
final DeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), deviceRequest.getMessagePriority(), status);
deviceResponseHandler.handleResponse(deviceResponse);
} else {
// Process next page
pager.nextPage();
this.processOslpRequestSetSchedulePaged(deviceRequest, pager);
}
}
Aggregations