diff --git a/java_console/autotest/src/com/rusefi/AutoTest.java b/java_console/autotest/src/com/rusefi/AutoTest.java index 1322dd325e..3e0ee3d64e 100644 --- a/java_console/autotest/src/com/rusefi/AutoTest.java +++ b/java_console/autotest/src/com/rusefi/AutoTest.java @@ -22,6 +22,7 @@ public class AutoTest { static void mainTestBody() { sendCommand("fl 1"); // just in case it was disabled + testMitsu(); testCitroenBerlingo(); testMazda626(); test2003DodgeNeon(); @@ -32,9 +33,17 @@ public class AutoTest { testFordFiesta(); } + private static void testMitsu() { + setEngineType(16); + String msg = "Mitsubishi"; + IoUtil.changeRpm(1200); + // todo: add more content + } + private static void testCitroenBerlingo() { setEngineType(15); String msg = "Citroen"; + IoUtil.changeRpm(1200); // todo: add more content } diff --git a/java_console/autotest/src/com/rusefi/RealHwTest.java b/java_console/autotest/src/com/rusefi/RealHwTest.java index ba53a44c50..35de3168a2 100644 --- a/java_console/autotest/src/com/rusefi/RealHwTest.java +++ b/java_console/autotest/src/com/rusefi/RealHwTest.java @@ -9,6 +9,11 @@ import static com.rusefi.AutoTest.*; */ public class RealHwTest { public static void main(String[] args) { + /** + * 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; FileLog.MAIN.start(); String port; if (args.length == 1) { diff --git a/java_console/autotest/src/com/rusefi/TestingUtils.java b/java_console/autotest/src/com/rusefi/TestingUtils.java index 17e234f863..0cbc595d93 100644 --- a/java_console/autotest/src/com/rusefi/TestingUtils.java +++ b/java_console/autotest/src/com/rusefi/TestingUtils.java @@ -19,6 +19,8 @@ import static com.rusefi.waves.WaveReport.isCloseEnough; * 3/19/14. */ public class TestingUtils { + static boolean skipWaveCheck; + static void assertTrue(String msg, boolean b) { if (!b) fail("Not true: " + msg); @@ -35,7 +37,7 @@ public class TestingUtils { } private static String printRange(double current, double ratio) { - return " expected range from " + current * (1 - ratio) + " to " + current * (1 + ratio); + return " expected range from " + current * (1 - ratio) + " to " + current * (1 + ratio) + " with ratio " + ratio; } private static double fixAngle(double angle) { @@ -46,7 +48,9 @@ public class TestingUtils { private static void fail(String message) { FileLog.MAIN.logLine("FAILURE: " + message); - throw new IllegalStateException(message); + IllegalStateException exception = new IllegalStateException(message); + FileLog.MAIN.log(exception); + throw exception; } static void assertTrue(boolean b) { @@ -70,7 +74,9 @@ public class TestingUtils { assertWave(false, msg, chart, key, width, WaveReport.RATIO, WaveReport.RATIO, expectedAngles); } - static void assertWave(boolean rise, String msg, WaveChart chart, String key, double width, double angleRatio, double widthRatio, double... expectedAngles) { + static void assertWave(boolean rise, String msg, WaveChart chart, String key, double expectedWidth, double angleRatio, double widthRatio, double... expectedAngles) { + if(skipWaveCheck) + return; RevolutionLog revolutionLog = chart.getRevolutionsLog(); if (revolutionLog.keySet().isEmpty()) throw new IllegalStateException(msg + " Empty revolutions in " + chart); @@ -84,7 +90,13 @@ public class TestingUtils { double angleByTime = revolutionLog.getCrankAngleByTime(eventTime); assertCloseEnough(msg + " angle for " + key + "@" + eventTime, fixAngle(angleByTime), angleRatio, expectedAngles); - assertCloseEnough(msg + "width for " + key, ud.getDutyCycle(revolutionLog), widthRatio, width); + double actualWidth = ud.getDutyCycle(revolutionLog); + if (!isCloseEnough(fixAngle(actualWidth), expectedWidth, widthRatio)) { + System.out.println("f " + revolutionLog.getCrankAngleByTime(ud.downTime)); + System.out.println("t " + revolutionLog.getCrankAngleByTime(ud.upTime)); + } + assertCloseEnough(msg + "width for " + key, actualWidth, widthRatio, expectedWidth); + } } @@ -100,6 +112,7 @@ public class TestingUtils { // we need to skip TWO because spark could have been scheduled a while ago and happen now // todo: improve this logic, compare times getWaveChart(); + getWaveChart(); // we want to wait for the 2nd chart to see same same RPM across the whole chart String result = getWaveChart(); FileLog.MAIN.logLine("current chart: " + result); diff --git a/java_console/io/src/com/rusefi/FileLog.java b/java_console/io/src/com/rusefi/FileLog.java index 82b3dfe815..65913cd5d4 100644 --- a/java_console/io/src/com/rusefi/FileLog.java +++ b/java_console/io/src/com/rusefi/FileLog.java @@ -83,4 +83,11 @@ public enum FileLog { public static void rlog(String msg) { System.out.println("r " + msg); } + + public void log(IllegalStateException exception) { + if (fileLog == null) + throw new NullPointerException("fileLog"); + OutputStreamWriter os = new OutputStreamWriter(fileLog); + exception.printStackTrace(new PrintWriter(os)); + } } \ No newline at end of file diff --git a/java_console/ui/src/com/rusefi/ui/engine/EngineSnifferPanel.java b/java_console/ui/src/com/rusefi/ui/engine/EngineSnifferPanel.java index 4ad03724b4..9e8e76f360 100644 --- a/java_console/ui/src/com/rusefi/ui/engine/EngineSnifferPanel.java +++ b/java_console/ui/src/com/rusefi/ui/engine/EngineSnifferPanel.java @@ -33,6 +33,7 @@ import static com.rusefi.ui.util.LocalizedMessages.PAUSE; * Andrey Belomutskiy (c) 2012-2013 * * @see EngineSnifferStatusPanel status bar + * @see com.rusefi.ui.test.WavePanelSandbox */ public class EngineSnifferPanel { private static final int EFI_DEFAULT_CHART_SIZE = 180;