diff --git a/firmware/controllers/core/fsio_core.h b/firmware/controllers/core/fsio_core.h index e3d2a9c372..0a107805ff 100644 --- a/firmware/controllers/core/fsio_core.h +++ b/firmware/controllers/core/fsio_core.h @@ -59,6 +59,8 @@ typedef enum { LE_METHOD_FSIO_DIGITAL_INPUT = 123, LE_METHOD_FSIO_SETTING = 124, +#include "fsio_enums_generated.def" + Force_4b_le_action = ENUM_32_BITS, } le_action_e; diff --git a/firmware/controllers/generated/fsio_enums_generated.def b/firmware/controllers/generated/fsio_enums_generated.def new file mode 100644 index 0000000000..84edd54920 --- /dev/null +++ b/firmware/controllers/generated/fsio_enums_generated.def @@ -0,0 +1,24 @@ +// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Tue Sep 10 22:45:42 EDT 2019 + +// by class com.rusefi.output.FileFsioSettingsConsumer +FSIO_SETTING_FANONTEMPERATURE = 1000, +FSIO_SETTING_FANOFFTEMPERATURE = 1001, +FSIO_SETTING_ALTERNATORCONTROL_OFFSET = 1002, +FSIO_SETTING_ALTERNATORCONTROL_MINVALUE = 1003, +FSIO_SETTING_ETB_OFFSET = 1004, +FSIO_SETTING_ETB_MINVALUE = 1005, +FSIO_SETTING_IDLERPMPID_OFFSET = 1006, +FSIO_SETTING_IDLERPMPID_MINVALUE = 1007, +FSIO_SETTING_STARTUPFUELPUMPDURATION = 1008, +FSIO_SETTING_FUELCLOSEDLOOPPID_OFFSET = 1009, +FSIO_SETTING_FUELCLOSEDLOOPPID_MINVALUE = 1010, +FSIO_SETTING_AUXPID1_OFFSET = 1011, +FSIO_SETTING_AUXPID1_MINVALUE = 1012, +FSIO_SETTING_AUXPID2_OFFSET = 1013, +FSIO_SETTING_AUXPID2_MINVALUE = 1014, +FSIO_SETTING_AUXPID3_OFFSET = 1015, +FSIO_SETTING_AUXPID3_MINVALUE = 1016, +FSIO_SETTING_AUXPID4_OFFSET = 1017, +FSIO_SETTING_AUXPID4_MINVALUE = 1018, +FSIO_SETTING_IDLETIMINGPID_OFFSET = 1019, +FSIO_SETTING_IDLETIMINGPID_MINVALUE = 1020, diff --git a/firmware/gen_config.bat b/firmware/gen_config.bat index 0d486c5791..54b3856818 100644 --- a/firmware/gen_config.bat +++ b/firmware/gen_config.bat @@ -18,8 +18,9 @@ java -DSystemOut.name=gen_config ^ -ts_destination tunerstudio ^ -with_c_defines false ^ -initialize_to_zero false ^ - -c_defines controllers\generated\rusefi_generated.h ^ - -c_destination controllers\generated\engine_configuration_generated_structures.h ^ + -c_defines controllers\generated\rusefi_generated.h ^ + -c_destination controllers\generated\engine_configuration_generated_structures.h ^ + -c_fsio_constants controllers\generated\fsio_enums_generated.def ^ -java_destination ../java_console/models/src/com/rusefi/config/generated/Fields.java ^ -romraider_destination ../java_console/rusefi.xml ^ -skip build/config.gen diff --git a/java_console/models/src/com/rusefi/config/generated/Fields.java b/java_console/models/src/com/rusefi/config/generated/Fields.java index d78da3ebbf..f72cf7cc28 100644 --- a/java_console/models/src/com/rusefi/config/generated/Fields.java +++ b/java_console/models/src/com/rusefi/config/generated/Fields.java @@ -1,8 +1,8 @@ package com.rusefi.config.generated; -// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Mon Sep 09 21:25:07 EDT 2019 +// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Tue Sep 10 22:45:42 EDT 2019 -// by class com.rusefi.output.JavaFieldsConsumer +// by class com.rusefi.output.FileJavaFieldsConsumer import com.rusefi.config.*; public class Fields { diff --git a/java_tools/configuration_definition/src/com/rusefi/ConfigDefinition.java b/java_tools/configuration_definition/src/com/rusefi/ConfigDefinition.java index 7ee15ed189..032f67ce8c 100644 --- a/java_tools/configuration_definition/src/com/rusefi/ConfigDefinition.java +++ b/java_tools/configuration_definition/src/com/rusefi/ConfigDefinition.java @@ -1,9 +1,6 @@ package com.rusefi; -import com.rusefi.output.CHeaderConsumer; -import com.rusefi.output.ConfigurationConsumer; -import com.rusefi.output.FileJavaFieldsConsumer; -import com.rusefi.output.TSProjectConsumer; +import com.rusefi.output.*; import com.rusefi.util.IoUtils; import com.rusefi.util.LazyFile; import com.rusefi.util.SystemOut; @@ -31,6 +28,7 @@ public class ConfigDefinition { private static final String KEY_ROM_INPUT = "-romraider"; public static final String KEY_TS_DESTINATION = "-ts_destination"; private static final String KEY_C_DESTINATION = "-c_destination"; + private static final String KEY_C_FSIO_CONSTANTS = "-c_fsio_constants"; private static final String KEY_C_DEFINES = "-c_defines"; private static final String KEY_WITH_C_DEFINES = "-with_c_defines"; private static final String KEY_JAVA_DESTINATION = "-java_destination"; @@ -65,9 +63,10 @@ public class ConfigDefinition { } String tsPath = null; - String destCHeader = null; - String destCDefines = null; - String javaDestination = null; + String destCHeaderFileName = null; + String destCDefinesFileName = null; + String destCFsioConstantsFileName = null; + String javaDestinationFileName = null; String romRaiderDestination = null; List prependFiles = new ArrayList<>(); String skipRebuildFile = null; @@ -81,15 +80,17 @@ public class ConfigDefinition { } else if (key.equals(KEY_TS_DESTINATION)) { tsPath = args[i + 1]; } else if (key.equals(KEY_C_DESTINATION)) { - destCHeader = args[i + 1]; + destCHeaderFileName = args[i + 1]; + } else if (key.equals(KEY_C_FSIO_CONSTANTS)) { + destCFsioConstantsFileName = args[i + 1]; } else if (key.equals(KEY_ZERO_INIT)) { needZeroInit = Boolean.parseBoolean(args[i + 1]); } else if (key.equals(KEY_WITH_C_DEFINES)) { CHeaderConsumer.withC_Defines = Boolean.parseBoolean(args[i + 1]); } else if (key.equals(KEY_C_DEFINES)) { - destCDefines = args[i + 1]; + destCDefinesFileName = args[i + 1]; } else if (key.equals(KEY_JAVA_DESTINATION)) { - javaDestination = args[i + 1]; + javaDestinationFileName = args[i + 1]; } else if (key.equals(KEY_ROMRAIDER_DESTINATION)) { romRaiderDestination = args[i + 1]; } else if (key.equals(KEY_PREPEND)) { @@ -124,15 +125,19 @@ public class ConfigDefinition { ReaderState state = new ReaderState(); List destinations = new ArrayList<>(); - if (destCHeader != null) { - destinations.add(new CHeaderConsumer(destCHeader)); + if (destCHeaderFileName != null) { + destinations.add(new CHeaderConsumer(destCHeaderFileName)); } if (tsPath != null) { CharArrayWriter tsWriter = new CharArrayWriter(); destinations.add(new TSProjectConsumer(tsWriter, tsPath, state)); } - if (javaDestination != null) { - destinations.add(new FileJavaFieldsConsumer(state, javaDestination)); + if (javaDestinationFileName != null) { + destinations.add(new FileJavaFieldsConsumer(state, javaDestinationFileName)); + } + + if (destCFsioConstantsFileName != null) { + destinations.add(new FileFsioSettingsConsumer(state, destCFsioConstantsFileName)); } if (destinations.isEmpty()) @@ -141,8 +146,8 @@ public class ConfigDefinition { - if (destCDefines != null) - VariableRegistry.INSTANCE.writeDefinesToFile(destCDefines); + if (destCDefinesFileName != null) + VariableRegistry.INSTANCE.writeDefinesToFile(destCDefinesFileName); if (romRaiderDestination != null && romRaiderInputFile != null) { String inputFileName = romRaiderInputFile + File.separator + ROM_RAIDER_XML_TEMPLATE; diff --git a/java_tools/configuration_definition/src/com/rusefi/output/FileFsioSettingsConsumer.java b/java_tools/configuration_definition/src/com/rusefi/output/FileFsioSettingsConsumer.java new file mode 100644 index 0000000000..2b48e65153 --- /dev/null +++ b/java_tools/configuration_definition/src/com/rusefi/output/FileFsioSettingsConsumer.java @@ -0,0 +1,30 @@ +package com.rusefi.output; + +import com.rusefi.ConfigDefinition; +import com.rusefi.ReaderState; +import com.rusefi.util.LazyFile; + +import java.io.IOException; + +import static com.rusefi.ConfigDefinition.EOL; + +public class FileFsioSettingsConsumer extends FsioSettingsConsumer { + private final LazyFile enumFile; + + public FileFsioSettingsConsumer(ReaderState state, String destCFsioConstantsFileName) { + super(state); + enumFile = new LazyFile(destCFsioConstantsFileName); + } + + @Override + public void startFile() { + enumFile.write("// this file " + ConfigDefinition.MESSAGE + ConfigDefinition.EOL + EOL); + enumFile.write("// by " + getClass() + EOL); + } + + @Override + public void endFile() throws IOException { + enumFile.write(enumDefinition.toString()); + enumFile.close(); + } +} diff --git a/java_tools/configuration_definition/src/com/rusefi/output/FsioSettingsConsumer.java b/java_tools/configuration_definition/src/com/rusefi/output/FsioSettingsConsumer.java index dbd0f48710..c6e2525c0c 100644 --- a/java_tools/configuration_definition/src/com/rusefi/output/FsioSettingsConsumer.java +++ b/java_tools/configuration_definition/src/com/rusefi/output/FsioSettingsConsumer.java @@ -7,9 +7,14 @@ import com.rusefi.ReaderState; import java.io.CharArrayWriter; import java.util.List; +/** + * Some configuration settings are exposed to FSIO + * Here we generate relevant FSIO constants and lookup code + */ + public abstract class FsioSettingsConsumer implements ConfigurationConsumer { private final CharArrayWriter content = new CharArrayWriter(); - private final CharArrayWriter enumDefinition = new CharArrayWriter(); + protected final CharArrayWriter enumDefinition = new CharArrayWriter(); private final ReaderState state; private int currentIndex = 1000; @@ -38,7 +43,6 @@ public abstract class FsioSettingsConsumer implements ConfigurationConsumer { for (int i = 0; i < tsFields.size(); i++) { ConfigField cf = tsFields.get(i); writeOneField(cf, prefix); - } } @@ -50,17 +54,14 @@ public abstract class FsioSettingsConsumer implements ConfigurationConsumer { return; } - if (configField.isFsioVisible()) { String nameWithPrefix = prefix + configField.getName(); - enumDefinition.append("FSIO_SETTING_" + nameWithPrefix.toUpperCase() + " = " + currentIndex++ + ",\n"); + enumDefinition.append("\tFSIO_SETTING_" + nameWithPrefix.toUpperCase() + " = " + currentIndex++ + ",\n"); content.append(nameWithPrefix + "\n"); } - - } } 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 f4146fc525..f2f153b8b0 100644 --- a/java_tools/configuration_definition/src/com/rusefi/test/ConfigFieldParserTest.java +++ b/java_tools/configuration_definition/src/com/rusefi/test/ConfigFieldParserTest.java @@ -101,12 +101,12 @@ public class ConfigFieldParserTest { "etb_minValue\n"); assertEquals(fsioSettingsConsumer.getEnumDefinition(), - "FSIO_SETTING_OFFSET = 1000,\n" + - "FSIO_SETTING_MINVALUE = 1001,\n" + - "FSIO_SETTING_ALTERNATORCONTROL_OFFSET = 1002,\n" + - "FSIO_SETTING_ALTERNATORCONTROL_MINVALUE = 1003,\n" + - "FSIO_SETTING_ETB_OFFSET = 1004,\n" + - "FSIO_SETTING_ETB_MINVALUE = 1005,\n"); + "\tFSIO_SETTING_OFFSET = 1000,\n" + + "\tFSIO_SETTING_MINVALUE = 1001,\n" + + "\tFSIO_SETTING_ALTERNATORCONTROL_OFFSET = 1002,\n" + + "\tFSIO_SETTING_ALTERNATORCONTROL_MINVALUE = 1003,\n" + + "\tFSIO_SETTING_ETB_OFFSET = 1004,\n" + + "\tFSIO_SETTING_ETB_MINVALUE = 1005,\n"); } }