new parser TS output fixes, config file fixes (#4261)

* new parser TS output fixes, config file fixes

* jar
This commit is contained in:
Matthew Kennedy 2022-06-18 22:24:50 +01:00 committed by GitHub
parent cc6fcfefdc
commit aa7a404a44
9 changed files with 57 additions and 48 deletions

View File

@ -335,7 +335,7 @@ custom brain_input_pin_e 2 bits, U16, @OFFSET@, [0:7], @@brain_input_pin_e_enum@
#define switch_input_pin_e_enum "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "PF0", "PF1", "PF2", "PF3", "PF4", "PF5", "PF6", "PF7", "PF8", "PF9", "PF10", "PF11", "PF12", "PF13", "PF14", "PF15", "PG0", "PG1", "PG2", "PG3", "PG4", "PG5", "PG6", "PG7", "PG8", "PG9", "PG10", "PG11", "PG12", "PG13", "PG14", "PG15", "PH0", "PH1", "PH2", "PH3", "PH4", "PH5", "PH6", "PH7", "PH8", "PH9", "PH10", "PH11", "PH12", "PH13", "PH14", "PH15", "PI0", "PI1", "PI2", "PI3", "PI4", "PI5", "PI6", "PI7", "PI8", "PI9", "PI10", "PI11", "PI12", "PI13", "PI14", "PI15"
custom Gpio 2 bits, U16, @OFFSET@, [0:7], @@Gpio_enum@@
custom switch_input_pin_e 2 bits, U08, @OFFSET@, [0:7], @@switch_input_pin_e_enum@@
custom switch_input_pin_e 2 bits, U16, @OFFSET@, [0:7], @@switch_input_pin_e_enum@@
#define output_pin_e_enum "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "PF0", "PF1", "PF2", "PF3", "PF4", "PF5", "PF6", "PF7", "PF8", "PF9", "PF10", "PF11", "PF12", "PF13", "PF14", "PF15", "PG0", "PG1", "PG2", "PG3", "PG4", "PG5", "PG6", "PG7", "PG8", "PG9", "PG10", "PG11", "PG12", "PG13", "PG14", "PG15", "PH0", "PH1", "PH2", "PH3", "PH4", "PH5", "PH6", "PH7", "PH8", "PH9", "PH10", "PH11", "PH12", "PH13", "PH14", "PH15", "PI0", "PI1", "PI2", "PI3", "PI4", "PI5", "PI6", "PI7", "PI8", "PI9", "PI10", "PI11", "PI12", "PI13", "PI14", "PI15", "MC33972_1", "MC33972_2", "MC33972_3", "MC33972_4", "MC33972_5", "MC33972_6", "MC33972_7", "MC33972_8", "MC33972_9", "MC33972_10", "MC33972_11", "MC33972_12", "MC33972_13", "MC33972_14", "MC33972_15", "MC33972_16", "MC33972_17", "MC33972_18", "MC33972_19", "MC33972_20", "MC33972_21", "MC33972_22", "TLE8888_1", "TLE8888_2", "TLE8888_3", "TLE8888_4", "TLE8888_5", "TLE8888_6", "TLE8888_7", "TLE8888_8", "TLE8888_9", "TLE8888_10", "TLE8888_11", "TLE8888_12", "TLE8888_13", "TLE8888_14", "TLE8888_15", "TLE8888_16", "TLE8888_17", "TLE8888_18", "TLE8888_19", "TLE8888_20", "TLE8888_21", "TLE8888_22", "TLE8888_23", "TLE8888_24", "TLE8888_25", "TLE8888_26", "TLE8888_27", "TLE8888_28", "INVALID", "INVALID", "INVALID", "TLE6240_1", "TLE6240_2", "TLE6240_3", "TLE6240_4", "TLE6240_5", "TLE6240_6", "TLE6240_7", "TLE6240_8", "TLE6240_9", "TLE6240_10", "TLE6240_11", "TLE6240_12", "TLE6240_13", "TLE6240_14", "TLE6240_15", "TLE6240_16"
custom output_pin_e 2 bits, U16, @OFFSET@, [0:7], @@output_pin_e_enum@@
@ -604,7 +604,7 @@ float globalFuelCorrection;set global_fuel_correction X;"coef", 1, 0, 0, 1000, 2
float adcVcc;;"volts", 1, 0, 0, 6, 3
float mapCamDetectionAnglePosition;;"Deg", 1, 0, 0, 360, 0
brain_input_pin_e[CAM_INPUTS_COUNT iterate] camInputs;+Camshaft input could be used either just for engine phase detection if your trigger shape does not include cam sensor as 'primary' channel, or it could be used for Variable Valve timing on one of the camshafts.
brain_input_pin_e[CAM_INPUTS_COUNT iterate] camInputs;Camshaft input could be used either just for engine phase detection if your trigger shape does not include cam sensor as 'primary' channel, or it could be used for Variable Valve timing on one of the camshafts.
uint8_t[CAM_INPUTS_COUNT_padding] camInputsPadding;;
struct afr_sensor_s
@ -987,7 +987,7 @@ bit verboseCan2,"Print all","Do not print";Print incoming and outgoing second bu
output_pin_e[LUA_PWM_COUNT iterate] luaOutputPins
float[CAM_INPUTS_COUNT iterate] vvtOffsets;+Angle between cam sensor and VVT zero position\nset vvt_offset X;"value", 1, 0, -720, 1000, 1
float[CAM_INPUTS_COUNT iterate] vvtOffsets;Angle between cam sensor and VVT zero position\nset vvt_offset X;"value", 1, 0, -720, 1000, 1
float[CAM_INPUTS_COUNT_padding] vvtOffsetsPadding;;
struct vr_threshold_s
@ -1393,7 +1393,7 @@ tChargeMode_e tChargeMode;
float etbIdleThrottleRange;+This sets the range of the idle control on the ETB. At 100% idle position, the value specified here sets the base ETB position.;"%", 1, 0, 0, 15, 0
uint8_t[MAX_CYLINDER_COUNT iterate] cylinderBankSelect;+Select which fuel correction bank this cylinder belongs to. Group cylinders that share the same O2 sensor;"", 1, 1, 1, 2, 0
uint8_t[MAX_CYLINDER_COUNT iterate] cylinderBankSelect;Select which fuel correction bank this cylinder belongs to. Group cylinders that share the same O2 sensor;"", 1, 1, 1, 2, 0
uint8_t[8] autoscale primeValues;;"mg", 5, 0, 0, 1250, 0
@ -1433,7 +1433,7 @@ tChargeMode_e tChargeMode;
uint8_t autoscale maxCamPhaseResolveRpm;Below this RPM, use camshaft information to synchronize the crank's position for full sequential operation. Use this if your cam sensor does weird things at high RPM. Set to 0 to disable, and always use cam to help sync crank.;"rpm", 50, 0, 0, 12500, 0
int8_t[11] unused4080;;"",1,0,0,0,0
int8_t[11] unused4080;;"", 1, 0, 0, 0, 0
float[GAP_TRACKING_LENGTH iterate] triggerGapOverrideTo;;"to", 1, 0, 0, 20, 2

Binary file not shown.

View File

@ -190,6 +190,10 @@ public class ConfigDefinition {
new TriggerWheelTSLogic().execute(triggersFolder, state.variableRegistry);
if (pinoutLogic != null) {
pinoutLogic.registerBoardSpecificPinNames(state.variableRegistry, state, parseState);
}
// Parse the input files
{
// Load prepend files
@ -215,7 +219,7 @@ public class ConfigDefinition {
// Write tunerstudio layout
// TsWriter writer = new TsWriter();
// writer.writeTunerstudio(parseState, tsPath + "/rusefi.input", tsPath + "/" + TSProjectConsumer.TS_FILE_OUTPUT_NAME);
// writer.writeTunerstudio(parseState, tsInputFileFolder + "/rusefi.input", tsInputFileFolder + "/" + state.tsFileOutputName);
}
if (tsOutputsDestination != null) {
@ -239,10 +243,6 @@ public class ConfigDefinition {
if (state.destinations.isEmpty())
throw new IllegalArgumentException("No destinations specified");
if (pinoutLogic != null) {
pinoutLogic.registerBoardSpecificPinNames(state.variableRegistry, state);
}
state.doJob();
if (destCDefinesFileName != null) {

View File

@ -2,6 +2,8 @@ package com.rusefi;
import com.devexperts.logging.Logging;
import com.rusefi.enum_reader.Value;
import com.rusefi.newparse.ParseState;
import com.rusefi.newparse.parsing.Definition;
import com.rusefi.util.SystemOut;
import org.jetbrains.annotations.NotNull;
import org.yaml.snakeyaml.Yaml;
@ -43,7 +45,7 @@ public class PinoutLogic {
return null;
}
private static void registerPins(String boardName, ArrayList<PinState> listPins, VariableRegistry registry, ReaderState state) {
private static void registerPins(String boardName, ArrayList<PinState> listPins, VariableRegistry registry, ReaderState state, ParseState parseState) {
if (listPins == null || listPins.isEmpty()) {
return;
}
@ -84,8 +86,10 @@ public class PinoutLogic {
EnumPair pair = enumToOptionsList(nothingName, enumList, kv.getValue());
if (pair.getSimpleForm().length() > 0) {
registry.register(outputEnumName + ENUM_SUFFIX, pair.getShorterForm());
parseState.addDefinition(outputEnumName + ENUM_SUFFIX, pair.getShorterForm(), Definition.OverwritePolicy.IgnoreNew);
}
registry.register(outputEnumName + FULL_JAVA_ENUM, pair.getSimpleForm());
parseState.addDefinition(outputEnumName + FULL_JAVA_ENUM, pair.getSimpleForm(), Definition.OverwritePolicy.IgnoreNew);
}
}
@ -209,9 +213,9 @@ public class PinoutLogic {
return new PinoutLogic(boardName, boardYamlFiles);
}
public void registerBoardSpecificPinNames(VariableRegistry registry, ReaderState state) throws IOException {
public void registerBoardSpecificPinNames(VariableRegistry registry, ReaderState state, ParseState parseState) throws IOException {
readFiles();
registerPins(boardName, globalList, registry, state);
registerPins(boardName, globalList, registry, state, parseState);
try (FileWriter getTsNameByIdFile = new FileWriter(PinoutLogic.CONFIG_BOARDS + boardName + PinoutLogic.CONNECTORS + File.separator + "generated_ts_name_by_pin.cpp")) {
getTsNameByIdFile.append(header);

View File

@ -204,14 +204,8 @@ public class ParseState {
@Override
public void enterEnumTypedefSuffix(RusefiConfigGrammarParser.EnumTypedefSuffixContext ctx) {
String replacementIdent = ctx.replacementIdent().getText();
int endBit;
if (replacementIdent == null) {
RusefiConfigGrammarParser.IntegerContext integer = ctx.integer(2);
endBit = Integer.parseInt(integer.getText());
} else {
endBit = Integer.parseInt(replacementIdent);
}
int endBit = Integer.parseInt(ctx.integer(1).getText());
Type datatype = Type.findByTsType(ctx.Datatype().getText());
String rhs = ctx.enumRhs().getText();
@ -296,10 +290,10 @@ public class ParseState {
// this is a legacy field option list, parse it as such
if (!ctx.numexpr().isEmpty()) {
options.units = ctx.QuotedString().getText();
options.scale = evalResults.remove().floatValue();
options.offset = evalResults.remove().floatValue();
options.min = evalResults.remove().floatValue();
options.max = evalResults.remove().floatValue();
options.scale = evalResults.remove();
options.offset = evalResults.remove();
options.min = evalResults.remove();
options.max = evalResults.remove();
options.digits = Integer.parseInt(ctx.integer().getText());
// we should have consumed everything on the results list
@ -329,16 +323,16 @@ public class ParseState {
switch (key) {
case "min":
options.min = value.floatValue();
options.min = value;
break;
case "max":
options.max = value.floatValue();
options.max = value;
break;
case "scale":
options.scale = value.floatValue();
options.scale = value;
break;
case "offset":
options.offset = value.floatValue();
options.offset = value;
break;
}
break;
@ -383,8 +377,11 @@ public class ParseState {
scope.structFields.add(new EnumField(bTypedef.type, type, name, bTypedef.endBit, bTypedef.values, options));
return;
} else if (typedef instanceof StringTypedef) {
options = new FieldOptions();
handleFieldOptionsList(options, ctx.fieldOptionsList());
StringTypedef sTypedef = (StringTypedef) typedef;
scope.structFields.add(new StringField(name, sTypedef.size));
scope.structFields.add(new StringField(name, sTypedef.size, options.comment));
return;
} else {
// TODO: throw
@ -492,7 +489,10 @@ public class ParseState {
// iterate required for strings
assert(iterate);
StringField prototype = new StringField(name, sTypedef.size);
options = new FieldOptions();
handleFieldOptionsList(options, ctx.fieldOptionsList());
StringField prototype = new StringField(name, sTypedef.size, options.comment);
scope.structFields.add(new ArrayField<>(prototype, length, iterate));
return;
} else {

View File

@ -86,9 +86,9 @@ public class ScalarLayout extends Layout {
}
private String makeScaleString() {
float scale = this.options.scale;
double scale = this.options.scale;
int mul, div;
long mul, div;
if (scale < 1) {
mul = Math.round(1 / scale);
@ -98,9 +98,9 @@ public class ScalarLayout extends Layout {
div = Math.round(scale);
}
float actualScale = (float)mul / div;
double actualScale = (double)mul / div;
if (mul < 1 || div < 1 || (Math.abs(scale - actualScale) < 0.0001f)) {
if (mul < 1 || div < 1 || (Math.abs(scale - actualScale) < 0.0001)) {
throw new RuntimeException("assertion failure: scale string generation failure for " + this.name);
}

View File

@ -8,10 +8,12 @@ import java.io.PrintStream;
public class StringLayout extends Layout {
private final String name;
private final int size;
private final String comment;
public StringLayout(StringField field) {
this.name = field.name;
this.size = field.size;
this.comment = field.comment;
}
@Override
@ -41,8 +43,9 @@ public class StringLayout extends Layout {
ps.println();
// TODO: write string comments
// meta.addComment(name, ??);
if (!this.comment.isEmpty()) {
meta.addComment(name, comment);
}
}
@Override

View File

@ -3,10 +3,10 @@ package com.rusefi.newparse.parsing;
import java.io.PrintStream;
public class FieldOptions {
public float min;
public float max;
public float scale;
public float offset;
public double min;
public double max;
public double scale;
public double offset;
public int digits;
public String units;
public String comment;
@ -36,14 +36,14 @@ public class FieldOptions {
return other;
}
public static String tryRound(float value) {
int intVal = Math.round(value);
public static String tryRound(double value) {
long longVal = Math.round(value);
// If the rounded value can exactly represent this float, then print as an integer
if (value == intVal) {
return Integer.toString(intVal);
if (value == longVal) {
return Long.toString(longVal);
} else {
return Float.toString(value);
return Double.toString(value);
}
}

View File

@ -1,11 +1,13 @@
package com.rusefi.newparse.parsing;
public class StringField extends PrototypeField{
public class StringField extends PrototypeField {
public final int size;
public final String comment;
public StringField(String name, int size) {
public StringField(String name, int size, String comment) {
super(name);
this.size = size;
this.comment = comment;
}
}