TS project: hide all invalid entries #1505

This commit is contained in:
rusefi 2020-06-17 20:33:17 -04:00
parent 2c83db49fb
commit 8293a92632
6 changed files with 51 additions and 22 deletions

View File

@ -244,10 +244,10 @@ int16_t rpm;+This sets the RPM limit below which the ECU will use cranking fuel
end_struct
#define debug_mode_e_enum "Alternator PID", "TPS acceleration enrichment", "INVALID", "Idle Control", "Engine Load accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "VVT input", "Cranking", "Timing", "Closed-loop fuel corr PID", "VSS", "SD card", "sr5", "Knock", "mode16", "Electronic Throttle", "Executor", "Bench Test / TS commands", "Aux Valves", "Analog inputs #1", "INSTANT_RPM", "FSIO_EXPRESSION", "Status", "CJ125", "CAN", "MAP", "Metrics", "ETB#2", "Ion Sense", "TLE8888", "Analog inputs #2", "Dwell Metric", "INVALID", "ETB Logic", "Boost Control", "Start/Stop", "Launch", "ETB Autotune", "Mode40"
custom debug_mode_e 4 bits, U32, @OFFSET@, [0:7], @@debug_mode_e_enum@@
custom debug_mode_e 4 bits, U32, @OFFSET@, [0:5], @@debug_mode_e_enum@@
#define vvt_mode_e_enum "Inactive", "Second half", "2GZ", "Miata NB2", "First half", "mode5", "mode6", "mode7"
custom vvt_mode_e 4 bits, U32, @OFFSET@, [0:3], @@vvt_mode_e_enum@@
custom vvt_mode_e 4 bits, U32, @OFFSET@, [0:2], @@vvt_mode_e_enum@@
#define mass_storage_e_enum "Auto", "Always", "Never", "INVALID"
custom mass_storage_e 4 bits, U32, @OFFSET@, [0:1], @@mass_storage_e_enum@@
@ -260,7 +260,7 @@ custom mass_storage_e 4 bits, U32, @OFFSET@, [0:1], @@mass_storage_e_enum@@
! todo: maybe convert fast ADC to software scheduler as well? less sure about that
#define brain_input_pin_e_enum "NONE", "INVALID", "INVALID", "PA1", "PA2", "PA3", "INVALID", "PA5", "PA6", "PA7", "PA8", "PA9", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PA15", "INVALID", "INVALID", "INVALID", "PB3", "PB4", "PB5", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PC6", "PC7", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PE5", "PE6", "INVALID", "INVALID", "PE9", "INVALID", "PE11", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
custom brain_input_pin_e 1 bits, U08, @OFFSET@, [0:7], @@brain_input_pin_e_enum@@
custom brain_input_pin_e 1 bits, U08, @OFFSET@, [0:6], @@brain_input_pin_e_enum@@
!
! 'brain_pin_e' is the most flexible kind of pin
@ -312,7 +312,7 @@ struct gppwm_channel
gppwm_table_t table;
end_struct
custom air_pressure_sensor_type_e 4 bits, U32, @OFFSET@, [0:4] "Custom", "DENSO183", "MPX4250", "HONDA3BAR", "NEON_2003", "22012AA090", "3 Bar", "MPX4100", "Toyota 89420-02010", "MPX4250A", "Bosch 2.5", "Mazda1Bar", "type12", "type13", "INVALID", "INVALID"
custom air_pressure_sensor_type_e 4 bits, U32, @OFFSET@, [0:3] "Custom", "DENSO183", "MPX4250", "HONDA3BAR", "NEON_2003", "22012AA090", "3 Bar", "MPX4100", "Toyota 89420-02010", "MPX4250A", "Bosch 2.5", "Mazda1Bar", "type12", "type13", "INVALID", "INVALID"
!
! lower 16 values are used on stm32 rusEfi, values above 16 are related to Kinetis work in progress
@ -362,7 +362,7 @@ struct ThermistorConf @brief Thermistor curve parameters
adc_channel_e adcChannel;
end_struct
custom engine_type_e 4 bits, S32, @OFFSET@, [0:7], "AUDI_AAN", "DODGE_NEON_1995", "FORD_ASPIRE_1996", "FORD_FIESTA", "NISSAN_PRIMERA", "HONDA_ACCORD", "FORD_INLINE_6_1995", "GY6_139QMB"
custom engine_type_e 4 bits, S32, @OFFSET@, [0:2], "AUDI_AAN", "DODGE_NEON_1995", "FORD_ASPIRE_1996", "FORD_FIESTA", "NISSAN_PRIMERA", "HONDA_ACCORD", "FORD_INLINE_6_1995", "GY6_139QMB"
engine_type_e engineType;http://rusefi.com/wiki/index.php?title=Manual:Engine_Type\nset engine_type X
int engineSnifferRpmThreshold;Engine sniffer would be disabled above this rpm\nset engineSnifferRpmThreshold X;"RPM", 1, 0, 0,30000, 0
@ -1007,7 +1007,7 @@ float[BARO_CORR_SIZE] baroCorrRpmBins;;"RPM", 1, 0, 0.0, 18000,
baro_corr_table_t baroCorrTable;
#define pin_mode_e_enum "default", "INVALID", "INVALID", "INVALID", "opendrain", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PULLUP", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PULLDOWN"
custom pin_mode_e 1 bits, U08, @OFFSET@, [0:7], @@pin_mode_e_enum@@
custom pin_mode_e 1 bits, U08, @OFFSET@, [0:6], @@pin_mode_e_enum@@
float[CRANKING_CURVE_SIZE] crankingTpsCoef;Cranking fuel correction coefficient based on TPS;"Ratio", 1, 0, 0.0, 700.0, 2

View File

@ -113,15 +113,35 @@ public class EnumIniField extends IniField {
int offset = Integer.parseInt(list.get(3));
String bitRange = list.get(4);
bitRange = bitRange.replaceAll("[\\]\\[:]", " ").trim();
String bitPositions[] = bitRange.split(" ");
if (bitPositions.length != 2)
throw new IllegalStateException("Bit position " + bitRange);
int bitPosition = Integer.parseInt(bitPositions[0]);
int bitSize0 = Integer.parseInt(bitPositions[1]) - bitPosition;
ParseBitRange parseBitRange = new ParseBitRange().invoke(bitRange);
int bitPosition = parseBitRange.getBitPosition();
int bitSize0 = parseBitRange.getBitSize0();
List<String> enums = list.subList(5, list.size());
return new EnumIniField(name, offset, type, enums, bitPosition, bitSize0);
}
public static class ParseBitRange {
private int bitPosition;
private int bitSize0;
public int getBitPosition() {
return bitPosition;
}
public int getBitSize0() {
return bitSize0;
}
public ParseBitRange invoke(String bitRange) {
bitRange = bitRange.replaceAll("[\\]\\[:]", " ").trim();
String bitPositions[] = bitRange.split(" ");
if (bitPositions.length != 2)
throw new IllegalStateException("Bit position " + bitRange);
bitPosition = Integer.parseInt(bitPositions[0]);
bitSize0 = Integer.parseInt(bitPositions[1]) - bitPosition;
return this;
}
}
}

Binary file not shown.

View File

@ -1,20 +1,19 @@
package com.rusefi;
import com.opensr5.ini.RawIniFile;
import com.opensr5.ini.field.EnumIniField;
import com.rusefi.output.ConfigurationConsumer;
import com.rusefi.util.SystemOut;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;
import java.util.*;
import static com.rusefi.ConfigField.BOOLEAN_T;
/**
* We keep state here as we read configuration definition
*
* <p>
* Andrey Belomutskiy, (c) 2013-2020
* 12/19/18
*/
@ -77,6 +76,18 @@ public class ReaderState {
tunerStudioLine = VariableRegistry.INSTANCE.applyVariables(tunerStudioLine);
int size = parseSize(customSize, line);
state.tsCustomSize.put(name, size);
RawIniFile.Line rawLine = new RawIniFile.Line(tunerStudioLine);
if (rawLine.getTokens()[0].equals("bits")) {
EnumIniField.ParseBitRange bitRange = new EnumIniField.ParseBitRange().invoke(rawLine.getTokens()[3]);
int totalCount = 1 << (bitRange.getBitSize0() + 1);
List<String> enums = Arrays.asList(rawLine.getTokens()).subList(4, rawLine.getTokens().length);
if (enums.size() > totalCount)
throw new IllegalStateException("Too many options in " + tunerStudioLine + " capacity=" + totalCount + "/size=" + enums.size());
if (enums.size() <= totalCount / 2)
throw new IllegalStateException("Too many bits allocated for " + enums + " capacity=" + totalCount + "/size=" + enums.size());
}
state.tsCustomLine.put(name, tunerStudioLine);
}
@ -214,7 +225,7 @@ public class ReaderState {
structure.addAlignmentFill(state);
} else {
// adding a structure instance - had to be aligned
// todo? structure.addAlignmentFill(state);
// todo? structure.addAlignmentFill(state);
}
if (cf.isIterate()) {

View File

@ -62,8 +62,6 @@ public class TSProjectConsumer implements ConfigurationConsumer {
if (configField.getState().tsCustomLine.containsKey(configField.getType())) {
String bits = configField.getState().tsCustomLine.get(configField.getType());
RawIniFile.Line line = new RawIniFile.Line(bits);
tsHeader.write("\t" + addTabsUpTo(nameWithPrefix, LENGTH));
int size = configField.getState().tsCustomSize.get(configField.getType());
// tsHeader.headerWrite("\t" + size + ",");

View File

@ -38,7 +38,7 @@ public class ConfigFieldParserTest {
public void testCustomEnum() throws IOException {
String test = "struct pid_s\n" +
"#define ego_sensor_e_enum \"BPSX\", \"Innovate\", \"14Point7\"\n" +
"custom ego_sensor_e 4 bits, S32, @OFFSET@, [0:2], @@ego_sensor_e_enum@@\n" +
"custom ego_sensor_e 4 bits, S32, @OFFSET@, [0:1], @@ego_sensor_e_enum@@\n" +
"ego_sensor_e afr_type;\n" +
"end_struct\n";
ReaderState state = new ReaderState();
@ -47,7 +47,7 @@ public class ConfigFieldParserTest {
CharArrayWriter writer = new CharArrayWriter();
TestTSProjectConsumer javaFieldsConsumer = new TestTSProjectConsumer(writer, "", state);
state.readBufferedReader(reader, Arrays.asList(javaFieldsConsumer));
assertEquals("\tafr_type\t\t\t\t\t = bits, S32, 0, [0:2], \"BPSX\", \"Innovate\", \"14Point7\"\n" +
assertEquals("\tafr_type\t\t\t\t\t = bits, S32, 0, [0:1], \"BPSX\", \"Innovate\", \"14Point7\"\n" +
"; total TS size = 4\n", new String(writer.toCharArray()));
}