let's use composition

This commit is contained in:
rusefillc 2020-12-12 18:58:30 -05:00
parent 118cec97c2
commit 31df994c79
6 changed files with 128 additions and 133 deletions

View File

@ -5,7 +5,7 @@ import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.core.Sensor; import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral; import com.rusefi.core.SensorCentral;
import com.rusefi.functional_tests.BaseTest; import com.rusefi.functional_tests.EcuTestHelper;
import com.rusefi.io.CommandQueue; import com.rusefi.io.CommandQueue;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;
import com.rusefi.waves.EngineChart; import com.rusefi.waves.EngineChart;
@ -16,7 +16,6 @@ import java.util.function.Function;
import static com.rusefi.IoUtil.*; import static com.rusefi.IoUtil.*;
import static com.rusefi.TestingUtils.*; import static com.rusefi.TestingUtils.*;
import static com.rusefi.binaryprotocol.BinaryProtocol.sleep;
import static com.rusefi.config.generated.Fields.*; import static com.rusefi.config.generated.Fields.*;
import static com.rusefi.waves.EngineReport.isCloseEnough; import static com.rusefi.waves.EngineReport.isCloseEnough;
@ -28,12 +27,13 @@ import static com.rusefi.waves.EngineReport.isCloseEnough;
* @author Andrey Belomutskiy * @author Andrey Belomutskiy
* 3/5/14 * 3/5/14
*/ */
public class AutoTest extends BaseTest { public class AutoTest {
private final LinkManager linkManager; private final LinkManager linkManager;
private final EcuTestHelper ecu;
public AutoTest(LinkManager linkManager, CommandQueue commandQueue) { public AutoTest(LinkManager linkManager, CommandQueue commandQueue) {
super(commandQueue); ecu = new EcuTestHelper(commandQueue);
this.linkManager = linkManager; this.linkManager = linkManager;
} }
@ -42,8 +42,8 @@ public class AutoTest extends BaseTest {
// let's make sure 'burn' command works since sometimes it does not // let's make sure 'burn' command works since sometimes it does not
bp.burn(); bp.burn();
sendCommand(getDisableCommand(Fields.CMD_TRIGGER_HW_INPUT)); ecu.sendCommand(getDisableCommand(Fields.CMD_TRIGGER_HW_INPUT));
enableFunctionalMode(); ecu.enableFunctionalMode();
testCustomEngine(); testCustomEngine();
testVW_60_2(); testVW_60_2();
testV12(); testV12();
@ -70,24 +70,24 @@ public class AutoTest extends BaseTest {
}; };
private void testVW_60_2() { private void testVW_60_2() {
setEngineType(ET_VW_ABA); ecu.setEngineType(ET_VW_ABA);
// trying to disable engine sniffer to help https://github.com/rusefi/rusefi/issues/1849 // trying to disable engine sniffer to help https://github.com/rusefi/rusefi/issues/1849
sendCommand("set " + CMD_ENGINESNIFFERRPMTHRESHOLD + " 100"); ecu.sendCommand("set " + CMD_ENGINESNIFFERRPMTHRESHOLD + " 100");
changeRpm(900); ecu.changeRpm(900);
// first let's get to expected RPM // first let's get to expected RPM
assertRpmDoesNotJump(16000, 5, 40, FAIL, commandQueue); assertRpmDoesNotJump(16000, 5, 40, FAIL, ecu.commandQueue);
} }
private void testV12() { private void testV12() {
setEngineType(ET_BMW_M73_F); ecu.setEngineType(ET_BMW_M73_F);
changeRpm(700); ecu.changeRpm(700);
// first let's get to expected RPM // first let's get to expected RPM
assertRpmDoesNotJump(16000, 5, 40, FAIL, commandQueue); assertRpmDoesNotJump(16000, 5, 40, FAIL, ecu.commandQueue);
testCaseBug1873(); testCaseBug1873();
} }
private void testCaseBug1873() { private void testCaseBug1873() {
assertRpmDoesNotJump(60, 5, 110, FAIL, commandQueue); assertRpmDoesNotJump(60, 5, 110, FAIL, ecu.commandQueue);
} }
public static void assertRpmDoesNotJump(int rpm, int settleTime, int testDuration, Function<String, Object> callback, CommandQueue commandQueue) { public static void assertRpmDoesNotJump(int rpm, int settleTime, int testDuration, Function<String, Object> callback, CommandQueue commandQueue) {
@ -109,8 +109,8 @@ public class AutoTest extends BaseTest {
} }
private void testCustomEngine() { private void testCustomEngine() {
setEngineType(ET_DEFAULT_FRANKENSO); ecu.setEngineType(ET_DEFAULT_FRANKENSO);
sendCommand("set_toothed_wheel 4 0"); ecu.sendCommand("set_toothed_wheel 4 0");
// sendCommand("enable trigger_only_front"); // sendCommand("enable trigger_only_front");
// changeRpm(100); // changeRpm(100);
// changeRpm(1500); // changeRpm(1500);
@ -120,34 +120,34 @@ public class AutoTest extends BaseTest {
} }
private void testMazdaMiata2003() { private void testMazdaMiata2003() {
setEngineType(ET_FRANKENSO_MIATA_NB2); ecu.setEngineType(ET_FRANKENSO_MIATA_NB2);
sendCommand("get cranking_dwell"); // just test coverage ecu.sendCommand("get cranking_dwell"); // just test coverage
// sendCommand("get nosuchgettersdfsdfsdfsdf"); // just test coverage // sendCommand("get nosuchgettersdfsdfsdfsdf"); // just test coverage
} }
private void testCamaro() { private void testCamaro() {
setEngineType(ET_CAMARO); ecu.setEngineType(ET_CAMARO);
} }
private void testSachs() { private void testSachs() {
setEngineType(ET_SACHS); ecu.setEngineType(ET_SACHS);
// String msg = "BMW"; // String msg = "BMW";
changeRpm(1200); ecu.changeRpm(1200);
// todo: add more content // todo: add more content
} }
private void testBmwE34() { private void testBmwE34() {
setEngineType(ET_BMW_E34); ecu.setEngineType(ET_BMW_E34);
sendCommand("chart 1"); ecu.sendCommand("chart 1");
String msg = "BMW"; String msg = "BMW";
EngineChart chart; EngineChart chart;
changeRpm(200); ecu.changeRpm(200);
chart = nextChart(); chart = nextChart();
double x = 173.988; double x = 173.988;
// something is wrong here - it's a 6 cylinder here, why 4 cylinder cycle? // something is wrong here - it's a 6 cylinder here, why 4 cylinder cycle?
assertWave(msg, chart, EngineChart.SPARK_1, 0.0199666, x, x + 180, x + 360, x + 540); assertWave(msg, chart, EngineChart.SPARK_1, 0.0199666, x, x + 180, x + 360, x + 540);
changeRpm(1200); ecu.changeRpm(1200);
chart = nextChart(); chart = nextChart();
x = 688.464; x = 688.464;
@ -160,29 +160,29 @@ public class AutoTest extends BaseTest {
} }
private void testCitroenBerlingo() { private void testCitroenBerlingo() {
setEngineType(ET_CITROEN_TU3JP); ecu.setEngineType(ET_CITROEN_TU3JP);
// String msg = "Citroen"; // String msg = "Citroen";
changeRpm(1200); ecu.changeRpm(1200);
// todo: add more content // todo: add more content
} }
private EngineChart nextChart() { private EngineChart nextChart() {
return TestingUtils.nextChart(commandQueue); return TestingUtils.nextChart(ecu.commandQueue);
} }
private void test2003DodgeNeon() { private void test2003DodgeNeon() {
setEngineType(ET_DODGE_NEON_2003_CRANK); ecu.setEngineType(ET_DODGE_NEON_2003_CRANK);
sendCommand("set wwaeTau 0"); ecu.sendCommand("set wwaeTau 0");
sendCommand("set wwaeBeta 0"); ecu.sendCommand("set wwaeBeta 0");
sendCommand("set mock_map_voltage 1"); ecu.sendCommand("set mock_map_voltage 1");
sendCommand("set mock_vbatt_voltage 1.20"); ecu.sendCommand("set mock_vbatt_voltage 1.20");
sendCommand("disable cylinder_cleanup"); ecu.sendCommand("disable cylinder_cleanup");
EngineChart chart; EngineChart chart;
String msg = "2003 Neon cranking "; String msg = "2003 Neon cranking ";
changeRpm(200); ecu.changeRpm(200);
changeRpm(250); // another approach to artificial delay ecu.changeRpm(250); // another approach to artificial delay
changeRpm(200); ecu.changeRpm(200);
assertEquals("VBatt", 12, SensorCentral.getInstance().getValue(Sensor.VBATT)); EcuTestHelper.assertEquals("VBatt", 12, SensorCentral.getInstance().getValue(Sensor.VBATT));
chart = nextChart(); chart = nextChart();
double x = 100; double x = 100;
@ -201,9 +201,9 @@ public class AutoTest extends BaseTest {
assertWave(true, msg, chart, EngineChart.INJECTOR_4, 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);
msg = "2003 Neon running"; msg = "2003 Neon running";
changeRpm(2000); ecu.changeRpm(2000);
changeRpm(2700); ecu.changeRpm(2700);
changeRpm(2000); ecu.changeRpm(2000);
chart = nextChart(); chart = nextChart();
x = 104.0; x = 104.0;
assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540); assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540);
@ -218,34 +218,34 @@ public class AutoTest extends BaseTest {
assertWave(true, msg, chart, EngineChart.INJECTOR_3, 0.29233, 0.15, EngineReport.RATIO, x + 540); 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); assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.29233, 0.15, 0.2, x);
sendCommand(getEnableCommand("trigger_only_front")); ecu.sendCommand(getEnableCommand("trigger_only_front"));
chart = nextChart(); chart = nextChart();
assertWave(true, msg, chart, EngineChart.INJECTOR_1, 0.29233, 0.1, 0.2, x + 360); 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_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_3, 0.29233, 0.1, 0.2, x + 540);
assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.29233, 0.1, 0.2, x); assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.29233, 0.1, 0.2, x);
sendCommand("set_whole_timing_map 520"); ecu.sendCommand("set_whole_timing_map 520");
chart = nextChart(); chart = nextChart();
x = 328; x = 328;
assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540); assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540);
sendCommand("set_whole_timing_map 0"); ecu.sendCommand("set_whole_timing_map 0");
chart = nextChart(); chart = nextChart();
x = 128; x = 128;
assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540); assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540);
} }
private void testMazdaProtege() { private void testMazdaProtege() {
setEngineType(ET_FORD_ESCORT_GT); ecu.setEngineType(ET_FORD_ESCORT_GT);
EngineChart chart; EngineChart chart;
sendCommand("set mock_vbatt_voltage 1.395"); ecu.sendCommand("set mock_vbatt_voltage 1.395");
changeRpm(200); ecu.changeRpm(200);
changeRpm(260); ecu.changeRpm(260);
changeRpm(200); ecu.changeRpm(200);
String msg = "ProtegeLX cranking"; String msg = "ProtegeLX cranking";
chart = nextChart(); chart = nextChart();
assertEquals("", 12, SensorCentral.getInstance().getValue(Sensor.VBATT), 0.1); EcuTestHelper.assertEquals("", 12, SensorCentral.getInstance().getValue(Sensor.VBATT), 0.1);
double x = 107; double x = 107;
assertWave(msg, chart, EngineChart.SPARK_3, 0.194433, x); assertWave(msg, chart, EngineChart.SPARK_3, 0.194433, x);
assertWave(msg, chart, EngineChart.SPARK_1, 0.194433, x + 540); assertWave(msg, chart, EngineChart.SPARK_1, 0.194433, x + 540);
@ -254,7 +254,7 @@ public class AutoTest extends BaseTest {
assertWaveFall(msg, chart, EngineChart.INJECTOR_2, 0.008566666666, x, x + 180, x + 360, x + 540); assertWaveFall(msg, chart, EngineChart.INJECTOR_2, 0.008566666666, x, x + 180, x + 360, x + 540);
msg = "ProtegeLX running"; msg = "ProtegeLX running";
changeRpm(2000); ecu.changeRpm(2000);
chart = nextChart(); chart = nextChart();
x = 112; x = 112;
assertWave(msg, chart, EngineChart.SPARK_1, 0.13333333333333333, x, x + 180, x + 360, x + 540); assertWave(msg, chart, EngineChart.SPARK_1, 0.13333333333333333, x, x + 180, x + 360, x + 540);
@ -264,14 +264,14 @@ public class AutoTest extends BaseTest {
} }
private void test1995DodgeNeon() { private void test1995DodgeNeon() {
setEngineType(ET_DODGE_NEON_1995); ecu.setEngineType(ET_DODGE_NEON_1995);
EngineChart chart; EngineChart chart;
sendComplexCommand("set_whole_fuel_map 3"); sendComplexCommand("set_whole_fuel_map 3");
sendComplexCommand("set_individual_coils_ignition"); sendComplexCommand("set_individual_coils_ignition");
/** /**
* note that command order matters - RPM change resets wave chart * note that command order matters - RPM change resets wave chart
*/ */
changeRpm(2000); ecu.changeRpm(2000);
chart = nextChart(); chart = nextChart();
String msg = "1995 Neon"; String msg = "1995 Neon";
@ -288,23 +288,23 @@ public class AutoTest extends BaseTest {
assertWave(msg, chart, EngineChart.SPARK_3, 0.13333, x + 360); assertWave(msg, chart, EngineChart.SPARK_3, 0.13333, x + 360);
// switching to Speed Density // switching to Speed Density
sendCommand("set mock_map_voltage 1"); ecu.sendCommand("set mock_map_voltage 1");
sendComplexCommand("set algorithm 3"); sendComplexCommand("set algorithm 3");
changeRpm(2600); ecu.changeRpm(2600);
changeRpm(2000); ecu.changeRpm(2000);
chart = nextChart(); chart = nextChart();
x = -70; x = -70;
assertWaveFall(msg, chart, EngineChart.INJECTOR_4, 0.493, x + 540); assertWaveFall(msg, chart, EngineChart.INJECTOR_4, 0.493, x + 540);
} }
private void testRoverV8() { private void testRoverV8() {
setEngineType(ET_ROVER_V8); ecu.setEngineType(ET_ROVER_V8);
} }
private void testFordFiesta() { private void testFordFiesta() {
setEngineType(ET_FORD_FIESTA); ecu.setEngineType(ET_FORD_FIESTA);
EngineChart chart; EngineChart chart;
changeRpm(2000); ecu.changeRpm(2000);
chart = nextChart(); chart = nextChart();
String msg = "Fiesta"; String msg = "Fiesta";
@ -316,9 +316,9 @@ public class AutoTest extends BaseTest {
} }
private void testFord6() { private void testFord6() {
setEngineType(ET_FORD_INLINE_6); ecu.setEngineType(ET_FORD_INLINE_6);
EngineChart chart; EngineChart chart;
changeRpm(2000); ecu.changeRpm(2000);
chart = nextChart(); chart = nextChart();
String msg = "ford 6"; String msg = "ford 6";
@ -333,60 +333,60 @@ public class AutoTest extends BaseTest {
} }
private void testFordAspire() { private void testFordAspire() {
setEngineType(ET_FORD_ASPIRE); ecu.setEngineType(ET_FORD_ASPIRE);
sendCommand("disable cylinder_cleanup"); ecu.sendCommand("disable cylinder_cleanup");
sendCommand("set mock_map_voltage 1"); ecu.sendCommand("set mock_map_voltage 1");
sendCommand("set mock_vbatt_voltage 2.2"); ecu.sendCommand("set mock_vbatt_voltage 2.2");
String msg; String msg;
EngineChart chart; EngineChart chart;
// todo: interesting changeRpm(100); // todo: interesting changeRpm(100);
sendComplexCommand("set cranking_rpm 500"); sendComplexCommand("set cranking_rpm 500");
changeRpm(200); ecu.changeRpm(200);
double x; double x;
chart = nextChart(); chart = nextChart();
assertEquals(12, SensorCentral.getInstance().getValue(Sensor.VBATT)); EcuTestHelper.assertEquals(12, SensorCentral.getInstance().getValue(Sensor.VBATT));
x = 55; x = 55;
assertWave("aspire default cranking ", chart, EngineChart.SPARK_1, 0.1944, x, x + 180, x + 360, x + 540); assertWave("aspire default cranking ", chart, EngineChart.SPARK_1, 0.1944, x, x + 180, x + 360, x + 540);
changeRpm(600); ecu.changeRpm(600);
chart = nextChart(); chart = nextChart();
x = 78; x = 78;
assertWave(true, "aspire default running ", chart, EngineChart.SPARK_1, 0.04, 0.1, 0.1, x, x + 180, x + 360, x + 540); assertWave(true, "aspire default running ", chart, EngineChart.SPARK_1, 0.04, 0.1, 0.1, x, x + 180, x + 360, x + 540);
changeRpm(200); ecu.changeRpm(200);
sendCommand("set cranking_charge_angle 65"); ecu.sendCommand("set cranking_charge_angle 65");
sendCommand("set cranking_timing_angle -31"); ecu.sendCommand("set cranking_timing_angle -31");
chart = nextChart(); chart = nextChart();
x = 55; x = 55;
assertWave("aspire cranking", chart, EngineChart.SPARK_1, 0.18, x, x + 180, x + 360, x + 540); assertWave("aspire cranking", chart, EngineChart.SPARK_1, 0.18, x, x + 180, x + 360, x + 540);
sendCommand("set cranking_timing_angle -40"); ecu.sendCommand("set cranking_timing_angle -40");
chart = nextChart(); chart = nextChart();
x = 64; x = 64;
assertWave("aspire", chart, EngineChart.SPARK_1, 0.18, x, x + 180, x + 360, x + 540); assertWave("aspire", chart, EngineChart.SPARK_1, 0.18, x, x + 180, x + 360, x + 540);
sendCommand("set cranking_timing_angle 149"); ecu.sendCommand("set cranking_timing_angle 149");
sendCommand("set cranking_charge_angle 40"); ecu.sendCommand("set cranking_charge_angle 40");
chart = nextChart(); chart = nextChart();
x = 80; x = 80;
assertWave("aspire", chart, EngineChart.SPARK_1, 40.0 / 360, x, x + 180, x + 360, x + 540); assertWave("aspire", chart, EngineChart.SPARK_1, 40.0 / 360, x, x + 180, x + 360, x + 540);
sendCommand("set cranking_charge_angle 65"); ecu.sendCommand("set cranking_charge_angle 65");
changeRpm(600); ecu.changeRpm(600);
sendComplexCommand("set cranking_rpm 700"); sendComplexCommand("set cranking_rpm 700");
chart = nextChart(); chart = nextChart();
x = 55; x = 55;
assertWave("cranking@600", chart, EngineChart.SPARK_1, 0.18, x, x + 180, x + 360, x + 540); assertWave("cranking@600", chart, EngineChart.SPARK_1, 0.18, x, x + 180, x + 360, x + 540);
changeRpm(2000); ecu.changeRpm(2000);
sendCommand("set_whole_fuel_map 1.57"); ecu.sendCommand("set_whole_fuel_map 1.57");
changeRpm(2600); ecu.changeRpm(2600);
changeRpm(2000); ecu.changeRpm(2000);
chart = nextChart(); chart = nextChart();
msg = "aspire running"; msg = "aspire running";
@ -399,12 +399,12 @@ public class AutoTest extends BaseTest {
x = 7; x = 7;
assertWave(chart, EngineChart.SPARK_1, 0.133, x, x + 180, x + 360, x + 540); assertWave(chart, EngineChart.SPARK_1, 0.133, x, x + 180, x + 360, x + 540);
sendCommand("set_fuel_map 2200 4 15.66"); ecu.sendCommand("set_fuel_map 2200 4 15.66");
sendCommand("set_fuel_map 2000 4 15.66"); ecu.sendCommand("set_fuel_map 2000 4 15.66");
sendCommand("set_fuel_map 2200 4.2 15.66"); ecu.sendCommand("set_fuel_map 2200 4.2 15.66");
sendCommand("set_fuel_map 2000 4.2 15.66"); ecu.sendCommand("set_fuel_map 2000 4.2 15.66");
// mock 2 means 4 on the gauge because of the divider. should we simplify this? // mock 2 means 4 on the gauge because of the divider. should we simplify this?
sendCommand("set " + MOCK_MAF_COMMAND + " 2"); ecu.sendCommand("set " + MOCK_MAF_COMMAND + " 2");
sendComplexCommand("set global_trigger_offset_angle 175"); sendComplexCommand("set global_trigger_offset_angle 175");
chart = nextChart(); chart = nextChart();
@ -429,18 +429,18 @@ public class AutoTest extends BaseTest {
assertWave("Switching Aspire into INDIVIDUAL_COILS mode", chart, EngineChart.SPARK_2, 0.133, x + 540); assertWave("Switching Aspire into INDIVIDUAL_COILS mode", chart, EngineChart.SPARK_2, 0.133, x + 540);
assertWave(chart, EngineChart.SPARK_3, 0.133, x + 180); assertWave(chart, EngineChart.SPARK_3, 0.133, x + 180);
sendCommand("set_whole_timing_map 520"); ecu.sendCommand("set_whole_timing_map 520");
chart = nextChart(); chart = nextChart();
x = 58.92; x = 58.92;
assertWave(chart, EngineChart.SPARK_2, 0.133, x); assertWave(chart, EngineChart.SPARK_2, 0.133, x);
// switching to Speed Density // switching to Speed Density
sendCommand("set mock_maf_voltage 2"); ecu.sendCommand("set mock_maf_voltage 2");
sendComplexCommand("set algorithm 3"); sendComplexCommand("set algorithm 3");
changeRpm(2400); ecu.changeRpm(2400);
changeRpm(2000); ecu.changeRpm(2000);
chart = nextChart(); chart = nextChart();
assertEquals("MAP", 69.12, SensorCentral.getInstance().getValue(Sensor.MAP)); EcuTestHelper.assertEquals("MAP", 69.12, SensorCentral.getInstance().getValue(Sensor.MAP));
//assertEquals(1, SensorCentral.getInstance().getValue(Sensor.)); //assertEquals(1, SensorCentral.getInstance().getValue(Sensor.));
x = 8.88; x = 8.88;
assertWave(false, msg + " fuel SD #1", chart, EngineChart.INJECTOR_1, 0.577, 0.1, 0.1, x + 180); assertWave(false, msg + " fuel SD #1", chart, EngineChart.INJECTOR_1, 0.577, 0.1, 0.1, x + 180);
@ -449,7 +449,7 @@ public class AutoTest extends BaseTest {
assertWave(false, msg + " fuel SD #4", chart, EngineChart.INJECTOR_4, 0.577, 0.1, 0.1, x + 540); assertWave(false, msg + " fuel SD #4", chart, EngineChart.INJECTOR_4, 0.577, 0.1, 0.1, x + 540);
// above hard limit // above hard limit
changeRpm(10000); ecu.changeRpm(10000);
chart = nextChart(); chart = nextChart();
assertWaveNull("hard limit check", chart, EngineChart.INJECTOR_1); assertWaveNull("hard limit check", chart, EngineChart.INJECTOR_1);
} }
@ -458,7 +458,7 @@ public class AutoTest extends BaseTest {
* This method waits for longer then usual. * This method waits for longer then usual.
*/ */
private void sendComplexCommand(String command) { private void sendComplexCommand(String command) {
sendCommand(command, COMPLEX_COMMAND_RETRY, Timeouts.CMD_TIMEOUT); ecu.sendCommand(command, EcuTestHelper.COMPLEX_COMMAND_RETRY, Timeouts.CMD_TIMEOUT);
} }
private static void assertWaveNull(EngineChart chart, String key) { private static void assertWaveNull(EngineChart chart, String key) {

View File

@ -1,7 +1,7 @@
package com.rusefi; package com.rusefi;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.functional_tests.BaseTest; import com.rusefi.functional_tests.EcuTestHelper;
import com.rusefi.io.CommandQueue; import com.rusefi.io.CommandQueue;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;
@ -24,13 +24,13 @@ public class EnduranceTestUtility {
CommandQueue commandQueue = linkManager.getCommandQueue(); CommandQueue commandQueue = linkManager.getCommandQueue();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
BaseTest.currentEngineType = Fields.ET_FORD_ASPIRE; EcuTestHelper.currentEngineType = Fields.ET_FORD_ASPIRE;
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, BaseTest.COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT, commandQueue); sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, EcuTestHelper.COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT, commandQueue);
sleepSeconds(2); sleepSeconds(2);
sendCommand(getEnableCommand("self_stimulation"), commandQueue); sendCommand(getEnableCommand("self_stimulation"), commandQueue);
// IoUtil.changeRpm(1200); // IoUtil.changeRpm(1200);
BaseTest.currentEngineType = Fields.ET_DEFAULT_FRANKENSO; EcuTestHelper.currentEngineType = Fields.ET_DEFAULT_FRANKENSO;
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 28, BaseTest.COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT, commandQueue); sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 28, EcuTestHelper.COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT, commandQueue);
sleepSeconds(2); sleepSeconds(2);
FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ " + i + " +++++++++++++++"); FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ " + i + " +++++++++++++++");
} }

View File

@ -3,7 +3,7 @@ package com.rusefi;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.core.Sensor; import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral; import com.rusefi.core.SensorCentral;
import com.rusefi.functional_tests.BaseTest; import com.rusefi.functional_tests.EcuTestHelper;
import com.rusefi.io.CommandQueue; import com.rusefi.io.CommandQueue;
import static com.rusefi.IoUtil.getDisableCommand; import static com.rusefi.IoUtil.getDisableCommand;
@ -11,10 +11,12 @@ import static com.rusefi.IoUtil.getEnableCommand;
import static com.rusefi.binaryprotocol.BinaryProtocol.sleep; import static com.rusefi.binaryprotocol.BinaryProtocol.sleep;
import static com.rusefi.config.generated.Fields.*; import static com.rusefi.config.generated.Fields.*;
public class HardwareTests extends BaseTest { public class HardwareTests {
private final EcuTestHelper ecu;
public HardwareTests(CommandQueue commandQueue) { public HardwareTests(CommandQueue commandQueue) {
super(commandQueue); ecu = new EcuTestHelper(commandQueue);
} }
/** /**
@ -23,24 +25,24 @@ public class HardwareTests extends BaseTest {
* PD2<>PA5 * PD2<>PA5
*/ */
public void runRealHardwareTests() { public void runRealHardwareTests() {
sendCommand(getEnableCommand(Fields.CMD_TRIGGER_HW_INPUT)); ecu.sendCommand(getEnableCommand(Fields.CMD_TRIGGER_HW_INPUT));
enableFunctionalMode(); ecu.enableFunctionalMode();
setEngineType(ET_FRANKENSO_MIATA_NA6); ecu.setEngineType(ET_FRANKENSO_MIATA_NA6);
sendCommand(getDisableCommand(Fields.CMD_SELF_STIMULATION)); ecu.sendCommand(getDisableCommand(Fields.CMD_SELF_STIMULATION));
changeRpm(1400); ecu.changeRpm(1400);
// moving second trigger to another pin // moving second trigger to another pin
sendCommand(CMD_TRIGGER_PIN + " 1 PA8"); ecu.sendCommand(CMD_TRIGGER_PIN + " 1 PA8");
assertEquals("VSS no input", 0, SensorCentral.getInstance().getValue(Sensor.VSS)); ecu.assertEquals("VSS no input", 0, SensorCentral.getInstance().getValue(Sensor.VSS));
// attaching VSS to trigger simulator since there is a jumper on test discovery // attaching VSS to trigger simulator since there is a jumper on test discovery
sendCommand("set " + CMD_VSS_PIN + " pa5"); ecu.sendCommand("set " + CMD_VSS_PIN + " pa5");
sleep(2 * Timeouts.SECOND); sleep(2 * Timeouts.SECOND);
assertEquals("VSS with input", 3, SensorCentral.getInstance().getValue(Sensor.VSS)); ecu.assertEquals("VSS with input", 3, SensorCentral.getInstance().getValue(Sensor.VSS));
} }
} }

View File

@ -33,7 +33,7 @@ public class RealHwTest {
log.info(HW_TESTS_START_UP_SLEEP + " VM option not specified, no start-up sleep in java code"); log.info(HW_TESTS_START_UP_SLEEP + " VM option not specified, no start-up sleep in java code");
} }
boolean isSuccess = runHardwareTest(args); boolean isSuccess = runHardwareTest();
if (!isSuccess) if (!isSuccess)
System.exit(-1); System.exit(-1);
log.info("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); log.info("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
@ -42,13 +42,6 @@ public class RealHwTest {
System.exit(0); // this is a safer method eliminating the issue of non-daemon threads System.exit(0); // this is a safer method eliminating the issue of non-daemon threads
} }
/**
* @return true if test is a SUCCESS, false if a FAILURE
*/
public static boolean runHardwareTest(String[] args) {
return runHardwareTest();
}
/** /**
* @return true if test is a SUCCESS, false if a FAILURE * @return true if test is a SUCCESS, false if a FAILURE
*/ */

View File

@ -3,7 +3,7 @@ package com.rusefi;
import com.devexperts.logging.Logging; import com.devexperts.logging.Logging;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.core.EngineState; import com.rusefi.core.EngineState;
import com.rusefi.functional_tests.BaseTest; import com.rusefi.functional_tests.EcuTestHelper;
import com.rusefi.io.CommandQueue; import com.rusefi.io.CommandQueue;
import com.rusefi.waves.EngineChart; import com.rusefi.waves.EngineChart;
import com.rusefi.waves.EngineReport; import com.rusefi.waves.EngineReport;
@ -145,7 +145,7 @@ public class TestingUtils {
int timeoutMs = 60 * Timeouts.SECOND; int timeoutMs = 60 * Timeouts.SECOND;
long waitStartTime = System.currentTimeMillis(); long waitStartTime = System.currentTimeMillis();
IoUtil.wait(engineChartLatch, timeoutMs); IoUtil.wait(engineChartLatch, timeoutMs);
log.info("got next chart in " + (System.currentTimeMillis() - waitStartTime) + "ms for engine_type " + BaseTest.currentEngineType); log.info("got next chart in " + (System.currentTimeMillis() - waitStartTime) + "ms for engine_type " + EcuTestHelper.currentEngineType);
commandQueue.getLinkManager().getEngineState().replaceStringValueAction(EngineReport.ENGINE_CHART, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID); commandQueue.getLinkManager().getEngineState().replaceStringValueAction(EngineReport.ENGINE_CHART, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
if (result.get() == null) if (result.get() == null)
throw new IllegalStateException("Chart timeout: " + timeoutMs); throw new IllegalStateException("Chart timeout: " + timeoutMs);

View File

@ -11,35 +11,35 @@ import static com.devexperts.logging.Logging.getLogging;
import static com.rusefi.IoUtil.*; import static com.rusefi.IoUtil.*;
import static com.rusefi.waves.EngineReport.isCloseEnough; import static com.rusefi.waves.EngineReport.isCloseEnough;
public class BaseTest { public class EcuTestHelper {
private static final Logging log = getLogging(BaseTest.class); private static final Logging log = getLogging(EcuTestHelper.class);
public static final int COMPLEX_COMMAND_RETRY = 10000; public static final int COMPLEX_COMMAND_RETRY = 10000;
public static int currentEngineType; public static int currentEngineType;
protected final CommandQueue commandQueue; public final CommandQueue commandQueue;
public BaseTest(CommandQueue commandQueue) { public EcuTestHelper(CommandQueue commandQueue) {
this.commandQueue = commandQueue; this.commandQueue = commandQueue;
} }
protected static void assertEquals(double expected, double actual) { public static void assertEquals(double expected, double actual) {
BaseTest.assertEquals("", expected, actual); EcuTestHelper.assertEquals("", expected, actual);
} }
protected static void assertEquals(String msg, double expected, double actual) { public static void assertEquals(String msg, double expected, double actual) {
BaseTest.assertEquals(msg, expected, actual, EngineReport.RATIO); EcuTestHelper.assertEquals(msg, expected, actual, EngineReport.RATIO);
} }
protected static void assertEquals(String msg, double expected, double actual, double ratio) { public static void assertEquals(String msg, double expected, double actual, double ratio) {
if (!isCloseEnough(expected, actual, ratio)) if (!isCloseEnough(expected, actual, ratio))
throw new IllegalStateException(msg + " Expected " + expected + " but got " + actual); throw new IllegalStateException(msg + " Expected " + expected + " but got " + actual);
} }
protected void sendCommand(String command) { public void sendCommand(String command) {
sendCommand(command, CommandQueue.DEFAULT_TIMEOUT, Timeouts.CMD_TIMEOUT); sendCommand(command, CommandQueue.DEFAULT_TIMEOUT, Timeouts.CMD_TIMEOUT);
} }
protected void sendCommand(String command, int retryTimeoutMs, int timeoutMs) { public void sendCommand(String command, int retryTimeoutMs, int timeoutMs) {
TestHelper.INSTANCE.assertNotFatal(); TestHelper.INSTANCE.assertNotFatal();
IoUtil.sendCommand(command, retryTimeoutMs, timeoutMs, commandQueue); IoUtil.sendCommand(command, retryTimeoutMs, timeoutMs, commandQueue);
} }
@ -47,15 +47,15 @@ public class BaseTest {
/** /**
* this seem to adjust engine sniffer behaviour * this seem to adjust engine sniffer behaviour
*/ */
protected void enableFunctionalMode() { public void enableFunctionalMode() {
sendCommand(getEnableCommand(Fields.CMD_FUNCTIONAL_TEST_MODE)); sendCommand(getEnableCommand(Fields.CMD_FUNCTIONAL_TEST_MODE));
} }
protected void changeRpm(final int rpm) { public void changeRpm(final int rpm) {
IoUtil.changeRpm(commandQueue, rpm); IoUtil.changeRpm(commandQueue, rpm);
} }
protected void setEngineType(int type) { public void setEngineType(int type) {
log.info("AUTOTEST setEngineType " + type); log.info("AUTOTEST setEngineType " + type);
currentEngineType = type; currentEngineType = type;
// sendCommand(CMD_PINS); // sendCommand(CMD_PINS);