2021-02-03 06:05:18 -08:00
|
|
|
package com.rusefi.f4discovery;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2023-05-24 05:23:50 -07:00
|
|
|
import com.rusefi.config.generated.Fields;
|
2021-02-02 20:10:21 -08:00
|
|
|
import com.rusefi.RusefiTestBase;
|
2015-07-10 06:01:56 -07:00
|
|
|
import com.rusefi.core.Sensor;
|
|
|
|
import com.rusefi.core.SensorCentral;
|
2023-02-20 19:17:42 -08:00
|
|
|
import com.rusefi.enums.SensorType;
|
2021-10-24 06:00:10 -07:00
|
|
|
import com.rusefi.enums.engine_type_e;
|
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;
|
2020-12-12 21:02:19 -08:00
|
|
|
import org.junit.Test;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-12-29 16:42:03 -08:00
|
|
|
import java.util.Arrays;
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
import static com.rusefi.IoUtil.getEnableCommand;
|
2021-06-20 21:50:11 -07:00
|
|
|
import static com.rusefi.TestingUtils.assertNull;
|
2023-07-31 22:04:06 -07:00
|
|
|
import static com.rusefi.config.generated.Fields.CMD_SET_SENSOR_MOCK;
|
2020-12-26 14:14:04 -08:00
|
|
|
import static org.junit.Assert.assertFalse;
|
2021-02-02 20:10:21 -08:00
|
|
|
import static org.junit.Assert.assertTrue;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
/**
|
2022-12-17 07:04:25 -08:00
|
|
|
* rusEFI firmware simulator functional test suite
|
2015-07-10 06:01:56 -07:00
|
|
|
* <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
|
|
|
*/
|
2021-02-02 20:10:21 -08:00
|
|
|
public class CommonFunctionalTest extends RusefiTestBase {
|
2020-12-24 17:50:52 -08:00
|
|
|
@Test
|
2020-12-29 16:42:03 -08:00
|
|
|
public void testChangingIgnitionMode() {
|
2021-10-24 06:00:10 -07:00
|
|
|
ecu.setEngineType(engine_type_e.FORD_ASPIRE_1996);
|
2020-12-29 16:42:03 -08:00
|
|
|
ecu.changeRpm(2000);
|
2020-12-22 06:23:17 -08:00
|
|
|
|
2020-12-29 16:42:03 -08:00
|
|
|
// First is wasted spark
|
|
|
|
ecu.sendCommand("set ignition_mode 2");
|
2020-12-22 06:23:17 -08:00
|
|
|
|
2020-12-29 16:42:03 -08:00
|
|
|
{
|
|
|
|
// Check that we're in wasted spark mode
|
|
|
|
EngineChart chart = nextChart();
|
2020-12-22 06:23:17 -08:00
|
|
|
|
2020-12-29 16:42:03 -08:00
|
|
|
// Wasted spark should fire cylinders 1/3...
|
|
|
|
assertWaveNotNull(chart,
|
|
|
|
EngineChart.SPARK_1,
|
|
|
|
EngineChart.SPARK_3
|
|
|
|
);
|
2020-12-22 06:23:17 -08:00
|
|
|
|
|
|
|
// ...but not cylinders 2/4
|
2020-12-29 16:42:03 -08:00
|
|
|
assertWaveNull(chart,
|
|
|
|
EngineChart.SPARK_2,
|
|
|
|
EngineChart.SPARK_4
|
|
|
|
);
|
|
|
|
}
|
2020-12-22 06:23:17 -08:00
|
|
|
|
2020-12-29 16:42:03 -08:00
|
|
|
// Now switch to sequential mode
|
|
|
|
ecu.sendCommand("set ignition_mode 1");
|
2020-12-22 06:23:17 -08:00
|
|
|
|
2020-12-29 16:42:03 -08:00
|
|
|
{
|
|
|
|
// Check that we're in sequential spark mode
|
|
|
|
EngineChart chart = nextChart();
|
2020-12-22 06:23:17 -08:00
|
|
|
|
2020-12-29 16:42:03 -08:00
|
|
|
// All 4 cylinders should be firing
|
|
|
|
assertWaveNotNull(chart,
|
|
|
|
EngineChart.SPARK_1,
|
|
|
|
EngineChart.SPARK_2,
|
|
|
|
EngineChart.SPARK_3,
|
|
|
|
EngineChart.SPARK_4
|
|
|
|
);
|
|
|
|
}
|
2020-12-22 06:23:17 -08:00
|
|
|
|
2020-12-29 16:42:03 -08:00
|
|
|
// Now switch to "one coil" mode
|
2020-12-22 06:23:17 -08:00
|
|
|
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
|
2020-12-29 16:42:03 -08:00
|
|
|
assertWaveNull(chart,
|
|
|
|
EngineChart.SPARK_2,
|
|
|
|
EngineChart.SPARK_3,
|
|
|
|
EngineChart.SPARK_4
|
|
|
|
);
|
2020-12-22 06:23:17 -08:00
|
|
|
}
|
|
|
|
|
2020-12-29 16:42:03 -08:00
|
|
|
// Now switch BACK to wasted mode
|
|
|
|
ecu.sendCommand("set ignition_mode 2");
|
2020-12-22 06:23:17 -08:00
|
|
|
|
2020-12-29 16:42:03 -08:00
|
|
|
{
|
|
|
|
// Check that we're in wasted spark mode
|
|
|
|
EngineChart chart = nextChart();
|
2020-12-22 06:23:17 -08:00
|
|
|
|
|
|
|
// Wasted spark should fire cylinders 1/3...
|
2020-12-29 16:42:03 -08:00
|
|
|
assertWaveNotNull(chart,
|
|
|
|
EngineChart.SPARK_1,
|
|
|
|
EngineChart.SPARK_3
|
|
|
|
);
|
2020-12-22 06:23:17 -08:00
|
|
|
|
|
|
|
// ...but not cylinders 2/4
|
2020-12-29 16:42:03 -08:00
|
|
|
assertWaveNull(chart,
|
|
|
|
EngineChart.SPARK_2,
|
|
|
|
EngineChart.SPARK_4
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-12-22 06:23:17 -08:00
|
|
|
|
2020-12-26 14:14:04 -08:00
|
|
|
@Test
|
|
|
|
public void testRevLimiter() {
|
2021-10-24 06:00:10 -07:00
|
|
|
ecu.setEngineType(engine_type_e.FORD_ASPIRE_1996);
|
2020-12-26 14:14:04 -08:00
|
|
|
ecu.changeRpm(2000);
|
|
|
|
|
|
|
|
// Alpha-N mode so that we actually inject some fuel (without mocking tons of sensors)
|
2023-01-20 18:42:27 -08:00
|
|
|
ecu.sendCommand("set algorithm 2");
|
2020-12-26 14:14:04 -08:00
|
|
|
// Set tps to 25% - make alpha-n happy
|
2023-07-31 22:04:06 -07:00
|
|
|
ecu.sendCommand(CMD_SET_SENSOR_MOCK + " " + SensorType.Tps1.ordinal() + " 25");
|
2020-12-26 14:14:04 -08:00
|
|
|
ecu.sendCommand("set rpm_hard_limit 2500");
|
|
|
|
|
|
|
|
{
|
|
|
|
// Check that neither ignition nor injection is cut
|
|
|
|
EngineChart chart = nextChart();
|
|
|
|
|
2020-12-29 16:42:03 -08:00
|
|
|
assertWaveNotNull(chart,
|
|
|
|
EngineChart.SPARK_1,
|
|
|
|
EngineChart.INJECTOR_1
|
|
|
|
);
|
2020-12-26 14:14:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
2020-12-29 16:42:03 -08:00
|
|
|
assertWaveNoRises(chart,
|
|
|
|
EngineChart.SPARK_1,
|
|
|
|
EngineChart.INJECTOR_1
|
|
|
|
);
|
2020-12-26 14:14:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
2020-12-29 16:42:03 -08:00
|
|
|
assertWaveNotNull(chart,
|
|
|
|
EngineChart.SPARK_1,
|
|
|
|
EngineChart.INJECTOR_1
|
|
|
|
);
|
2020-12-26 14:14:04 -08:00
|
|
|
}
|
2020-12-29 16:42:03 -08:00
|
|
|
}
|
2020-12-26 14:14:04 -08:00
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void testCustomEngine() {
|
2021-10-24 06:00:10 -07:00
|
|
|
ecu.setEngineType(engine_type_e.DEFAULT_FRANKENSO);
|
2020-12-12 15:58:30 -08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-02-17 21:11:26 -08:00
|
|
|
@Test
|
|
|
|
public void testAuxValveNissan() {
|
2021-10-24 06:00:10 -07:00
|
|
|
ecu.setEngineType(engine_type_e.NISSAN_PRIMERA);
|
2021-02-17 21:11:26 -08:00
|
|
|
ecu.changeRpm(1200);
|
|
|
|
}
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
2024-01-16 07:31:03 -08:00
|
|
|
public void testTwoStrokeSachs() {
|
2021-10-24 06:00:10 -07:00
|
|
|
ecu.setEngineType(engine_type_e.SACHS);
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(1200);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void test2003DodgeNeon() {
|
2021-10-24 06:00:10 -07:00
|
|
|
ecu.setEngineType(engine_type_e.DODGE_NEON_2003_CRANK);
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("set wwaeTau 0");
|
|
|
|
ecu.sendCommand("set wwaeBeta 0");
|
2023-07-31 22:04:06 -07:00
|
|
|
ecu.sendCommand(CMD_SET_SENSOR_MOCK + " " + SensorType.Map.ordinal() + " 69.12");
|
|
|
|
ecu.sendCommand(CMD_SET_SENSOR_MOCK + " " + SensorType.BatteryVoltage.ordinal() + " 12");
|
2020-12-12 15:58:30 -08:00
|
|
|
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);
|
2021-06-20 23:46:11 -07:00
|
|
|
EcuTestHelper.assertSomewhatClose("VBatt", 12, SensorCentral.getInstance().getValue(Sensor.VBATT));
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
chart = nextChart();
|
2023-04-29 04:36:58 -07:00
|
|
|
double x = 100;
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg, chart, EngineChart.SPARK_1);
|
2023-04-29 04:36:58 -07:00
|
|
|
assertWaveNull(msg, chart, EngineChart.SPARK_2);
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg, chart, EngineChart.SPARK_3);
|
2023-04-29 04:36:58 -07:00
|
|
|
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;
|
|
|
|
// WAT? this was just 0.009733333333333387?
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_1);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_2);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_3);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_4);
|
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();
|
2023-04-29 04:36:58 -07:00
|
|
|
x = 104.0;
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg, chart, EngineChart.SPARK_1);
|
2023-04-29 04:36:58 -07:00
|
|
|
assertWaveNull(msg, chart, EngineChart.SPARK_2);
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg, chart, EngineChart.SPARK_3);
|
2023-04-29 04:36:58 -07:00
|
|
|
assertWaveNull(msg, chart, EngineChart.SPARK_4);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2016-01-21 22:01:42 -08:00
|
|
|
chart = nextChart();
|
2023-04-29 04:36:58 -07:00
|
|
|
x = 74;
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_1);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_2);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_3);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_4);
|
2016-08-17 19:03:05 -07:00
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand(getEnableCommand("trigger_only_front"));
|
2015-09-24 19:02:47 -07:00
|
|
|
chart = nextChart();
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_1);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_2);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_3);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_4);
|
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();
|
2023-04-29 04:36:58 -07:00
|
|
|
x = 328;
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg, chart, EngineChart.SPARK_1);
|
2016-11-28 17:03:43 -08:00
|
|
|
|
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();
|
2023-04-29 04:36:58 -07:00
|
|
|
x = 128;
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg, chart, EngineChart.SPARK_1);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void testMazdaProtege() {
|
2021-10-24 06:00:10 -07:00
|
|
|
ecu.setEngineType(engine_type_e.FORD_ESCORT_GT);
|
2015-07-10 06:01:56 -07:00
|
|
|
EngineChart chart;
|
2023-07-31 22:04:06 -07:00
|
|
|
ecu.sendCommand(CMD_SET_SENSOR_MOCK + " " + SensorType.BatteryVoltage.ordinal() + " 12");
|
2021-01-10 17:27:21 -08:00
|
|
|
|
|
|
|
// Alpha-N mode so that we actually inject some fuel (without mocking tons of sensors)
|
2023-01-20 18:42:27 -08:00
|
|
|
ecu.sendCommand("set algorithm 2");
|
2021-01-10 17:27:21 -08:00
|
|
|
// Set tps to 25% - make alpha-n happy
|
2023-07-31 22:04:06 -07:00
|
|
|
ecu.sendCommand(CMD_SET_SENSOR_MOCK + " " + SensorType.Tps1.ordinal() + " 25");
|
2021-01-10 17:27:21 -08:00
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
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();
|
2021-06-20 23:46:11 -07:00
|
|
|
EcuTestHelper.assertSomewhatClose("", 12, SensorCentral.getInstance().getValue(Sensor.VBATT), 0.1);
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg, chart, EngineChart.SPARK_3);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.SPARK_1);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_1);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_2);
|
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();
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg, chart, EngineChart.SPARK_1);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_1);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_2);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void test1995DodgeNeon() {
|
2021-10-24 06:00:10 -07:00
|
|
|
ecu.setEngineType(engine_type_e.DODGE_NEON_1995);
|
2015-07-10 06:01:56 -07:00
|
|
|
EngineChart chart;
|
2023-05-24 05:23:50 -07:00
|
|
|
sendComplexCommand(Fields.CMD_INDIVIDUAL_INJECTION);
|
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";
|
2020-12-29 15:39:54 -08:00
|
|
|
//assertWaveNotNull(msg, chart, EngineChart.INJECTOR_4);
|
|
|
|
//assertWaveNotNull(msg, chart, EngineChart.INJECTOR_2);
|
|
|
|
//assertWaveNotNull(msg, chart, EngineChart.INJECTOR_1);
|
|
|
|
//assertWaveNotNull(msg, chart, EngineChart.INJECTOR_3);
|
|
|
|
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.SPARK_4);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.SPARK_2);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.SPARK_1);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.SPARK_3);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// switching to Speed Density
|
2023-07-31 22:04:06 -07:00
|
|
|
ecu.sendCommand(CMD_SET_SENSOR_MOCK + " " + SensorType.Map.ordinal() + " 69.12");
|
2023-01-20 18:42:27 -08:00
|
|
|
sendComplexCommand("set algorithm 0");
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(2600);
|
|
|
|
ecu.changeRpm(2000);
|
2020-06-25 19:27:39 -07:00
|
|
|
chart = nextChart();
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_4);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2020-12-12 21:02:19 -08:00
|
|
|
@Test
|
|
|
|
public void testFord6() {
|
2021-10-24 06:00:10 -07:00
|
|
|
ecu.setEngineType(engine_type_e.FORD_INLINE_6_1995);
|
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";
|
|
|
|
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg, chart, EngineChart.SPARK_1);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
assertWaveNull(msg, chart, EngineChart.TRIGGER_2);
|
2021-10-25 09:34:52 -07:00
|
|
|
sendComplexCommand("set " + "trigger_type" + " " + com.rusefi.enums.trigger_type_e.TT_FORD_ASPIRE.ordinal());
|
2020-06-25 19:27:39 -07:00
|
|
|
chart = nextChart();
|
2021-02-02 20:10:21 -08:00
|
|
|
assertTrue(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() {
|
2021-10-24 06:00:10 -07:00
|
|
|
ecu.setEngineType(engine_type_e.FORD_ASPIRE_1996);
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.sendCommand("disable cylinder_cleanup");
|
2023-07-31 22:04:06 -07:00
|
|
|
ecu.sendCommand(CMD_SET_SENSOR_MOCK + " " + SensorType.Map.ordinal() + " 69.12");
|
|
|
|
ecu.sendCommand(CMD_SET_SENSOR_MOCK + " " + SensorType.BatteryVoltage.ordinal() + " 12");
|
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
|
|
|
|
2020-06-25 19:27:39 -07:00
|
|
|
chart = nextChart();
|
2021-06-20 23:46:11 -07:00
|
|
|
EcuTestHelper.assertSomewhatClose(12, SensorCentral.getInstance().getValue(Sensor.VBATT));
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull("aspire default cranking ", chart, EngineChart.SPARK_1);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(600);
|
2020-06-25 19:27:39 -07:00
|
|
|
chart = nextChart();
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull("aspire default running ", chart, EngineChart.SPARK_1);
|
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();
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull("aspire cranking", chart, EngineChart.SPARK_1);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
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();
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull("aspire", chart, EngineChart.SPARK_1);
|
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();
|
2020-12-29 15:39:54 -08:00
|
|
|
|
|
|
|
assertWaveNotNull("aspire", chart, EngineChart.SPARK_1);
|
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();
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull("cranking@600", chart, EngineChart.SPARK_1);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(2000);
|
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";
|
|
|
|
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_1);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_2);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_3);
|
|
|
|
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_4);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
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");
|
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();
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(msg + " fuel", chart, EngineChart.INJECTOR_1);
|
|
|
|
assertWaveNotNull(msg + " fuel", chart, EngineChart.INJECTOR_2);
|
|
|
|
assertWaveNotNull(msg + " fuel", chart, EngineChart.INJECTOR_3);
|
|
|
|
assertWaveNotNull(msg + " fuel", chart, EngineChart.INJECTOR_4);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
2015-07-10 06:01:56 -07:00
|
|
|
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();
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(chart, EngineChart.SPARK_1);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// let's enable more channels dynamically
|
2023-05-24 05:23:50 -07:00
|
|
|
sendComplexCommand(Fields.CMD_INDIVIDUAL_INJECTION);
|
2015-07-10 06:01:56 -07:00
|
|
|
chart = nextChart();
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull("Switching Aspire into INDIVIDUAL_COILS mode", chart, EngineChart.SPARK_2);
|
|
|
|
assertWaveNotNull(chart, EngineChart.SPARK_3);
|
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();
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull(chart, EngineChart.SPARK_2);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// switching to Speed Density
|
2023-01-20 18:42:27 -08:00
|
|
|
sendComplexCommand("set algorithm 0");
|
2020-12-12 15:58:30 -08:00
|
|
|
ecu.changeRpm(2400);
|
|
|
|
ecu.changeRpm(2000);
|
2015-07-10 06:01:56 -07:00
|
|
|
chart = nextChart();
|
2021-06-20 23:46:11 -07:00
|
|
|
EcuTestHelper.assertSomewhatClose("MAP", 69.12, SensorCentral.getInstance().getValue(Sensor.MAP));
|
2015-07-10 06:01:56 -07:00
|
|
|
//assertEquals(1, SensorCentral.getInstance().getValue(Sensor.));
|
2020-12-29 15:39:54 -08:00
|
|
|
|
|
|
|
assertWaveNotNull(msg + " fuel SD #1", chart, EngineChart.INJECTOR_1);
|
|
|
|
assertWaveNotNull(msg + " fuel SD #2", chart, EngineChart.INJECTOR_2);
|
|
|
|
assertWaveNotNull(msg + " fuel SD #3", chart, EngineChart.INJECTOR_3);
|
|
|
|
assertWaveNotNull(msg + " fuel SD #4", chart, EngineChart.INJECTOR_4);
|
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);
|
|
|
|
}
|
|
|
|
|
2021-10-04 05:19:58 -07:00
|
|
|
@Test
|
|
|
|
public void testStackOverflow() {
|
|
|
|
// This ECU command has a built in check to make sure no threads are near overflow
|
|
|
|
ecu.sendCommand("threadsinfo");
|
|
|
|
}
|
|
|
|
|
2016-01-26 14:01:57 -08:00
|
|
|
/**
|
|
|
|
* This method waits for longer then usual.
|
2021-06-20 20:58:32 -07:00
|
|
|
* todo: inline this method? complex and less complex seem to have same timeout these days?
|
2016-01-26 14:01:57 -08:00
|
|
|
*/
|
2020-06-25 18:14:08 -07:00
|
|
|
private void sendComplexCommand(String command) {
|
2021-06-20 20:58:32 -07:00
|
|
|
ecu.sendCommand(command);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void assertWaveNull(EngineChart chart, String key) {
|
|
|
|
assertWaveNull("", chart, key);
|
|
|
|
}
|
|
|
|
|
2020-12-29 16:42:03 -08:00
|
|
|
private static void assertWaveNull(EngineChart chart, String... keys) {
|
|
|
|
Arrays.stream(keys).peek(k -> assertWaveNull(chart, k));
|
|
|
|
}
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
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) {
|
2020-12-29 15:39:54 -08:00
|
|
|
assertWaveNotNull("", chart, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void assertWaveNotNull(String msg, EngineChart chart, String key) {
|
|
|
|
assertTrue(msg, chart.get(key) != null);
|
2020-12-22 06:23:17 -08:00
|
|
|
}
|
|
|
|
|
2020-12-29 16:42:03 -08:00
|
|
|
private static void assertWaveNotNull(EngineChart chart, String... keys) {
|
|
|
|
Arrays.stream(keys).peek(k -> assertWaveNotNull(chart, k));
|
|
|
|
}
|
|
|
|
|
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-29 16:42:03 -08:00
|
|
|
private static void assertWaveNoRises(EngineChart chart, String... keys) {
|
|
|
|
Arrays.stream(keys).peek(k -> assertWaveNoRises(chart, k));
|
|
|
|
}
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|