HW CI: rev limiter (#2141)
* test rev limit * comment, format * make test work * check that it goes back to normal Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
041b84596f
commit
b2cb46d724
|
@ -13,6 +13,7 @@ import org.junit.Test;
|
||||||
import static com.rusefi.IoUtil.getEnableCommand;
|
import static com.rusefi.IoUtil.getEnableCommand;
|
||||||
import static com.rusefi.TestingUtils.*;
|
import static com.rusefi.TestingUtils.*;
|
||||||
import static com.rusefi.config.generated.Fields.*;
|
import static com.rusefi.config.generated.Fields.*;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rusEfi firmware simulator functional test suite
|
* rusEfi firmware simulator functional test suite
|
||||||
|
@ -93,6 +94,52 @@ public class FunctionalTest extends RusefiTestBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRevLimiter() {
|
||||||
|
String msg = "rev limiter";
|
||||||
|
|
||||||
|
ecu.setEngineType(ET_FORD_ASPIRE);
|
||||||
|
ecu.changeRpm(2000);
|
||||||
|
|
||||||
|
// Alpha-N mode so that we actually inject some fuel (without mocking tons of sensors)
|
||||||
|
ecu.sendCommand("set algorithm 5");
|
||||||
|
// Set tps to 25% - make alpha-n happy
|
||||||
|
ecu.sendCommand("set_sensor_mock 10 25");
|
||||||
|
ecu.sendCommand("set rpm_hard_limit 2500");
|
||||||
|
|
||||||
|
{
|
||||||
|
// Check that neither ignition nor injection is cut
|
||||||
|
EngineChart chart = nextChart();
|
||||||
|
|
||||||
|
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
||||||
|
assertWaveNotNull(chart, EngineChart.INJECTOR_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now go above the hard limiter
|
||||||
|
ecu.changeRpm(3000);
|
||||||
|
|
||||||
|
{
|
||||||
|
// Check that both ignition and injection are cut
|
||||||
|
EngineChart chart = nextChart();
|
||||||
|
|
||||||
|
// These channels are allowed to have falling edges - aka closing injectors and firing coils
|
||||||
|
// but not allowed to have rising edges - aka opening injectors and charging coils
|
||||||
|
assertWaveNoRises(chart, EngineChart.SPARK_1);
|
||||||
|
assertWaveNoRises(chart, EngineChart.INJECTOR_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that it recovers when we go back under the limit
|
||||||
|
ecu.changeRpm(2000);
|
||||||
|
|
||||||
|
{
|
||||||
|
// Check that neither ignition nor injection is cut
|
||||||
|
EngineChart chart = nextChart();
|
||||||
|
|
||||||
|
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
||||||
|
assertWaveNotNull(chart, EngineChart.INJECTOR_1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCustomEngine() {
|
public void testCustomEngine() {
|
||||||
ecu.setEngineType(ET_DEFAULT_FRANKENSO);
|
ecu.setEngineType(ET_DEFAULT_FRANKENSO);
|
||||||
|
@ -421,6 +468,18 @@ public class FunctionalTest extends RusefiTestBase {
|
||||||
assertTrue(chart.get(key) != null);
|
assertTrue(chart.get(key) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void assertWaveNoRises(EngineChart chart, String key) {
|
||||||
|
StringBuilder events = chart.get(key);
|
||||||
|
|
||||||
|
// if no events of this type at all, return since this passes the test
|
||||||
|
if (events == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assert that there are no up (rise) events in the channel's sequence
|
||||||
|
assertFalse(events.toString().contains("u"));
|
||||||
|
}
|
||||||
|
|
||||||
private EngineChart nextChart() {
|
private EngineChart nextChart() {
|
||||||
return TestingUtils.nextChart(ecu.commandQueue);
|
return TestingUtils.nextChart(ecu.commandQueue);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue