only:expose fuel_pump_control and other engineModules via Lua #5239
This commit is contained in:
parent
5d15135d6b
commit
ef566e1959
|
@ -85,7 +85,7 @@ public class LiveDataProcessor {
|
|||
}
|
||||
|
||||
interface EntryHandler {
|
||||
void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames, String constexpr, String conditional) throws IOException;
|
||||
void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames, String constexpr, String conditional, String engineModule) throws IOException;
|
||||
}
|
||||
|
||||
private int handleYaml(Map<String, Object> data) throws IOException {
|
||||
|
@ -101,7 +101,7 @@ public class LiveDataProcessor {
|
|||
|
||||
EntryHandler handler = new EntryHandler() {
|
||||
@Override
|
||||
public void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames, String constexpr, String conditional) throws IOException {
|
||||
public void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames, String constexpr, String conditional, String engineModule) throws IOException {
|
||||
// TODO: use outputNames
|
||||
|
||||
int startingPosition = javaSensorsConsumer.sensorTsPosition;
|
||||
|
@ -133,9 +133,14 @@ public class LiveDataProcessor {
|
|||
state.addDestination((state1, structure) -> sdCardFieldsConsumer.handleEndStruct(state1, structure));
|
||||
|
||||
outputValueConsumer.currentSectionPrefix = constexpr;
|
||||
outputValueConsumer.moduleMode = false;
|
||||
outputValueConsumer.conditional = conditional;
|
||||
state.addDestination((state1, structure) -> outputValueConsumer.handleEndStruct(state1, structure));
|
||||
|
||||
} else if (engineModule != null) {
|
||||
outputValueConsumer.currentEngineModule = engineModule;
|
||||
outputValueConsumer.moduleMode = true;
|
||||
|
||||
}
|
||||
state.addDestination(new ConfigurationConsumer() {
|
||||
@Override
|
||||
|
@ -163,6 +168,7 @@ public class LiveDataProcessor {
|
|||
String folder = (String) entry.get("folder");
|
||||
String prepend = (String) entry.get("prepend");
|
||||
String constexpr = (String) entry.get("constexpr");
|
||||
String engineModule = (String) entry.get("engineModule");
|
||||
String conditional = (String) entry.get("conditional_compilation");
|
||||
Boolean withCDefines = (Boolean) entry.get("withCDefines");
|
||||
// Defaults to false if not specified
|
||||
|
@ -182,7 +188,7 @@ public class LiveDataProcessor {
|
|||
nameList.toArray(outputNamesArr);
|
||||
}
|
||||
|
||||
handler.onEntry(name, java, folder, prepend, withCDefines, outputNamesArr, constexpr, conditional);
|
||||
handler.onEntry(name, java, folder, prepend, withCDefines, outputNamesArr, constexpr, conditional, engineModule);
|
||||
|
||||
String enumName = "LDS_" + name;
|
||||
String type = name + "_s"; // convention
|
||||
|
|
|
@ -27,6 +27,8 @@ public class GetOutputValueConsumer implements ConfigurationConsumer {
|
|||
private final String fileName;
|
||||
|
||||
public String currentSectionPrefix = "engine->outputChannels";
|
||||
public boolean moduleMode;
|
||||
public String currentEngineModule;
|
||||
public String conditional;
|
||||
|
||||
public GetOutputValueConsumer(String fileName) {
|
||||
|
@ -53,9 +55,14 @@ public class GetOutputValueConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
String userName = prefix + cf.getName();
|
||||
String javaName = currentSectionPrefix + "." + prefix;
|
||||
String javaName;
|
||||
if (moduleMode) {
|
||||
javaName = "engine->module<" + currentEngineModule + ">()->" + prefix;
|
||||
} else {
|
||||
javaName = currentSectionPrefix + "." + prefix;
|
||||
}
|
||||
|
||||
getterPairs.add(new VariableRecord(userName, javaName + cf.getName(), null, conditional));
|
||||
getterPairs.add(new VariableRecord(userName, javaName + cf.getName(), null, conditional));
|
||||
|
||||
|
||||
return "";
|
||||
|
|
|
@ -45,4 +45,44 @@ public class GetOutputValueConsumerTest {
|
|||
"\treturn EFI_ERROR_CODE;\n" +
|
||||
"}\n", outputValueConsumer.getContent());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void generateGetEngineModuleOutputs() {
|
||||
String test = "struct_no_prefix fuel_pump_control_s\n" +
|
||||
"\tbit isPrime\n" +
|
||||
"\tbit engineTurnedRecently\n" +
|
||||
"\tbit isFuelPumpOn\n" +
|
||||
"\tbit ignitionOn\n" +
|
||||
"end_struct\n";
|
||||
ReaderStateImpl state = new ReaderStateImpl();
|
||||
|
||||
GetOutputValueConsumer outputValueConsumer = new GetOutputValueConsumer(null);
|
||||
outputValueConsumer.moduleMode = true;
|
||||
outputValueConsumer.currentEngineModule = "FuelPumpController";
|
||||
|
||||
state.readBufferedReader(test, (outputValueConsumer));
|
||||
assertEquals(
|
||||
"// generated by GetOutputValueConsumer.java\n" +
|
||||
"#include \"pch.h\"\n" +
|
||||
"#include \"value_lookup.h\"\n" +
|
||||
"float getOutputValueByName(const char *name) {\n" +
|
||||
"\tint hash = djb2lowerCase(name);\n" +
|
||||
"\tswitch(hash) {\n" +
|
||||
"// isPrime\n" +
|
||||
"\t\tcase -1429286498:\n" +
|
||||
"\t\t\treturn engine->module<FuelPumpController>()->isPrime;\n" +
|
||||
"// engineTurnedRecently\n" +
|
||||
"\t\tcase -1270448973:\n" +
|
||||
"\t\t\treturn engine->module<FuelPumpController>()->engineTurnedRecently;\n" +
|
||||
"// isFuelPumpOn\n" +
|
||||
"\t\tcase -344048084:\n" +
|
||||
"\t\t\treturn engine->module<FuelPumpController>()->isFuelPumpOn;\n" +
|
||||
"// ignitionOn\n" +
|
||||
"\t\tcase -381519965:\n" +
|
||||
"\t\t\treturn engine->module<FuelPumpController>()->ignitionOn;\n" +
|
||||
"\t}\n" +
|
||||
"\treturn EFI_ERROR_CODE;\n" +
|
||||
"}\n", outputValueConsumer.getContent());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue