Refactoring, technical debt: export more of trigger attributes into triggers.txt file #2077
This commit is contained in:
parent
73ca428217
commit
b0d2a7b8bd
|
@ -1816,8 +1816,8 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
|
|||
dialog = triggerConfiguration_settings, "Trigger Pattern"
|
||||
field = "!https://rusefi.com/s/trigger"
|
||||
field = "Trigger type", trigger_type
|
||||
field = "Total tooth count", trigger_customTotalToothCount, {trigger_type == 0}, {trigger_type == 0}
|
||||
field = "Missing/skipped tooth count", trigger_customSkippedToothCount, {trigger_type == 0}, {trigger_type == 0}
|
||||
field = "Total tooth count", trigger_customTotalToothCount, {trigger_type == @@TT_TT_TOOTHED_WHEEL@@}, {trigger_type == @@TT_TT_TOOTHED_WHEEL@@}
|
||||
field = "Missing/skipped tooth count", trigger_customSkippedToothCount, {trigger_type == @@TT_TT_TOOTHED_WHEEL@@}, {trigger_type == @@TT_TT_TOOTHED_WHEEL@@}
|
||||
|
||||
; see also in firmware '[doesTriggerImplyOperationMode]' tag
|
||||
field = "Operation mode / speed", ambiguousOperationMode
|
||||
|
|
|
@ -72,7 +72,7 @@ public class ReaderState {
|
|||
int index = line.indexOf(' ');
|
||||
String name = line.substring(0, index);
|
||||
|
||||
String autoEnumOptions = VariableRegistry.getEnumOptionsForTunerStudio(state.enumsReader, VariableRegistry.INSTANCE, name);
|
||||
String autoEnumOptions = VariableRegistry.INSTANCE.getEnumOptionsForTunerStudio(state.enumsReader, name);
|
||||
if (autoEnumOptions != null) {
|
||||
VariableRegistry.INSTANCE.register(name + "_auto_enum", autoEnumOptions);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.rusefi;
|
|||
import com.rusefi.enum_reader.Value;
|
||||
import com.rusefi.util.LazyFile;
|
||||
import com.rusefi.util.SystemOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -35,7 +34,8 @@ public class VariableRegistry {
|
|||
public VariableRegistry() {
|
||||
}
|
||||
|
||||
public static String getEnumOptionsForTunerStudio(EnumsReader enumsReader, VariableRegistry variableRegistry, String enumName) {
|
||||
@Nullable
|
||||
public TreeMap<Integer, String> resolveEnumValues(EnumsReader enumsReader, String enumName) {
|
||||
TreeMap<Integer, String> valueNameById = new TreeMap<>();
|
||||
|
||||
Map<String, Value> stringValueMap = enumsReader.getEnums().get(enumName);
|
||||
|
@ -48,13 +48,20 @@ public class VariableRegistry {
|
|||
if (isNumeric(value.getValue())) {
|
||||
valueNameById.put(value.getIntValue(), value.getName());
|
||||
} else {
|
||||
String valueFromRegistry = variableRegistry.get(value.getValue());
|
||||
String valueFromRegistry = get(value.getValue());
|
||||
if (valueFromRegistry == null)
|
||||
throw new IllegalStateException("No value for " + value);
|
||||
int intValue = Integer.parseInt(valueFromRegistry);
|
||||
valueNameById.put(intValue, value.getName());
|
||||
}
|
||||
}
|
||||
return valueNameById;
|
||||
}
|
||||
|
||||
public String getEnumOptionsForTunerStudio(EnumsReader enumsReader, String enumName) {
|
||||
TreeMap<Integer, String> valueNameById = resolveEnumValues(enumsReader, enumName);
|
||||
if (valueNameById == null)
|
||||
return null;
|
||||
|
||||
int maxValue = valueNameById.lastKey();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public class ConfigDefinitionTest {
|
|||
ConfigDefinition.readPrependValues(variableRegistry, FIRMWARE + File.separator + "integration/rusefi_config.txt");
|
||||
|
||||
|
||||
String sb = VariableRegistry.getEnumOptionsForTunerStudio(enumsReader, variableRegistry, "engine_type_e");
|
||||
String sb = variableRegistry.getEnumOptionsForTunerStudio(enumsReader, "engine_type_e");
|
||||
|
||||
System.out.println(sb);
|
||||
assertNotNull(sb);
|
||||
|
|
Loading…
Reference in New Issue