mirror of https://github.com/rusefi/RomRaider.git
lm2 mts tweaks
git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@295 38686702-15cf-42e4-a595-3071df8bf5ea
This commit is contained in:
parent
4d5f0c3bb3
commit
b6cff09e90
Binary file not shown.
|
@ -43,7 +43,7 @@ public final class GenericDataSourceConnector implements Stoppable {
|
|||
break;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(dataSource.getName() + ": connect error", e);
|
||||
sleep(500L);
|
||||
sleep(1000L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,13 +30,12 @@ import static org.apache.log4j.Logger.getLogger;
|
|||
public final class MTSRunner implements Stoppable {
|
||||
private static final Logger LOGGER = getLogger(MTSRunner.class);
|
||||
private final DataListener listener;
|
||||
private final int mtsInput = 0;
|
||||
private final int mtsPort;
|
||||
private final MTS mts;
|
||||
private boolean running;
|
||||
private boolean stop;
|
||||
|
||||
public MTSRunner(int mtsPort, DataListener listener) {
|
||||
this.mtsPort = mtsPort;
|
||||
this.mts = mts(mtsPort);
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
|
@ -59,24 +58,40 @@ public final class MTSRunner implements Stoppable {
|
|||
while (running && currentTimeMillis() < timeout) sleep(100L);
|
||||
}
|
||||
|
||||
private void doRun() {
|
||||
if (mtsPort < 0) return;
|
||||
private MTS mts(int mtsPort) {
|
||||
// bail out early if we know specified mts port is invalid
|
||||
if (mtsPort < 0) throw new IllegalArgumentException("Bad MTS port: " + mtsPort);
|
||||
|
||||
// create mts interface
|
||||
MTS mts = createMTS();
|
||||
try {
|
||||
int portCount = mts.portCount();
|
||||
LOGGER.debug("MTS: found " + portCount + " ports.");
|
||||
|
||||
try {
|
||||
// check there are ports available
|
||||
int portCount = mts.portCount();
|
||||
if (portCount <= 0) throw new IllegalStateException("No MTS ports found");
|
||||
LOGGER.info("MTS: found " + portCount + " ports.");
|
||||
|
||||
// select the specified port
|
||||
mts.currentPort(mtsPort);
|
||||
String portName = mts.portName();
|
||||
LOGGER.debug("MTS: current port [" + mtsPort + "]: " + portName);
|
||||
LOGGER.info("MTS: current port [" + mtsPort + "]: " + portName);
|
||||
|
||||
return mts;
|
||||
} catch (RuntimeException t) {
|
||||
// cleanup mts and rethrow exception
|
||||
if (mts != null) mts.dispose();
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
private void doRun() {
|
||||
try {
|
||||
// attempt to connect to the specified device
|
||||
mts.connect();
|
||||
try {
|
||||
|
||||
try {
|
||||
// select the input
|
||||
mts.currentInput(mtsInput);
|
||||
mts.currentInput(0);
|
||||
|
||||
// attempt to get data
|
||||
mts.startData();
|
||||
|
|
|
@ -35,7 +35,7 @@ public final class Lm2MtsDataSource implements ExternalDataSource {
|
|||
private static final Logger LOGGER = getLogger(Lm2MtsDataSource.class);
|
||||
private final Lm2MtsDataItem dataItem = new Lm2MtsDataItem();
|
||||
private MTSRunner runner;
|
||||
private int mtsPort = 0;
|
||||
private int mtsPort = -1;
|
||||
|
||||
public String getId() {
|
||||
return getClass().getName();
|
||||
|
@ -46,7 +46,7 @@ public final class Lm2MtsDataSource implements ExternalDataSource {
|
|||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "0.02";
|
||||
return "0.03";
|
||||
}
|
||||
|
||||
public List<? extends ExternalDataItem> getDataItems() {
|
||||
|
@ -79,7 +79,7 @@ public final class Lm2MtsDataSource implements ExternalDataSource {
|
|||
return parseInt(port);
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Bad MTS port: " + port);
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue