use of com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse in project Protocol-Adapter-OSLP by OSGP.
the class CommonUpdateFirmwareRequestMessageProcessor 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 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) {
CommonUpdateFirmwareRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, CommonUpdateFirmwareRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
}
@Override
public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
CommonUpdateFirmwareRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, null, CommonUpdateFirmwareRequestMessageProcessor.this.responseMessageSender, deviceResponse, domain, domainVersion, messageType, isScheduled, retryCount);
}
};
final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid);
try {
this.deviceService.doUpdateFirmware(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress);
} catch (final IOException e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, retryCount);
}
}
use of com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse in project Protocol-Adapter-OSLP by OSGP.
the class PublicLightingGetPowerUsageHistoryRequestMessageProcessor 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 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) {
PublicLightingGetPowerUsageHistoryRequestMessageProcessor.this.handleGetPowerUsageHistoryDeviceResponse(deviceResponse, null, PublicLightingGetPowerUsageHistoryRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, isScheduled, retryCount);
}
@Override
public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
PublicLightingGetPowerUsageHistoryRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, ((PowerUsageHistoryResponseMessageDataContainerDto) unsignedOslpEnvelopeDto.getExtraData()).getRequestContainer(), PublicLightingGetPowerUsageHistoryRequestMessageProcessor.this.responseMessageSender, deviceResponse, domain, domainVersion, messageType, isScheduled, retryCount);
}
};
try {
final PowerUsageHistoryResponseMessageDataContainerDto powerUsageHistoryResponseMessageDataContainer = (PowerUsageHistoryResponseMessageDataContainerDto) unsignedOslpEnvelopeDto.getExtraData();
final TimePeriodDto timePeriod = new TimePeriodDto(powerUsageHistoryResponseMessageDataContainer.getStartTime(), powerUsageHistoryResponseMessageDataContainer.getEndTime());
final HistoryTermTypeDto historyTermType = powerUsageHistoryResponseMessageDataContainer.getHistoryTermType();
final GetPowerUsageHistoryDeviceRequest deviceRequest = new GetPowerUsageHistoryDeviceRequest(organisationIdentification, deviceIdentification, correlationUid, new PowerUsageHistoryMessageDataContainerDto(timePeriod, historyTermType), domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
this.deviceService.doGetPowerUsageHistory(oslpEnvelope, powerUsageHistoryResponseMessageDataContainer, deviceRequest, deviceResponseHandler, ipAddress, domain, domainVersion, messageType, retryCount, isScheduled);
} catch (final IOException e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, retryCount);
}
}
use of com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse in project Protocol-Adapter-OSLP by OSGP.
the class PublicLightingSetLightRequestMessageProcessor 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 String ipAddress = unsignedOslpEnvelopeDto.getIpAddress();
final int retryCount = unsignedOslpEnvelopeDto.getRetryCount();
final boolean isScheduled = unsignedOslpEnvelopeDto.isScheduled();
final DeviceResponseHandler setLightDeviceResponseHandler = new DeviceResponseHandler() {
@Override
public void handleResponse(final DeviceResponse deviceResponse) {
if (((EmptyDeviceResponse) deviceResponse).getStatus().equals(DeviceMessageStatus.OK)) {
// If the response is OK, just log it. The resumeSchedule()
// function will be called next.
LOGGER.info("setLight() successful for device : {}", deviceResponse.getDeviceIdentification());
} else {
// If the response is not OK, send a response message to the
// responses queue.
PublicLightingSetLightRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, PublicLightingSetLightRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
}
}
@Override
public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
PublicLightingSetLightRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, unsignedOslpEnvelopeDto.getExtraData(), PublicLightingSetLightRequestMessageProcessor.this.responseMessageSender, deviceResponse, domain, domainVersion, messageType, isScheduled, retryCount);
}
};
final DeviceRequest setLightdeviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
// Execute a ResumeSchedule call with 'immediate = false' and 'index
// = 0' as arguments.
final ResumeScheduleMessageDataContainerDto resumeScheduleMessageDataContainer = new ResumeScheduleMessageDataContainerDto(0, false);
final DeviceResponseHandler resumeScheduleDeviceResponseHandler = this.publicLightingResumeScheduleRequestMessageProcessor.createResumeScheduleDeviceResponseHandler(domain, domainVersion, DeviceRequestMessageType.RESUME_SCHEDULE.name(), retryCount, resumeScheduleMessageDataContainer, isScheduled);
// The data of the setLightdeviceRequest can be reused
final ResumeScheduleDeviceRequest resumeScheduleDeviceRequest = new ResumeScheduleDeviceRequest(setLightdeviceRequest.getOrganisationIdentification(), setLightdeviceRequest.getDeviceIdentification(), setLightdeviceRequest.getCorrelationUid(), resumeScheduleMessageDataContainer, setLightdeviceRequest.getDomain(), setLightdeviceRequest.getDomainVersion(), DeviceRequestMessageType.RESUME_SCHEDULE.name(), setLightdeviceRequest.getIpAddress(), setLightdeviceRequest.getRetryCount(), setLightdeviceRequest.isScheduled());
try {
this.deviceService.doSetLight(oslpEnvelope, setLightdeviceRequest, resumeScheduleDeviceRequest, setLightDeviceResponseHandler, resumeScheduleDeviceResponseHandler, ipAddress);
} catch (final IOException e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, retryCount);
}
}
use of com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse in project Protocol-Adapter-OSLP 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 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, null, TariffSwitchingGetStatusRequestMessageProcessor.this.responseMessageSender, deviceResponse, domain, domainVersion, messageType, isScheduled, retryCount);
}
};
final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid);
try {
this.deviceService.doGetStatus(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress);
} catch (final IOException e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, retryCount);
}
}
use of com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse in project Protocol-Adapter-OSLP by OSGP.
the class TariffSwitchingSetScheduleRequestMessageProcessor 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 String ipAddress = unsignedOslpEnvelopeDto.getIpAddress();
final int retryCount = unsignedOslpEnvelopeDto.getRetryCount();
final boolean isScheduled = unsignedOslpEnvelopeDto.isScheduled();
final ScheduleMessageDataContainerDto scheduleMessageDataContainer = (ScheduleMessageDataContainerDto) unsignedOslpEnvelopeDto.getExtraData();
final DeviceResponseHandler deviceResponseHandler = new DeviceResponseHandler() {
@Override
public void handleResponse(final DeviceResponse deviceResponse) {
TariffSwitchingSetScheduleRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, TariffSwitchingSetScheduleRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
}
@Override
public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
TariffSwitchingSetScheduleRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, unsignedOslpEnvelopeDto.getExtraData(), TariffSwitchingSetScheduleRequestMessageProcessor.this.responseMessageSender, deviceResponse, domain, domainVersion, messageType, isScheduled, retryCount);
}
};
final SetScheduleDeviceRequest deviceRequest = new SetScheduleDeviceRequest(organisationIdentification, deviceIdentification, correlationUid, scheduleMessageDataContainer, RelayTypeDto.TARIFF, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
try {
this.deviceService.doSetSchedule(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress, domain, domainVersion, messageType, retryCount, isScheduled, scheduleMessageDataContainer.getPageInfo());
} catch (final IOException e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, retryCount);
}
}
Aggregations