auto-sync

This commit is contained in:
rusEfi 2015-03-22 20:05:14 -05:00
parent 9384ef858b
commit a0028d3483
6 changed files with 32 additions and 7 deletions

View File

@ -45,6 +45,8 @@ public class AutoTest {
private static void testMitsu() {
setEngineType(16);
String msg = "Mitsubishi";
IoUtil.changeRpm(200);
IoUtil.changeRpm(1200);
// todo: add more content
}
@ -58,7 +60,7 @@ public class AutoTest {
static void setEngineType(int type) {
currentEngineType = type;
sendCommand("set_engine_type " + type, COMPLEX_COMMAND_RETRY, 600);
sendCommand("set_engine_type " + type, COMPLEX_COMMAND_RETRY, 30);
sleep(10);
sendCommand("enable self_stimulation");
}
@ -326,6 +328,14 @@ public class AutoTest {
}
public static void main(String[] args) throws InterruptedException {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
e.printStackTrace();
System.exit(-1);
}
});
long start = System.currentTimeMillis();
FileLog.SIMULATOR_CONSOLE.start();
FileLog.MAIN.start();

View File

@ -24,12 +24,12 @@ public class EnduranceTest {
IoUtil.realHardwareConnect(port);
for (int i = 0; i < count; i++) {
AutoTest.currentEngineType = 3;
sendCommand("set_engine_type " + 3, AutoTest.COMPLEX_COMMAND_RETRY, 600);
sendCommand("set_engine_type " + 3, AutoTest.COMPLEX_COMMAND_RETRY, 60);
sleep(2);
sendCommand("enable self_stimulation");
// IoUtil.changeRpm(1200);
AutoTest.currentEngineType = 28;
sendCommand("set_engine_type " + 28, AutoTest.COMPLEX_COMMAND_RETRY, 600);
sendCommand("set_engine_type " + 28, AutoTest.COMPLEX_COMMAND_RETRY, 60);
sleep(2);
FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ " + i + " +++++++++++++++");
}

View File

@ -163,6 +163,7 @@ public class IoUtil {
static void realHardwareConnect(String port) {
LinkManager.start(port);
final CountDownLatch connected = new CountDownLatch(1);
LinkManager.open(new LinkManager.LinkStateListener() {
@Override
public void onConnectionFailed() {
@ -172,10 +173,18 @@ public class IoUtil {
@Override
public void onConnectionEstablished() {
connected.countDown();
}
});
LinkManager.engineState.registerStringValueAction(EngineState.RUS_EFI_VERSION_TAG, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
LinkManager.engineState.registerStringValueAction(EngineState.OUTPIN_TAG, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
LinkManager.engineState.registerStringValueAction(AverageAnglesUtil.KEY, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
try {
connected.await(60, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
if (connected.getCount() > 0)
throw new IllegalStateException("Not connected in time");
}
}

View File

@ -105,4 +105,9 @@ public enum FileLog {
OutputStreamWriter os = new OutputStreamWriter(fileLog);
exception.printStackTrace(new PrintWriter(os));
}
public void logException(String msg, Throwable e) {
logLine(msg + e);
e.printStackTrace();
}
}

View File

@ -36,10 +36,9 @@ public class CommandQueue {
while (true) {
try {
sendPendingCommand();
} catch (InterruptedException e) {
FileLog.MAIN.logLine("CommandQueue error");
e.printStackTrace();
throw new IllegalStateException(e);
} catch (Throwable e) {
FileLog.MAIN.logException("CommandQueue error", e);
System.exit(-2);
}
}
}

View File

@ -164,6 +164,8 @@ public class PortHolder {
Future f = LinkManager.COMMUNICATION_EXECUTOR.submit(new Runnable() {
@Override
public void run() {
if (bp == null)
throw new NullPointerException("bp");
bp.sendTextCommand(command);
}