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;
|
break;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error(dataSource.getName() + ": connect error", 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 {
|
public final class MTSRunner implements Stoppable {
|
||||||
private static final Logger LOGGER = getLogger(MTSRunner.class);
|
private static final Logger LOGGER = getLogger(MTSRunner.class);
|
||||||
private final DataListener listener;
|
private final DataListener listener;
|
||||||
private final int mtsInput = 0;
|
private final MTS mts;
|
||||||
private final int mtsPort;
|
|
||||||
private boolean running;
|
private boolean running;
|
||||||
private boolean stop;
|
private boolean stop;
|
||||||
|
|
||||||
public MTSRunner(int mtsPort, DataListener listener) {
|
public MTSRunner(int mtsPort, DataListener listener) {
|
||||||
this.mtsPort = mtsPort;
|
this.mts = mts(mtsPort);
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,24 +58,40 @@ public final class MTSRunner implements Stoppable {
|
||||||
while (running && currentTimeMillis() < timeout) sleep(100L);
|
while (running && currentTimeMillis() < timeout) sleep(100L);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doRun() {
|
private MTS mts(int mtsPort) {
|
||||||
if (mtsPort < 0) return;
|
// 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();
|
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);
|
mts.currentPort(mtsPort);
|
||||||
String portName = mts.portName();
|
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
|
// attempt to connect to the specified device
|
||||||
mts.connect();
|
mts.connect();
|
||||||
try {
|
|
||||||
|
|
||||||
|
try {
|
||||||
// select the input
|
// select the input
|
||||||
mts.currentInput(mtsInput);
|
mts.currentInput(0);
|
||||||
|
|
||||||
// attempt to get data
|
// attempt to get data
|
||||||
mts.startData();
|
mts.startData();
|
||||||
|
|
|
@ -35,7 +35,7 @@ public final class Lm2MtsDataSource implements ExternalDataSource {
|
||||||
private static final Logger LOGGER = getLogger(Lm2MtsDataSource.class);
|
private static final Logger LOGGER = getLogger(Lm2MtsDataSource.class);
|
||||||
private final Lm2MtsDataItem dataItem = new Lm2MtsDataItem();
|
private final Lm2MtsDataItem dataItem = new Lm2MtsDataItem();
|
||||||
private MTSRunner runner;
|
private MTSRunner runner;
|
||||||
private int mtsPort = 0;
|
private int mtsPort = -1;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return getClass().getName();
|
return getClass().getName();
|
||||||
|
@ -46,7 +46,7 @@ public final class Lm2MtsDataSource implements ExternalDataSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return "0.02";
|
return "0.03";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<? extends ExternalDataItem> getDataItems() {
|
public List<? extends ExternalDataItem> getDataItems() {
|
||||||
|
@ -79,7 +79,7 @@ public final class Lm2MtsDataSource implements ExternalDataSource {
|
||||||
return parseInt(port);
|
return parseInt(port);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.warn("Bad MTS port: " + port);
|
LOGGER.warn("Bad MTS port: " + port);
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue