Search in sources :

Example 26 with ConnectionFailureException

use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850SsldDeviceService method getConfiguration.

@Override
public void getConfiguration(final DeviceRequest 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 ConfigurationDto configuration = new Iec61850GetConfigurationCommand().getConfigurationFromDevice(this.iec61850Client, deviceConnection, ssld, this.mapper);
        final GetConfigurationDeviceResponse response = new GetConfigurationDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.OK, configuration);
        deviceResponseHandler.handleResponse(response);
    } 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 : ConfigurationDto(com.alliander.osgp.dto.valueobjects.ConfigurationDto) GetConfigurationDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetConfigurationDeviceResponse) ConnectionFailureException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException) DeviceConnection(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection) Iec61850GetConfigurationCommand(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850GetConfigurationCommand) 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)

Example 27 with ConnectionFailureException

use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850SsldDeviceService method setReboot.

@Override
public void setReboot(final DeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
    DeviceConnection deviceConnection = null;
    try {
        deviceConnection = this.connectToDevice(deviceRequest);
        new Iec61850RebootCommand().rebootDevice(this.iec61850Client, deviceConnection);
        this.createSuccessfulDefaultResponse(deviceRequest, deviceResponseHandler);
    } 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 : Iec61850RebootCommand(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850RebootCommand) ConnectionFailureException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException) DeviceConnection(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection) 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)

Example 28 with ConnectionFailureException

use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException in project open-smart-grid-platform 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);
        if (getDataResponse == null) {
            throw new ProtocolAdapterException("No valid response received during GetData");
        }
        final GetDataDeviceResponse deviceResponse = new GetDataDeviceResponse(deviceRequest, 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, DeviceMessageStatus.FAILURE);
        deviceResponseHandler.handleConnectionFailure(se, deviceResponse);
    } catch (final Exception e) {
        LOGGER.error("Unexpected exception during Get Data", e);
        final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest, DeviceMessageStatus.FAILURE);
        deviceResponseHandler.handleException(e, deviceResponse);
    }
}
Also used : GetDataDeviceResponse(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.GetDataDeviceResponse) ServerModel(com.beanit.openiec61850.ServerModel) Iec61850Connection(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.Iec61850Connection) Iec61850ClientAssociation(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation) GetDataResponseDto(org.opensmartgridplatform.dto.valueobjects.microgrids.GetDataResponseDto) 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) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) 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)

Example 29 with ConnectionFailureException

use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException in project open-smart-grid-platform by OSGP.

the class Iec61850SsldDeviceService method updateFirmware.

@Override
public void updateFirmware(final UpdateFirmwareDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
    DeviceConnection deviceConnection = null;
    try {
        deviceConnection = this.connectToDevice(deviceRequest);
        new Iec61850UpdateFirmwareCommand(this.deviceMessageLoggingService).pushFirmwareToDevice(this.iec61850Client, deviceConnection, deviceRequest.getFirmwareDomain().concat(deviceRequest.getFirmwareUrl()), deviceRequest.getFirmwareModuleData());
        this.createSuccessfulDefaultResponse(deviceRequest, deviceResponseHandler);
    } 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 : Iec61850UpdateFirmwareCommand(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850UpdateFirmwareCommand) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException) DeviceConnection(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) JMSException(javax.jms.JMSException) NodeException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException)

Example 30 with ConnectionFailureException

use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException in project open-smart-grid-platform by OSGP.

the class Iec61850SsldDeviceService method updateDeviceSslCertification.

@Override
public void updateDeviceSslCertification(final UpdateDeviceSslCertificationDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
    DeviceConnection deviceConnection = null;
    try {
        deviceConnection = this.connectToDevice(deviceRequest);
        new Iec61850UpdateSslCertificateCommand(this.deviceMessageLoggingService).pushSslCertificateToDevice(this.iec61850Client, deviceConnection, deviceRequest.getCertification());
        this.createSuccessfulDefaultResponse(deviceRequest, deviceResponseHandler);
    } 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 : Iec61850UpdateSslCertificateCommand(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850UpdateSslCertificateCommand) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException) DeviceConnection(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) JMSException(javax.jms.JMSException) NodeException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException)

Aggregations

JMSException (javax.jms.JMSException)32 ConnectionFailureException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException)19 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)18 ConnectionFailureException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException)18 DeviceConnection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)17 DeviceConnection (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)17 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)16 NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)14 FunctionalException (com.alliander.osgp.shared.exceptionhandling.FunctionalException)13 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)13 NodeException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeException)13 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)12 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)12 Ssld (com.alliander.osgp.core.db.api.iec61850.entities.Ssld)6 ClientAssociation (com.beanit.openiec61850.ClientAssociation)5 ClientAssociation (org.openmuc.openiec61850.ClientAssociation)5 EmptyDeviceResponse (org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)5 Ssld (org.opensmartgridplatform.core.db.api.iec61850.entities.Ssld)5 Iec61850ClientAssociation (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation)4 Iec61850Connection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection)4