Search in sources :

Example 1 with Iec61850PowerUsageHistoryCommand

use of com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850PowerUsageHistoryCommand 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);
}
Also used : ConnectionFailureException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException) DeviceConnection(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection) DeviceOutputSetting(com.alliander.osgp.core.db.api.iec61850.entities.DeviceOutputSetting) GetPowerUsageHistoryDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetPowerUsageHistoryDeviceResponse) PowerUsageDataDto(com.alliander.osgp.dto.valueobjects.PowerUsageDataDto) Iec61850PowerUsageHistoryCommand(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850PowerUsageHistoryCommand) NodeWriteException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException) FunctionalException(com.alliander.osgp.shared.exceptionhandling.FunctionalException) JMSException(javax.jms.JMSException) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) ConnectionFailureException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException) Ssld(com.alliander.osgp.core.db.api.iec61850.entities.Ssld)

Aggregations

GetPowerUsageHistoryDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetPowerUsageHistoryDeviceResponse)1 ConnectionFailureException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException)1 NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)1 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 DeviceConnection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)1 Iec61850PowerUsageHistoryCommand (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850PowerUsageHistoryCommand)1 DeviceOutputSetting (com.alliander.osgp.core.db.api.iec61850.entities.DeviceOutputSetting)1 Ssld (com.alliander.osgp.core.db.api.iec61850.entities.Ssld)1 PowerUsageDataDto (com.alliander.osgp.dto.valueobjects.PowerUsageDataDto)1 FunctionalException (com.alliander.osgp.shared.exceptionhandling.FunctionalException)1 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)1 JMSException (javax.jms.JMSException)1