only: YET_ANOTHER_ROOT

This commit is contained in:
rusefillc 2024-03-06 14:41:47 -05:00
parent fbffd2e4bf
commit fbe143feac
5 changed files with 17 additions and 10 deletions

View File

@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@ -67,7 +68,7 @@ public class Msq {
}
public static Msq readTune(String fileName) throws JAXBException {
return XmlUtil.readModel(Msq.class, fileName);
return XmlUtil.readModel(Msq.class, new File(fileName));
}
public void writeXmlFile(String outputXmlFileName) throws JAXBException, IOException {

View File

@ -31,8 +31,7 @@ public class XmlUtil {
writer.close();
}
public static <T> T readModel(Class<?> modelClass, String fileName) throws JAXBException {
File xmlFile = new File(fileName);
public static <T> T readModel(Class<?> modelClass, File xmlFile) throws JAXBException {
JAXBContext jaxbContext;
jaxbContext = JAXBContext.newInstance(modelClass);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();

View File

@ -23,7 +23,7 @@ public class TsTuneReader {
public static Msq readTsTune(String ecuName) throws Exception {
String fileName = getTsTuneFileName(ecuName);
return XmlUtil.readModel(Msq.class, fileName);
return XmlUtil.readModel(Msq.class, new File(fileName));
}
@NotNull

View File

@ -8,6 +8,7 @@ import com.rusefi.core.preferences.storage.Node;
import com.rusefi.enums.engine_type_e;
import com.rusefi.tune.xml.Constant;
import com.rusefi.tune.xml.Msq;
import com.rusefi.xml.XmlUtil;
import org.jetbrains.annotations.NotNull;
import javax.xml.bind.JAXBException;
@ -27,7 +28,6 @@ import java.util.TreeSet;
import static com.devexperts.logging.Logging.getLogging;
import static com.rusefi.ConfigFieldImpl.unquote;
import static com.rusefi.config.Field.niceToString;
import static com.rusefi.tools.tune.WriteSimulatorConfiguration.INI_FILE_FOR_SIMULATOR;
/**
* this command line utility compares two TS calibration files and produces .md files with C++ source code of the difference between those two files.
@ -49,6 +49,8 @@ public class TuneCanTool implements TuneCanToolConstants {
public static final String DEFAULT_TUNE = SIMULATED_PREFIX + TUNE_FILE_SUFFIX;
private static final String workingFolder = "downloaded_tunes";
public static final String MD_FIXED_FORMATTING = "```\n";
// IDE and GHA run from different working folders :(
public static final String YET_ANOTHER_ROOT = "../simulator/";
protected static IniFileModel ini;
@ -81,7 +83,7 @@ public class TuneCanTool implements TuneCanToolConstants {
@NotNull
public static String getDefaultTuneName(engine_type_e engineType) {
return SIMULATED_PREFIX + "_" + engineType.name() + TUNE_FILE_SUFFIX;
return YET_ANOTHER_ROOT + SIMULATED_PREFIX + "_" + engineType.name() + TUNE_FILE_SUFFIX;
}
private static void handle(String vehicleName, int tuneId, String defaultTuneFileName, String methodNamePrefix) throws JAXBException, IOException {
@ -107,20 +109,22 @@ public class TuneCanTool implements TuneCanToolConstants {
new File(REPORTS_OUTPUT_FOLDER).mkdir();
Msq customTune = Msq.readTune(customTuneFileName);
Msq defaultTune = Msq.readTune(defaultTuneFileName);
File xmlFile = new File(defaultTuneFileName);
log.info("Reading " + xmlFile.getAbsolutePath());
Msq defaultTune = XmlUtil.readModel(Msq.class, xmlFile);
StringBuilder methods = new StringBuilder();
StringBuilder sb = getTunePatch(defaultTune, customTune, ini, customTuneFileName, methods, defaultTuneFileName, methodNamePrefix);
String fileNameMethods = REPORTS_OUTPUT_FOLDER + "/" + vehicleName + "_methods.md";
String fileNameMethods = YET_ANOTHER_ROOT + REPORTS_OUTPUT_FOLDER + "/" + vehicleName + "_methods.md";
try (FileWriter methodsWriter = new FileWriter(fileNameMethods)) {
methodsWriter.append(MD_FIXED_FORMATTING);
methodsWriter.append(methods);
methodsWriter.append(MD_FIXED_FORMATTING);
}
String fileName = REPORTS_OUTPUT_FOLDER + "/" + vehicleName + ".md";
String fileName = YET_ANOTHER_ROOT + REPORTS_OUTPUT_FOLDER + "/" + vehicleName + ".md";
File outputFile = new File(fileName);
log.info("Writing to " + outputFile.getAbsolutePath());
@ -232,7 +236,7 @@ public class TuneCanTool implements TuneCanToolConstants {
System.out.println(" " + fieldName);
continue;
}
System.out.println("Handling table " + fieldName);
System.out.println("Handling table " + fieldName + " with " + cf.autoscaleSpecPair());
if (defaultTuneFileName != null) {
TableData defaultTableData = TableData.readTable(defaultTuneFileName, fieldName, ini);

View File

@ -17,6 +17,9 @@ public class TuneCanToolRunner extends TuneCanTool {
RootHolder.ROOT = "../firmware/";
}
public static void main(String[] args) throws JAXBException, IOException {
runPopular();
}
public static void runPopular() throws JAXBException, IOException {
// while adding a line here make sure corresponding line is at rusEfiFunctionalTest.cpp