Search in sources :

Example 1 with ClientAssociation

use of com.beanit.iec61850bean.ClientAssociation in project OpenMUC by isc-konstanz.

the class Iec61850Driver method connect.

@Override
public Connection connect(String deviceAddress, String settings) throws ArgumentSyntaxException, ConnectionException {
    DeviceAddress deviceAdress = new DeviceAddress(deviceAddress);
    DeviceSettings deviceSettings = new DeviceSettings(settings);
    ClientSap clientSap = new ClientSap();
    clientSap.setTSelLocal(deviceSettings.getTSelLocal());
    clientSap.setTSelLocal(deviceSettings.getTSelRemote());
    ClientAssociation clientAssociation;
    try {
        clientAssociation = clientSap.associate(deviceAdress.getAdress(), deviceAdress.getRemotePort(), deviceSettings.getAuthentication(), null);
    } catch (IOException e) {
        throw new ConnectionException(e);
    }
    ServerModel serverModel;
    try {
        serverModel = clientAssociation.retrieveModel();
    } catch (ServiceError e) {
        clientAssociation.close();
        throw new ConnectionException("Service error retrieving server model" + e.getMessage(), e);
    } catch (IOException e) {
        clientAssociation.close();
        throw new ConnectionException("IOException retrieving server model: " + e.getMessage(), e);
    }
    return new Iec61850Connection(clientAssociation, serverModel);
}
Also used : ServiceError(com.beanit.iec61850bean.ServiceError) ClientSap(com.beanit.iec61850bean.ClientSap) ServerModel(com.beanit.iec61850bean.ServerModel) ClientAssociation(com.beanit.iec61850bean.ClientAssociation) IOException(java.io.IOException) ConnectionException(org.openmuc.framework.driver.spi.ConnectionException)

Aggregations

ClientAssociation (com.beanit.iec61850bean.ClientAssociation)1 ClientSap (com.beanit.iec61850bean.ClientSap)1 ServerModel (com.beanit.iec61850bean.ServerModel)1 ServiceError (com.beanit.iec61850bean.ServiceError)1 IOException (java.io.IOException)1 ConnectionException (org.openmuc.framework.driver.spi.ConnectionException)1