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.NamedThreadFactory;
|
||||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||||
import com.rusefi.binaryprotocol.BinaryProtocolState;
|
import com.rusefi.binaryprotocol.BinaryProtocolState;
|
||||||
|
import com.rusefi.binaryprotocol.IncomingDataBuffer;
|
||||||
import com.rusefi.core.EngineState;
|
import com.rusefi.core.EngineState;
|
||||||
import com.rusefi.io.serial.StreamConnector;
|
import com.rusefi.io.serial.StreamConnector;
|
||||||
import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
||||||
|
@ -195,15 +196,38 @@ public class LinkManager {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Callable<IoStream> ioStreamCallable = new Callable<IoStream>() {
|
||||||
|
@Override
|
||||||
setConnector(new StreamConnector(this, port, logger, streamFactory));
|
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;
|
isSimulationMode = true;
|
||||||
} else {
|
} else {
|
||||||
Callable<IoStream> ioStreamCallable = () -> SerialIoStreamJSerialComm.openPort(port, logger);
|
Callable<IoStream> ioStreamCallable = () -> SerialIoStreamJSerialComm.openPort(port, logger);
|
||||||
|
|
||||||
|
Callable<IoStream> ioStreamCallable1 = new Callable<IoStream>() {
|
||||||
setConnector(new StreamConnector(this, port, logger, ioStreamCallable));
|
@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.opensr5.Logger;
|
||||||
import com.rusefi.Callable;
|
import com.rusefi.Callable;
|
||||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||||
import com.rusefi.binaryprotocol.IncomingDataBuffer;
|
|
||||||
import com.rusefi.core.MessagesCentral;
|
import com.rusefi.core.MessagesCentral;
|
||||||
import com.rusefi.io.ConnectionStateListener;
|
import com.rusefi.io.ConnectionStateListener;
|
||||||
import com.rusefi.io.IoStream;
|
import com.rusefi.io.IoStream;
|
||||||
|
@ -20,24 +19,10 @@ public class StreamConnector implements LinkConnector {
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
private final LinkManager linkManager;
|
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.linkManager = linkManager;
|
||||||
this.logger = logger;
|
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);
|
portHolder = new PortHolder(portName, linkManager, logger, ioStreamCallable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue