parent
404cf73627
commit
40c56722a7
|
@ -37,6 +37,9 @@ public class IoUtil {
|
||||||
return Fields.CMD_DISABLE + " " + settingName;
|
return Fields.CMD_DISABLE + " " + settingName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 totalTimeoutSeconds) {
|
||||||
final CountDownLatch responseLatch = new CountDownLatch(1);
|
final CountDownLatch responseLatch = new CountDownLatch(1);
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
|
@ -68,6 +71,7 @@ public class IoUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void changeRpm(final int rpm) {
|
static void changeRpm(final int rpm) {
|
||||||
|
FileLog.MAIN.logLine("AUTOTEST rpm EN " + rpm);
|
||||||
sendCommand("rpm " + rpm);
|
sendCommand("rpm " + rpm);
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
@ -86,7 +90,6 @@ public class IoUtil {
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
FileLog.MAIN.logLine("RPM change [" + rpm + "] executed in " + (System.currentTimeMillis() - time));
|
|
||||||
SensorCentral.getInstance().removeListener(Sensor.RPM, listener);
|
SensorCentral.getInstance().removeListener(Sensor.RPM, listener);
|
||||||
|
|
||||||
double actualRpm = SensorCentral.getInstance().getValue(Sensor.RPM);
|
double actualRpm = SensorCentral.getInstance().getValue(Sensor.RPM);
|
||||||
|
@ -94,17 +97,13 @@ public class IoUtil {
|
||||||
if (!isCloseEnough(rpm, actualRpm))
|
if (!isCloseEnough(rpm, actualRpm))
|
||||||
throw new IllegalStateException("rpm change did not happen: " + rpm + ", actual " + actualRpm);
|
throw new IllegalStateException("rpm change did not happen: " + rpm + ", actual " + actualRpm);
|
||||||
sendCommand(Fields.CMD_RESET_ENGINE_SNIFFER);
|
sendCommand(Fields.CMD_RESET_ENGINE_SNIFFER);
|
||||||
|
FileLog.MAIN.logLine("AUTOTEST RPM change [" + rpm + "] executed in " + (System.currentTimeMillis() - time));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void waitForFirstResponse() throws InterruptedException {
|
static void waitForFirstResponse() throws InterruptedException {
|
||||||
FileLog.MAIN.logLine("Let's give it some time to start...");
|
FileLog.MAIN.logLine("Let's give it some time to start...");
|
||||||
final CountDownLatch startup = new CountDownLatch(1);
|
final CountDownLatch startup = new CountDownLatch(1);
|
||||||
SensorCentral.SensorListener listener = new SensorCentral.SensorListener() {
|
SensorCentral.SensorListener listener = value -> startup.countDown();
|
||||||
@Override
|
|
||||||
public void onSensorUpdate(double value) {
|
|
||||||
startup.countDown();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
long waitStart = System.currentTimeMillis();
|
long waitStart = System.currentTimeMillis();
|
||||||
SensorCentral.getInstance().addListener(Sensor.RPM, listener);
|
SensorCentral.getInstance().addListener(Sensor.RPM, listener);
|
||||||
startup.await(5, TimeUnit.SECONDS);
|
startup.await(5, TimeUnit.SECONDS);
|
||||||
|
|
Loading…
Reference in New Issue