can factory progress?

This commit is contained in:
rusefillc 2024-07-16 22:15:59 -04:00
parent 0f6adb8e84
commit 4af221e370
6 changed files with 41 additions and 18 deletions

View File

@ -1,7 +1,9 @@
package com.rusefi.tools.tune; package com.rusefi.tools.tune;
public interface CannableEntity { public interface CannableEntity {
String getCsourceMethod(String reference, String methodNamePrefix); String getCsourceMethod(String reference, String methodNamePrefix, String name);
String getCinvokeMethod(String methodNamePrefix); String getCinvokeMethod(String methodNamePrefix);
String getName();
} }

View File

@ -101,10 +101,10 @@ public class CurveData implements CannableEntity {
} }
@Override @Override
public String getCsourceMethod(String reference, String methodNamePrefix) { public String getCsourceMethod(String reference, String methodNamePrefix, String name) {
return "static void " + getCannedMethod(methodNamePrefix) + " {\n" return "static void " + getCannedMethod(methodNamePrefix) + " {\n"
+ "\t" + getCsourceCode() + + "\t" + getCsourceCode() +
"\tcopyArray(" + reference + curveName + ", " + getCannedName() + ");\n" + "\tcopyArray(" + reference + name + ", " + getCannedName() + ");\n" +
"}\n\n"; "}\n\n";
} }
@ -117,4 +117,9 @@ public class CurveData implements CannableEntity {
public String getCinvokeMethod(String methodNamePrefix) { public String getCinvokeMethod(String methodNamePrefix) {
return "\t" + getCannedMethod(methodNamePrefix) + ";\n"; return "\t" + getCannedMethod(methodNamePrefix) + ";\n";
} }
@Override
public String getName() {
return curveName;
}
} }

View File

@ -107,7 +107,7 @@ public class TableData implements CannableEntity {
} }
@Override @Override
public String getCsourceMethod(String reference, String methodNamePrefix) { public String getCsourceMethod(String reference, String methodNamePrefix, String name) {
String scale = ""; String scale = "";
if (tableName.equals("lambdaTable")) if (tableName.equals("lambdaTable"))
scale = ", 1.0 / 14.7"; scale = ", 1.0 / 14.7";
@ -118,6 +118,12 @@ public class TableData implements CannableEntity {
"}\n\n"; "}\n\n";
} }
@Override
public String getName() {
return tableName;
}
@Override @Override
public String getCinvokeMethod(String methodNamePrefix) { public String getCinvokeMethod(String methodNamePrefix) {
return "\t" + getCannedMethod(methodNamePrefix) + ";\n"; return "\t" + getCannedMethod(methodNamePrefix) + ";\n";

View File

@ -30,6 +30,7 @@ import java.util.TreeSet;
import static com.devexperts.logging.Logging.getLogging; import static com.devexperts.logging.Logging.getLogging;
import static com.rusefi.ConfigFieldImpl.unquote; import static com.rusefi.ConfigFieldImpl.unquote;
import static com.rusefi.config.Field.niceToString; 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. * this command line utility compares two TS calibration files and produces .md files with C++ source code of the difference between those two files.
@ -60,7 +61,8 @@ public class TuneCanTool implements TuneCanToolConstants {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
//writeDiffBetweenLocalTuneFileAndDefaultTune("../1.msq"); //writeDiffBetweenLocalTuneFileAndDefaultTune("../1.msq");
TuneCanToolRunner.initialize(); // TuneCanToolRunner.initialize("C:\\stuff\\fw\\generated\\tunerstudio\\generated\\rusefi_.ini");
TuneCanToolRunner.initialize(INI_FILE_FOR_SIMULATOR);
// writeDiffBetweenLocalTuneFileAndDefaultTune("harley", "C:\\stuff\\fw\\fw-\\generated\\simulator_tune_HARLEY.msq", // writeDiffBetweenLocalTuneFileAndDefaultTune("harley", "C:\\stuff\\fw\\fw-\\generated\\simulator_tune_HARLEY.msq",
// "c:\\stuff\\hd-\\tunes\\pnp-april-8-inverted-offsets.msq","comment", ""); // "c:\\stuff\\hd-\\tunes\\pnp-april-8-inverted-offsets.msq","comment", "");
@ -242,7 +244,7 @@ public class TuneCanTool implements TuneCanToolConstants {
} else { } else {
// todo: unit test? // todo: unit test?
String path = getPath(cf.getParentStructureType()); String path = getPath(cf.getParentStructureType());
parentReference = "engineConfiguration->" + path + "."; parentReference = path + ".";
} }
if (cf.getArraySizes().length == 2) { if (cf.getArraySizes().length == 2) {
@ -253,10 +255,10 @@ public class TuneCanTool implements TuneCanToolConstants {
} }
log.info("Handling table " + fieldName + " with " + cf.autoscaleSpecPair()); log.info("Handling table " + fieldName + " with " + cf.autoscaleSpecPair());
String customContent = tableData.getCsourceMethod(parentReference, methodNamePrefix); String customContent = tableData.getCsourceMethod(parentReference, methodNamePrefix, tableData.getName());
if (defaultTuneFileName != null) { if (defaultTuneFileName != null) {
TableData defaultTableData = TableData.readTable(defaultTuneFileName, fieldName, ini); TableData defaultTableData = TableData.readTable(defaultTuneFileName, fieldName, ini);
String defaultContent = defaultTableData.getCsourceMethod(parentReference, methodNamePrefix); String defaultContent = defaultTableData.getCsourceMethod(parentReference, methodNamePrefix, defaultTableData.getName());
if (defaultContent.equals(customContent)) { if (defaultContent.equals(customContent)) {
log.info("Table " + fieldName + " matches default content"); log.info("Table " + fieldName + " matches default content");
continue; continue;
@ -276,10 +278,10 @@ public class TuneCanTool implements TuneCanToolConstants {
if (data == null) if (data == null)
continue; continue;
String customContent = data.getCsourceMethod(parentReference, methodNamePrefix); String customContent = data.getCsourceMethod(parentReference, methodNamePrefix, cName);
if (defaultTuneFileName != null) { if (defaultTuneFileName != null) {
CurveData defaultCurveData = CurveData.valueOf(defaultTuneFileName, fieldName, ini); CurveData defaultCurveData = CurveData.valueOf(defaultTuneFileName, fieldName, ini);
String defaultContent = defaultCurveData.getCsourceMethod(parentReference, methodNamePrefix); String defaultContent = defaultCurveData.getCsourceMethod(parentReference, methodNamePrefix, cName);
if (defaultContent.equals(customContent)) { if (defaultContent.equals(customContent)) {
log.info("Curve " + fieldName + " matches default content"); log.info("Curve " + fieldName + " matches default content");
continue; continue;
@ -363,7 +365,17 @@ public class TuneCanTool implements TuneCanToolConstants {
private static String getPath(ConfigStructure parentType) { private static String getPath(ConfigStructure parentType) {
String parentTypeName = parentType.getName(); String parentTypeName = parentType.getName();
return parentType.getParent().getCurrentInstance().get(parentTypeName).getName(); ConfigField configField = parentType.getParent().getCurrentInstance().get(parentTypeName);
ConfigStructure grandFather = configField.getParentStructureType();
String grandParentName;
if (grandFather.getName().equals("persistent_config_s")) {
grandParentName = "config->";
} else if (grandFather.getName().equals("engine_configuration_s")) {
grandParentName = "engineConfiguration->";
} else {
throw new IllegalStateException("Unexpected grandParentName " + grandFather);
}
return grandParentName + configField.getOriginalArrayName();
} }
private final static Set<String> HARDWARE_PROPERTIES = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); private final static Set<String> HARDWARE_PROPERTIES = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);

View File

@ -6,20 +6,18 @@ import com.rusefi.enums.engine_type_e;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import java.io.IOException; import java.io.IOException;
import java.util.Set;
import java.util.TreeSet;
import static com.rusefi.tools.tune.WriteSimulatorConfiguration.INI_FILE_FOR_SIMULATOR; import static com.rusefi.tools.tune.WriteSimulatorConfiguration.INI_FILE_FOR_SIMULATOR;
public class TuneCanToolRunner extends TuneCanTool { public class TuneCanToolRunner extends TuneCanTool {
static { static {
initialize(); initialize(INI_FILE_FOR_SIMULATOR);
} }
protected static void initialize() { protected static void initialize(String iniFileForSimulator) {
ini = new IniFileModel().readIniFile(INI_FILE_FOR_SIMULATOR); ini = new IniFileModel().readIniFile(iniFileForSimulator);
if (ini == null) if (ini == null)
throw new IllegalStateException("Not found " + INI_FILE_FOR_SIMULATOR); throw new IllegalStateException("Not found " + iniFileForSimulator);
/* /*
Set<String> allFields = new TreeSet<>(); Set<String> allFields = new TreeSet<>();
allFields.addAll(ini.allIniFields.keySet()); allFields.addAll(ini.allIniFields.keySet());

View File

@ -50,7 +50,7 @@ public class TuneReadWriteTest {
"\tstatic const float hardCodedignitionIatCorrRpmBins[16] = {880.0, 1260.0, 1640.0, 2020.0, 2400.0, 2780.0, 3000.0, 3380.0, 3760.0, 4140.0, 4520.0, 5000.0, 5700.0, 6500.0, 7200.0, 8000.0};\n" + "\tstatic const float hardCodedignitionIatCorrRpmBins[16] = {880.0, 1260.0, 1640.0, 2020.0, 2400.0, 2780.0, 3000.0, 3380.0, 3760.0, 4140.0, 4520.0, 5000.0, 5700.0, 6500.0, 7200.0, 8000.0};\n" +
"\tcopyArray(config->ignitionIatCorrRpmBins, hardCodedignitionIatCorrRpmBins);\n" + "\tcopyArray(config->ignitionIatCorrRpmBins, hardCodedignitionIatCorrRpmBins);\n" +
"}\n" + "}\n" +
"\n", xRpmCurve.getCsourceMethod("config->", "prefix")); "\n", xRpmCurve.getCsourceMethod("config->", "prefix", xRpmCurve.getName()));
TS2C.FINGER_PRINT = "/*unittest*/\n"; TS2C.FINGER_PRINT = "/*unittest*/\n";
String tableSource = TS2C.getTableCSourceCode2(TUNE_NAME, tableName, model); String tableSource = TS2C.getTableCSourceCode2(TUNE_NAME, tableName, model);