removing a bit of dead code
This commit is contained in:
parent
c0a2dc99de
commit
372d321878
|
@ -53,14 +53,11 @@ public class PortHolder {
|
||||||
* @return true if everything fine
|
* @return true if everything fine
|
||||||
*/
|
*/
|
||||||
private boolean open(String port, final DataListener listener) {
|
private boolean open(String port, final DataListener listener) {
|
||||||
EstablishConnection establishConnection = new EstablishConnection(port).invoke();
|
IoStream stream = EstablishConnection.create(port);
|
||||||
if (!establishConnection.isConnected())
|
|
||||||
return false;
|
|
||||||
synchronized (portLock) {
|
synchronized (portLock) {
|
||||||
PortHolder.this.serialPort = establishConnection.stream;
|
PortHolder.this.serialPort = stream;
|
||||||
portLock.notifyAll();
|
portLock.notifyAll();
|
||||||
}
|
}
|
||||||
IoStream stream = establishConnection.getStream();
|
|
||||||
|
|
||||||
bp = BinaryProtocolHolder.getInstance().create(FileLog.LOGGER, stream);
|
bp = BinaryProtocolHolder.getInstance().create(FileLog.LOGGER, stream);
|
||||||
|
|
||||||
|
@ -100,27 +97,8 @@ public class PortHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class EstablishConnection {
|
public static class EstablishConnection {
|
||||||
private boolean isConnected;
|
public static IoStream create(String port) {
|
||||||
private String port;
|
return SerialIoStreamJSerialComm.open(port, BAUD_RATE, FileLog.LOGGER);
|
||||||
private IoStream stream;
|
|
||||||
|
|
||||||
public EstablishConnection(String port) {
|
|
||||||
this.port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo: remove dead code - always true?
|
|
||||||
public boolean isConnected() {
|
|
||||||
return isConnected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IoStream getStream() {
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EstablishConnection invoke() {
|
|
||||||
stream = SerialIoStreamJSerialComm.open(port, BAUD_RATE, FileLog.LOGGER);
|
|
||||||
isConnected = true;
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,10 +278,7 @@ public class Launcher {
|
||||||
String autoDetectedPort = autoDetectPort();
|
String autoDetectedPort = autoDetectPort();
|
||||||
if (autoDetectedPort == null)
|
if (autoDetectedPort == null)
|
||||||
return;
|
return;
|
||||||
PortHolder.EstablishConnection establishConnection = new PortHolder.EstablishConnection(autoDetectedPort).invoke();
|
IoStream stream = PortHolder.EstablishConnection.create(autoDetectedPort);
|
||||||
if (!establishConnection.isConnected())
|
|
||||||
return;
|
|
||||||
IoStream stream = establishConnection.getStream();
|
|
||||||
byte[] commandBytes = BinaryProtocol.getTextCommandBytes(command);
|
byte[] commandBytes = BinaryProtocol.getTextCommandBytes(command);
|
||||||
stream.sendPacket(commandBytes, FileLog.LOGGER);
|
stream.sendPacket(commandBytes, FileLog.LOGGER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,7 @@ class SerialAutoChecker implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PortHolder.EstablishConnection establishConnection = new PortHolder.EstablishConnection(serialPort).invoke();
|
IoStream stream = PortHolder.EstablishConnection.create(serialPort);
|
||||||
if (!establishConnection.isConnected())
|
|
||||||
return;
|
|
||||||
IoStream stream = establishConnection.getStream();
|
|
||||||
Logger logger = FileLog.LOGGER;
|
Logger logger = FileLog.LOGGER;
|
||||||
IncomingDataBuffer incomingData = new IncomingDataBuffer(logger);
|
IncomingDataBuffer incomingData = new IncomingDataBuffer(logger);
|
||||||
stream.setInputListener(incomingData::addData);
|
stream.setInputListener(incomingData::addData);
|
||||||
|
|
Loading…
Reference in New Issue