use of com.beanit.openiec61850.ClientSap in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850Client method connect.
/**
* Connect to a given device. This will try to establish the
* {@link ClientAssociation} between client and IED.
*
* @param deviceIdentification
* The device identification.
* @param ipAddress
* The IP address of the device.
* @param reportListener
* The report listener instance which can be created using
* {@link Iec61850ClientEventListenerFactory}.
* @param port
* The port number of the IED.
*
* @return An {@link Iec61850ClientAssociation} instance.
*
* @throws ConnectionFailureException
* In case the connection to the device could not be
* established.
*/
public Iec61850ClientAssociation connect(final String deviceIdentification, final InetAddress ipAddress, final Iec61850ClientBaseEventListener reportListener, final int port) throws ConnectionFailureException {
// Alternatively you could use ClientSap(SocketFactory factory) to e.g.
// connect using SSL.
final ClientSap clientSap = new ClientSap();
final Iec61850ClientAssociation clientAssociation;
LOGGER.info("Attempting to connect to server: {} on port: {}, max redelivery count: {} and max retry count: {}", ipAddress.getHostAddress(), port, this.maxRedeliveriesForIec61850Requests, this.maxRetryCount);
try {
final ClientAssociation association = clientSap.associate(ipAddress, port, null, reportListener);
clientAssociation = new Iec61850ClientAssociation(association, reportListener);
} catch (final IOException e) {
// An IOException will always indicate a fatal exception. It
// indicates that the association was closed and
// cannot be recovered. You will need to create a new association
// using ClientSap.associate() in order to
// reconnect.
LOGGER.error("Error connecting to device: " + deviceIdentification, e);
throw new ConnectionFailureException(e.getMessage(), e);
}
LOGGER.info("Connected to device: {}", deviceIdentification);
return clientAssociation;
}
use of com.beanit.openiec61850.ClientSap in project open-smart-grid-platform by OSGP.
the class Iec61850Client method connect.
/**
* Connect to a given device. This will try to establish the {@link ClientAssociation} between
* client and IED.
*
* @param deviceIdentification The device identification.
* @param ipAddress The IP address of the device.
* @param reportListener The report listener instance which can be created using {@link
* Iec61850ClientEventListenerFactory}.
* @param port The port number of the IED.
* @return An {@link Iec61850ClientAssociation} instance.
* @throws ConnectionFailureException In case the connection to the device could not be
* established.
*/
public Iec61850ClientAssociation connect(final String deviceIdentification, final InetAddress ipAddress, final Iec61850ClientBaseEventListener reportListener, final int port) throws ConnectionFailureException {
// Alternatively you could use ClientSap(SocketFactory factory) to e.g.
// connect using SSL.
final ClientSap clientSap = new ClientSap();
final Iec61850ClientAssociation clientAssociation;
LOGGER.info("Attempting to connect to server: {} on port: {}, max redelivery count: {} and max retry count: {}", ipAddress.getHostAddress(), port, this.maxRedeliveriesForIec61850Requests, this.maxRetryCount);
try {
clientSap.setResponseTimeout(this.connectionTimeout);
final ClientAssociation association = clientSap.associate(ipAddress, port, null, reportListener);
clientAssociation = new Iec61850ClientAssociation(association, reportListener);
} catch (final IOException e) {
// An IOException will always indicate a fatal exception. It
// indicates that the association was closed and
// cannot be recovered. You will need to create a new association
// using ClientSap.associate() in order to
// reconnect.
LOGGER.error("Error connecting to device: {}", deviceIdentification, e);
throw new ConnectionFailureException(e.getMessage(), e);
}
LOGGER.info("Connected to device: {}", deviceIdentification);
return clientAssociation;
}
Aggregations