generate java enum from C enum? generate both C and java from yaml? #2102

This commit is contained in:
rusefillc 2021-10-23 23:37:04 -04:00
parent c4576200fe
commit 96cc93090c
8 changed files with 36 additions and 31 deletions

View File

@ -2,6 +2,7 @@ package com.rusefi;
import com.rusefi.autotest.ControllerConnectorState; import com.rusefi.autotest.ControllerConnectorState;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.enums.engine_type_e;
import com.rusefi.functional_tests.EcuTestHelper; 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;
@ -25,12 +26,12 @@ 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++) {
EcuTestHelper.currentEngineType = Fields.ET_FORD_ASPIRE; EcuTestHelper.currentEngineType = engine_type_e.FORD_ASPIRE_1996.ordinal();
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, Timeouts.SET_ENGINE_TIMEOUT, commandQueue); sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, 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);
EcuTestHelper.currentEngineType = Fields.ET_DEFAULT_FRANKENSO; EcuTestHelper.currentEngineType = engine_type_e.DEFAULT_FRANKENSO.ordinal();
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 28, Timeouts.SET_ENGINE_TIMEOUT, commandQueue); sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 28, Timeouts.SET_ENGINE_TIMEOUT, commandQueue);
sleepSeconds(2); sleepSeconds(2);
FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ " + i + " +++++++++++++++"); FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ " + i + " +++++++++++++++");

View File

@ -4,6 +4,7 @@ package com.rusefi.f4discovery;
import com.rusefi.RusefiTestBase; import com.rusefi.RusefiTestBase;
import com.rusefi.core.Sensor; import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral; import com.rusefi.core.SensorCentral;
import com.rusefi.enums.engine_type_e;
import com.rusefi.functional_tests.EcuTestHelper; import com.rusefi.functional_tests.EcuTestHelper;
import com.rusefi.waves.EngineChart; import com.rusefi.waves.EngineChart;
import org.junit.Test; import org.junit.Test;
@ -27,7 +28,7 @@ import static org.junit.Assert.assertTrue;
public class CommonFunctionalTest extends RusefiTestBase { public class CommonFunctionalTest extends RusefiTestBase {
@Test @Test
public void testChangingIgnitionMode() { public void testChangingIgnitionMode() {
ecu.setEngineType(ET_FORD_ASPIRE); ecu.setEngineType(engine_type_e.FORD_ASPIRE_1996);
ecu.changeRpm(2000); ecu.changeRpm(2000);
// First is wasted spark // First is wasted spark
@ -109,7 +110,7 @@ public class CommonFunctionalTest extends RusefiTestBase {
public void testRevLimiter() { public void testRevLimiter() {
String msg = "rev limiter"; String msg = "rev limiter";
ecu.setEngineType(ET_FORD_ASPIRE); ecu.setEngineType(engine_type_e.FORD_ASPIRE_1996);
ecu.changeRpm(2000); ecu.changeRpm(2000);
// Alpha-N mode so that we actually inject some fuel (without mocking tons of sensors) // Alpha-N mode so that we actually inject some fuel (without mocking tons of sensors)
@ -159,7 +160,7 @@ public class CommonFunctionalTest extends RusefiTestBase {
@Test @Test
public void testCustomEngine() { public void testCustomEngine() {
ecu.setEngineType(ET_DEFAULT_FRANKENSO); ecu.setEngineType(engine_type_e.DEFAULT_FRANKENSO);
ecu.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);
@ -171,25 +172,25 @@ public class CommonFunctionalTest extends RusefiTestBase {
@Test @Test
public void testAuxValveNissan() { public void testAuxValveNissan() {
ecu.setEngineType(ET_NISSAN_PRIMERA); ecu.setEngineType(engine_type_e.NISSAN_PRIMERA);
ecu.changeRpm(1200); ecu.changeRpm(1200);
} }
@Test @Test
public void testMazdaMiata2003() { public void testMazdaMiata2003() {
ecu.setEngineType(ET_FRANKENSO_MIATA_NB2); ecu.setEngineType(engine_type_e.MAZDA_MIATA_2003);
ecu.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
} }
@Test @Test
public void testCamaro() { public void testCamaro() {
ecu.setEngineType(ET_CAMARO); ecu.setEngineType(engine_type_e.CAMARO_4);
} }
@Test @Test
public void testSachs() { public void testSachs() {
ecu.setEngineType(ET_SACHS); ecu.setEngineType(engine_type_e.SACHS);
// String msg = "BMW"; // String msg = "BMW";
ecu.changeRpm(1200); ecu.changeRpm(1200);
// todo: add more content // todo: add more content
@ -197,13 +198,13 @@ public class CommonFunctionalTest extends RusefiTestBase {
@Test @Test
public void testCitroenBerlingo() { public void testCitroenBerlingo() {
ecu.setEngineType(ET_CITROEN_TU3JP); ecu.setEngineType(engine_type_e.CITROEN_TU3JP);
ecu.changeRpm(1200); ecu.changeRpm(1200);
} }
@Test @Test
public void test2003DodgeNeon() { public void test2003DodgeNeon() {
ecu.setEngineType(ET_DODGE_NEON_2003_CRANK); ecu.setEngineType(engine_type_e.DODGE_NEON_2003_CRANK);
ecu.sendCommand("set wwaeTau 0"); ecu.sendCommand("set wwaeTau 0");
ecu.sendCommand("set wwaeBeta 0"); ecu.sendCommand("set wwaeBeta 0");
ecu.sendCommand("set_sensor_mock 4 69.12"); // MAP ecu.sendCommand("set_sensor_mock 4 69.12"); // MAP
@ -270,7 +271,7 @@ public class CommonFunctionalTest extends RusefiTestBase {
@Test @Test
public void testMazdaProtege() { public void testMazdaProtege() {
ecu.setEngineType(ET_FORD_ESCORT_GT); ecu.setEngineType(engine_type_e.FORD_ESCORT_GT);
EngineChart chart; EngineChart chart;
ecu.sendCommand("set_sensor_mock 27 12"); ecu.sendCommand("set_sensor_mock 27 12");
@ -300,7 +301,7 @@ public class CommonFunctionalTest extends RusefiTestBase {
@Test @Test
public void test1995DodgeNeon() { public void test1995DodgeNeon() {
ecu.setEngineType(ET_DODGE_NEON_1995); ecu.setEngineType(engine_type_e.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");
@ -332,7 +333,7 @@ public class CommonFunctionalTest extends RusefiTestBase {
@Test @Test
public void testFord6() { public void testFord6() {
ecu.setEngineType(ET_FORD_INLINE_6); ecu.setEngineType(engine_type_e.FORD_INLINE_6_1995);
EngineChart chart; EngineChart chart;
ecu.changeRpm(2000); ecu.changeRpm(2000);
chart = nextChart(); chart = nextChart();
@ -349,7 +350,7 @@ public class CommonFunctionalTest extends RusefiTestBase {
@Test @Test
public void testFordAspire() { public void testFordAspire() {
ecu.setEngineType(ET_FORD_ASPIRE); ecu.setEngineType(engine_type_e.FORD_ASPIRE_1996);
ecu.sendCommand("disable cylinder_cleanup"); ecu.sendCommand("disable cylinder_cleanup");
ecu.sendCommand("set_sensor_mock 4 69.12"); // MAP ecu.sendCommand("set_sensor_mock 4 69.12"); // MAP
ecu.sendCommand("set_sensor_mock 27 12"); // vbatt ecu.sendCommand("set_sensor_mock 27 12"); // vbatt

View File

@ -1,6 +1,7 @@
package com.rusefi.f4discovery; package com.rusefi.f4discovery;
import com.rusefi.RusefiTestBase; import com.rusefi.RusefiTestBase;
import com.rusefi.enums.engine_type_e;
import com.rusefi.functional_tests.EcuTestHelper; import com.rusefi.functional_tests.EcuTestHelper;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
@ -11,7 +12,7 @@ import static com.rusefi.config.generated.Fields.*;
public class HighRevTest extends RusefiTestBase { public class HighRevTest extends RusefiTestBase {
@Test @Test
public void testVW() { public void testVW() {
ecu.setEngineType(ET_VW_ABA); ecu.setEngineType(engine_type_e.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
ecu.sendCommand("set " + CMD_ENGINESNIFFERRPMTHRESHOLD + " 100"); ecu.sendCommand("set " + CMD_ENGINESNIFFERRPMTHRESHOLD + " 100");
ecu.changeRpm(900); ecu.changeRpm(900);
@ -21,7 +22,7 @@ public class HighRevTest extends RusefiTestBase {
@Test @Test
public void testV12() { public void testV12() {
ecu.setEngineType(ET_BMW_M73_F); ecu.setEngineType(engine_type_e.BMW_M73_F);
ecu.changeRpm(700); ecu.changeRpm(700);
// first let's get to expected RPM // first let's get to expected RPM
EcuTestHelper.assertRpmDoesNotJump(6000, 5, 40, FAIL, ecu.commandQueue); EcuTestHelper.assertRpmDoesNotJump(6000, 5, 40, FAIL, ecu.commandQueue);

View File

@ -6,6 +6,7 @@ import com.rusefi.Timeouts;
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.enums.engine_type_e;
import com.rusefi.functional_tests.EcuTestHelper; import com.rusefi.functional_tests.EcuTestHelper;
import org.junit.Test; import org.junit.Test;
@ -35,7 +36,7 @@ public class PwmHardwareTest extends RusefiTestBase {
@Test @Test
public void scheduleBurnDoesNotAffectTriggerIssue2839() { public void scheduleBurnDoesNotAffectTriggerIssue2839() {
ecu.setEngineType(ET_FORD_ASPIRE); ecu.setEngineType(engine_type_e.FORD_ASPIRE_1996);
ecu.sendCommand("set " + "trigger_type" + " " + TT_TT_TOOTHED_WHEEL_60_2); ecu.sendCommand("set " + "trigger_type" + " " + TT_TT_TOOTHED_WHEEL_60_2);
ecu.sendCommand(getDisableCommand(Fields.CMD_SELF_STIMULATION)); ecu.sendCommand(getDisableCommand(Fields.CMD_SELF_STIMULATION));
ecu.sendCommand(getEnableCommand(CMD_EXTERNAL_STIMULATION)); ecu.sendCommand(getEnableCommand(CMD_EXTERNAL_STIMULATION));
@ -56,7 +57,7 @@ public class PwmHardwareTest extends RusefiTestBase {
@Test @Test
public void testIdlePin() { public void testIdlePin() {
ecu.setEngineType(ET_FRANKENSO_MIATA_NA6); ecu.setEngineType(engine_type_e.MAZDA_MIATA_2003);
ecu.changeRpm(1000); ecu.changeRpm(1000);
ecu.sendCommand(CMD_TRIGGER_SIMULATOR_PIN + " 0 none"); ecu.sendCommand(CMD_TRIGGER_SIMULATOR_PIN + " 0 none");

View File

@ -6,6 +6,7 @@ import com.rusefi.Timeouts;
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.enums.engine_type_e;
import com.rusefi.functional_tests.EcuTestHelper; import com.rusefi.functional_tests.EcuTestHelper;
import org.junit.Test; import org.junit.Test;
@ -27,7 +28,7 @@ public class VssHardwareLoopTest extends RusefiTestBase {
@Test @Test
public void test() { public void test() {
ecu.setEngineType(ET_FRANKENSO_MIATA_NA6); ecu.setEngineType(engine_type_e.MAZDA_MIATA_2003);
ecu.sendCommand(getEnableCommand(Fields.CMD_EXTERNAL_STIMULATION)); ecu.sendCommand(getEnableCommand(Fields.CMD_EXTERNAL_STIMULATION));
ecu.changeRpm(1400); ecu.changeRpm(1400);

View File

@ -8,6 +8,7 @@ import com.rusefi.config.generated.Fields;
import com.rusefi.core.ISensorCentral; import com.rusefi.core.ISensorCentral;
import com.rusefi.core.Sensor; import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral; import com.rusefi.core.SensorCentral;
import com.rusefi.enums.engine_type_e;
import com.rusefi.io.CommandQueue; import com.rusefi.io.CommandQueue;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;
import com.rusefi.waves.EngineReport; import com.rusefi.waves.EngineReport;
@ -115,8 +116,9 @@ public class EcuTestHelper {
IoUtil.changeRpm(commandQueue, rpm); IoUtil.changeRpm(commandQueue, rpm);
} }
public void setEngineType(int type) { public void setEngineType(engine_type_e engineTypeE) {
log.info("AUTOTEST setEngineType " + type); int type = engineTypeE.ordinal();
log.info("AUTOTEST setEngineType " + engineTypeE);
currentEngineType = type; currentEngineType = type;
// sendCommand(CMD_PINS); // sendCommand(CMD_PINS);
/* /*

View File

@ -3,6 +3,7 @@ package com.rusefi.proteus;
import com.rusefi.RusefiTestBase; import com.rusefi.RusefiTestBase;
import com.rusefi.core.Sensor; import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral; import com.rusefi.core.SensorCentral;
import com.rusefi.enums.engine_type_e;
import org.junit.Test; import org.junit.Test;
import static com.rusefi.config.generated.Fields.*; import static com.rusefi.config.generated.Fields.*;
@ -40,7 +41,7 @@ public class ProteusAnalogTest extends RusefiTestBase {
@Test @Test
public void testTpsAnalogInput() { public void testTpsAnalogInput() {
ecu.setEngineType(ET_PROTEUS_ANALOG_PWM_TEST); // proteus analog input PWM tester ecu.setEngineType(engine_type_e.PROTEUS_ANALOG_PWM_TEST); // proteus analog input PWM tester
ecu.changeRpm(1000); ecu.changeRpm(1000);
// engine has to be spinning for idle valve to work // engine has to be spinning for idle valve to work
ecu.sendCommand(getEnableCommand(CMD_SELF_STIMULATION)); ecu.sendCommand(getEnableCommand(CMD_SELF_STIMULATION));

View File

@ -1,6 +1,7 @@
package com.rusefi; package com.rusefi;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.enums.engine_type_e;
import com.rusefi.ui.UIContext; import com.rusefi.ui.UIContext;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -12,10 +13,6 @@ import java.awt.event.ActionListener;
* Andrey Belomutskiy, (c) 2013-2020 * Andrey Belomutskiy, (c) 2013-2020
*/ */
public class PresetsPane { public class PresetsPane {
// see rusefi_enums.h
private static final int TEST_V_12 = 49;
private static final int ETB_BENCH = 58;
private static final int MINIMAL_PINS = 99;
private final UIContext uiContext; private final UIContext uiContext;
private final JPanel content = new JPanel(new GridLayout(4, 5)); private final JPanel content = new JPanel(new GridLayout(4, 5));
@ -32,10 +29,10 @@ public class PresetsPane {
content.add(new SetEngineTypeCommandControl(uiContext, "MRE Miata NB2 MAF", "engines/miata_nb.png", Fields.ET_MRE_MIATA_NB2_MAF).getContent()); content.add(new SetEngineTypeCommandControl(uiContext, "MRE Miata NB2 MAF", "engines/miata_nb.png", Fields.ET_MRE_MIATA_NB2_MAF).getContent());
content.add(new SetEngineTypeCommandControl(uiContext, "Proteus NB2 MAP", "engines/miata_nb.png", Fields.ET_PROTEUS_MIATA_NB2).getContent()); content.add(new SetEngineTypeCommandControl(uiContext, "Proteus NB2 MAP", "engines/miata_nb.png", Fields.ET_PROTEUS_MIATA_NB2).getContent());
content.add(new SetEngineTypeCommandControl(uiContext, "Hellen72 NB2 MAP", "engines/miata_nb.png", Fields.ET_HELLEN_NB2).getContent()); content.add(new SetEngineTypeCommandControl(uiContext, "Hellen72 NB2 MAP", "engines/miata_nb.png", Fields.ET_HELLEN_NB2).getContent());
content.add(new SetEngineTypeCommandControl(uiContext, "MRE Miata Defaults", "", Fields.ET_MRE_DEFAULTS).getContent()); content.add(new SetEngineTypeCommandControl(uiContext, "MRE Miata Defaults", "", engine_type_e.MICRO_RUS_EFI.ordinal()).getContent());
content.add(new SetEngineTypeCommandControl(uiContext, "Frankenso V12", "/engines/v12", TEST_V_12).getContent()); content.add(new SetEngineTypeCommandControl(uiContext, "Frankenso V12", "/engines/v12", engine_type_e.BMW_M73_PROTEUS.ordinal()).getContent());
content.add(new SetEngineTypeCommandControl(uiContext, "ETB bench", "", ETB_BENCH).getContent()); content.add(new SetEngineTypeCommandControl(uiContext, "ETB bench", "", engine_type_e.ETB_BENCH_ENGINE.ordinal()).getContent());
content.add(new SetEngineTypeCommandControl(uiContext, "Minimal", "", MINIMAL_PINS).getContent()); content.add(new SetEngineTypeCommandControl(uiContext, "Minimal", "", engine_type_e.MINIMAL_PINS.ordinal()).getContent());
content.add(new SetEngineTypeCommandControl(uiContext, "MRE old test", "", Fields.ET_MRE_OLD_TEST_BOARD).getContent()); content.add(new SetEngineTypeCommandControl(uiContext, "MRE old test", "", Fields.ET_MRE_OLD_TEST_BOARD).getContent());
content.add(new SetEngineTypeCommandControl(uiContext, "MRE new test", "", Fields.ET_MRE_NEW_TEST_BOARD).getContent()); content.add(new SetEngineTypeCommandControl(uiContext, "MRE new test", "", Fields.ET_MRE_NEW_TEST_BOARD).getContent());
} }