Search in sources :

Example 6 with EmptyDeviceResponse

use of org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850RtuDeviceService method getData.

@Override
public void getData(final GetDataDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
    try {
        final String serverName = this.getServerName(deviceRequest);
        final ServerModel serverModel = this.connectAndRetrieveServerModel(deviceRequest, serverName);
        final ClientAssociation clientAssociation = this.iec61850DeviceConnectionService.getClientAssociation(deviceRequest.getDeviceIdentification());
        final GetDataResponseDto getDataResponse = this.handleGetData(new DeviceConnection(new Iec61850Connection(new Iec61850ClientAssociation(clientAssociation, null), serverModel), deviceRequest.getDeviceIdentification(), deviceRequest.getOrganisationIdentification(), serverName), deviceRequest);
        final GetDataDeviceResponse deviceResponse = new GetDataDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.OK, getDataResponse);
        deviceResponseHandler.handleResponse(deviceResponse);
    } catch (final ConnectionFailureException se) {
        LOGGER.error("Could not connect to device after all retries", se);
        final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.FAILURE);
        deviceResponseHandler.handleConnectionFailure(se, deviceResponse);
    } catch (final Exception e) {
        LOGGER.error("Unexpected exception during Get Data", e);
        final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.FAILURE);
        deviceResponseHandler.handleException(e, deviceResponse);
    }
}
Also used : GetDataDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetDataDeviceResponse) ServerModel(org.openmuc.openiec61850.ServerModel) Iec61850Connection(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection) Iec61850ClientAssociation(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation) GetDataResponseDto(com.alliander.osgp.dto.valueobjects.microgrids.GetDataResponseDto) ConnectionFailureException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException) DeviceConnection(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection) Iec61850ClientAssociation(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation) ClientAssociation(org.openmuc.openiec61850.ClientAssociation) ConnectionFailureException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException) JMSException(javax.jms.JMSException) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) EmptyDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)

Example 7 with EmptyDeviceResponse

use of org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850SsldDeviceService method createSuccessfulDefaultResponse.

private void createSuccessfulDefaultResponse(final DeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler, final DeviceMessageStatus deviceMessageStatus) {
    final EmptyDeviceResponse deviceResponse = this.createDefaultResponse(deviceRequest, deviceMessageStatus);
    deviceResponseHandler.handleResponse(deviceResponse);
}
Also used : EmptyDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)

Example 8 with EmptyDeviceResponse

use of org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse in project open-smart-grid-platform by OSGP.

the class Iec61850SsldDeviceService method handleConnectionFailureException.

private void handleConnectionFailureException(final DeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler, final ConnectionFailureException connectionFailureException) throws JMSException {
    LOGGER.error("Could not connect to device", connectionFailureException);
    final EmptyDeviceResponse deviceResponse = this.createDefaultResponse(deviceRequest, DeviceMessageStatus.FAILURE);
    deviceResponseHandler.handleConnectionFailure(connectionFailureException, deviceResponse);
}
Also used : EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)

Example 9 with EmptyDeviceResponse

use of org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse in project open-smart-grid-platform by OSGP.

the class Iec61850SsldDeviceService method handleProtocolAdapterException.

private void handleProtocolAdapterException(final SetScheduleDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler, final ProtocolAdapterException protocolAdapterException) {
    LOGGER.error("Could not complete the request: {} for device: {}", deviceRequest.getMessageType(), deviceRequest.getDeviceIdentification(), protocolAdapterException);
    final EmptyDeviceResponse deviceResponse = this.createDefaultResponse(deviceRequest, DeviceMessageStatus.FAILURE);
    deviceResponseHandler.handleException(protocolAdapterException, deviceResponse);
}
Also used : EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)

Example 10 with EmptyDeviceResponse

use of org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse in project open-smart-grid-platform by OSGP.

the class Iec61850RtuDeviceService method setData.

@Override
public void setData(final SetDataDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
    try {
        final String serverName = this.getServerName(deviceRequest);
        final ServerModel serverModel = this.connectAndRetrieveServerModel(deviceRequest, serverName);
        final ClientAssociation clientAssociation = this.iec61850DeviceConnectionService.getClientAssociation(deviceRequest.getDeviceIdentification());
        this.handleSetData(new DeviceConnection(new Iec61850Connection(new Iec61850ClientAssociation(clientAssociation, null), serverModel), deviceRequest.getDeviceIdentification(), deviceRequest.getOrganisationIdentification(), serverName), deviceRequest);
        final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest, DeviceMessageStatus.OK);
        deviceResponseHandler.handleResponse(deviceResponse);
    } catch (final ConnectionFailureException se) {
        LOGGER.error("Could not connect to device after all retries", se);
        final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest, DeviceMessageStatus.FAILURE);
        deviceResponseHandler.handleConnectionFailure(se, deviceResponse);
    } catch (final Exception e) {
        LOGGER.error("Unexpected exception during Set Data", e);
        final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest, DeviceMessageStatus.FAILURE);
        deviceResponseHandler.handleException(e, deviceResponse);
    }
}
Also used : ServerModel(com.beanit.openiec61850.ServerModel) Iec61850Connection(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.Iec61850Connection) Iec61850ClientAssociation(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException) DeviceConnection(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection) Iec61850ClientAssociation(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation) ClientAssociation(com.beanit.openiec61850.ClientAssociation) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) JMSException(javax.jms.JMSException) EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)

Aggregations

EmptyDeviceResponse (org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)10 EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)8 JMSException (javax.jms.JMSException)6 ConnectionFailureException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException)3 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)3 Iec61850ClientAssociation (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation)3 Iec61850Connection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection)3 DeviceConnection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)3 ClientAssociation (com.beanit.openiec61850.ClientAssociation)3 ServerModel (com.beanit.openiec61850.ServerModel)3 ClientAssociation (org.openmuc.openiec61850.ClientAssociation)3 ServerModel (org.openmuc.openiec61850.ServerModel)3 ConnectionFailureException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException)3 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)3 Iec61850ClientAssociation (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation)3 Iec61850Connection (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.Iec61850Connection)3 DeviceConnection (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)3 Serializable (java.io.Serializable)2 DaDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.da.rtu.DaDeviceResponse)1 GetDataDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetDataDeviceResponse)1