only: zero RPM using existing API

This commit is contained in:
rusefillc 2023-11-10 20:05:36 -05:00
parent 4a43395155
commit 1f81b10e82
2 changed files with 18 additions and 7 deletions

View File

@ -79,6 +79,17 @@ public class IoUtil {
sendBlockingCommand(CMD_RPM + " " + rpm, commandQueue);
long time = System.currentTimeMillis();
awaitRpm(rpm);
double actualRpm = SensorCentral.getInstance().getValue(Sensor.RPMValue);
if (!isCloseEnough(rpm, actualRpm))
throw new IllegalStateException("rpm change did not happen: " + rpm + ", actual " + actualRpm);
// sendCommand(Fields.CMD_RESET_ENGINE_SNIFFER);
log.info("AUTOTEST RPM change [" + rpm + "] executed in " + (System.currentTimeMillis() - time));
}
public static void awaitRpm(int rpm) {
final CountDownLatch rpmLatch = new CountDownLatch(1);
SensorCentral.ListenerToken listenerToken = SensorCentral.getInstance().addListener(Sensor.RPMValue, actualRpm -> {
@ -95,13 +106,6 @@ public class IoUtil {
// We don't need to listen to RPM anymore
listenerToken.remove();
double actualRpm = SensorCentral.getInstance().getValue(Sensor.RPMValue);
if (!isCloseEnough(rpm, actualRpm))
throw new IllegalStateException("rpm change did not happen: " + rpm + ", actual " + actualRpm);
// sendCommand(Fields.CMD_RESET_ENGINE_SNIFFER);
log.info("AUTOTEST RPM change [" + rpm + "] executed in " + (System.currentTimeMillis() - time));
}
private static void waitForFirstResponse() throws InterruptedException {

View File

@ -1,6 +1,7 @@
package com.rusefi.simulator;
import com.devexperts.logging.Logging;
import com.rusefi.IoUtil;
import com.rusefi.Timeouts;
import com.rusefi.config.generated.Fields;
import com.rusefi.core.Sensor;
@ -9,6 +10,7 @@ import com.rusefi.enums.bench_mode_e;
import com.rusefi.enums.bench_test_magic_numbers_e;
import com.rusefi.enums.bench_test_packet_ids_e;
import com.rusefi.enums.bench_test_io_control_e;
import com.rusefi.functional_tests.EcuTestHelper;
import com.rusefi.io.LinkManager;
import etch.util.CircularByteBuffer;
@ -16,6 +18,7 @@ import java.io.EOFException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import static com.rusefi.IoUtil.getDisableCommand;
import static com.rusefi.binaryprotocol.IoHelper.swap16;
import static com.rusefi.config.generated.Fields.TS_SIMULATE_CAN;
import static org.junit.Assert.assertTrue;
@ -48,6 +51,10 @@ public class SimulatorFunctionalTest {
testOutputPin(bench_mode_e.HD_ACR2, Fields.BENCH_AC_RELAY_DURATION);
testOutputPin(bench_mode_e.BENCH_AC_COMPRESSOR_RELAY, Fields.BENCH_AC_RELAY_DURATION);
testOutputPin(bench_mode_e.BENCH_STARTER_ENABLE_RELAY, Fields.BENCH_STARTER_DURATION);
EcuTestHelper ecu = new EcuTestHelper(linkManager);
ecu.sendCommand(getDisableCommand(Fields.CMD_SELF_STIMULATION));
IoUtil.awaitRpm(0);
// todo: fix me as well! testOutputPin(bench_mode_e.BENCH_VVT0_VALVE, Fields.BENCH_VVT_DURATION);
}