Tokenisation of multipler expressions #1735

This commit is contained in:
rusefi 2020-08-30 15:31:22 -04:00
parent 601fd541f9
commit 88bedcb978
4 changed files with 33 additions and 23 deletions

View File

@ -1303,8 +1303,8 @@ float[IGN_TPS_COUNT] ignitionTpsBins;;"TPS", 1, 0.0, 0, 100.0, 2
float tChargeAirCoefMin;;"Min tCharge Coeff.", 1, 0, 0.0, 1.0, 4
float tChargeAirCoefMax;;"Max tCharge Coeff.", 1, 0, 0.0, 1.0, 4
float tChargeAirFlowMax;;"Max Air Flow (kg/h)", 1, 0, 0.0, 1000.0, 1
float tChargeAirIncrLimit;;"tChange Increment Limit, deg/sec", 1, 0, 0.0, 100.0, 1
float tChargeAirDecrLimit;;"tChange Decrement Limit, deg/sec", 1, 0, 0.0, 100.0, 1
float tChargeAirIncrLimit;;"tChange Increment Limit (deg/sec)", 1, 0, 0.0, 100.0, 1
float tChargeAirDecrLimit;;"tChange Decrement Limit (deg/sec)", 1, 0, 0.0, 100.0, 1
#define tChargeMode_e_enum "RPM+TPS (Default)", "Air Mass Interpolation"
custom tChargeMode_e 4 bits, U32, @OFFSET@, [0:0], @@tChargeMode_e_enum@@
@ -1405,7 +1405,7 @@ float[CLT_CRANKING_CURVE_SIZE] cltCrankingCorr ;CLT-based cranking position m
float[IDLE_ADVANCE_CURVE_SIZE] idleAdvanceBins;Optional timing advance table for Idle (see useSeparateAdvanceForIdle);"RPM", 1, 0, 0.0, 18000, 2
float[IDLE_ADVANCE_CURVE_SIZE] idleAdvance ;Optional timing advance table for Idle (see useSeparateAdvanceForIdle);"deg", 1, 0, -20, 90, 2
float[IDLE_VE_CURVE_SIZE] idleVeBins;Optional VE table for Idle (see useSeparateVEForIdle);"RPM", 1, 0, 0.0, 18000, 2
float[IDLE_VE_CURVE_SIZE] idleVe; Optional VE table for Idle (see useSeparateVEForIdle);,"%", 1, 0, 0, 999.0, 2
float[IDLE_VE_CURVE_SIZE] idleVe; Optional VE table for Idle (see useSeparateVEForIdle);"%", 1, 0, 0, 999.0, 2
le_formula_t[FSIO_COMMAND_COUNT iterate] fsioFormulas;
le_formula_t timingMultiplier;

Binary file not shown.

View File

@ -7,7 +7,6 @@ import com.rusefi.util.Output;
import com.rusefi.util.SystemOut;
import java.io.*;
import java.util.Arrays;
import static com.rusefi.util.IoUtils.CHARSET;
import static com.rusefi.ConfigDefinition.EOL;
@ -62,6 +61,9 @@ public class TSProjectConsumer implements ConfigurationConsumer {
if (configField.getState().tsCustomLine.containsKey(configField.getType())) {
String bits = configField.getState().tsCustomLine.get(configField.getType());
if (!bits.startsWith("bits")) {
bits = handleTsInfo(bits, 5);
}
tsHeader.write("\t" + addTabsUpTo(nameWithPrefix, LENGTH));
int size = configField.getState().tsCustomSize.get(configField.getType());
@ -78,37 +80,41 @@ public class TSProjectConsumer implements ConfigurationConsumer {
tsHeader.write(TypesHelper.convertToTs(configField.getType()) + ",");
tsHeader.write("\t" + tsPosition + ",");
tsHeader.write("\t[" + configField.getArraySize() + "],");
tsHeader.write("\t" + configField.getTsInfo());
tsHeader.write("\t" + handleTsInfo(configField.getTsInfo(), 1));
tsPosition += configField.getArraySize() * configField.getElementSize();
} else {
tsHeader.write("\t" + addTabsUpTo(nameWithPrefix, LENGTH) + "\t\t= scalar, ");
tsHeader.write(TypesHelper.convertToTs(configField.getType()) + ",");
tsHeader.write("\t" + tsPosition + ",");
tsHeader.write("\t" + handleTsInfo(configField.getTsInfo()));
tsHeader.write("\t" + handleTsInfo(configField.getTsInfo(), 1));
tsPosition += configField.getArraySize() * configField.getElementSize();
}
tsHeader.write(EOL);
return tsPosition;
}
private static String handleTsInfo(String tsInfo) {
String[] fields = tsInfo.split("\\,");
if (fields.length > 1) {
/**
* Evaluate static math on .ini layer to simplify rusEFI java and rusEFI PHP project consumers
* https://github.com/rusefi/web_backend/issues/97
*/
fields[1] = " " + IniField.parseDouble(fields[1]);
}
StringBuilder sb = new StringBuilder();
for (String f : fields) {
if (sb.length() > 0) {
sb.append(",");
private static String handleTsInfo(String tsInfo, int mutliplierIndex) {
try {
String[] fields = tsInfo.split("\\,");
if (fields.length > mutliplierIndex) {
/**
* Evaluate static math on .ini layer to simplify rusEFI java and rusEFI PHP project consumers
* https://github.com/rusefi/web_backend/issues/97
*/
fields[mutliplierIndex] = " " + IniField.parseDouble(fields[mutliplierIndex]);
}
sb.append(f);
StringBuilder sb = new StringBuilder();
for (String f : fields) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(f);
}
return sb.toString();
} catch (Throwable e) {
throw new IllegalStateException("While parsing " + tsInfo, e);
}
return sb.toString();
}
private int writeTunerStudio(ConfigStructure configStructure, String prefix, Writer tsHeader, int tsPosition) throws IOException {

View File

@ -104,6 +104,9 @@ public class ConfigFieldParserTest {
public void expressionInMultiplier() throws IOException {
String test = "struct pid_s\n" +
"\tint16_t periodMs;PID dTime;\"ms\", {1/10}, 0, 0, 3000, 0\n" +
"\tint16_t periodMs2;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
"custom afr_table_t 4x4 array, U08, @OFFSET@, [4x4],\"deg\",\t {1/10}, 0, 0, 25.0, 1 \n" +
"afr_table_t afrTable;\t\t\n" +
"end_struct\n" +
"";
@ -117,8 +120,9 @@ public class ConfigFieldParserTest {
state.readBufferedReader(reader, Collections.singletonList(javaFieldsConsumer));
assertEquals("\tperiodMs\t\t\t\t\t\t= scalar, S16,\t0,\t\"ms\", 0.1, 0, 0, 3000, 0\n" +
"\talignmentFill_at_2\t\t\t\t= array, U08,\t2,\t[2],\t\"units\", 1, 0, -20, 100, 0\n" +
"; total TS size = 4\n", new String(writer.toCharArray()));
"\tperiodMs2\t\t\t\t\t\t= scalar, S16,\t2,\t\"ms\", 1.0, 0, 0, 3000, 0\n" +
"\tafrTable\t\t\t\t\t = array, U08, 4, [4x4],\"deg\", 0.1, 0, 0, 25.0, 1\n" +
"; total TS size = 20\n", new String(writer.toCharArray()));
}
@Test