use of com.infiniteautomation.mango.io.serial.SerialPortException in project ma-core-public by infiniteautomation.
the class SerialServerSocketBridge method closeImpl.
@Override
public void closeImpl() throws SerialPortException {
if (this.serverThread != null) {
this.serverThread.shutdown();
Exception ex = null;
try {
// unblock the accept() method
this.serverSocket.close();
} catch (IOException e) {
ex = e;
LOG.error(e.getMessage(), e);
}
if (this.socket != null) {
try {
// unblock the read() method
this.socket.close();
} catch (IOException e) {
ex = e;
LOG.error(e.getMessage(), e);
} finally {
this.socket = null;
}
}
if (ex != null)
throw new SerialPortException(ex);
}
}
use of com.infiniteautomation.mango.io.serial.SerialPortException in project ma-core-public by infiniteautomation.
the class SerialServerSocketBridge method openImpl.
@Override
public void openImpl() throws SerialPortException {
try {
if (this.serverThread != null)
throw new SerialPortException("Already Open.");
this.serverSocket = new ServerSocket(this.port);
this.serverSocket.setSoTimeout(0);
this.serverThread = new SerialServerSocketThread(this);
this.serverThread.start();
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new SerialPortException(e);
}
}
use of com.infiniteautomation.mango.io.serial.SerialPortException in project ma-modules-public by infiniteautomation.
the class MangoMBusSerialConnection method open.
@Override
public void open() throws IOException {
try {
setConnState(State.OPENING);
this.serialPort = Common.serialPortManager.open(ownerName, commPortId, baudRate, SerialPort.FLOWCONTROL_NONE, SerialPort.FLOWCONTROL_NONE, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_EVEN);
this.is = this.serialPort.getInputStream();
this.os = this.serialPort.getOutputStream();
setConnState(State.OPEN);
} catch (SerialPortException e) {
close();
throw new IOException(e);
}
}
use of com.infiniteautomation.mango.io.serial.SerialPortException in project ma-modules-public by infiniteautomation.
the class SerialDataSourceRT method terminate.
@Override
public void terminate() {
super.terminate();
if (this.port != null)
try {
Common.serialPortManager.close(this.port);
} catch (SerialPortException e) {
LOG.debug("Error while closing serial port", e);
raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("event.serial.portError", this.port.getCommPortId(), e.getLocalizedMessage()));
}
if (this.vo.isLogIO()) {
this.ioLog.log("Data source stopped");
this.ioLog.close();
}
}
use of com.infiniteautomation.mango.io.serial.SerialPortException in project ma-core-public by infiniteautomation.
the class SerialSocketBridge method openImpl.
@Override
public void openImpl() throws SerialPortException {
try {
this.socket = new Socket(this.address, this.port);
this.socket.setSoTimeout(timeout);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new SerialPortException(e);
}
}
Aggregations