only:EPIC: Improve toolset for default tune canned tune generation #4871

This commit is contained in:
rusefillc 2024-03-06 00:29:59 -05:00 committed by Andrey
parent 3bcfe85b8d
commit ae8125fd89
8 changed files with 47 additions and 10 deletions

View File

@ -90,6 +90,7 @@ jobs:
git status
git pull https://github.com/rusefi/rusefi master
git add 'simulator/generated/*xml'
git add 'simulator/generated/canned-tunes/*md'
echo "Status 3/3"
git status
OUT=$(git commit -am "Auto-generated default tune" 2>&1) || echo "commit failed, finding out why"

View File

@ -2,4 +2,7 @@
#include "bmw_m52.h"
void bmwM52() {
engineConfiguration->ignitionMode = IM_WASTED_SPARK;
engineConfiguration->cylindersCount = 6;
engineConfiguration->displacement = 3;
}

View File

@ -19,7 +19,10 @@ import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import static com.devexperts.logging.Logging.getLogging;
import static com.rusefi.ConfigFieldImpl.unquote;
@ -38,7 +41,7 @@ import static com.rusefi.tools.tune.WriteSimulatorConfiguration.INI_FILE_FOR_SIM
*/
public class TuneCanTool {
private static final Logging log = getLogging(TuneCanTool.class);
private static final String REPORTS_OUTPUT_FOLDER = "tune_reports";
private static final String REPORTS_OUTPUT_FOLDER = "generated\\canned-tunes";
public static final String SRC_TEST_RESOURCES = "src/test/resources/";
private static final String FOLDER = "generated";
@ -63,8 +66,9 @@ public class TuneCanTool {
// "C:\\stuff\\i\\canam-2022-short\\canam-progress-pnp-dec-29.msq", "comment");
// processREOtune(1507, Fields.engine_type_e_HELLEN_154_HYUNDAI_COUPE_BK2, "BK2");
processREOtune(1507, Fields.engine_type_e_HELLEN_154_HYUNDAI_COUPE_BK2, "COUPE-BK2");
processREOtune(1576, Fields.engine_type_e_HYUNDAI_PB, "PB");
processREOtune(1591, Fields.engine_type_e_BMW_M52, "M52");
// processREOtune(1490, Fields.engine_type_e_MRE_M111, "m111-alex");
// handle("Mitsubicha", 1258);
// handle("Scion-1NZ-FE", 1448);
@ -77,9 +81,9 @@ public class TuneCanTool {
*/
private static void processREOtune(int tuneId, int engineType, String key) throws JAXBException, IOException {
// compare specific internet tune to total global default
handle(key, tuneId, TuneCanTool.DEFAULT_TUNE);
handle(key + "-comparing-against-global-defaults", tuneId, TuneCanTool.DEFAULT_TUNE);
// compare same internet tune to default tune of specified engine type
handle(key + "-diff", tuneId, getDefaultTuneName(engineType));
handle(key + "-comparing-against-current-" + key + "-default", tuneId, getDefaultTuneName(engineType));
}
@NotNull
@ -204,6 +208,10 @@ public class TuneCanTool {
}
String cName = context + cf.getOriginalArrayName();
if (isHardwareProperty(cf.getName())) {
continue;
}
if (cf.getType().equals("boolean")) {
sb.append(TuneTools.getAssignmentCode(defaultValue, cName, unquote(customValue.getValue())));
continue;
@ -265,7 +273,6 @@ public class TuneCanTool {
continue;
}
if (!Node.isNumeric(customValue.getValue())) {
// todo: smarter logic for enums
@ -310,4 +317,23 @@ public class TuneCanTool {
return sb;
}
private final static Set<String> HARDWARE_PROPERTIES = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
static {
HARDWARE_PROPERTIES.addAll(Arrays.asList(
"invertPrimaryTriggerSignal",
"invertSecondaryTriggerSignal",
"invertCamVVTSignal",
"adcVcc",
"vbattDividerCoeff",
"isSdCardEnabled",
"is_enabled_spi_1",
"is_enabled_spi_2",
"is_enabled_spi_3"
));
}
private static boolean isHardwareProperty(String name) {
return HARDWARE_PROPERTIES.contains(name);
}
}

View File

@ -33,6 +33,7 @@ public class WriteSimulatorConfiguration {
// [CannedTunes] see 'rusEfiFunctionalTest.cpp' which exports default tunes into binary files for us
Fields.engine_type_e_MRE_M111,
Fields.engine_type_e_BMW_M52,
Fields.engine_type_e_MAZDA_MIATA_NB2,
Fields.engine_type_e_HONDA_K,
Fields.engine_type_e_HELLEN_154_HYUNDAI_COUPE_BK1,
Fields.engine_type_e_HELLEN_154_HYUNDAI_COUPE_BK2,
@ -42,6 +43,7 @@ public class WriteSimulatorConfiguration {
}) {
writeSpecificEngineType(type);
}
TuneCanTool.main(args);
} catch (Throwable e) {
log.error("Unfortunately", e);
System.exit(-1);

View File

@ -106,16 +106,12 @@ public class LoadOlderTuneTest {
" engineConfiguration->knockDetectionWindowStart = 35;\n" +
" // default 60.0\n" +
" 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" +
@ -124,7 +120,12 @@ public class LoadOlderTuneTest {
" engineConfiguration->startCrankingDuration = 7;\n" +
" // default \"Duty cycle\"\n" +
" engineConfiguration->tachPulseDurationAsDutyCycle = false;\n" +
" // defa", sb.substring(0, 3500));
" // default 0.5\n" +
" engineConfiguration->tachPulseDuractionMs = 4;\n" +
" // default 1.0\n" +
" engineConfiguration->tachPulsePerRev = 0;\n" +
" // default \"true\"\n" +
" engine", sb.substring(0, 3500));
}
@Test

View File

@ -55,6 +55,8 @@ endif
# Pretend we are all different hardware so that all canned engine configs are included
# [CannedTunes]
USE_OPT += -DHW_HELLEN_HYUNDAI=1
USE_OPT += -DHW_HELLEN_NB2=1
USE_OPT += -DHW_HELLEN=1
USE_OPT += -DHW_PROTEUS=1
USE_OPT += -DHW_MICRO_RUSEFI=1

View File

@ -0,0 +1 @@

View File

@ -186,6 +186,7 @@ void rusEfiFunctionalTest(void) {
for (auto const type : {
engine_type_e::MRE_M111,
engine_type_e::BMW_M52,
engine_type_e::MAZDA_MIATA_NB2,
engine_type_e::HONDA_K,
engine_type_e::HELLEN_154_HYUNDAI_COUPE_BK1,
engine_type_e::HELLEN_154_HYUNDAI_COUPE_BK2,