diff --git a/java_console/autotest/src/com/rusefi/AutoTest.java b/java_console/autotest/src/com/rusefi/AutoTest.java index 878e3b79ac..87aa509e8c 100644 --- a/java_console/autotest/src/com/rusefi/AutoTest.java +++ b/java_console/autotest/src/com/rusefi/AutoTest.java @@ -190,7 +190,7 @@ this is just too unreliable at this point :( FileLog.MAIN.logLine("AUTOTEST setEngineType " + type); // sendCommand(CMD_PINS); currentEngineType = type; - sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + type, COMPLEX_COMMAND_RETRY, 2 * Timeouts.CMD_TIMEOUT); + sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + type, COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT); // TODO: document the reason for this sleep?! sleep(1); sendCommand(getEnableCommand("self_stimulation")); @@ -495,9 +495,9 @@ this is just too unreliable at this point :( sendCommand(command, CommandQueue.DEFAULT_TIMEOUT, Timeouts.CMD_TIMEOUT); } - private static void sendCommand(String command, int retryTimeoutMs, int totalTimeoutSeconds) { + private static void sendCommand(String command, int retryTimeoutMs, int timeoutMs) { assertNull("Fatal not expected", criticalError); - IoUtil.sendCommand(command, retryTimeoutMs, totalTimeoutSeconds); + IoUtil.sendCommand(command, retryTimeoutMs, timeoutMs); } private static void assertEquals(double expected, double actual) { diff --git a/java_console/autotest/src/com/rusefi/EnduranceTest.java b/java_console/autotest/src/com/rusefi/EnduranceTest.java index deb453ef07..1ba9c042b7 100644 --- a/java_console/autotest/src/com/rusefi/EnduranceTest.java +++ b/java_console/autotest/src/com/rusefi/EnduranceTest.java @@ -1,6 +1,7 @@ package com.rusefi; import com.rusefi.config.generated.Fields; +import org.junit.rules.Timeout; import static com.rusefi.IoUtil.*; import static com.rusefi.RealHwTest.startRealHardwareTest; @@ -25,12 +26,12 @@ public class EnduranceTest { IoUtil.realHardwareConnect(port); for (int i = 0; i < count; i++) { AutoTest.currentEngineType = 3; - sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, AutoTest.COMPLEX_COMMAND_RETRY, 60); + sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, AutoTest.COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT); sleep(2); sendCommand(getEnableCommand("self_stimulation")); // IoUtil.changeRpm(1200); AutoTest.currentEngineType = 28; - sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 28, AutoTest.COMPLEX_COMMAND_RETRY, 60); + sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 28, AutoTest.COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT); sleep(2); FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ " + i + " +++++++++++++++"); } diff --git a/java_console/autotest/src/com/rusefi/IoUtil.java b/java_console/autotest/src/com/rusefi/IoUtil.java index 3a31e2aa48..95cc37309f 100644 --- a/java_console/autotest/src/com/rusefi/IoUtil.java +++ b/java_console/autotest/src/com/rusefi/IoUtil.java @@ -41,7 +41,7 @@ public class IoUtil { /** * blocking method which would for confirmation from rusEfi */ - static void sendCommand(String command, int retryTimeoutMs, int totalTimeoutSeconds) { + static void sendCommand(String command, int retryTimeoutMs, int timeoutMs) { final CountDownLatch responseLatch = new CountDownLatch(1); long time = System.currentTimeMillis(); FileLog.MAIN.logLine("Sending command [" + command + "]"); @@ -53,15 +53,15 @@ public class IoUtil { FileLog.MAIN.logLine("Got confirmation in " + (System.currentTimeMillis() - begin) + "ms"); } }); - wait(responseLatch, totalTimeoutSeconds); + wait(responseLatch, timeoutMs); if (responseLatch.getCount() > 0) FileLog.MAIN.logLine("No confirmation in " + retryTimeoutMs); FileLog.MAIN.logLine("Command [" + command + "] executed in " + (System.currentTimeMillis() - time)); } - static void wait(CountDownLatch responseLatch, int seconds) { + static void wait(CountDownLatch responseLatch, int milliseconds) { try { - responseLatch.await(seconds, TimeUnit.SECONDS); + responseLatch.await(milliseconds, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { throw new IllegalStateException(e); } diff --git a/java_console/autotest/src/com/rusefi/TestingUtils.java b/java_console/autotest/src/com/rusefi/TestingUtils.java index 830c35bd3b..696d2ae96e 100644 --- a/java_console/autotest/src/com/rusefi/TestingUtils.java +++ b/java_console/autotest/src/com/rusefi/TestingUtils.java @@ -153,13 +153,13 @@ public class TestingUtils { result.set(value); } }); - int timeout = 60; + int timeoutMs = 60 * Timeouts.SECOND; long waitStartTime = System.currentTimeMillis(); - IoUtil.wait(engineChartLatch, timeout); + IoUtil.wait(engineChartLatch, timeoutMs); FileLog.MAIN.logLine("got next chart in " + (System.currentTimeMillis() - waitStartTime) + "ms for engine_type " + AutoTest.currentEngineType); LinkManager.engineState.replaceStringValueAction(EngineReport.ENGINE_CHART, (EngineState.ValueCallback) EngineState.ValueCallback.VOID); if (result.get() == null) - throw new IllegalStateException("Chart timeout: " + timeout); + throw new IllegalStateException("Chart timeout: " + timeoutMs); return result.get(); } } diff --git a/java_console/io/src/com/rusefi/Timeouts.java b/java_console/io/src/com/rusefi/Timeouts.java index ec359bb512..3e986a80f3 100644 --- a/java_console/io/src/com/rusefi/Timeouts.java +++ b/java_console/io/src/com/rusefi/Timeouts.java @@ -7,10 +7,12 @@ public interface Timeouts { int SECOND = 1000; int COMMAND_TIMEOUT_SEC = 10; // seconds int BINARY_IO_TIMEOUT = 5 * SECOND; - int CMD_TIMEOUT = 20; int READ_IMAGE_TIMEOUT = 60 * SECOND; int CONNECTION_RESTART_DELAY = 20 * SECOND; int CONNECTION_STATUS_TIMEOUT = 3 * SECOND; + + int CMD_TIMEOUT = 20 * SECOND; + int SET_ENGINE_TIMEOUT = 60 * SECOND; }