diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 969cfbf930..fd320ed826 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -3144,4 +3144,4 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00" ;addTool = toolName, PanelName addTool = veTableGenerator, "VE Table Generator", veTableTbl addTool = afrTableGenerator, "AFR Table Generator", afrTableTbl - + \ No newline at end of file diff --git a/java_tools/ConfigDefinition.jar b/java_tools/ConfigDefinition.jar index 39a8cc4afe..097ca7a730 100644 Binary files a/java_tools/ConfigDefinition.jar and b/java_tools/ConfigDefinition.jar differ diff --git a/java_tools/configuration_definition/src/com/rusefi/output/TSProjectConsumer.java b/java_tools/configuration_definition/src/com/rusefi/output/TSProjectConsumer.java index 6477a855f1..795f512b56 100644 --- a/java_tools/configuration_definition/src/com/rusefi/output/TSProjectConsumer.java +++ b/java_tools/configuration_definition/src/com/rusefi/output/TSProjectConsumer.java @@ -1,11 +1,13 @@ package com.rusefi.output; +import com.opensr5.ini.field.IniField; import com.rusefi.*; import com.rusefi.util.LazyFile; import com.rusefi.util.Output; import com.rusefi.util.SystemOut; import java.io.*; +import java.util.Arrays; import static com.rusefi.util.IoUtils.CHARSET; import static com.rusefi.ConfigDefinition.EOL; @@ -83,13 +85,32 @@ public class TSProjectConsumer implements ConfigurationConsumer { tsHeader.write("\t" + addTabsUpTo(nameWithPrefix, LENGTH) + "\t\t= scalar, "); tsHeader.write(TypesHelper.convertToTs(configField.getType()) + ","); tsHeader.write("\t" + tsPosition + ","); - tsHeader.write("\t" + configField.getTsInfo()); + tsHeader.write("\t" + handleTsInfo(configField.getTsInfo())); tsPosition += configField.getArraySize() * configField.getElementSize(); } tsHeader.write(EOL); return tsPosition; } + private static String handleTsInfo(String tsInfo) { + String[] fields = tsInfo.split("\\,"); + if (fields.length > 1) { + /** + * Evaluate static math on .ini layer to simplify rusEFI java and rusEFI PHP project consumers + * https://github.com/rusefi/web_backend/issues/97 + */ + fields[1] = " " + IniField.parseDouble(fields[1]); + } + StringBuilder sb = new StringBuilder(); + for (String f : fields) { + if (sb.length() > 0) { + sb.append(","); + } + sb.append(f); + } + return sb.toString(); + } + private int writeTunerStudio(ConfigStructure configStructure, String prefix, Writer tsHeader, int tsPosition) throws IOException { BitState bitState = new BitState(); for (int i = 0; i < configStructure.tsFields.size(); i++) { diff --git a/java_tools/configuration_definition/src/com/rusefi/test/ConfigFieldParserTest.java b/java_tools/configuration_definition/src/com/rusefi/test/ConfigFieldParserTest.java index c2a3667485..c3dc6d4366 100644 --- a/java_tools/configuration_definition/src/com/rusefi/test/ConfigFieldParserTest.java +++ b/java_tools/configuration_definition/src/com/rusefi/test/ConfigFieldParserTest.java @@ -116,7 +116,7 @@ public class ConfigFieldParserTest { state.readBufferedReader(reader, Collections.singletonList(javaFieldsConsumer)); - assertEquals("\tperiodMs\t\t\t\t\t\t= scalar, S16,\t0,\t\"ms\", {1/10}, 0, 0, 3000, 0\n" + + assertEquals("\tperiodMs\t\t\t\t\t\t= scalar, S16,\t0,\t\"ms\", 0.1, 0, 0, 3000, 0\n" + "\talignmentFill_at_2\t\t\t\t= array, U08,\t2,\t[2],\t\"units\", 1, 0, -20, 100, 0\n" + "; total TS size = 4\n", new String(writer.toCharArray())); }