functional testing should not be that darn slow #1076

nicer logging
This commit is contained in:
rusefi 2019-12-21 23:15:50 -05:00
parent 404cf73627
commit 40c56722a7
1 changed files with 6 additions and 7 deletions

View File

@ -37,6 +37,9 @@ public class IoUtil {
return Fields.CMD_DISABLE + " " + settingName;
}
/**
* blocking method which would for confirmation from rusEfi
*/
static void sendCommand(String command, int retryTimeoutMs, int totalTimeoutSeconds) {
final CountDownLatch responseLatch = new CountDownLatch(1);
long time = System.currentTimeMillis();
@ -68,6 +71,7 @@ public class IoUtil {
}
static void changeRpm(final int rpm) {
FileLog.MAIN.logLine("AUTOTEST rpm EN " + rpm);
sendCommand("rpm " + rpm);
long time = System.currentTimeMillis();
@ -86,7 +90,6 @@ public class IoUtil {
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
FileLog.MAIN.logLine("RPM change [" + rpm + "] executed in " + (System.currentTimeMillis() - time));
SensorCentral.getInstance().removeListener(Sensor.RPM, listener);
double actualRpm = SensorCentral.getInstance().getValue(Sensor.RPM);
@ -94,17 +97,13 @@ public class IoUtil {
if (!isCloseEnough(rpm, actualRpm))
throw new IllegalStateException("rpm change did not happen: " + rpm + ", actual " + actualRpm);
sendCommand(Fields.CMD_RESET_ENGINE_SNIFFER);
FileLog.MAIN.logLine("AUTOTEST RPM change [" + rpm + "] executed in " + (System.currentTimeMillis() - time));
}
static void waitForFirstResponse() throws InterruptedException {
FileLog.MAIN.logLine("Let's give it some time to start...");
final CountDownLatch startup = new CountDownLatch(1);
SensorCentral.SensorListener listener = new SensorCentral.SensorListener() {
@Override
public void onSensorUpdate(double value) {
startup.countDown();
}
};
SensorCentral.SensorListener listener = value -> startup.countDown();
long waitStart = System.currentTimeMillis();
SensorCentral.getInstance().addListener(Sensor.RPM, listener);
startup.await(5, TimeUnit.SECONDS);