parent
e7a408b415
commit
c55bf7a4c7
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue