2015-07-10 06:01:56 -07:00
|
|
|
package com.rusefi;
|
|
|
|
|
|
|
|
|
|
|
|
import com.rusefi.core.Sensor;
|
|
|
|
import com.rusefi.core.SensorCentral;
|
2020-12-12 15:58:30 -08:00
|
|
|
import com.rusefi.functional_tests.EcuTestHelper;
|
2015-07-10 06:01:56 -07:00
|
|
|
import com.rusefi.waves.EngineChart;
|
|
|
|
import com.rusefi.waves.EngineReport;
|
2020-12-12 21:02:19 -08:00
|
|
|
import org.junit.Before;
|
2020-12-18 15:55:02 -08:00
|
|
|
import org.junit.Ignore;
|
2020-12-12 21:02:19 -08:00
|
|
|
import org.junit.Test;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
import static com.rusefi.IoUtil.getEnableCommand;
|
2015-07-10 06:01:56 -07:00
|
|
|
import static com.rusefi.TestingUtils.*;
|
2020-08-08 14:07:23 -07:00
|
|
|
import static com.rusefi.config.generated.Fields.*;
|
2020-12-26 14:14:04 -08:00
|
|
|
import static org.junit.Assert.assertFalse;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* rusEfi firmware simulator functional test suite
|
|
|
|
* <p/>
|
|
|
|
* java -cp rusefi_console.jar com.rusefi.AutoTest
|
|
|
|
*
|
|
|
|
* @author Andrey Belomutskiy
|
2020-04-22 21:47:40 -07:00
|
|
|
* 3/5/14
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
2020-12-24 17:50:52 -08:00
|
|
|
public class FunctionalTest extends RusefiTestBase {
|
|
|
|
@Test
|
2020-12-22 06:23:17 -08:00
|
|
|
public void testChangingIgnitionMode() {
|
|
|
|
String msg = "change ign mode";
|
|
|
|
|
2020-12-22 15:47:17 -08:00
|
|
|
ecu.setEngineType(ET_FORD_ASPIRE);
|
2020-12-22 06:23:17 -08:00
|
|
|
ecu.changeRpm(2000);
|
|
|
|
|
|
|
|
// First is wasted spark
|
|
|
|
ecu.sendCommand("set ignition_mode 2");
|
|
|
|
|
|
|
|
{
|
|
|
|
// Check that we're in wasted spark mode
|
|
|
|
EngineChart chart = nextChart();
|
|
|
|
|
|
|
|
// Wasted spark should fire cylinders 1/3...
|
|
|
|
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
|
|
|
assertWaveNotNull(chart, EngineChart.SPARK_3);
|
|
|
|
|
|
|
|
// ...but not cylinders 2/4
|
|
|
|
assertWaveNull(chart, EngineChart.SPARK_2);
|
|
|
|
assertWaveNull(chart, EngineChart.SPARK_4);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now switch to sequential mode
|
|
|
|
ecu.sendCommand("set ignition_mode 1");
|
|
|
|
|
|
|
|
{
|
|
|
|
// Check that we're in sequential spark mode
|
|
|
|
EngineChart chart = nextChart();
|
|
|
|
|
|
|
|
// All 4 cylinders should be firing
|
2020-12-24 17:50:52 -08:00
|
|
|
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
2020-12-22 06:23:17 -08:00
|
|
|
assertWaveNotNull(chart, EngineChart.SPARK_2);
|
|
|
|
assertWaveNotNull(chart, EngineChart.SPARK_3);
|
|
|
|
assertWaveNotNull(chart, EngineChart.SPARK_4);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now switch to "one coil" mode
|
|
|
|
ecu.sendCommand("set ignition_mode 0");
|
|
|
|
|
|
|
|
{
|
|
|
|
// Check that we're in sequential spark mode
|
|
|
|
EngineChart chart = nextChart();
|
|
|
|
|
|
|
|
// Only coil 1 should be active
|
|
|
|
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
|
|
|
|
|
|
|
// And no others
|
|
|
|
assertWaveNull(chart, EngineChart.SPARK_2);
|
|
|
|
assertWaveNull(chart, EngineChart.SPARK_3);
|
|
|
|
assertWaveNull(chart, EngineChart.SPARK_4);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now switch BACK to wasted mode
|
|
|
|
ecu.sendCommand("set ignition_mode 2");
|
|
|
|
|
|
|
|
{
|
|
|
|
// Check that we're in wasted spark mode
|
|
|
|
EngineChart chart = nextChart();
|
|
|
|
|
|
|
|
// Wasted spark should fire cylinders 1/3...
|
|
|
|
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
|
|
|
assertWaveNotNull(chart, EngineChart.SPARK_3);
|
|
|
|
|
|
|
|
// ...but not cylinders 2/4
|
|
|
|
assertWaveNull(chart, EngineChart.SPARK_2);
|
|
|
|
assertWaveNull(msg, chart, EngineChart.SPARK_4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-26 14:14:04 -08:00
|
|
|
@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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void testCustomEngine() {
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.setEngineType(ET_DEFAULT_FRANKENSO);
|
|
|
|
ecu.sendCommand("set_toothed_wheel 4 0");
|
2017-02-24 07:06:31 -08:00
|
|
|
// sendCommand("enable trigger_only_front");
|
|
|
|
// changeRpm(100);
|
|
|
|
// changeRpm(1500);
|
2017-02-24 08:55:38 -08:00
|
|
|
// sendCommand("disable trigger_only_front");
|
|
|
|
// changeRpm(100);
|
|
|
|
// changeRpm(1500);
|
2017-02-23 05:12:03 -08:00
|
|
|
}
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void testMazdaMiata2003() {
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.setEngineType(ET_FRANKENSO_MIATA_NB2);
|
|
|
|
ecu.sendCommand("get cranking_dwell"); // just test coverage
|
2017-05-12 08:10:40 -07:00
|
|
|
// sendCommand("get nosuchgettersdfsdfsdfsdf"); // just test coverage
|
2017-01-22 06:03:08 -08:00
|
|
|
}
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void testCamaro() {
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.setEngineType(ET_CAMARO);
|
2017-01-28 12:05:25 -08:00
|
|
|
}
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void testSachs() {
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.setEngineType(ET_SACHS);
|
2020-08-08 08:04:26 -07:00
|
|
|
// String msg = "BMW";
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(1200);
|
2015-07-10 06:01:56 -07:00
|
|
|
// todo: add more content
|
|
|
|
}
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void testCitroenBerlingo() {
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.setEngineType(ET_CITROEN_TU3JP);
|
|
|
|
ecu.changeRpm(1200);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void test2003DodgeNeon() {
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.setEngineType(ET_DODGE_NEON_2003_CRANK);
|
|
|
|
ecu.sendCommand("set wwaeTau 0");
|
|
|
|
ecu.sendCommand("set wwaeBeta 0");
|
|
|
|
ecu.sendCommand("set mock_map_voltage 1");
|
|
|
|
ecu.sendCommand("set mock_vbatt_voltage 1.20");
|
|
|
|
ecu.sendCommand("disable cylinder_cleanup");
|
2015-07-10 06:01:56 -07:00
|
|
|
EngineChart chart;
|
|
|
|
String msg = "2003 Neon cranking ";
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(200);
|
|
|
|
ecu.changeRpm(250); // another approach to artificial delay
|
|
|
|
ecu.changeRpm(200);
|
|
|
|
EcuTestHelper.assertEquals("VBatt", 12, SensorCentral.getInstance().getValue(Sensor.VBATT));
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
chart = nextChart();
|
|
|
|
double x = 100;
|
|
|
|
assertWave(true, msg, chart, EngineChart.SPARK_1, 0.194433, 0.01, EngineReport.RATIO, x + 180, x + 540);
|
|
|
|
assertWaveNull(msg, chart, EngineChart.SPARK_2);
|
|
|
|
assertWave(true, msg, chart, EngineChart.SPARK_3, 0.194433, 0.01, EngineReport.RATIO, x, x + 360);
|
|
|
|
assertWaveNull(msg, chart, EngineChart.SPARK_4);
|
|
|
|
|
|
|
|
x = 176.856;
|
|
|
|
// todo: why is width precision so low here? is that because of loaded Windows with 1ms precision?
|
|
|
|
double widthRatio = 0.25;
|
2015-09-23 20:01:40 -07:00
|
|
|
// WAT? this was just 0.009733333333333387?
|
2016-08-17 19:03:05 -07:00
|
|
|
assertWave(true, msg, chart, EngineChart.INJECTOR_1, 0.01056666666666691, 0.02, widthRatio, x, x + 180, x + 360, x + 540);
|
|
|
|
assertWave(true, msg, chart, EngineChart.INJECTOR_2, 0.01056666666666691, 0.02, widthRatio, x, x + 180, x + 360, x + 540);
|
|
|
|
assertWave(true, msg, chart, EngineChart.INJECTOR_3, 0.01056666666666691, 0.02, widthRatio, x, x + 180, x + 360, x + 540);
|
|
|
|
assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.01056666666666691, 0.02, widthRatio, x, x + 180, x + 360, x + 540);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
msg = "2003 Neon running";
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(2000);
|
|
|
|
ecu.changeRpm(2700);
|
|
|
|
ecu.changeRpm(2000);
|
2015-07-10 06:01:56 -07:00
|
|
|
chart = nextChart();
|
2016-01-21 22:01:42 -08:00
|
|
|
x = 104.0;
|
2016-08-17 19:03:05 -07:00
|
|
|
assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540);
|
2015-07-10 06:01:56 -07:00
|
|
|
assertWaveNull(msg, chart, EngineChart.SPARK_2);
|
2016-08-17 19:03:05 -07:00
|
|
|
assertWave(true, msg, chart, EngineChart.SPARK_3, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x, x + 360);
|
2015-07-10 06:01:56 -07:00
|
|
|
assertWaveNull(msg, chart, EngineChart.SPARK_4);
|
|
|
|
|
2016-01-21 22:01:42 -08:00
|
|
|
chart = nextChart();
|
2016-08-17 19:03:05 -07:00
|
|
|
x = 74;
|
|
|
|
assertWave(true, msg, chart, EngineChart.INJECTOR_1, 0.29233, EngineReport.RATIO, 0.2, x + 360);
|
|
|
|
assertWave(true, msg, chart, EngineChart.INJECTOR_2, 0.29233, 0.15, 0.2, x + 180);
|
|
|
|
assertWave(true, msg, chart, EngineChart.INJECTOR_3, 0.29233, 0.15, EngineReport.RATIO, x + 540);
|
|
|
|
assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.29233, 0.15, 0.2, x);
|
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand(getEnableCommand("trigger_only_front"));
|
2015-09-24 19:02:47 -07:00
|
|
|
chart = nextChart();
|
2016-08-17 19:03:05 -07:00
|
|
|
assertWave(true, msg, chart, EngineChart.INJECTOR_1, 0.29233, 0.1, 0.2, x + 360);
|
|
|
|
assertWave(true, msg, chart, EngineChart.INJECTOR_2, 0.29233, EngineReport.RATIO, 0.2, x + 180);
|
|
|
|
assertWave(true, msg, chart, EngineChart.INJECTOR_3, 0.29233, 0.1, 0.2, x + 540);
|
|
|
|
assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.29233, 0.1, 0.2, x);
|
2016-11-28 17:03:43 -08:00
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("set_whole_timing_map 520");
|
2020-06-25 19:27:39 -07:00
|
|
|
chart = nextChart();
|
2016-11-28 17:03:43 -08:00
|
|
|
x = 328;
|
|
|
|
assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540);
|
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("set_whole_timing_map 0");
|
2020-06-25 19:27:39 -07:00
|
|
|
chart = nextChart();
|
2016-11-28 17:03:43 -08:00
|
|
|
x = 128;
|
|
|
|
assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void testMazdaProtege() {
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.setEngineType(ET_FORD_ESCORT_GT);
|
2015-07-10 06:01:56 -07:00
|
|
|
EngineChart chart;
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("set mock_vbatt_voltage 1.395");
|
|
|
|
ecu.changeRpm(200);
|
|
|
|
ecu.changeRpm(260);
|
|
|
|
ecu.changeRpm(200);
|
2015-07-10 06:01:56 -07:00
|
|
|
String msg = "ProtegeLX cranking";
|
2020-06-25 19:27:39 -07:00
|
|
|
chart = nextChart();
|
2020-12-12 15:58:30 -08:00
|
|
|
EcuTestHelper.assertEquals("", 12, SensorCentral.getInstance().getValue(Sensor.VBATT), 0.1);
|
2015-07-10 06:01:56 -07:00
|
|
|
double x = 107;
|
2016-08-19 05:03:09 -07:00
|
|
|
assertWave(msg, chart, EngineChart.SPARK_3, 0.194433, x);
|
|
|
|
assertWave(msg, chart, EngineChart.SPARK_1, 0.194433, x + 540);
|
2015-07-10 06:01:56 -07:00
|
|
|
x = 0;
|
2016-08-16 22:01:48 -07:00
|
|
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_1, 0.008566666666, x, x + 180, x + 360, x + 540);
|
|
|
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_2, 0.008566666666, x, x + 180, x + 360, x + 540);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
msg = "ProtegeLX running";
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(2000);
|
2020-06-25 19:27:39 -07:00
|
|
|
chart = nextChart();
|
2016-02-29 18:02:38 -08:00
|
|
|
x = 112;
|
2015-07-10 06:01:56 -07:00
|
|
|
assertWave(msg, chart, EngineChart.SPARK_1, 0.13333333333333333, x, x + 180, x + 360, x + 540);
|
|
|
|
x = 0;
|
2016-08-16 22:01:48 -07:00
|
|
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_1, 0.21433333333333345, x + 180, x + 540);
|
|
|
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_2, 0.21433333333333345, x, x + 360);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void test1995DodgeNeon() {
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.setEngineType(ET_DODGE_NEON_1995);
|
2015-07-10 06:01:56 -07:00
|
|
|
EngineChart chart;
|
|
|
|
sendComplexCommand("set_whole_fuel_map 3");
|
2015-12-18 15:01:16 -08:00
|
|
|
sendComplexCommand("set_individual_coils_ignition");
|
2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* note that command order matters - RPM change resets wave chart
|
|
|
|
*/
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(2000);
|
2020-06-25 19:27:39 -07:00
|
|
|
chart = nextChart();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
String msg = "1995 Neon";
|
|
|
|
double x = -70;
|
|
|
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_4, 0.133, x + 540);
|
|
|
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_2, 0.133, x + 720);
|
|
|
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_1, 0.133, x + 180);
|
|
|
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_3, 0.133, x + 360);
|
|
|
|
|
2015-11-11 18:01:31 -08:00
|
|
|
x = 112.92;
|
2015-07-10 06:01:56 -07:00
|
|
|
assertWave(msg, chart, EngineChart.SPARK_4, 0.13333, x + 540);
|
|
|
|
assertWave(msg, chart, EngineChart.SPARK_2, 0.13333, x);
|
|
|
|
assertWave(msg, chart, EngineChart.SPARK_1, 0.13333, x + 180);
|
|
|
|
assertWave(msg, chart, EngineChart.SPARK_3, 0.13333, x + 360);
|
|
|
|
|
|
|
|
// switching to Speed Density
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("set mock_map_voltage 1");
|
2017-01-06 13:03:41 -08:00
|
|
|
sendComplexCommand("set algorithm 3");
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(2600);
|
|
|
|
ecu.changeRpm(2000);
|
2020-06-25 19:27:39 -07:00
|
|
|
chart = nextChart();
|
2015-07-10 06:01:56 -07:00
|
|
|
x = -70;
|
2016-08-16 22:01:48 -07:00
|
|
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_4, 0.493, x + 540);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void testFord6() {
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.setEngineType(ET_FORD_INLINE_6);
|
2015-07-10 06:01:56 -07:00
|
|
|
EngineChart chart;
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(2000);
|
2020-06-25 19:27:39 -07:00
|
|
|
chart = nextChart();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
String msg = "ford 6";
|
|
|
|
|
2015-11-11 18:01:31 -08:00
|
|
|
double x = 7;
|
2015-07-10 06:01:56 -07:00
|
|
|
assertWave(msg, chart, EngineChart.SPARK_1, 0.01666, x, x + 120, x + 240, x + 360, x + 480, x + 600);
|
|
|
|
|
|
|
|
assertWaveNull(msg, chart, EngineChart.TRIGGER_2);
|
2019-12-21 22:03:58 -08:00
|
|
|
sendComplexCommand("set " + "trigger_type" + " 1"); // TT_FORD_ASPIRE
|
2020-06-25 19:27:39 -07:00
|
|
|
chart = nextChart();
|
2020-09-12 01:31:35 -07:00
|
|
|
assertTrue(msg + " trigger2", chart.get(EngineChart.TRIGGER_2) != null);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void testFordAspire() {
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.setEngineType(ET_FORD_ASPIRE);
|
|
|
|
ecu.sendCommand("disable cylinder_cleanup");
|
|
|
|
ecu.sendCommand("set mock_map_voltage 1");
|
|
|
|
ecu.sendCommand("set mock_vbatt_voltage 2.2");
|
2015-07-10 06:01:56 -07:00
|
|
|
String msg;
|
|
|
|
EngineChart chart;
|
|
|
|
// todo: interesting changeRpm(100);
|
2017-01-06 06:03:33 -08:00
|
|
|
sendComplexCommand("set cranking_rpm 500");
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(200);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
double x;
|
2020-06-25 19:27:39 -07:00
|
|
|
chart = nextChart();
|
2020-12-12 15:58:30 -08:00
|
|
|
EcuTestHelper.assertEquals(12, SensorCentral.getInstance().getValue(Sensor.VBATT));
|
2015-07-10 06:01:56 -07:00
|
|
|
x = 55;
|
|
|
|
assertWave("aspire default cranking ", chart, EngineChart.SPARK_1, 0.1944, x, x + 180, x + 360, x + 540);
|
|
|
|
|
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(600);
|
2020-06-25 19:27:39 -07:00
|
|
|
chart = nextChart();
|
2016-08-17 06:01:36 -07:00
|
|
|
x = 78;
|
|
|
|
assertWave(true, "aspire default running ", chart, EngineChart.SPARK_1, 0.04, 0.1, 0.1, x, x + 180, x + 360, x + 540);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(200);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("set cranking_charge_angle 65");
|
|
|
|
ecu.sendCommand("set cranking_timing_angle -31");
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
chart = nextChart();
|
|
|
|
x = 55;
|
|
|
|
assertWave("aspire cranking", chart, EngineChart.SPARK_1, 0.18, x, x + 180, x + 360, x + 540);
|
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("set cranking_timing_angle -40");
|
2015-07-10 06:01:56 -07:00
|
|
|
chart = nextChart();
|
|
|
|
x = 64;
|
|
|
|
assertWave("aspire", chart, EngineChart.SPARK_1, 0.18, x, x + 180, x + 360, x + 540);
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("set cranking_timing_angle 149");
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("set cranking_charge_angle 40");
|
2015-07-10 06:01:56 -07:00
|
|
|
chart = nextChart();
|
|
|
|
x = 80;
|
|
|
|
assertWave("aspire", chart, EngineChart.SPARK_1, 40.0 / 360, x, x + 180, x + 360, x + 540);
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("set cranking_charge_angle 65");
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(600);
|
2017-01-06 06:03:33 -08:00
|
|
|
sendComplexCommand("set cranking_rpm 700");
|
2015-07-10 06:01:56 -07:00
|
|
|
chart = nextChart();
|
|
|
|
x = 55;
|
|
|
|
assertWave("cranking@600", chart, EngineChart.SPARK_1, 0.18, x, x + 180, x + 360, x + 540);
|
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(2000);
|
|
|
|
ecu.sendCommand("set_whole_fuel_map 1.57");
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(2600);
|
|
|
|
ecu.changeRpm(2000);
|
2015-07-10 06:01:56 -07:00
|
|
|
chart = nextChart();
|
|
|
|
|
|
|
|
msg = "aspire running";
|
|
|
|
|
2016-08-16 22:01:48 -07:00
|
|
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_1, 0.109, 238.75);
|
|
|
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_2, 0.109, 53.04);
|
|
|
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_3, 0.109, 417.04);
|
|
|
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_4, 0.109, 594.04);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2016-08-17 19:03:05 -07:00
|
|
|
x = 7;
|
2015-07-10 06:01:56 -07:00
|
|
|
assertWave(chart, EngineChart.SPARK_1, 0.133, x, x + 180, x + 360, x + 540);
|
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("set_fuel_map 2200 4 15.66");
|
|
|
|
ecu.sendCommand("set_fuel_map 2000 4 15.66");
|
|
|
|
ecu.sendCommand("set_fuel_map 2200 4.2 15.66");
|
|
|
|
ecu.sendCommand("set_fuel_map 2000 4.2 15.66");
|
2015-07-10 06:01:56 -07:00
|
|
|
// mock 2 means 4 on the gauge because of the divider. should we simplify this?
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("set " + MOCK_MAF_COMMAND + " 2");
|
2017-01-06 07:04:41 -08:00
|
|
|
sendComplexCommand("set global_trigger_offset_angle 175");
|
2015-07-10 06:01:56 -07:00
|
|
|
chart = nextChart();
|
|
|
|
|
2016-08-16 22:01:48 -07:00
|
|
|
assertWaveFall(msg + " fuel", chart, EngineChart.INJECTOR_1, 0.763, 238.75);
|
|
|
|
assertWaveFall(msg + " fuel", chart, EngineChart.INJECTOR_2, 0.763, 53.04);
|
|
|
|
assertWaveFall(msg + " fuel", chart, EngineChart.INJECTOR_3, 0.763, 417.04);
|
|
|
|
assertWaveFall(msg + " fuel", chart, EngineChart.INJECTOR_4, 0.763, 594.04);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2016-01-21 22:01:42 -08:00
|
|
|
x = 33.0;
|
2015-07-10 06:01:56 -07:00
|
|
|
assertWave(chart, EngineChart.SPARK_1, 0.133, x, x + 180, x + 360, x + 540);
|
|
|
|
assertWaveNull(chart, EngineChart.SPARK_2);
|
|
|
|
|
2017-01-06 07:04:41 -08:00
|
|
|
sendComplexCommand("set global_trigger_offset_angle 130");
|
|
|
|
sendComplexCommand("set injection_offset 369");
|
2015-07-10 06:01:56 -07:00
|
|
|
chart = nextChart();
|
2016-01-21 22:01:42 -08:00
|
|
|
x = 33;
|
2015-07-10 06:01:56 -07:00
|
|
|
assertWave(chart, EngineChart.SPARK_1, 0.133, x, x + 180, x + 360, x + 540);
|
|
|
|
|
|
|
|
// let's enable more channels dynamically
|
2015-12-18 15:01:16 -08:00
|
|
|
sendComplexCommand("set_individual_coils_ignition");
|
2015-07-10 06:01:56 -07:00
|
|
|
chart = nextChart();
|
2015-11-11 18:01:31 -08:00
|
|
|
assertWave("Switching Aspire into INDIVIDUAL_COILS mode", chart, EngineChart.SPARK_2, 0.133, x + 540);
|
|
|
|
assertWave(chart, EngineChart.SPARK_3, 0.133, x + 180);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("set_whole_timing_map 520");
|
2015-07-10 06:01:56 -07:00
|
|
|
chart = nextChart();
|
2015-11-11 18:01:31 -08:00
|
|
|
x = 58.92;
|
2015-07-10 06:01:56 -07:00
|
|
|
assertWave(chart, EngineChart.SPARK_2, 0.133, x);
|
|
|
|
|
|
|
|
// switching to Speed Density
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("set mock_maf_voltage 2");
|
2017-01-06 07:04:41 -08:00
|
|
|
sendComplexCommand("set algorithm 3");
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(2400);
|
|
|
|
ecu.changeRpm(2000);
|
2015-07-10 06:01:56 -07:00
|
|
|
chart = nextChart();
|
2020-12-12 15:58:30 -08:00
|
|
|
EcuTestHelper.assertEquals("MAP", 69.12, SensorCentral.getInstance().getValue(Sensor.MAP));
|
2015-07-10 06:01:56 -07:00
|
|
|
//assertEquals(1, SensorCentral.getInstance().getValue(Sensor.));
|
|
|
|
x = 8.88;
|
2016-08-16 22:01:48 -07:00
|
|
|
assertWave(false, msg + " fuel SD #1", chart, EngineChart.INJECTOR_1, 0.577, 0.1, 0.1, x + 180);
|
|
|
|
assertWave(false, msg + " fuel SD #2", chart, EngineChart.INJECTOR_2, 0.577, 0.1, 0.1, x);
|
|
|
|
assertWave(false, msg + " fuel SD #3", chart, EngineChart.INJECTOR_3, 0.577, 0.1, 0.1, x + 360);
|
|
|
|
assertWave(false, msg + " fuel SD #4", chart, EngineChart.INJECTOR_4, 0.577, 0.1, 0.1, x + 540);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// above hard limit
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(10000);
|
2015-07-10 06:01:56 -07:00
|
|
|
chart = nextChart();
|
|
|
|
assertWaveNull("hard limit check", chart, EngineChart.INJECTOR_1);
|
|
|
|
}
|
|
|
|
|
2016-01-26 14:01:57 -08:00
|
|
|
/**
|
|
|
|
* This method waits for longer then usual.
|
|
|
|
*/
|
2020-06-25 18:14:08 -07:00
|
|
|
private void sendComplexCommand(String command) {
|
2020-12-24 06:23:46 -08:00
|
|
|
ecu.sendCommand(command, Timeouts.CMD_TIMEOUT);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void assertWaveNull(EngineChart chart, String key) {
|
|
|
|
assertWaveNull("", chart, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void assertWaveNull(String msg, EngineChart chart, String key) {
|
|
|
|
assertNull(msg + "chart for " + key, chart.get(key));
|
|
|
|
}
|
2020-12-12 21:02:19 -08:00
|
|
|
|
2020-12-22 06:23:17 -08:00
|
|
|
private static void assertWaveNotNull(EngineChart chart, String key) {
|
|
|
|
assertTrue(chart.get(key) != null);
|
|
|
|
}
|
|
|
|
|
2020-12-26 14:14:04 -08:00
|
|
|
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"));
|
|
|
|
}
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
private EngineChart nextChart() {
|
|
|
|
return TestingUtils.nextChart(ecu.commandQueue);
|
|
|
|
}
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|