mirror of https://github.com/rusefi/rusefi.git
only:EPIC: Improve toolset for default tune canned tune generation #4871
This commit is contained in:
parent
b274bde160
commit
ebb0a42f84
|
@ -298,6 +298,30 @@ static void commonGenesisCoupe() {
|
|||
engineConfiguration->tpsAccelFractionDivisor = 3;
|
||||
// default "Throttle 2"
|
||||
engineConfiguration->etbFunctions[1] = DC_Wastegate;
|
||||
// default "false"
|
||||
engineConfiguration->useSeparateAdvanceForIdle = true;
|
||||
// default 0.0
|
||||
engineConfiguration->iacByTpsHoldTime = 2;
|
||||
// default 0.0
|
||||
engineConfiguration->iacByTpsDecayTime = 3;
|
||||
// default "false"
|
||||
engineConfiguration->useIdleTimingPidControl = true;
|
||||
// default "false"
|
||||
engineConfiguration->invertVvtControlExhaust = true;
|
||||
// default 33.0
|
||||
engineConfiguration->auxPid[0].offset = 38;
|
||||
// default 0.005
|
||||
engineConfiguration->auxPid[0].iFactor = 25.4;
|
||||
// default 0.0
|
||||
engineConfiguration->auxPid[0].dFactor = 0.1;
|
||||
// default 0.0
|
||||
engineConfiguration->auxPid[1].offset = 38;
|
||||
// default 0.0
|
||||
engineConfiguration->auxPid[1].pFactor = 2;
|
||||
// default 0.0
|
||||
engineConfiguration->auxPid[1].iFactor = 25.4;
|
||||
// default 0.0
|
||||
engineConfiguration->auxPid[1].dFactor = 0.2;
|
||||
// end of canned tune
|
||||
|
||||
strncpy(config->luaScript, R"(
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.opensr5.ini.IniFileModel;
|
|||
import com.rusefi.*;
|
||||
import com.rusefi.core.preferences.storage.Node;
|
||||
import com.rusefi.output.ConfigStructure;
|
||||
import com.rusefi.pinout.PinoutLogic;
|
||||
import com.rusefi.tune.xml.Constant;
|
||||
import com.rusefi.tune.xml.Msq;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -50,7 +49,8 @@ public class TuneCanTool {
|
|||
|
||||
RootHolder.ROOT = "../firmware/";
|
||||
|
||||
handle("BK2", 1507);
|
||||
// handle("BK2", 1507, simulatorDefaultTune);
|
||||
handle("BK2-diff", 1507, Msq.readTune(SIMULATED_PREFIX + "_95" + SIMULATED_SUFFIX));
|
||||
// handle("PB", 1502);
|
||||
// handle("Mitsubicha", 1258);
|
||||
// handle("Scion-1NZ-FE", 1448);
|
||||
|
@ -59,7 +59,7 @@ public class TuneCanTool {
|
|||
// handle("m111-alex", 1490);
|
||||
}
|
||||
|
||||
private static void handle(String vehicleName, int tuneId) throws JAXBException, IOException {
|
||||
private static void handle(String vehicleName, int tuneId, Msq currentTune) throws JAXBException, IOException {
|
||||
String localFileName = workingFolder + File.separator + tuneId + ".msq";
|
||||
String url = "https://rusefi.com/online/view.php?msq=" + tuneId;
|
||||
|
||||
|
@ -69,11 +69,14 @@ public class TuneCanTool {
|
|||
new File(reportsOutputFolder).mkdir();
|
||||
|
||||
Msq custom = Msq.readTune(localFileName);
|
||||
StringBuilder sb = TuneCanTool.getTunePatch(simulatorDefaultTune, custom, ini);
|
||||
StringBuilder sb = TuneCanTool.getTunePatch(currentTune, custom, ini);
|
||||
|
||||
FileWriter w = new FileWriter(reportsOutputFolder + "/" + vehicleName + ".md");
|
||||
String fileName = reportsOutputFolder + "/" + vehicleName + ".md";
|
||||
log.info("Writing to " + fileName);
|
||||
|
||||
FileWriter w = new FileWriter(fileName);
|
||||
w.append("# " + vehicleName + "\n\n");
|
||||
w.append("Tune " + url + "\n\n");
|
||||
w.append("// canned tune " + url + "\n\n");
|
||||
|
||||
w.append("```\n");
|
||||
w.append(sb);
|
||||
|
@ -135,14 +138,14 @@ public class TuneCanTool {
|
|||
boolean isSameValue = simplerSpaces(defaultValue.getValue()).equals(simplerSpaces(customValue.getValue()));
|
||||
if (!isSameValue) {
|
||||
// todo: what about stuff outside of engine_configuration_s?
|
||||
ConfigStructure s = state.getStructures().get("engine_configuration_s");
|
||||
// log.info("We have a custom value " + name);
|
||||
ConfigField cf = s.getTsFieldByName(name);
|
||||
StringBuffer context = new StringBuffer();
|
||||
|
||||
ConfigField cf = findField(state, name, context);
|
||||
if (cf == null) {
|
||||
log.info("Not found " + name);
|
||||
continue;
|
||||
}
|
||||
String cName = cf.getOriginalArrayName();
|
||||
String cName = context + cf.getOriginalArrayName();
|
||||
|
||||
if (cf.getType().equals("boolean")) {
|
||||
sb.append(TuneTools.getAssignmentCode(defaultValue, customValue.getName(), unquote(customValue.getValue())));
|
||||
|
@ -175,7 +178,7 @@ public class TuneCanTool {
|
|||
log.info(cf + " " + sourceCodeEnum + " " + customEnum + " " + ordinal);
|
||||
|
||||
String sourceCodeValue = sourceCodeEnum.findByValue(ordinal);
|
||||
sb.append(TuneTools.getAssignmentCode(defaultValue, customValue.getName(), sourceCodeValue));
|
||||
sb.append(TuneTools.getAssignmentCode(defaultValue, cName, sourceCodeValue));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -191,4 +194,38 @@ public class TuneCanTool {
|
|||
}
|
||||
return sb;
|
||||
}
|
||||
|
||||
private static ConfigField findField(ReaderStateImpl state, String name, StringBuffer context) {
|
||||
ConfigStructure s = state.getStructures().get("engine_configuration_s");
|
||||
// log.info("We have a custom value " + name);
|
||||
ConfigField cf = s.getTsFieldByName(name);
|
||||
if (cf != null) {
|
||||
return cf; // it was easy!
|
||||
}
|
||||
int fromIndex = 0;
|
||||
while (true) {
|
||||
fromIndex = name.indexOf('_', fromIndex);
|
||||
if (fromIndex == -1) {
|
||||
// no struct names
|
||||
return null;
|
||||
}
|
||||
String parentName = name.substring(0, fromIndex);
|
||||
cf = s.getTsFieldByName(parentName);
|
||||
String type = cf.getType();
|
||||
s = state.getStructures().get(type);
|
||||
|
||||
if (s != null) {
|
||||
String substring = name.substring(fromIndex + 1);
|
||||
ConfigField tsFieldByName = s.getTsFieldByName(substring);
|
||||
if (tsFieldByName == null) {
|
||||
log.info("Not located " + substring + " in " + s);
|
||||
} else {
|
||||
context.append(cf.getOriginalArrayName()).append(".");
|
||||
log.info("Located " + tsFieldByName + " in " + s);
|
||||
}
|
||||
return tsFieldByName;
|
||||
}
|
||||
fromIndex++; // skip underscore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ public class LoadOlderTuneTest {
|
|||
" engineConfiguration->ignitionMode = IM_ONE_COIL;\n" +
|
||||
" // default 4.0\n" +
|
||||
" engineConfiguration->cylindersCount = 4;\n" +
|
||||
" // default \"60/2\"\n" +
|
||||
" engineConfiguration->trigger.type = TT_ONE_PLUS_ONE;\n" +
|
||||
" // default 1000.0\n" +
|
||||
" engineConfiguration->tps1SecondaryMin = 0;\n" +
|
||||
" // default 0.0\n" +
|
||||
|
@ -75,13 +77,25 @@ public class LoadOlderTuneTest {
|
|||
" // default \"true\"\n" +
|
||||
" engineConfiguration->stepperForceParkingEveryRestart = false;\n" +
|
||||
" // default -20.0\n" +
|
||||
" engineConfiguration->idleRpmPid.minValue = 0;\n" +
|
||||
" // default 20.0\n" +
|
||||
" engineConfiguration->idleRpmPid.maxValue = 99;\n" +
|
||||
" // default -20.0\n" +
|
||||
" engineConfiguration->idlerpmpid_iTermMin = -200;\n" +
|
||||
" // default 20.0\n" +
|
||||
" engineConfiguration->idlerpmpid_iTermMax = 200;\n" +
|
||||
" // default 0.0\n" +
|
||||
" engineConfiguration->idleRpmPid.periodMs = 10;\n" +
|
||||
" // default 300.0\n" +
|
||||
" engineConfiguration->idlePidRpmUpperLimit = 0;\n" +
|
||||
" // default 5.0\n" +
|
||||
" engineConfiguration->idlePidDeactivationTpsThreshold = 2;\n" +
|
||||
" // default 0.10000000149011612\n" +
|
||||
" engineConfiguration->idleTimingPid.pFactor = 0;\n" +
|
||||
" // default -10.0\n" +
|
||||
" engineConfiguration->idleTimingPid.minValue = 0;\n" +
|
||||
" // default 10.0\n" +
|
||||
" engineConfiguration->idleTimingPid.maxValue = 0;\n" +
|
||||
" // default 0.0\n" +
|
||||
" engineConfiguration->warningPeriod = 10;\n" +
|
||||
" // default \"false\"\n" +
|
||||
|
@ -94,36 +108,23 @@ public class LoadOlderTuneTest {
|
|||
" engineConfiguration->knockDetectionWindowEnd = 135;\n" +
|
||||
" // default \"false\"\n" +
|
||||
" engineConfiguration->is_enabled_spi_3 = true;\n" +
|
||||
" // default 33.0\n" +
|
||||
" engineConfiguration->auxPid[0].offset = 0;\n" +
|
||||
" // default 2.0\n" +
|
||||
" engineConfiguration->auxPid[0].pFactor = 0;\n" +
|
||||
" // default 0.004999999888241291\n" +
|
||||
" engineConfiguration->auxPid[0].iFactor = 0;\n" +
|
||||
" // default 5.333333492279053\n" +
|
||||
" engineConfiguration->vbattDividerCoeff = 8.6;\n" +
|
||||
" // default 0.0\n" +
|
||||
" engineConfiguration->alternatorControl.minValue = 10;\n" +
|
||||
" // default \"DEFAULT\"\n" +
|
||||
" engineConfiguration->startStopButtonMode = 0;\n" +
|
||||
" // default 3.0\n" +
|
||||
" engineConfiguration->startCrankingDuration = 7;\n" +
|
||||
" // default \"Duty cycle\"\n" +
|
||||
" engineConfiguration->tachPulseDurationAsDutyCycle = false;\n" +
|
||||
" // default 0.5\n" +
|
||||
" engineConfiguration->tachPulseDuractionMs = 4;\n" +
|
||||
" // default 1.0\n" +
|
||||
" engineConfiguration->tachPulsePerRev = 0;\n" +
|
||||
" // default \"true\"\n" +
|
||||
" engineConfiguration->canReadEnabled = false;\n" +
|
||||
" // default \"None\"\n" +
|
||||
" engineConfiguration->canNbcType = CAN_BUS_MAZDA_RX8;\n" +
|
||||
" // default \"false\"\n" +
|
||||
" engineConfiguration->isSdCardEnabled = true;\n" +
|
||||
" // default \"Speed Density\"\n" +
|
||||
" engineConfiguration->fuelAlgorithm = LM_SPEED_DENSITY;\n" +
|
||||
" // default 300.0\n" +
|
||||
" engineConfiguration->boostCutPressure = 0;\n" +
|
||||
" // default 200.0\n" +
|
||||
" engineConfiguration->afterCrankingIACtaperDuration = 0;\n" +
|
||||
" // default 6.0\n" +
|
||||
" engineConfiguration->crankingTimingAngle = 0;\n" +
|
||||
" // default \"Fixed (auto taper)\"\n" +
|
||||
" engineConfiguration->useSeparateAdvanceForCranking = false;\n" +
|
||||
" // default 1.2000000476837158\n" +
|
||||
" engineConfiguration->postCra", sb.substring(0, 3500));
|
||||
" // defa", sb.substring(0, 3500));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
|
|
Loading…
Reference in New Issue