diff --git a/java_tools/ConfigDefinition.jar b/java_tools/ConfigDefinition.jar index 6273f98944..99b476a09f 100644 Binary files a/java_tools/ConfigDefinition.jar and b/java_tools/ConfigDefinition.jar differ diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/pinout/PinoutLogic.java b/java_tools/configuration_definition/src/main/java/com/rusefi/pinout/PinoutLogic.java index 74f4177bd1..48cd2b3eaa 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/pinout/PinoutLogic.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/pinout/PinoutLogic.java @@ -154,10 +154,13 @@ public class PinoutLogic { Object pinId = pin.get("id"); Object pinClass = pin.get("class"); Object pinName = pin.get("pin"); - String pinTsName = (String) pin.get("ts_name"); + Object pinTsName = pin.get("ts_name"); if (pinId == null || pinClass == null || pinTsName == null) { continue; } + if (pinName != null) { + pinTsName = pinTsName.toString().replace("___", pinName.toString()); + } if (pinId instanceof ArrayList) { ArrayList pinIds = (ArrayList) pinId; if (!(pinClass instanceof ArrayList)) @@ -167,14 +170,14 @@ public class PinoutLogic { throw new IllegalStateException(pinName + ": id array length should match class array length: " + pinId + " vs " + pinClassArray); for (int i = 0; i < pinIds.size(); i++) { String id = pinIds.get(i); - addPinToList(id, pinTsName, pinClassArray.get(i)); + addPinToList(id, (String) pinTsName, pinClassArray.get(i)); } } else if (pinId instanceof String) { String pinIdString = (String) pinId; if (pinIdString.length() == 0) { throw new IllegalStateException("Unexpected empty ID field"); } - addPinToList(pinIdString, pinTsName, (String) pinClass); + addPinToList(pinIdString, (String) pinTsName, (String) pinClass); } else { throw new IllegalStateException("Unexpected type of ID field: " + pinId.getClass().getSimpleName()); } diff --git a/java_tools/configuration_definition/src/test/java/com/rusefi/pinout/PinoutLogicIntegratedTest.java b/java_tools/configuration_definition/src/test/java/com/rusefi/pinout/PinoutLogicIntegratedTest.java index 50d396dbca..e828710f7c 100644 --- a/java_tools/configuration_definition/src/test/java/com/rusefi/pinout/PinoutLogicIntegratedTest.java +++ b/java_tools/configuration_definition/src/test/java/com/rusefi/pinout/PinoutLogicIntegratedTest.java @@ -39,6 +39,31 @@ public class PinoutLogicIntegratedTest { } + @Test + public void testTemplate() throws IOException { + runPinoutTest("pins:\n" + + " - pin: 1\n" + + " id: [E11, E11]\n" + + " class: [event_inputs, switch_inputs]\n" + + " function: Digital trigger/switch input for instance Hall type CAM\n" + + " ts_name: ___ - Digital 2\n" + + " type: din", + "//DO NOT EDIT MANUALLY, let automation work hard.\n" + + "\n" + + "// auto-generated by PinoutLogic.java based on key\n" + + "#include \"pch.h\"\n" + + "\n" + + "// see comments at declaration in pin_repository.h\n" + + "const char * getBoardSpecificPinName(brain_pin_e brainPin) {\n" + + "\tswitch(brainPin) {\n" + + "\t\tcase Gpio::E11: return \"1 - Digital 2\";\n" + + "\t\tdefault: return nullptr;\n" + + "\t}\n" + + "\treturn nullptr;\n" + + "}\n"); + + } + private static void runPinoutTest(String inputYaml, String expected) throws IOException { StringWriter testWriter = new StringWriter();