can factory progress?
This commit is contained in:
parent
0f6adb8e84
commit
4af221e370
|
@ -1,7 +1,9 @@
|
|||
package com.rusefi.tools.tune;
|
||||
|
||||
public interface CannableEntity {
|
||||
String getCsourceMethod(String reference, String methodNamePrefix);
|
||||
String getCsourceMethod(String reference, String methodNamePrefix, String name);
|
||||
|
||||
String getCinvokeMethod(String methodNamePrefix);
|
||||
|
||||
String getName();
|
||||
}
|
||||
|
|
|
@ -101,10 +101,10 @@ public class CurveData implements CannableEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getCsourceMethod(String reference, String methodNamePrefix) {
|
||||
public String getCsourceMethod(String reference, String methodNamePrefix, String name) {
|
||||
return "static void " + getCannedMethod(methodNamePrefix) + " {\n"
|
||||
+ "\t" + getCsourceCode() +
|
||||
"\tcopyArray(" + reference + curveName + ", " + getCannedName() + ");\n" +
|
||||
"\tcopyArray(" + reference + name + ", " + getCannedName() + ");\n" +
|
||||
"}\n\n";
|
||||
}
|
||||
|
||||
|
@ -117,4 +117,9 @@ public class CurveData implements CannableEntity {
|
|||
public String getCinvokeMethod(String methodNamePrefix) {
|
||||
return "\t" + getCannedMethod(methodNamePrefix) + ";\n";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return curveName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ public class TableData implements CannableEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getCsourceMethod(String reference, String methodNamePrefix) {
|
||||
public String getCsourceMethod(String reference, String methodNamePrefix, String name) {
|
||||
String scale = "";
|
||||
if (tableName.equals("lambdaTable"))
|
||||
scale = ", 1.0 / 14.7";
|
||||
|
@ -118,6 +118,12 @@ public class TableData implements CannableEntity {
|
|||
"}\n\n";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCinvokeMethod(String methodNamePrefix) {
|
||||
return "\t" + getCannedMethod(methodNamePrefix) + ";\n";
|
||||
|
|
|
@ -30,6 +30,7 @@ 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.
|
||||
|
@ -60,7 +61,8 @@ public class TuneCanTool implements TuneCanToolConstants {
|
|||
public static void main(String[] args) throws Exception {
|
||||
//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",
|
||||
// "c:\\stuff\\hd-\\tunes\\pnp-april-8-inverted-offsets.msq","comment", "");
|
||||
|
@ -242,7 +244,7 @@ public class TuneCanTool implements TuneCanToolConstants {
|
|||
} else {
|
||||
// todo: unit test?
|
||||
String path = getPath(cf.getParentStructureType());
|
||||
parentReference = "engineConfiguration->" + path + ".";
|
||||
parentReference = path + ".";
|
||||
}
|
||||
|
||||
if (cf.getArraySizes().length == 2) {
|
||||
|
@ -253,10 +255,10 @@ public class TuneCanTool implements TuneCanToolConstants {
|
|||
}
|
||||
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) {
|
||||
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)) {
|
||||
log.info("Table " + fieldName + " matches default content");
|
||||
continue;
|
||||
|
@ -276,10 +278,10 @@ public class TuneCanTool implements TuneCanToolConstants {
|
|||
if (data == null)
|
||||
continue;
|
||||
|
||||
String customContent = data.getCsourceMethod(parentReference, methodNamePrefix);
|
||||
String customContent = data.getCsourceMethod(parentReference, methodNamePrefix, cName);
|
||||
if (defaultTuneFileName != null) {
|
||||
CurveData defaultCurveData = CurveData.valueOf(defaultTuneFileName, fieldName, ini);
|
||||
String defaultContent = defaultCurveData.getCsourceMethod(parentReference, methodNamePrefix);
|
||||
String defaultContent = defaultCurveData.getCsourceMethod(parentReference, methodNamePrefix, cName);
|
||||
if (defaultContent.equals(customContent)) {
|
||||
log.info("Curve " + fieldName + " matches default content");
|
||||
continue;
|
||||
|
@ -363,7 +365,17 @@ public class TuneCanTool implements TuneCanToolConstants {
|
|||
|
||||
private static String getPath(ConfigStructure parentType) {
|
||||
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);
|
||||
|
|
|
@ -6,20 +6,18 @@ import com.rusefi.enums.engine_type_e;
|
|||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static com.rusefi.tools.tune.WriteSimulatorConfiguration.INI_FILE_FOR_SIMULATOR;
|
||||
|
||||
public class TuneCanToolRunner extends TuneCanTool {
|
||||
static {
|
||||
initialize();
|
||||
initialize(INI_FILE_FOR_SIMULATOR);
|
||||
}
|
||||
|
||||
protected static void initialize() {
|
||||
ini = new IniFileModel().readIniFile(INI_FILE_FOR_SIMULATOR);
|
||||
protected static void initialize(String iniFileForSimulator) {
|
||||
ini = new IniFileModel().readIniFile(iniFileForSimulator);
|
||||
if (ini == null)
|
||||
throw new IllegalStateException("Not found " + INI_FILE_FOR_SIMULATOR);
|
||||
throw new IllegalStateException("Not found " + iniFileForSimulator);
|
||||
/*
|
||||
Set<String> allFields = new TreeSet<>();
|
||||
allFields.addAll(ini.allIniFields.keySet());
|
||||
|
|
|
@ -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" +
|
||||
"\tcopyArray(config->ignitionIatCorrRpmBins, hardCodedignitionIatCorrRpmBins);\n" +
|
||||
"}\n" +
|
||||
"\n", xRpmCurve.getCsourceMethod("config->", "prefix"));
|
||||
"\n", xRpmCurve.getCsourceMethod("config->", "prefix", xRpmCurve.getName()));
|
||||
|
||||
TS2C.FINGER_PRINT = "/*unittest*/\n";
|
||||
String tableSource = TS2C.getTableCSourceCode2(TUNE_NAME, tableName, model);
|
||||
|
|
Loading…
Reference in New Issue