auto-sync
This commit is contained in:
parent
9384ef858b
commit
a0028d3483
|
@ -45,6 +45,8 @@ public class AutoTest {
|
||||||
private static void testMitsu() {
|
private static void testMitsu() {
|
||||||
setEngineType(16);
|
setEngineType(16);
|
||||||
String msg = "Mitsubishi";
|
String msg = "Mitsubishi";
|
||||||
|
IoUtil.changeRpm(200);
|
||||||
|
|
||||||
IoUtil.changeRpm(1200);
|
IoUtil.changeRpm(1200);
|
||||||
// todo: add more content
|
// todo: add more content
|
||||||
}
|
}
|
||||||
|
@ -58,7 +60,7 @@ public class AutoTest {
|
||||||
|
|
||||||
static void setEngineType(int type) {
|
static void setEngineType(int type) {
|
||||||
currentEngineType = type;
|
currentEngineType = type;
|
||||||
sendCommand("set_engine_type " + type, COMPLEX_COMMAND_RETRY, 600);
|
sendCommand("set_engine_type " + type, COMPLEX_COMMAND_RETRY, 30);
|
||||||
sleep(10);
|
sleep(10);
|
||||||
sendCommand("enable self_stimulation");
|
sendCommand("enable self_stimulation");
|
||||||
}
|
}
|
||||||
|
@ -326,6 +328,14 @@ public class AutoTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException {
|
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();
|
long start = System.currentTimeMillis();
|
||||||
FileLog.SIMULATOR_CONSOLE.start();
|
FileLog.SIMULATOR_CONSOLE.start();
|
||||||
FileLog.MAIN.start();
|
FileLog.MAIN.start();
|
||||||
|
|
|
@ -24,12 +24,12 @@ public class EnduranceTest {
|
||||||
IoUtil.realHardwareConnect(port);
|
IoUtil.realHardwareConnect(port);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
AutoTest.currentEngineType = 3;
|
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);
|
sleep(2);
|
||||||
sendCommand("enable self_stimulation");
|
sendCommand("enable self_stimulation");
|
||||||
// IoUtil.changeRpm(1200);
|
// IoUtil.changeRpm(1200);
|
||||||
AutoTest.currentEngineType = 28;
|
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);
|
sleep(2);
|
||||||
FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ " + i + " +++++++++++++++");
|
FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ " + i + " +++++++++++++++");
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,6 +163,7 @@ public class IoUtil {
|
||||||
|
|
||||||
static void realHardwareConnect(String port) {
|
static void realHardwareConnect(String port) {
|
||||||
LinkManager.start(port);
|
LinkManager.start(port);
|
||||||
|
final CountDownLatch connected = new CountDownLatch(1);
|
||||||
LinkManager.open(new LinkManager.LinkStateListener() {
|
LinkManager.open(new LinkManager.LinkStateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionFailed() {
|
public void onConnectionFailed() {
|
||||||
|
@ -172,10 +173,18 @@ public class IoUtil {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionEstablished() {
|
public void onConnectionEstablished() {
|
||||||
|
connected.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
LinkManager.engineState.registerStringValueAction(EngineState.RUS_EFI_VERSION_TAG, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
|
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(EngineState.OUTPIN_TAG, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
|
||||||
LinkManager.engineState.registerStringValueAction(AverageAnglesUtil.KEY, (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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,4 +105,9 @@ public enum FileLog {
|
||||||
OutputStreamWriter os = new OutputStreamWriter(fileLog);
|
OutputStreamWriter os = new OutputStreamWriter(fileLog);
|
||||||
exception.printStackTrace(new PrintWriter(os));
|
exception.printStackTrace(new PrintWriter(os));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void logException(String msg, Throwable e) {
|
||||||
|
logLine(msg + e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -36,10 +36,9 @@ public class CommandQueue {
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
sendPendingCommand();
|
sendPendingCommand();
|
||||||
} catch (InterruptedException e) {
|
} catch (Throwable e) {
|
||||||
FileLog.MAIN.logLine("CommandQueue error");
|
FileLog.MAIN.logException("CommandQueue error", e);
|
||||||
e.printStackTrace();
|
System.exit(-2);
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,8 @@ public class PortHolder {
|
||||||
Future f = LinkManager.COMMUNICATION_EXECUTOR.submit(new Runnable() {
|
Future f = LinkManager.COMMUNICATION_EXECUTOR.submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (bp == null)
|
||||||
|
throw new NullPointerException("bp");
|
||||||
bp.sendTextCommand(command);
|
bp.sendTextCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue