only:EPIC: Improve toolset for default tune canned tune generation #4871
This commit is contained in:
parent
2e797ae525
commit
ddbedd213c
|
@ -28,7 +28,9 @@ import static com.rusefi.tools.tune.WriteSimulatorConfiguration.INI_FILE_FOR_SIM
|
||||||
public class TuneCanTool {
|
public class TuneCanTool {
|
||||||
public static final String SRC_TEST_RESOURCES = "src/test/resources/";
|
public static final String SRC_TEST_RESOURCES = "src/test/resources/";
|
||||||
private static final String FOLDER = "generated";
|
private static final String FOLDER = "generated";
|
||||||
public static final String DEFAULT_TUNE = FOLDER + File.separator + "simulator_tune.xml";
|
public static final String SIMULATED_PREFIX = FOLDER + File.separator + "simulator_tune";
|
||||||
|
public static final String SIMULATED_SUFFIX = ".xml";
|
||||||
|
public static final String DEFAULT_TUNE = SIMULATED_PREFIX + SIMULATED_SUFFIX;
|
||||||
private static final String workingFolder = "downloaded_tunes";
|
private static final String workingFolder = "downloaded_tunes";
|
||||||
|
|
||||||
private static Msq simulatorDefaultTune;
|
private static Msq simulatorDefaultTune;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.rusefi.tools.tune;
|
package com.rusefi.tools.tune;
|
||||||
|
|
||||||
|
import com.devexperts.logging.Logging;
|
||||||
import com.opensr5.ConfigurationImage;
|
import com.opensr5.ConfigurationImage;
|
||||||
import com.opensr5.ini.IniFileModel;
|
import com.opensr5.ini.IniFileModel;
|
||||||
import com.rusefi.binaryprotocol.MsqFactory;
|
import com.rusefi.binaryprotocol.MsqFactory;
|
||||||
|
@ -12,24 +13,34 @@ import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static com.devexperts.logging.Logging.getLogging;
|
||||||
|
|
||||||
public class WriteSimulatorConfiguration {
|
public class WriteSimulatorConfiguration {
|
||||||
|
private static final Logging log = getLogging(WriteSimulatorConfiguration.class);
|
||||||
// f407-discovery is historically the most inclusive .ini file
|
// f407-discovery is historically the most inclusive .ini file
|
||||||
public static final String INI_FILE_FOR_SIMULATOR = "../firmware/tunerstudio/generated/rusefi_f407-discovery.ini";
|
public static final String INI_FILE_FOR_SIMULATOR = "../firmware/tunerstudio/generated/rusefi_f407-discovery.ini";
|
||||||
|
|
||||||
|
public static String ROOT_FOLDER = System.getProperty("ROOT_FOLDER", "");
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException, InterruptedException, JAXBException {
|
public static void main(String[] args) throws IOException, InterruptedException, JAXBException {
|
||||||
|
System.out.printf("ROOT_FOLDER=" + ROOT_FOLDER);
|
||||||
try {
|
try {
|
||||||
writeTune();
|
writeTune(Fields.SIMULATOR_TUNE_BIN_FILE_NAME, TuneCanTool.DEFAULT_TUNE);
|
||||||
|
String engine = "_" + 95;
|
||||||
|
writeTune(Fields.SIMULATOR_TUNE_BIN_FILE_NAME_PREFIX + engine + Fields.SIMULATOR_TUNE_BIN_FILE_NAME_SUFFIX,
|
||||||
|
TuneCanTool.SIMULATED_PREFIX + engine + TuneCanTool.SIMULATED_SUFFIX);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
System.err.println("Unfortunately " + e);
|
log.error("Unfortunately", e);
|
||||||
|
System.exit(-1);
|
||||||
} finally {
|
} finally {
|
||||||
// No way to set Process.exec to be a daemon, we need explicit exit
|
// No way to set Process.exec to be a daemon, we need explicit exit
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeTune() throws JAXBException, IOException {
|
private static void writeTune(String tuneBinFileName, String outputXmlFileName) throws JAXBException, IOException {
|
||||||
byte[] fileContent = Files.readAllBytes(new File(Fields.SIMULATOR_TUNE_BIN_FILE_NAME).toPath());
|
byte[] fileContent = Files.readAllBytes(new File(ROOT_FOLDER + tuneBinFileName).toPath());
|
||||||
System.out.println("Got " + fileContent.length + " from " + Fields.SIMULATOR_TUNE_BIN_FILE_NAME + " while expecting " + Fields.TOTAL_CONFIG_SIZE);
|
System.out.println("Got " + fileContent.length + " from " + tuneBinFileName + " while expecting " + Fields.TOTAL_CONFIG_SIZE);
|
||||||
if (fileContent.length != Fields.TOTAL_CONFIG_SIZE)
|
if (fileContent.length != Fields.TOTAL_CONFIG_SIZE)
|
||||||
throw new IllegalStateException("Unexpected image size " + fileContent.length);
|
throw new IllegalStateException("Unexpected image size " + fileContent.length);
|
||||||
ConfigurationImage configuration = new ConfigurationImage(fileContent);
|
ConfigurationImage configuration = new ConfigurationImage(fileContent);
|
||||||
|
@ -38,9 +49,9 @@ public class WriteSimulatorConfiguration {
|
||||||
if (ini == null)
|
if (ini == null)
|
||||||
throw new IllegalStateException("Not found " + INI_FILE_FOR_SIMULATOR);
|
throw new IllegalStateException("Not found " + INI_FILE_FOR_SIMULATOR);
|
||||||
Msq m = MsqFactory.valueOf(configuration, ini);
|
Msq m = MsqFactory.valueOf(configuration, ini);
|
||||||
m.writeXmlFile(TuneCanTool.DEFAULT_TUNE);
|
m.writeXmlFile(ROOT_FOLDER + outputXmlFileName);
|
||||||
|
|
||||||
Msq newTuneJustToValidate = Msq.readTune(TuneCanTool.DEFAULT_TUNE);
|
Msq newTuneJustToValidate = Msq.readTune(ROOT_FOLDER + outputXmlFileName);
|
||||||
System.out.println("Looks valid " + newTuneJustToValidate);
|
System.out.println("Looks valid " + newTuneJustToValidate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue