use of org.openmuc.j60870.ConnectionEventListener in project open-smart-grid-platform by OSGP.
the class ControlledStationSteps method sendInterrogationResponse.
private Object sendInterrogationResponse(final int commonAddress, final IeQualifierOfInterrogation qualifier, final ProcessImage processImage) {
final ConnectionEventListener listener = this.connectionSteps.getConnectionEventListener();
listener.newASdu(this.interrogationActivationConfirmationAsdu(commonAddress, qualifier));
for (final ASdu asdu : processImage.toInterrogationAsdus(commonAddress, qualifier)) {
listener.newASdu(asdu);
}
listener.newASdu(this.interrogationActivationTerminationAsdu(commonAddress, qualifier));
return null;
}
use of org.openmuc.j60870.ConnectionEventListener in project open-smart-grid-platform by OSGP.
the class Iec60870Client method connect.
@Override
public ClientConnection connect(final ConnectionParameters connectionParameters, final ConnectionEventListener asduListener) throws ConnectionFailureException {
final InetAddress address = this.convertIpAddress(connectionParameters.getIpAddress());
final String deviceIdentification = connectionParameters.getDeviceIdentification();
final int port = connectionParameters.getPort() == null ? IEC60870_DEFAULT_PORT : connectionParameters.getPort();
final ClientConnectionBuilder clientConnectionBuilder = new ClientConnectionBuilder(address).setPort(port).setConnectionTimeout(this.connectionTimeout);
try {
LOGGER.info("Connecting to device: {}...", deviceIdentification);
final Connection connection = clientConnectionBuilder.build();
connection.startDataTransfer(asduListener);
LOGGER.info("Connected to device: {}", deviceIdentification);
return new DeviceConnection(connection, connectionParameters);
} catch (final IOException e) {
final String errorMessage = "Unable to connect to remote host: " + connectionParameters.getIpAddress();
LOGGER.error(errorMessage, e);
throw new ConnectionFailureException(ComponentType.PROTOCOL_IEC60870, errorMessage);
}
}
Aggregations