diff --git a/java_tools/ConfigDefinition.jar b/java_tools/ConfigDefinition.jar index 763302cefa..714c652306 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/output/GetConfigValueConsumer.java b/java_tools/configuration_definition/src/main/java/com/rusefi/output/GetConfigValueConsumer.java index 629d5a880d..2542fad7f9 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/output/GetConfigValueConsumer.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/output/GetConfigValueConsumer.java @@ -14,13 +14,13 @@ import static com.rusefi.output.DataLogConsumer.UNUSED; @SuppressWarnings("StringConcatenationInsideStringBufferAppend") public class GetConfigValueConsumer extends AbstractConfigurationConsumer { - public static final String CONFIG_ENGINE_CONFIGURATION = "config->engineConfiguration."; - public static final String ENGINE_CONFIGURATION = "engineConfiguration."; - public static final String FILE_HEADER = "#include \"pch.h\"\n"; - public static final String GET_METHOD_HEADER = "float getConfigValueByName(const char *name) {\n"; - public static final String GET_METHOD_FOOTER = "\treturn EFI_ERROR_CODE;\n" + "}\n"; - public static final String SET_METHOD_HEADER = "void setConfigValueByName(const char *name, float value) {\n"; - public static final String SET_METHOD_FOOTER = "}\n"; + private static final String CONFIG_ENGINE_CONFIGURATION = "config->engineConfiguration."; + private static final String ENGINE_CONFIGURATION = "engineConfiguration."; + private static final String FILE_HEADER = "#include \"pch.h\"\n"; + private static final String GET_METHOD_HEADER = "float getConfigValueByName(const char *name) {\n"; + private static final String GET_METHOD_FOOTER = "\treturn EFI_ERROR_CODE;\n" + "}\n"; + private static final String SET_METHOD_HEADER = "void setConfigValueByName(const char *name, float value) {\n"; + private static final String SET_METHOD_FOOTER = "}\n"; private final StringBuilder getterBody = new StringBuilder(); private final StringBuilder setterBody = new StringBuilder(); private final String outputFIleName; @@ -79,14 +79,25 @@ public class GetConfigValueConsumer extends AbstractConfigurationConsumer { if (TypesHelper.isFloat(cf.getType())) { setterBody.append(getCompareName(userName)); - setterBody.append("\t{\n" + "\t\t" + javaName + cf.getName() + " = value;\n" + - "\t\treturn;\n\t}\n"); + String str = getAssignment(cf, javaName, ""); + setterBody.append(str); + } else { + setterBody.append(getCompareName(userName)); + String str = getAssignment(cf, javaName, "(int)"); + setterBody.append(str); } return ""; } + @NotNull + private String getAssignment(ConfigField cf, String javaName, String cast) { + return "\t{\n" + "\t\t" + javaName + cf.getName() + " = " + cast + + "value;\n" + + "\t\treturn;\n\t}\n"; + } + @NotNull private String getCompareName(String userName) { return "\tif (strEqualCaseInsensitive(name, \"" + userName + "\"))\n"; diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/test/OutputsTest.java b/java_tools/configuration_definition/src/main/java/com/rusefi/test/OutputsTest.java index cd35980c63..aa1e59acff 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/test/OutputsTest.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/test/OutputsTest.java @@ -156,6 +156,11 @@ public class OutputsTest { "\t{\n" + "\t\tconfig->iat.config.tempC_1 = value;\n" + "\t\treturn;\n" + + "\t}\n" + + "\tif (strEqualCaseInsensitive(name, \"iat.adcChannel\"))\n" + + "\t{\n" + + "\t\tconfig->iat.adcChannel = (int)value;\n" + + "\t\treturn;\n" + "\t}\n", getConfigValueConsumer.getSetterBody()); assertEquals("#include \"pch.h\"\n" +