From 1a5a7b1c91c47e524689ccd007ab7942066114ff Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Sat, 1 Jul 2023 21:39:10 -0400 Subject: [PATCH] flexibility for ptr vs. ref live data --- .../main/java/com/rusefi/ldmp/LiveDataProcessor.java | 10 +++++++--- .../java/com/rusefi/output/GetOutputValueConsumer.java | 3 ++- .../java/com/rusefi/output/SdCardFieldsContent.java | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/java_tools/configuration_definition_base/src/main/java/com/rusefi/ldmp/LiveDataProcessor.java b/java_tools/configuration_definition_base/src/main/java/com/rusefi/ldmp/LiveDataProcessor.java index 7432eefe5c..ccac094ee8 100644 --- a/java_tools/configuration_definition_base/src/main/java/com/rusefi/ldmp/LiveDataProcessor.java +++ b/java_tools/configuration_definition_base/src/main/java/com/rusefi/ldmp/LiveDataProcessor.java @@ -83,7 +83,7 @@ public class LiveDataProcessor { } interface EntryHandler { - void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames, String constexpr, String conditional, String engineModule) throws IOException; + void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames, String constexpr, String conditional, String engineModule, Boolean isPtr) throws IOException; } private int handleYaml(Map data) throws IOException { @@ -99,7 +99,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, String engineModule) throws IOException { + public void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames, String constexpr, String conditional, String engineModule, Boolean isPtr) throws IOException { // TODO: use outputNames int startingPosition = javaSensorsConsumer.sensorTsPosition; @@ -129,6 +129,7 @@ public class LiveDataProcessor { if (constexpr != null) { sdCardFieldsConsumer.home = constexpr; sdCardFieldsConsumer.conditional = conditional; + sdCardFieldsConsumer.isPtr = isPtr; state.addDestination((state1, structure) -> sdCardFieldsConsumer.handleEndStruct(state1, structure)); outputValueConsumer.currentSectionPrefix = constexpr; @@ -140,6 +141,7 @@ public class LiveDataProcessor { outputValueConsumer.currentEngineModule = engineModule; outputValueConsumer.moduleMode = true; outputValueConsumer.conditional = conditional; + outputValueConsumer.isPtr = isPtr; state.addDestination((state1, structure) -> outputValueConsumer.handleEndStruct(state1, structure)); } state.addDestination(new ConfigurationConsumer() { @@ -171,8 +173,10 @@ public class LiveDataProcessor { String engineModule = (String) entry.get("engineModule"); String conditional = (String) entry.get("conditional_compilation"); Boolean withCDefines = (Boolean) entry.get("withCDefines"); + Boolean isPtr = (Boolean) entry.get("isPtr"); // Defaults to false if not specified withCDefines = withCDefines != null && withCDefines; + isPtr = isPtr != null && isPtr; Object outputNames = entry.get("output_name"); @@ -188,7 +192,7 @@ public class LiveDataProcessor { nameList.toArray(outputNamesArr); } - handler.onEntry(name, java, folder, prepend, withCDefines, outputNamesArr, constexpr, conditional, engineModule); + handler.onEntry(name, java, folder, prepend, withCDefines, outputNamesArr, constexpr, conditional, engineModule, isPtr); String enumName = "LDS_" + name; String type = name + "_s"; // convention diff --git a/java_tools/configuration_definition_base/src/main/java/com/rusefi/output/GetOutputValueConsumer.java b/java_tools/configuration_definition_base/src/main/java/com/rusefi/output/GetOutputValueConsumer.java index c9f71fc23c..224f63e488 100644 --- a/java_tools/configuration_definition_base/src/main/java/com/rusefi/output/GetOutputValueConsumer.java +++ b/java_tools/configuration_definition_base/src/main/java/com/rusefi/output/GetOutputValueConsumer.java @@ -30,6 +30,7 @@ public class GetOutputValueConsumer implements ConfigurationConsumer { public boolean moduleMode; public String currentEngineModule; public String conditional; + public Boolean isPtr = false; public GetOutputValueConsumer(String fileName) { this.fileName = fileName; @@ -59,7 +60,7 @@ public class GetOutputValueConsumer implements ConfigurationConsumer { if (moduleMode) { javaName = "engine->module<" + currentEngineModule + ">()->" + prefix; } else { - javaName = currentSectionPrefix + "." + prefix; + javaName = currentSectionPrefix + (isPtr ? "->" : ".") + prefix; } getterPairs.add(new VariableRecord(userName, javaName + cf.getName(), null, conditional)); diff --git a/java_tools/configuration_definition_base/src/main/java/com/rusefi/output/SdCardFieldsContent.java b/java_tools/configuration_definition_base/src/main/java/com/rusefi/output/SdCardFieldsContent.java index 89d2f8d014..682785352d 100644 --- a/java_tools/configuration_definition_base/src/main/java/com/rusefi/output/SdCardFieldsContent.java +++ b/java_tools/configuration_definition_base/src/main/java/com/rusefi/output/SdCardFieldsContent.java @@ -12,6 +12,7 @@ public class SdCardFieldsContent { public String home = "engine->outputChannels"; public String conditional; + public Boolean isPtr = false; public void handleEndStruct(ReaderState state, ConfigStructure structure) throws IOException { if (state.isStackEmpty()) { @@ -52,7 +53,7 @@ public class SdCardFieldsContent { String after = conditional == null ? "" : "#endif\n"; return before - + "\t{" + home + "." + name + + + "\t{" + home + (isPtr ? "->" : ".") + name + ", " + DataLogConsumer.getHumanGaugeName(prefix, configField) + ", " +