2015-07-10 06:01:56 -07:00
|
|
|
package com.rusefi;
|
|
|
|
|
|
|
|
|
2019-09-09 17:49:16 -07:00
|
|
|
import com.opensr5.Logger;
|
|
|
|
import com.rusefi.binaryprotocol.BinaryProtocol;
|
|
|
|
import com.rusefi.binaryprotocol.BinaryProtocolHolder;
|
2019-07-14 12:22:02 -07:00
|
|
|
import com.rusefi.config.generated.Fields;
|
2017-04-05 14:28:38 -07:00
|
|
|
import com.rusefi.core.MessagesCentral;
|
2015-07-10 06:01:56 -07:00
|
|
|
import com.rusefi.core.Sensor;
|
|
|
|
import com.rusefi.core.SensorCentral;
|
2017-04-05 14:28:38 -07:00
|
|
|
import com.rusefi.io.CommandQueue;
|
|
|
|
import com.rusefi.io.ConnectionStatus;
|
2015-07-10 06:01:56 -07:00
|
|
|
import com.rusefi.waves.EngineChart;
|
|
|
|
import com.rusefi.waves.EngineReport;
|
|
|
|
|
2019-12-21 17:17:58 -08:00
|
|
|
import static com.rusefi.IoUtil.*;
|
|
|
|
import static com.rusefi.IoUtil.getEnableCommand;
|
2015-07-10 06:01:56 -07:00
|
|
|
import static com.rusefi.TestingUtils.*;
|
2019-09-01 14:35:43 -07:00
|
|
|
import static com.rusefi.config.generated.Fields.MOCK_MAF_COMMAND;
|
2015-07-10 06:01:56 -07:00
|
|
|
import static com.rusefi.waves.EngineReport.isCloseEnough;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* rusEfi firmware simulator functional test suite
|
|
|
|
* <p/>
|
|
|
|
* java -cp rusefi_console.jar com.rusefi.AutoTest
|
|
|
|
*
|
|
|
|
* @author Andrey Belomutskiy
|
|
|
|
* 3/5/14
|
|
|
|
*/
|
|
|
|
public class AutoTest {
|
|
|
|
public static final int COMPLEX_COMMAND_RETRY = 10000;
|
|
|
|
static int currentEngineType;
|
2020-03-28 18:28:32 -07:00
|
|
|
private static String criticalError;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-09-09 17:49:16 -07:00
|
|
|
static void mainTestBody() throws Exception {
|
2017-04-05 14:28:38 -07:00
|
|
|
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
|
|
|
@Override
|
|
|
|
public void onMessage(Class clazz, String message) {
|
2020-03-28 18:28:32 -07:00
|
|
|
if (message.startsWith(Fields.CRITICAL_PREFIX))
|
|
|
|
criticalError = message;
|
2017-04-05 14:28:38 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-09-09 17:49:16 -07:00
|
|
|
BinaryProtocol bp = BinaryProtocolHolder.getInstance().get();
|
|
|
|
// let's make sure 'burn' command works since sometimes it does not
|
|
|
|
bp.burn(Logger.CONSOLE);
|
|
|
|
|
2019-12-21 17:17:58 -08:00
|
|
|
sendCommand(getDisableCommand(Fields.CMD_TRIGGER_HW_INPUT));
|
2019-12-21 19:07:50 -08:00
|
|
|
sendCommand(getEnableCommand(Fields.CMD_FUNCTIONAL_TEST_MODE));
|
2017-02-23 05:12:03 -08:00
|
|
|
testCustomEngine();
|
2017-01-22 06:03:08 -08:00
|
|
|
testMazdaMiata2003();
|
2016-08-17 19:03:05 -07:00
|
|
|
test2003DodgeNeon();
|
|
|
|
testFordAspire();
|
2016-08-16 22:01:48 -07:00
|
|
|
test1995DodgeNeon();
|
|
|
|
testMazdaProtege();
|
2017-03-19 15:18:23 -07:00
|
|
|
// todo? sendCommand("reboot"); // this would cause firmware in 5 seconds
|
|
|
|
// todo? sleep(10); // time to reboot
|
2015-07-10 06:01:56 -07:00
|
|
|
testBmwE34();
|
|
|
|
testSachs();
|
2017-05-03 11:53:03 -07:00
|
|
|
testRoverV8();
|
2016-08-18 20:01:57 -07:00
|
|
|
testMitsu();
|
2017-01-28 12:05:25 -08:00
|
|
|
testCamaro();
|
2015-07-10 06:01:56 -07:00
|
|
|
testCitroenBerlingo();
|
|
|
|
testMazda626();
|
|
|
|
testFord6();
|
|
|
|
testFordFiesta();
|
|
|
|
}
|
|
|
|
|
2017-02-23 05:12:03 -08:00
|
|
|
private static void testCustomEngine() {
|
|
|
|
setEngineType(0);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-01-22 06:03:08 -08:00
|
|
|
private static void testMazdaMiata2003() {
|
|
|
|
setEngineType(47);
|
2017-05-12 10:08:11 -07:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-01-28 12:05:25 -08:00
|
|
|
private static void testCamaro() {
|
|
|
|
setEngineType(35);
|
|
|
|
}
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
private static void testSachs() {
|
|
|
|
setEngineType(29);
|
|
|
|
String msg = "BMW";
|
|
|
|
IoUtil.changeRpm(1200);
|
|
|
|
// todo: add more content
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void testBmwE34() {
|
|
|
|
setEngineType(25);
|
|
|
|
sendCommand("chart 1");
|
|
|
|
String msg = "BMW";
|
|
|
|
EngineChart chart;
|
|
|
|
IoUtil.changeRpm(200);
|
2019-12-21 22:03:58 -08:00
|
|
|
chart = nextChart1();
|
2015-07-10 06:01:56 -07:00
|
|
|
double x = 173.988;
|
2015-09-09 06:01:19 -07:00
|
|
|
// something is wrong here - it's a 6 cylinder here, why 4 cylinder cycle?
|
2015-07-10 06:01:56 -07:00
|
|
|
assertWave(msg, chart, EngineChart.SPARK_1, 0.0199666, x, x + 180, x + 360, x + 540);
|
|
|
|
|
|
|
|
IoUtil.changeRpm(1200);
|
2019-12-21 22:03:58 -08:00
|
|
|
chart = nextChart1();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
x = 688.464;
|
2015-09-09 06:01:19 -07:00
|
|
|
// something is wrong here - it's a 6 cylinder here, why 4 cylinder cycle?
|
2015-07-10 06:01:56 -07:00
|
|
|
assertWave(msg, chart, EngineChart.SPARK_1, 0.0597999999, x, x + 180, x + 360, x + 540);
|
|
|
|
|
2015-09-09 06:01:19 -07:00
|
|
|
x = 101;
|
|
|
|
// 6 cylinder
|
|
|
|
assertWave(msg, chart, EngineChart.MAP_AVERAGING, 0.139, x, x + 120, x + 240, x + 360, x + 480, x + 600);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void testMitsu() {
|
|
|
|
setEngineType(16);
|
2016-08-17 20:03:14 -07:00
|
|
|
sendCommand("disable cylinder_cleanup");
|
2015-07-10 06:01:56 -07:00
|
|
|
String msg = "Mitsubishi";
|
|
|
|
IoUtil.changeRpm(200);
|
|
|
|
|
|
|
|
IoUtil.changeRpm(1200);
|
|
|
|
// todo: add more content
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void testCitroenBerlingo() {
|
|
|
|
setEngineType(15);
|
|
|
|
String msg = "Citroen";
|
|
|
|
IoUtil.changeRpm(1200);
|
|
|
|
// todo: add more content
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setEngineType(int type) {
|
2019-12-21 19:07:50 -08:00
|
|
|
FileLog.MAIN.logLine("AUTOTEST setEngineType " + type);
|
|
|
|
// sendCommand(CMD_PINS);
|
2015-07-10 06:01:56 -07:00
|
|
|
currentEngineType = type;
|
2019-11-23 09:52:57 -08:00
|
|
|
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + type, COMPLEX_COMMAND_RETRY, 30);
|
2019-12-21 19:07:50 -08:00
|
|
|
// TODO: document the reason for this sleep?!
|
|
|
|
sleep(1);
|
2019-12-21 17:17:58 -08:00
|
|
|
sendCommand(getEnableCommand("self_stimulation"));
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void testMazda626() {
|
|
|
|
setEngineType(28);
|
|
|
|
String msg = "mazda 626 default cranking";
|
|
|
|
IoUtil.changeRpm(200);
|
|
|
|
EngineChart chart;
|
2019-12-21 22:03:58 -08:00
|
|
|
chart = nextChart1();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
double x = 102;
|
|
|
|
assertWave(msg, chart, EngineChart.SPARK_1, 0.1944, x, x + 180, x + 360, x + 540);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void test2003DodgeNeon() {
|
|
|
|
setEngineType(23);
|
2019-01-06 17:45:51 -08:00
|
|
|
sendCommand("set wwaeTau 0");
|
|
|
|
sendCommand("set wwaeBeta 0");
|
2017-01-06 07:04:41 -08:00
|
|
|
sendCommand("set mock_map_voltage 1");
|
|
|
|
sendCommand("set mock_vbatt_voltage 1.20");
|
2016-08-17 19:03:05 -07:00
|
|
|
sendCommand("disable cylinder_cleanup");
|
2015-07-10 06:01:56 -07:00
|
|
|
EngineChart chart;
|
|
|
|
String msg = "2003 Neon cranking ";
|
|
|
|
IoUtil.changeRpm(200);
|
2016-07-22 17:03:51 -07:00
|
|
|
IoUtil.changeRpm(250); // another approach to artificial delay
|
|
|
|
IoUtil.changeRpm(200);
|
2017-01-08 10:02:42 -08:00
|
|
|
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";
|
|
|
|
IoUtil.changeRpm(2000);
|
2016-08-17 19:03:05 -07:00
|
|
|
IoUtil.changeRpm(2700);
|
|
|
|
IoUtil.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);
|
|
|
|
|
2019-12-21 17:17:58 -08:00
|
|
|
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
|
|
|
|
|
|
|
sendCommand("set_whole_timing_map 520");
|
2019-12-21 22:03:58 -08:00
|
|
|
chart = nextChart1();
|
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);
|
|
|
|
|
|
|
|
sendCommand("set_whole_timing_map 0");
|
2019-12-21 22:03:58 -08:00
|
|
|
chart = nextChart1();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
private static void testMazdaProtege() {
|
|
|
|
setEngineType(14);
|
|
|
|
EngineChart chart;
|
2017-01-06 07:04:41 -08:00
|
|
|
sendCommand("set mock_vbatt_voltage 1.395");
|
2015-07-10 06:01:56 -07:00
|
|
|
IoUtil.changeRpm(200);
|
2016-08-19 05:03:09 -07:00
|
|
|
IoUtil.changeRpm(260);
|
|
|
|
IoUtil.changeRpm(200);
|
2015-07-10 06:01:56 -07:00
|
|
|
String msg = "ProtegeLX cranking";
|
2019-12-21 22:03:58 -08:00
|
|
|
chart = nextChart1();
|
2016-01-22 20:02:53 -08:00
|
|
|
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";
|
|
|
|
IoUtil.changeRpm(2000);
|
2019-12-21 22:03:58 -08:00
|
|
|
chart = nextChart1();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
private static void test1995DodgeNeon() {
|
|
|
|
setEngineType(2);
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
IoUtil.changeRpm(2000);
|
2019-12-21 22:03:58 -08:00
|
|
|
chart = nextChart1();
|
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
|
2017-01-06 07:04:41 -08:00
|
|
|
sendCommand("set mock_map_voltage 1");
|
2017-01-06 13:03:41 -08:00
|
|
|
sendComplexCommand("set algorithm 3");
|
2016-07-22 20:01:37 -07:00
|
|
|
IoUtil.changeRpm(2600);
|
|
|
|
IoUtil.changeRpm(2000);
|
2019-12-21 22:03:58 -08:00
|
|
|
chart = nextChart1();
|
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
|
|
|
}
|
|
|
|
|
2017-05-03 11:53:03 -07:00
|
|
|
private static void testRoverV8() {
|
|
|
|
setEngineType(10);
|
|
|
|
}
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
private static void testFordFiesta() {
|
|
|
|
setEngineType(4);
|
|
|
|
EngineChart chart;
|
|
|
|
IoUtil.changeRpm(2000);
|
2019-12-21 22:03:58 -08:00
|
|
|
chart = nextChart1();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
String msg = "Fiesta";
|
|
|
|
double x = 312;
|
|
|
|
assertWave("wasted spark #1 with Fiesta", chart, EngineChart.SPARK_1, 0.1333333, x, x + 360);
|
|
|
|
assertWaveNull(chart, EngineChart.SPARK_2);
|
|
|
|
assertWave("wasted spark #3 with Fiesta", chart, EngineChart.SPARK_3, 0.1333333, x + 180, x + 540);
|
|
|
|
assertWaveNull(msg, chart, EngineChart.SPARK_4);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void testFord6() {
|
|
|
|
setEngineType(7);
|
|
|
|
EngineChart chart;
|
|
|
|
IoUtil.changeRpm(2000);
|
2019-12-21 22:03:58 -08:00
|
|
|
chart = nextChart1();
|
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
|
|
|
|
chart = nextChart1();
|
2015-07-10 06:01:56 -07:00
|
|
|
assertTrue(msg, chart.get(EngineChart.TRIGGER_2) != null);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void testFordAspire() {
|
|
|
|
setEngineType(3);
|
2016-08-17 20:03:14 -07:00
|
|
|
sendCommand("disable cylinder_cleanup");
|
2017-01-06 07:04:41 -08:00
|
|
|
sendCommand("set mock_map_voltage 1");
|
|
|
|
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");
|
2015-07-10 06:01:56 -07:00
|
|
|
IoUtil.changeRpm(200);
|
|
|
|
|
|
|
|
double x;
|
2019-12-21 22:03:58 -08:00
|
|
|
chart = nextChart1();
|
2016-01-22 20:02:53 -08:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
IoUtil.changeRpm(600);
|
2019-12-21 22:03:58 -08:00
|
|
|
chart = nextChart1();
|
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
|
|
|
|
|
|
|
IoUtil.changeRpm(200);
|
|
|
|
|
2017-01-06 06:03:33 -08:00
|
|
|
sendCommand("set cranking_charge_angle 65");
|
|
|
|
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);
|
|
|
|
|
2017-01-06 06:03:33 -08:00
|
|
|
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);
|
2017-01-06 06:03:33 -08:00
|
|
|
sendCommand("set cranking_timing_angle 149");
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2017-01-06 06:03:33 -08:00
|
|
|
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);
|
2017-01-06 06:03:33 -08:00
|
|
|
sendCommand("set cranking_charge_angle 65");
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
IoUtil.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);
|
|
|
|
|
|
|
|
IoUtil.changeRpm(2000);
|
|
|
|
sendCommand("set_whole_fuel_map 1.57");
|
|
|
|
|
2016-07-23 21:01:37 -07:00
|
|
|
IoUtil.changeRpm(2600);
|
|
|
|
IoUtil.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);
|
|
|
|
|
|
|
|
sendCommand("set_fuel_map 2200 4 15.66");
|
|
|
|
sendCommand("set_fuel_map 2000 4 15.66");
|
|
|
|
sendCommand("set_fuel_map 2200 4.2 15.66");
|
|
|
|
sendCommand("set_fuel_map 2000 4.2 15.66");
|
|
|
|
// mock 2 means 4 on the gauge because of the divider. should we simplify this?
|
2019-09-01 14:35:43 -07:00
|
|
|
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
|
|
|
|
|
|
|
sendCommand("set_whole_timing_map 520");
|
|
|
|
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
|
2017-01-06 07:04:41 -08:00
|
|
|
sendCommand("set mock_maf_voltage 2");
|
|
|
|
sendComplexCommand("set algorithm 3");
|
2016-07-22 18:02:28 -07:00
|
|
|
IoUtil.changeRpm(2400);
|
|
|
|
IoUtil.changeRpm(2000);
|
2015-07-10 06:01:56 -07:00
|
|
|
chart = nextChart();
|
2018-01-24 19:57:47 -08:00
|
|
|
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
|
|
|
|
IoUtil.changeRpm(10000);
|
|
|
|
chart = nextChart();
|
|
|
|
assertWaveNull("hard limit check", chart, EngineChart.INJECTOR_1);
|
|
|
|
}
|
|
|
|
|
2017-04-05 14:28:38 -07:00
|
|
|
private static void sendCommand(String command) {
|
|
|
|
sendCommand(command, CommandQueue.DEFAULT_TIMEOUT, Timeouts.CMD_TIMEOUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void sendCommand(String command, int retryTimeoutMs, int totalTimeoutSeconds) {
|
2020-03-28 18:28:32 -07:00
|
|
|
assertNull("Fatal not expected", criticalError);
|
2017-04-05 14:28:38 -07:00
|
|
|
IoUtil.sendCommand(command, retryTimeoutMs, totalTimeoutSeconds);
|
|
|
|
}
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
private static void assertEquals(double expected, double actual) {
|
|
|
|
assertEquals("", expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void assertEquals(String msg, double expected, double actual) {
|
2016-01-22 20:02:53 -08:00
|
|
|
assertEquals(msg, expected, actual, EngineReport.RATIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void assertEquals(String msg, double expected, double actual, double ratio) {
|
|
|
|
if (!isCloseEnough(expected, actual, ratio))
|
2015-07-10 06:01:56 -07:00
|
|
|
throw new IllegalStateException(msg + " Expected " + expected + " but got " + actual);
|
|
|
|
}
|
|
|
|
|
2016-01-26 14:01:57 -08:00
|
|
|
/**
|
|
|
|
* This method waits for longer then usual.
|
|
|
|
*/
|
2015-07-10 06:01:56 -07:00
|
|
|
private static void sendComplexCommand(String command) {
|
|
|
|
sendCommand(command, COMPLEX_COMMAND_RETRY, Timeouts.CMD_TIMEOUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void main(String[] args) throws InterruptedException {
|
|
|
|
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
|
|
|
@Override
|
|
|
|
public void uncaughtException(Thread t, Throwable e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
System.exit(-1);
|
|
|
|
}
|
|
|
|
});
|
2019-02-28 15:38:27 -08:00
|
|
|
boolean startSimulator = args.length == 1 && args[0].equalsIgnoreCase("start");
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
FileLog.SIMULATOR_CONSOLE.start();
|
|
|
|
FileLog.MAIN.start();
|
|
|
|
|
|
|
|
boolean failed = false;
|
|
|
|
try {
|
2019-02-28 15:38:27 -08:00
|
|
|
IoUtil.connectToSimulator(startSimulator);
|
2015-07-10 06:01:56 -07:00
|
|
|
mainTestBody();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
failed = true;
|
|
|
|
} finally {
|
2019-06-30 21:22:47 -07:00
|
|
|
SimulatorExecHelper.destroy();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
if (failed)
|
|
|
|
System.exit(-1);
|
|
|
|
FileLog.MAIN.logLine("*******************************************************************************");
|
|
|
|
FileLog.MAIN.logLine("************************************ Looks good! *****************************");
|
|
|
|
FileLog.MAIN.logLine("*******************************************************************************");
|
|
|
|
long time = (System.currentTimeMillis() - start) / 1000;
|
|
|
|
FileLog.MAIN.logLine("Done in " + time + "secs");
|
|
|
|
System.exit(0); // this is a safer method eliminating the issue of non-daemon threads
|
|
|
|
}
|
|
|
|
}
|