lua getOutput documentation generator #4867
This commit is contained in:
parent
bc08f1f1ea
commit
e9142e48bb
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -13,7 +13,7 @@ COMMON_GEN_CONFIG="
|
||||||
-firing_order controllers/algo/firing_order.h \
|
-firing_order controllers/algo/firing_order.h \
|
||||||
-triggerInputFolder ../unit_tests \
|
-triggerInputFolder ../unit_tests \
|
||||||
-with_c_defines false \
|
-with_c_defines false \
|
||||||
-field_lookup_file controllers/lua/generated/value_lookup_generated.cpp \
|
-field_lookup_file controllers/lua/generated/value_lookup_generated.cpp controllers/lua/generated/value_lookup_generated.md \
|
||||||
-java_destination ../java_console/models/src/main/java/com/rusefi/config/generated/Fields.java \
|
-java_destination ../java_console/models/src/main/java/com/rusefi/config/generated/Fields.java \
|
||||||
-initialize_to_zero false \
|
-initialize_to_zero false \
|
||||||
-prepend console/binary/generated/total_live_data_generated.h \
|
-prepend console/binary/generated/total_live_data_generated.h \
|
||||||
|
|
Binary file not shown.
|
@ -107,8 +107,12 @@ public class ConfigDefinition {
|
||||||
case KEY_JAVA_DESTINATION:
|
case KEY_JAVA_DESTINATION:
|
||||||
state.addJavaDestination(args[i + 1]);
|
state.addJavaDestination(args[i + 1]);
|
||||||
break;
|
break;
|
||||||
case "-field_lookup_file":
|
case "-field_lookup_file": {
|
||||||
state.destinations.add(new GetConfigValueConsumer(args[i + 1]));
|
String cppFile = args[i + 1];
|
||||||
|
String mdFile = args[i + 2];
|
||||||
|
i++;
|
||||||
|
state.destinations.add(new GetConfigValueConsumer(cppFile, mdFile));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "-readfile":
|
case "-readfile":
|
||||||
String keyName = args[i + 1];
|
String keyName = args[i + 1];
|
||||||
|
|
|
@ -34,9 +34,17 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
||||||
private static final String SET_METHOD_FOOTER = "}\n";
|
private static final String SET_METHOD_FOOTER = "}\n";
|
||||||
private final List<Tuple<String>> variables = new ArrayList<>();
|
private final List<Tuple<String>> variables = new ArrayList<>();
|
||||||
private final String outputFileName;
|
private final String outputFileName;
|
||||||
|
private final String mdOutputFileName;
|
||||||
|
|
||||||
public GetConfigValueConsumer(String outputFileName) {
|
private final StringBuilder mdContent = new StringBuilder();
|
||||||
|
|
||||||
|
public GetConfigValueConsumer() {
|
||||||
|
this(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GetConfigValueConsumer(String outputFileName, String mdOutputFileName) {
|
||||||
this.outputFileName = outputFileName;
|
this.outputFileName = outputFileName;
|
||||||
|
this.mdOutputFileName = mdOutputFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeStringToFile(@Nullable String fileName, String content) throws IOException {
|
public static void writeStringToFile(@Nullable String fileName, String content) throws IOException {
|
||||||
|
@ -59,6 +67,7 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
||||||
@Override
|
@Override
|
||||||
public void endFile() throws IOException {
|
public void endFile() throws IOException {
|
||||||
writeStringToFile(outputFileName, getContent());
|
writeStringToFile(outputFileName, getContent());
|
||||||
|
writeStringToFile(mdOutputFileName, getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String processConfig(ReaderState readerState, ConfigField cf, String prefix) {
|
private String processConfig(ReaderState readerState, ConfigField cf, String prefix) {
|
||||||
|
@ -81,6 +90,9 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
||||||
|
|
||||||
variables.add(new Tuple<>(userName, javaName + cf.getName(), cf.getType()));
|
variables.add(new Tuple<>(userName, javaName + cf.getName(), cf.getType()));
|
||||||
|
|
||||||
|
mdContent.append("### " + userName + "\n");
|
||||||
|
mdContent.append(cf.getCommentContent() + "\n\n");
|
||||||
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -102,6 +114,10 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
||||||
getCompleteGetterBody();
|
getCompleteGetterBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMdContent() {
|
||||||
|
return mdContent.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getCompleteGetterBody() {
|
public String getCompleteGetterBody() {
|
||||||
StringBuilder switchBody = new StringBuilder();
|
StringBuilder switchBody = new StringBuilder();
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class GetConfigValueConsumerTest {
|
||||||
"end_struct\n" +
|
"end_struct\n" +
|
||||||
"\tdc_io[2 iterate] etbIn\n" +
|
"\tdc_io[2 iterate] etbIn\n" +
|
||||||
"end_struct\n";
|
"end_struct\n";
|
||||||
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer(null);
|
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer();
|
||||||
state.readBufferedReader(test, getConfigValueConsumer);
|
state.readBufferedReader(test, getConfigValueConsumer);
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
@ -42,7 +42,7 @@ public class GetConfigValueConsumerTest {
|
||||||
"end_struct\n" +
|
"end_struct\n" +
|
||||||
"ThermistorConf iat;\n" +
|
"ThermistorConf iat;\n" +
|
||||||
"end_struct\n";
|
"end_struct\n";
|
||||||
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer(null);
|
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer();
|
||||||
state.readBufferedReader(test, getConfigValueConsumer);
|
state.readBufferedReader(test, getConfigValueConsumer);
|
||||||
|
|
||||||
assertEquals("\tint hash = djb2lowerCase(name);\n" +
|
assertEquals("\tint hash = djb2lowerCase(name);\n" +
|
||||||
|
@ -121,7 +121,7 @@ public class GetConfigValueConsumerTest {
|
||||||
"end_struct\n" +
|
"end_struct\n" +
|
||||||
"MAP_sensor_config_s map;@see isMapAveragingEnabled\n" +
|
"MAP_sensor_config_s map;@see isMapAveragingEnabled\n" +
|
||||||
"struct injector_s\n" +
|
"struct injector_s\n" +
|
||||||
"\tfloat flow;+This is your injector flow at the fuel pressure used in the vehicle. cc/min, cubic centimetre per minute\\nBy the way, g/s = 0.125997881 * (lb/hr)\\ng/s = 0.125997881 * (cc/min)/10.5\\ng/s = 0.0119997981 * cc/min;\"cm3/min\", 1, 0, 0, 99999, 2\n" +
|
"\tfloat flow;This is your injector flow at the fuel pressure used in the vehicle. cc/min, cubic centimetre per minute\\nBy the way, g/s = 0.125997881 * (lb/hr)\\ng/s = 0.125997881 * (cc/min)/10.5\\ng/s = 0.0119997981 * cc/min;\"cm3/min\", 1, 0, 0, 99999, 2\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"float[8] battLagCorr;ms delay between injector open and close dead times;\"ms\", 1, 0, 0, 50, 2\n" +
|
"float[8] battLagCorr;ms delay between injector open and close dead times;\"ms\", 1, 0, 0, 50, 2\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
|
@ -129,7 +129,7 @@ public class GetConfigValueConsumerTest {
|
||||||
"\n" +
|
"\n" +
|
||||||
"injector_s injector\n" +
|
"injector_s injector\n" +
|
||||||
"\tint[12 iterate] ignitionPins;\n" +
|
"\tint[12 iterate] ignitionPins;\n" +
|
||||||
"\tfloat bias_resistor;+Pull-up resistor value on your board;\"Ohm\", 1, 0, 0, 200000, 1\n" +
|
"\tfloat bias_resistor;Pull-up resistor value on your board;\"Ohm\", 1, 0, 0, 200000, 1\n" +
|
||||||
"end_struct\n" +
|
"end_struct\n" +
|
||||||
"struct ThermistorConf @brief Thermistor curve parameters\n" +
|
"struct ThermistorConf @brief Thermistor curve parameters\n" +
|
||||||
"\tthermistor_conf_s config;\n" +
|
"\tthermistor_conf_s config;\n" +
|
||||||
|
@ -145,14 +145,14 @@ public class GetConfigValueConsumerTest {
|
||||||
"uint8_t autoscale vehicleSpeedKph;;\"kph\",1, 0, 0, 0, 0\n" +
|
"uint8_t autoscale vehicleSpeedKph;;\"kph\",1, 0, 0, 0, 0\n" +
|
||||||
"bit isForcedInduction;Does the vehicle have a turbo or supercharger?\n" +
|
"bit isForcedInduction;Does the vehicle have a turbo or supercharger?\n" +
|
||||||
"\tuint8_t unused37;;\"\",1, 0, 0, 0, 0\n" +
|
"\tuint8_t unused37;;\"\",1, 0, 0, 0, 0\n" +
|
||||||
"bit enableFan1WithAc;+Turn on this fan when AC is on.\n" +
|
"bit enableFan1WithAc;Turn on this fan when AC is on.\n" +
|
||||||
"end_struct\n";
|
"end_struct\n";
|
||||||
ReaderState state = new ReaderState();
|
ReaderState state = new ReaderState();
|
||||||
state.variableRegistry.register("PACK_MULT_PERCENT", 100);
|
state.variableRegistry.register("PACK_MULT_PERCENT", 100);
|
||||||
state.variableRegistry.register("GAUGE_NAME_FUEL_BASE", "hello");
|
state.variableRegistry.register("GAUGE_NAME_FUEL_BASE", "hello");
|
||||||
|
|
||||||
|
|
||||||
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer(null);
|
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer();
|
||||||
state.readBufferedReader(test, getConfigValueConsumer);
|
state.readBufferedReader(test, getConfigValueConsumer);
|
||||||
|
|
||||||
assertEquals("#include \"pch.h\"\n" +
|
assertEquals("#include \"pch.h\"\n" +
|
||||||
|
@ -191,6 +191,50 @@ public class GetConfigValueConsumerTest {
|
||||||
"\t}\n" +
|
"\t}\n" +
|
||||||
"\treturn EFI_ERROR_CODE;\n" +
|
"\treturn EFI_ERROR_CODE;\n" +
|
||||||
"}\n", getConfigValueConsumer.getHeaderAndGetter());
|
"}\n", getConfigValueConsumer.getHeaderAndGetter());
|
||||||
|
|
||||||
|
|
||||||
|
assertEquals("### clt.config.tempC_1\n" +
|
||||||
|
"these values are in Celcius\n" +
|
||||||
|
"\n" +
|
||||||
|
"### clt.config.map.sensor.highValue\n" +
|
||||||
|
"kPa value at high volts\n" +
|
||||||
|
"\n" +
|
||||||
|
"### clt.config.map.sensor.hwChannel\n" +
|
||||||
|
"\n" +
|
||||||
|
"\n" +
|
||||||
|
"### clt.config.injector.flow\n" +
|
||||||
|
"This is your injector flow at the fuel pressure used in the vehicle. cc/min, cubic centimetre per minute\\nBy the way, g/s = 0.125997881 * (lb/hr)\\ng/s = 0.125997881 * (cc/min)/10.5\\ng/s = 0.0119997981 * cc/min\n" +
|
||||||
|
"\n" +
|
||||||
|
"### clt.config.bias_resistor\n" +
|
||||||
|
"Pull-up resistor value on your board\n" +
|
||||||
|
"\n" +
|
||||||
|
"### clt.adcChannel\n" +
|
||||||
|
"\n" +
|
||||||
|
"\n" +
|
||||||
|
"### issue_294_31\n" +
|
||||||
|
"\n" +
|
||||||
|
"\n" +
|
||||||
|
"### baseFuel\n" +
|
||||||
|
"@@GAUGE_NAME_FUEL_BASE@@\\nThis is the raw value we take from the fuel map or base fuel algorithm, before the corrections\n" +
|
||||||
|
"\n" +
|
||||||
|
"### afr_type\n" +
|
||||||
|
"PID dTime\n" +
|
||||||
|
"\n" +
|
||||||
|
"### speedToRpmRatio\n" +
|
||||||
|
"s2rpm\n" +
|
||||||
|
"\n" +
|
||||||
|
"### afr_typet\n" +
|
||||||
|
"\n" +
|
||||||
|
"\n" +
|
||||||
|
"### vehicleSpeedKph\n" +
|
||||||
|
"\n" +
|
||||||
|
"\n" +
|
||||||
|
"### isForcedInduction\n" +
|
||||||
|
"Does the vehicle have a turbo or supercharger?\n" +
|
||||||
|
"\n" +
|
||||||
|
"### enableFan1WithAc\n" +
|
||||||
|
"Turn on this fan when AC is on.\n" +
|
||||||
|
"\n", getConfigValueConsumer.getMdContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = MaybeSemicolorWasMissedException.class)
|
@Test(expected = MaybeSemicolorWasMissedException.class)
|
||||||
|
@ -201,7 +245,7 @@ public class GetConfigValueConsumerTest {
|
||||||
ReaderState state = new ReaderState();
|
ReaderState state = new ReaderState();
|
||||||
|
|
||||||
|
|
||||||
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer(null);
|
GetConfigValueConsumer getConfigValueConsumer = new GetConfigValueConsumer();
|
||||||
state.readBufferedReader(test, getConfigValueConsumer);
|
state.readBufferedReader(test, getConfigValueConsumer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue