Search in sources :

Example 41 with DeviceRequest

use of com.alliander.osgp.adapter.protocol.iec61850.device.DeviceRequest 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 42 with DeviceRequest

use of com.alliander.osgp.adapter.protocol.iec61850.device.DeviceRequest in project Protocol-Adapter-IEC61850 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(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)

Example 43 with DeviceRequest

use of com.alliander.osgp.adapter.protocol.iec61850.device.DeviceRequest 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 44 with DeviceRequest

use of com.alliander.osgp.adapter.protocol.iec61850.device.DeviceRequest in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850SsldDeviceService method enableReporting.

private void enableReporting(final DeviceConnection deviceConnection, final DeviceRequest deviceRequest) throws NodeWriteException {
    // Enabling device reporting.
    new Iec61850EnableReportingCommand().enableReportingOnDeviceWithoutUsingSequenceNumber(this.iec61850Client, deviceConnection);
    // Don't disconnect now! The device should be able to send reports.
    new Timer().schedule(new TimerTask() {

        @Override
        public void run() {
            try {
                new Iec61850ClearReportCommand().clearReportOnDevice(deviceConnection);
            } catch (final ProtocolAdapterException e) {
                LOGGER.error("Unable to clear report for device: " + deviceRequest.getDeviceIdentification(), e);
            }
            Iec61850SsldDeviceService.this.iec61850DeviceConnectionService.disconnect(deviceConnection, deviceRequest);
        }
    }, this.disconnectDelay);
}
Also used : Iec61850ClearReportCommand(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850ClearReportCommand) Timer(java.util.Timer) TimerTask(java.util.TimerTask) Iec61850EnableReportingCommand(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850EnableReportingCommand) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)

Aggregations

JMSException (javax.jms.JMSException)36 RequestMessageData (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)20 Iec61850DeviceResponseHandler (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler)20 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)17 ConnectionFailureException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException)16 DeviceConnection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)16 NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)13 FunctionalException (com.alliander.osgp.shared.exceptionhandling.FunctionalException)13 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)13 DeviceRequest (com.alliander.osgp.adapter.protocol.iec61850.device.DeviceRequest)8 EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)7 Ssld (com.alliander.osgp.core.db.api.iec61850.entities.Ssld)6 Iec61850ClientAssociation (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation)3 Iec61850Connection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection)3 DeviceOutputSetting (com.alliander.osgp.core.db.api.iec61850.entities.DeviceOutputSetting)3 ClientAssociation (org.openmuc.openiec61850.ClientAssociation)3 ServerModel (org.openmuc.openiec61850.ServerModel)3 SetScheduleDeviceRequest (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.requests.SetScheduleDeviceRequest)2 DeviceMessageLog (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)2 SystemService (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.SystemService)2