From cbed211e9e39896e83fd6010db6065ff250743a0 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Mon, 23 Feb 2015 21:04:32 -0600 Subject: [PATCH] auto-sync --- .../autotest/src/com/rusefi/AutoTest.java | 26 ++++++++++++------- .../autotest/src/com/rusefi/IoUtil.java | 2 +- .../autotest/src/com/rusefi/RealHwTest.java | 19 ++++++++++++-- .../autotest/src/com/rusefi/TestingUtils.java | 4 +-- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/java_console/autotest/src/com/rusefi/AutoTest.java b/java_console/autotest/src/com/rusefi/AutoTest.java index 3e0ee3d64e..d6fcccfa71 100644 --- a/java_console/autotest/src/com/rusefi/AutoTest.java +++ b/java_console/autotest/src/com/rusefi/AutoTest.java @@ -18,6 +18,7 @@ import static com.rusefi.TestingUtils.*; * 3/5/14 */ public class AutoTest { + public static final int COMPLEX_COMMAND_RETRY = 10000; static int currentEngineType; static void mainTestBody() { @@ -49,7 +50,7 @@ public class AutoTest { private static void setEngineType(int type) { currentEngineType = type; - sendCommand("set_engine_type " + type, 10000, 600); + sendCommand("set_engine_type " + type, COMPLEX_COMMAND_RETRY, 600); sleep(10); sendCommand("enable self_stimulation"); } @@ -192,7 +193,7 @@ public class AutoTest { String msg; WaveChart chart; // todo: interesting changeRpm(100); - sendCommand("set_cranking_rpm 500"); + sendComplexCommand("set_cranking_rpm 500"); IoUtil.changeRpm(200); double x; @@ -228,7 +229,7 @@ public class AutoTest { sendCommand("set_cranking_charge_angle 65"); IoUtil.changeRpm(600); - sendCommand("set_cranking_rpm 700"); + sendComplexCommand("set_cranking_rpm 700"); chart = nextChart(); x = 55; assertWave("cranking@600", chart, WaveChart.SPARK_1, 0.18, x, x + 180, x + 360, x + 540); @@ -253,8 +254,9 @@ public class AutoTest { sendCommand("set_fuel_map 2200 4.2 15.66"); sendCommand("set_fuel_map 2000 4.2 15.66"); // mock 2 means 4 on the gauge because of the divider. should we simplify this? - sendCommand("set_mock_maf_voltage 2"); - sendCommand("set_global_trigger_offset_angle 175"); + if (!TestingUtils.isRealHardware) + sendCommand("set_mock_maf_voltage 2"); + sendComplexCommand("set_global_trigger_offset_angle 175"); chart = nextChart(); assertWaveFall(chart, WaveChart.INJECTOR_1, 0.555, 238.75); @@ -266,14 +268,14 @@ public class AutoTest { assertWave(chart, WaveChart.SPARK_1, 0.133, x, x + 180, x + 360, x + 540); assertWaveNull(chart, WaveChart.SPARK_2); - sendCommand("set_global_trigger_offset_angle 130"); - sendCommand("set_injection_offset 369"); + sendComplexCommand("set_global_trigger_offset_angle 130"); + sendComplexCommand("set_injection_offset 369"); chart = nextChart(); x = 580; assertWave(chart, WaveChart.SPARK_1, 0.133, x, x + 180, x + 360, x + 540); // let's enable more channels dynamically - sendCommand("set_ignition_mode 1"); + sendComplexCommand("set_ignition_mode 1"); chart = nextChart(); assertWave("Switching Aspire into INDIVIDUAL_COILS mode", chart, WaveChart.SPARK_2, 0.133, x); assertWave(chart, WaveChart.SPARK_3, 0.133, x + 360); @@ -285,8 +287,10 @@ public class AutoTest { // switching to Speed Density + if (!TestingUtils.isRealHardware) + sendCommand("set_mock_maf_voltage 2"); sendCommand("set_mock_map_voltage 1"); - sendCommand("set_algorithm 3"); + sendComplexCommand("set_algorithm 3"); chart = nextChart(); x = 8.88; assertWaveFall(msg, chart, WaveChart.INJECTOR_1, 0.329, x + 180); @@ -299,6 +303,10 @@ public class AutoTest { assertWaveNull("hard limit check", chart, WaveChart.INJECTOR_1); } + private static void sendComplexCommand(String command) { + sendCommand(command, COMPLEX_COMMAND_RETRY, IoUtil.CMD_TIMEOUT); + } + private static void assertWaveNull(WaveChart chart, String key) { assertWaveNull("", chart, key); } diff --git a/java_console/autotest/src/com/rusefi/IoUtil.java b/java_console/autotest/src/com/rusefi/IoUtil.java index 521c15c6d2..c26fded1e8 100644 --- a/java_console/autotest/src/com/rusefi/IoUtil.java +++ b/java_console/autotest/src/com/rusefi/IoUtil.java @@ -19,7 +19,7 @@ import static com.rusefi.waves.WaveReport.isCloseEnough; * 3/19/14. */ public class IoUtil { - private static final int CMD_TIMEOUT = 20; + protected static final int CMD_TIMEOUT = 20; /** * Send a command and wait for the confirmation diff --git a/java_console/autotest/src/com/rusefi/RealHwTest.java b/java_console/autotest/src/com/rusefi/RealHwTest.java index 35de3168a2..29f29dd46d 100644 --- a/java_console/autotest/src/com/rusefi/RealHwTest.java +++ b/java_console/autotest/src/com/rusefi/RealHwTest.java @@ -9,11 +9,12 @@ import static com.rusefi.AutoTest.*; */ public class RealHwTest { public static void main(String[] args) { + long start = System.currentTimeMillis(); /** * with real hardware we have noise on all analog inputs which gives us random sensor data, we cannot really * test exact numbers yet */ - TestingUtils.skipWaveCheck = true; + TestingUtils.isRealHardware = true; FileLog.MAIN.start(); String port; if (args.length == 1) { @@ -27,7 +28,21 @@ public class RealHwTest { System.out.println("Only one optional argument expected: port number"); return; } - runRealHardwareTest(port); + boolean failed = false; + try { + runRealHardwareTest(port); + } catch (Throwable e) { + e.printStackTrace(); + failed = true; + } + if (failed) + System.exit(-1); + FileLog.MAIN.logLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); + FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ Real Hardware Test Passed +++++++++++++++"); + FileLog.MAIN.logLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); + long time = (System.currentTimeMillis() - start) / 1000; + FileLog.MAIN.logLine("Done in " + time + "secs"); + System.exit(0); // this is a safer method eliminating the issue of non-daemon threads } private static void runRealHardwareTest(String port) { diff --git a/java_console/autotest/src/com/rusefi/TestingUtils.java b/java_console/autotest/src/com/rusefi/TestingUtils.java index 0cbc595d93..9ed0d09381 100644 --- a/java_console/autotest/src/com/rusefi/TestingUtils.java +++ b/java_console/autotest/src/com/rusefi/TestingUtils.java @@ -19,7 +19,7 @@ import static com.rusefi.waves.WaveReport.isCloseEnough; * 3/19/14. */ public class TestingUtils { - static boolean skipWaveCheck; + static boolean isRealHardware; static void assertTrue(String msg, boolean b) { if (!b) @@ -75,7 +75,7 @@ public class TestingUtils { } static void assertWave(boolean rise, String msg, WaveChart chart, String key, double expectedWidth, double angleRatio, double widthRatio, double... expectedAngles) { - if(skipWaveCheck) + if(isRealHardware) return; RevolutionLog revolutionLog = chart.getRevolutionsLog(); if (revolutionLog.keySet().isEmpty())