From 4309e5f7596832eedfec045d84f4135e97a0be3b Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sun, 26 Nov 2023 12:56:47 -0500 Subject: [PATCH] only:cast enum to int for data logging --- .../com/rusefi/test/SdCardFieldsGeneratorTest.java | 13 +++++++++++++ .../java/com/rusefi/output/SdCardFieldsContent.java | 9 +++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/java_tools/configuration_definition/src/test/java/com/rusefi/test/SdCardFieldsGeneratorTest.java b/java_tools/configuration_definition/src/test/java/com/rusefi/test/SdCardFieldsGeneratorTest.java index c954a428fa..0ac18947b2 100644 --- a/java_tools/configuration_definition/src/test/java/com/rusefi/test/SdCardFieldsGeneratorTest.java +++ b/java_tools/configuration_definition/src/test/java/com/rusefi/test/SdCardFieldsGeneratorTest.java @@ -74,6 +74,19 @@ public class SdCardFieldsGeneratorTest { }, true); } + @Test + public void enumField() { + processAndAssert("struct_no_prefix output_channels_s\n" + + " custom idle_state_e 4 bits, S32, @OFFSET@, [0:2], \"not important\"\n" + + " idle_state_e idleState\n" + + "end_struct", + "", + readerState -> { + + }, true); + } + + interface Actor { void act(ReaderStateImpl readerState); } 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 754e5577f5..7c2a163ee3 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 @@ -50,17 +50,22 @@ public class SdCardFieldsContent { private String getLine(ConfigField configField, String prefix, String name) { String categoryStr = configField.getCategory(); - if(categoryStr == null) { + if (categoryStr == null) { categoryStr = ""; } else { categoryStr = ", " + categoryStr; } + boolean isEnum = configField.getType().contains("_e"); + if (isEnum) + return ""; + String before = conditional == null ? "" : "#if " + conditional + "\n"; String after = conditional == null ? "" : "#endif\n"; return before - + "\t{" + home + (isPtr ? "->" : ".") + name + + + "\t{" + + home + (isPtr ? "->" : ".") + name + ", " + DataLogConsumer.getHumanGaugeName(prefix, configField) + ", " +