use of com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetPowerUsageHistoryDeviceResponse in project Protocol-Adapter-IEC61850 by OSGP.
the class PublicLightingGetPowerUsageHistoryRequestMessageProcessor method handleGetPowerUsageHistoryDeviceResponse.
private void handleGetPowerUsageHistoryDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount, final int messagePriority, final Long scheduleTime) {
final GetPowerUsageHistoryDeviceResponse getPowerUsageHistoryDeviceResponse = (GetPowerUsageHistoryDeviceResponse) deviceResponse;
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
PowerUsageHistoryResponseMessageDataContainerDto powerUsageHistoryResponseMessageDataContainer = null;
try {
powerUsageHistoryResponseMessageDataContainer = new PowerUsageHistoryResponseMessageDataContainerDto(getPowerUsageHistoryDeviceResponse.getPowerUsageHistoryData());
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.PROTOCOL_IEC61850, "Unexpected exception while retrieving response message", e);
}
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, messagePriority, scheduleTime);
final ProtocolResponseMessage.Builder builder = new ProtocolResponseMessage.Builder();
final ProtocolResponseMessage responseMessage = builder.domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(osgpException).dataObject(powerUsageHistoryResponseMessageDataContainer).retryCount(retryCount).build();
responseMessageSender.send(responseMessage);
}
use of com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetPowerUsageHistoryDeviceResponse in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850SsldDeviceService method getPowerUsageHistory.
@Override
public void getPowerUsageHistory(final GetPowerUsageHistoryDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
DeviceConnection deviceConnection = null;
try {
deviceConnection = this.connectToDevice(deviceRequest);
// Getting the SSLD for the device output-settings.
final Ssld ssld = this.ssldDataService.findDevice(deviceRequest.getDeviceIdentification());
final List<DeviceOutputSetting> deviceOutputSettingsLightRelays = this.ssldDataService.findByRelayType(ssld, RelayType.LIGHT);
final List<PowerUsageDataDto> powerUsageHistoryData = new Iec61850PowerUsageHistoryCommand().getPowerUsageHistoryDataFromDevice(this.iec61850Client, deviceConnection, deviceRequest.getPowerUsageHistoryContainer(), deviceOutputSettingsLightRelays);
final GetPowerUsageHistoryDeviceResponse deviceResponse = new GetPowerUsageHistoryDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.OK, powerUsageHistoryData);
deviceResponseHandler.handleResponse(deviceResponse);
} catch (final ConnectionFailureException se) {
this.handleConnectionFailureException(deviceRequest, deviceResponseHandler, se);
} catch (final Exception e) {
this.handleException(deviceRequest, deviceResponseHandler, e);
}
this.iec61850DeviceConnectionService.disconnect(deviceConnection, deviceRequest);
}
Aggregations