only:smarter default tunes output folder

This commit is contained in:
Andrey 2024-10-08 22:57:09 -04:00 committed by rusefi
parent 6820539e2a
commit a27285b4f6
5 changed files with 28 additions and 27 deletions

View File

@ -60,7 +60,10 @@ jobs:
- name: Convert .bin from Linux Simulator into .xml - name: Convert .bin from Linux Simulator into .xml
working-directory: ./simulator/ working-directory: ./simulator/
run: ./write_tune.sh ../firmware/tunerstudio/generated/rusefi_f407-discovery.ini run: |
export DEFAULT_TUNE_OUTPUT_FOLDER=../simulator/generated/
echo "DEFAULT_TUNE_OUTPUT_FOLDER=$DEFAULT_TUNE_OUTPUT_FOLDER"
./write_tune.sh ../firmware/tunerstudio/generated/rusefi_f407-discovery.ini
- name: Commit fresh generated default simulator tune - name: Commit fresh generated default simulator tune
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master'}} if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master'}}

View File

@ -122,6 +122,7 @@ runs:
: Echo : Echo
echo "rusefi_dir=${{inputs.rusefi_dir}}" echo "rusefi_dir=${{inputs.rusefi_dir}}"
echo "meta_info=${{inputs.meta_info}}" echo "meta_info=${{inputs.meta_info}}"
echo "sim_output=${{inputs.sim_output}}"
- name: Checkout Submodules - name: Checkout Submodules
working-directory: ${{inputs.rusefi_dir}} working-directory: ${{inputs.rusefi_dir}}
@ -163,7 +164,7 @@ runs:
shopt -s expand_aliases shopt -s expand_aliases
if which grealpath >/dev/null 2>&1; then alias realpath='grealpath'; fi if which grealpath >/dev/null 2>&1; then alias realpath='grealpath'; fi
echo "META_OUTPUT_ROOT_FOLDER=$(realpath --relative-to=${{inputs.rusefi_dir}}/firmware ${{inputs.meta_output}})/" >> $GITHUB_ENV echo "META_OUTPUT_ROOT_FOLDER=$(realpath --relative-to=${{inputs.rusefi_dir}}/firmware ${{inputs.meta_output}})/" >> $GITHUB_ENV
echo "SIM_OUTPUT_ROOT_FOLDER=$(realpath --relative-to=${{inputs.rusefi_dir}}/firmware ${{inputs.sim_output}})/" >> $GITHUB_ENV echo "DEFAULT_TUNE_OUTPUT_FOLDER=$(realpath --relative-to=${{inputs.rusefi_dir}}/firmware ${{inputs.sim_output}})/" >> $GITHUB_ENV
source ${{inputs.rusefi_dir}}/firmware/config/boards/common_script_read_meta_env.inc "${{inputs.meta_info}}" source ${{inputs.rusefi_dir}}/firmware/config/boards/common_script_read_meta_env.inc "${{inputs.meta_info}}"
cd ${{inputs.rusefi_dir}}/firmware cd ${{inputs.rusefi_dir}}/firmware
ABSOLUTE_BOARD_DIR=${{github.workspace}}/$BOARD_DIR ABSOLUTE_BOARD_DIR=${{github.workspace}}/$BOARD_DIR
@ -339,16 +340,8 @@ runs:
: Run Simulator : Run Simulator
cd ${{inputs.rusefi_dir}}/simulator/ cd ${{inputs.rusefi_dir}}/simulator/
./build/rusefi_simulator 10 ./build/rusefi_simulator 10
mkdir -p ${{inputs.sim_output}}canned-tunes
./write_tune.sh ${ABSOLUTE_BOARD_DIR}/generated/tunerstudio/generated/rusefi_${SHORT_BOARD_NAME}.ini ./write_tune.sh ${ABSOLUTE_BOARD_DIR}/generated/tunerstudio/generated/rusefi_${SHORT_BOARD_NAME}.ini
cd $OLDPWD
echo "action.yaml: Current directory: $PWD"
if [ ! "${{inputs.sim_output}}" -ef "${{inputs.rusefi_dir}}/simulator/generated" ]; then
ls ${{inputs.rusefi_dir}}/simulator/generated/
mkdir -p ${{inputs.sim_output}}canned-tunes
cp -v ${{inputs.rusefi_dir}}/simulator/generated/*.msq ${{inputs.sim_output}}
cp -v ${{inputs.rusefi_dir}}/simulator/generated/canned-tunes/*.md ${{inputs.sim_output}}canned-tunes
ls ${{inputs.sim_output}}
fi
- name: Add Tune to Commit - name: Add Tune to Commit
if: ${{ inputs.run_simulator == 'true' && inputs.push == 'true' }} if: ${{ inputs.run_simulator == 'true' && inputs.push == 'true' }}

View File

@ -44,19 +44,23 @@ import static com.rusefi.LocalIniFileProvider.INI_FILE_FOR_SIMULATOR;
*/ */
public class TuneCanTool { public class TuneCanTool {
private static final Logging log = getLogging(TuneCanTool.class); private static final Logging log = getLogging(TuneCanTool.class);
private static final String REPORTS_OUTPUT_FOLDER = "generated/canned-tunes"; private static final String REPORTS_OUTPUT_FOLDER = "canned-tunes";
private static final String FOLDER = "generated"; public static final String SIMULATED_PREFIX = "simulator_tune";
public static final String SIMULATED_PREFIX = FOLDER + File.separator + "simulator_tune";
public static final String TUNE_FILE_SUFFIX = ".msq"; public static final String TUNE_FILE_SUFFIX = ".msq";
public static final String DEFAULT_TUNE = SIMULATED_PREFIX + TUNE_FILE_SUFFIX; public static final String DEFAULT_TUNE = SIMULATED_PREFIX + TUNE_FILE_SUFFIX;
private static final String workingFolder = "downloaded_tunes"; private static final String workingFolder = "downloaded_tunes";
public static final String MD_FIXED_FORMATTING = "```\n"; public static final String MD_FIXED_FORMATTING = "```\n";
// IDE and GHA run from different working folders :( // IDE and GHA run from different working folders :(
public static final String YET_ANOTHER_ROOT = "../simulator/"; // see write_tune.sh for env variable to property mapping
static final String ENGINE_TUNE_OUTPUT_FOLDER = System.getProperty("ENGINE_TUNE_OUTPUT_FOLDER", "../simulator/generated/");
protected static IniFileModel ini; protected static IniFileModel ini;
static {
log.info("ENGINE_TUNE_OUTPUT_FOLDER=" + ENGINE_TUNE_OUTPUT_FOLDER);
}
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
//writeDiffBetweenLocalTuneFileAndDefaultTune("../1.msq"); //writeDiffBetweenLocalTuneFileAndDefaultTune("../1.msq");
@ -87,14 +91,14 @@ public class TuneCanTool {
protected static void processREOtune(int tuneId, engine_type_e engineType, String key, protected static void processREOtune(int tuneId, engine_type_e engineType, String key,
String methodNamePrefix) throws JAXBException, IOException { String methodNamePrefix) throws JAXBException, IOException {
// compare specific internet tune to total global default // compare specific internet tune to total global default
handle(key + "-comparing-against-global-defaults", tuneId, YET_ANOTHER_ROOT + TuneCanTool.DEFAULT_TUNE, methodNamePrefix); handle(key + "-comparing-against-global-defaults", tuneId, ENGINE_TUNE_OUTPUT_FOLDER + TuneCanTool.DEFAULT_TUNE, methodNamePrefix);
// compare same internet tune to default tune of specified engine type // compare same internet tune to default tune of specified engine type
handle(key + "-comparing-against-current-" + key + "-default", tuneId, getDefaultTuneName(engineType), methodNamePrefix); handle(key + "-comparing-against-current-" + key + "-default", tuneId, getDefaultTuneOutputFileName(engineType), methodNamePrefix);
} }
@NotNull @NotNull
public static String getDefaultTuneName(engine_type_e engineType) { public static String getDefaultTuneOutputFileName(engine_type_e engineType) {
return YET_ANOTHER_ROOT + SIMULATED_PREFIX + "_" + engineType.name() + TUNE_FILE_SUFFIX; return ENGINE_TUNE_OUTPUT_FOLDER + SIMULATED_PREFIX + "_" + engineType.name() + TUNE_FILE_SUFFIX;
} }
private static void handle(String vehicleName, int tuneId, String defaultTuneFileName, String methodNamePrefix) throws JAXBException, IOException { private static void handle(String vehicleName, int tuneId, String defaultTuneFileName, String methodNamePrefix) throws JAXBException, IOException {
@ -128,14 +132,14 @@ public class TuneCanTool {
StringBuilder sb = getTunePatch(defaultTune, customTune, ini, customTuneFileName, methods, defaultTuneFileName, methodNamePrefix); StringBuilder sb = getTunePatch(defaultTune, customTune, ini, customTuneFileName, methods, defaultTuneFileName, methodNamePrefix);
String fileNameMethods = YET_ANOTHER_ROOT + REPORTS_OUTPUT_FOLDER + "/" + vehicleName + "_methods.md"; String fileNameMethods = ENGINE_TUNE_OUTPUT_FOLDER + REPORTS_OUTPUT_FOLDER + "/" + vehicleName + "_methods.md";
try (FileWriter methodsWriter = new FileWriter(fileNameMethods)) { try (FileWriter methodsWriter = new FileWriter(fileNameMethods)) {
methodsWriter.append(MD_FIXED_FORMATTING); methodsWriter.append(MD_FIXED_FORMATTING);
methodsWriter.append(methods); methodsWriter.append(methods);
methodsWriter.append(MD_FIXED_FORMATTING); methodsWriter.append(MD_FIXED_FORMATTING);
} }
String fileName = YET_ANOTHER_ROOT + REPORTS_OUTPUT_FOLDER + "/" + vehicleName + ".md"; String fileName = ENGINE_TUNE_OUTPUT_FOLDER + REPORTS_OUTPUT_FOLDER + "/" + vehicleName + ".md";
File outputFile = new File(fileName); File outputFile = new File(fileName);
log.info("Writing to " + outputFile.getAbsolutePath()); log.info("Writing to " + outputFile.getAbsolutePath());

View File

@ -17,6 +17,7 @@ import java.nio.file.Files;
import java.util.Objects; import java.util.Objects;
import static com.devexperts.logging.Logging.getLogging; import static com.devexperts.logging.Logging.getLogging;
import static com.rusefi.tools.tune.TuneCanTool.ENGINE_TUNE_OUTPUT_FOLDER;
/** /**
* see <a href="https://github.com/rusefi/rusefi/wiki/Canned-Tune-Process">...</a> * see <a href="https://github.com/rusefi/rusefi/wiki/Canned-Tune-Process">...</a>
@ -24,7 +25,7 @@ import static com.devexperts.logging.Logging.getLogging;
public class WriteSimulatorConfiguration { public class WriteSimulatorConfiguration {
private static final Logging log = getLogging(WriteSimulatorConfiguration.class); private static final Logging log = getLogging(WriteSimulatorConfiguration.class);
public static String ROOT_FOLDER = System.getProperty("ROOT_FOLDER", "../simulator/"); private static final String ROOT_FOLDER = System.getProperty("ROOT_FOLDER", "../simulator/");
public static void main(String[] args) { public static void main(String[] args) {
if (args.length != 1) if (args.length != 1)
@ -33,10 +34,10 @@ public class WriteSimulatorConfiguration {
IniFileModelImpl ini = new IniFileModelImpl().readIniFile(iniFileName); IniFileModelImpl ini = new IniFileModelImpl().readIniFile(iniFileName);
BinaryProtocol.iniFileProvider = signature -> ini; BinaryProtocol.iniFileProvider = signature -> ini;
System.out.println("ROOT_FOLDER=" + ROOT_FOLDER); log.info("ROOT_FOLDER=" + ROOT_FOLDER);
try { try {
try { try {
readBinaryWriteXmlTune(iniFileName, Fields.SIMULATOR_TUNE_BIN_FILE_NAME, TuneCanTool.DEFAULT_TUNE, ini); readBinaryWriteXmlTune(iniFileName, Fields.SIMULATOR_TUNE_BIN_FILE_NAME, ENGINE_TUNE_OUTPUT_FOLDER + TuneCanTool.DEFAULT_TUNE, ini);
} catch (Throwable e) { } catch (Throwable e) {
throw new IllegalStateException("White default tune", e); throw new IllegalStateException("White default tune", e);
} }
@ -57,7 +58,7 @@ public class WriteSimulatorConfiguration {
try { try {
String in = Fields.SIMULATOR_TUNE_BIN_FILE_NAME_PREFIX + "_" + engineType.ordinal() + Fields.SIMULATOR_TUNE_BIN_FILE_NAME_SUFFIX; String in = Fields.SIMULATOR_TUNE_BIN_FILE_NAME_PREFIX + "_" + engineType.ordinal() + Fields.SIMULATOR_TUNE_BIN_FILE_NAME_SUFFIX;
readBinaryWriteXmlTune(iniFileName, in, readBinaryWriteXmlTune(iniFileName, in,
TuneCanTool.getDefaultTuneName(engineType), ini); TuneCanTool.getDefaultTuneOutputFileName(engineType), ini);
} catch (Throwable e) { } catch (Throwable e) {
throw new IllegalStateException("With " + engineType, e); throw new IllegalStateException("With " + engineType, e);
} }
@ -80,7 +81,7 @@ public class WriteSimulatorConfiguration {
Constant noiseRpmBins = m.page.get(1).getConstantsAsMap().get(name); Constant noiseRpmBins = m.page.get(1).getConstantsAsMap().get(name);
if (!noiseRpmBins.getValue().contains(Fields.DEFAULT_RPM_AXIS_HIGH_VALUE + ".0")) if (!noiseRpmBins.getValue().contains(Fields.DEFAULT_RPM_AXIS_HIGH_VALUE + ".0"))
throw new IllegalStateException(name + " canary wonders if everything is fine?"); throw new IllegalStateException(name + " canary wonders if everything is fine?");
m.writeXmlFile(ROOT_FOLDER + outputXmlFileName); m.writeXmlFile(outputXmlFileName);
Msq newTuneJustToValidate = Msq.readTune(ROOT_FOLDER + outputXmlFileName); Msq newTuneJustToValidate = Msq.readTune(ROOT_FOLDER + outputXmlFileName);
log.info("Looks valid " + newTuneJustToValidate); log.info("Looks valid " + newTuneJustToValidate);

View File

@ -7,4 +7,4 @@ then
echo ".ini file argument is expected" echo ".ini file argument is expected"
exit -1 exit -1
fi fi
java -cp ../java_tools/tune-tools/build/libs/tune-tools-all.jar com.rusefi.tools.tune.WriteSimulatorConfiguration $1 java -DENGINE_TUNE_OUTPUT_FOLDER=$DEFAULT_TUNE_OUTPUT_FOLDER -cp ../java_tools/tune-tools/build/libs/tune-tools-all.jar com.rusefi.tools.tune.WriteSimulatorConfiguration $1