proxy progress
This commit is contained in:
parent
4f7302f268
commit
6e76a9c4a9
|
@ -6,6 +6,7 @@ import com.rusefi.Callable;
|
|||
import com.rusefi.NamedThreadFactory;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocolState;
|
||||
import com.rusefi.binaryprotocol.IncomingDataBuffer;
|
||||
import com.rusefi.core.EngineState;
|
||||
import com.rusefi.io.serial.StreamConnector;
|
||||
import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
||||
|
@ -195,15 +196,38 @@ public class LinkManager {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
setConnector(new StreamConnector(this, port, logger, streamFactory));
|
||||
Callable<IoStream> ioStreamCallable = new Callable<IoStream>() {
|
||||
@Override
|
||||
public IoStream call() {
|
||||
IoStream stream = streamFactory.call();
|
||||
if (stream == null) {
|
||||
// error already reported
|
||||
return null;
|
||||
}
|
||||
IncomingDataBuffer dataBuffer = IncomingDataBuffer.createDataBuffer(stream, logger);
|
||||
stream.setDataBuffer(dataBuffer);
|
||||
return stream;
|
||||
}
|
||||
};
|
||||
setConnector(new StreamConnector(this, port, logger, ioStreamCallable));
|
||||
isSimulationMode = true;
|
||||
} else {
|
||||
Callable<IoStream> ioStreamCallable = () -> SerialIoStreamJSerialComm.openPort(port, logger);
|
||||
|
||||
|
||||
setConnector(new StreamConnector(this, port, logger, ioStreamCallable));
|
||||
Callable<IoStream> ioStreamCallable1 = new Callable<IoStream>() {
|
||||
@Override
|
||||
public IoStream call() {
|
||||
IoStream stream = ioStreamCallable.call();
|
||||
if (stream == null) {
|
||||
// error already reported
|
||||
return null;
|
||||
}
|
||||
IncomingDataBuffer dataBuffer = IncomingDataBuffer.createDataBuffer(stream, logger);
|
||||
stream.setDataBuffer(dataBuffer);
|
||||
return stream;
|
||||
}
|
||||
};
|
||||
setConnector(new StreamConnector(this, port, logger, ioStreamCallable1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.rusefi.io.serial;
|
|||
import com.opensr5.Logger;
|
||||
import com.rusefi.Callable;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.binaryprotocol.IncomingDataBuffer;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.io.ConnectionStateListener;
|
||||
import com.rusefi.io.IoStream;
|
||||
|
@ -20,24 +19,10 @@ public class StreamConnector implements LinkConnector {
|
|||
private final Logger logger;
|
||||
private final LinkManager linkManager;
|
||||
|
||||
public StreamConnector(LinkManager linkManager, String portName, Logger logger, Callable<IoStream> streamFactory) {
|
||||
public StreamConnector(LinkManager linkManager, String portName, Logger logger, Callable<IoStream> ioStreamCallable) {
|
||||
this.linkManager = linkManager;
|
||||
this.logger = logger;
|
||||
|
||||
Callable<IoStream> ioStreamCallable = new Callable<IoStream>() {
|
||||
@Override
|
||||
public IoStream call() {
|
||||
IoStream stream = streamFactory.call();
|
||||
if (stream == null) {
|
||||
// error already reported
|
||||
return null;
|
||||
}
|
||||
IncomingDataBuffer dataBuffer = IncomingDataBuffer.createDataBuffer(stream, logger);
|
||||
stream.setDataBuffer(dataBuffer);
|
||||
return stream;
|
||||
}
|
||||
};
|
||||
|
||||
portHolder = new PortHolder(portName, linkManager, logger, ioStreamCallable);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue