From 4af221e3700d514a8e1cd2afe5d1e24805b689dd Mon Sep 17 00:00:00 2001 From: rusefillc Date: Tue, 16 Jul 2024 22:15:59 -0400 Subject: [PATCH] can factory progress? --- .../com/rusefi/tools/tune/CannableEntity.java | 4 ++- .../java/com/rusefi/tools/tune/CurveData.java | 9 +++++-- .../java/com/rusefi/tools/tune/TableData.java | 8 +++++- .../com/rusefi/tools/tune/TuneCanTool.java | 26 ++++++++++++++----- .../rusefi/tools/tune/TuneCanToolRunner.java | 10 +++---- .../com/rusefi/tune/TuneReadWriteTest.java | 2 +- 6 files changed, 41 insertions(+), 18 deletions(-) diff --git a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/CannableEntity.java b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/CannableEntity.java index aacad3ddcb..8b1b1acf6f 100644 --- a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/CannableEntity.java +++ b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/CannableEntity.java @@ -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(); } diff --git a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/CurveData.java b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/CurveData.java index e091bb0ce0..cc090c674c 100644 --- a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/CurveData.java +++ b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/CurveData.java @@ -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; + } } diff --git a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TableData.java b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TableData.java index a4a33d9592..18dd1a7236 100644 --- a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TableData.java +++ b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TableData.java @@ -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"; diff --git a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TuneCanTool.java b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TuneCanTool.java index d30b456586..18daf2be7a 100644 --- a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TuneCanTool.java +++ b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TuneCanTool.java @@ -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 HARDWARE_PROPERTIES = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); diff --git a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TuneCanToolRunner.java b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TuneCanToolRunner.java index 043941b96c..98532af0a7 100644 --- a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TuneCanToolRunner.java +++ b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TuneCanToolRunner.java @@ -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 allFields = new TreeSet<>(); allFields.addAll(ini.allIniFields.keySet()); diff --git a/java_tools/tune-tools/src/test/java/com/rusefi/tune/TuneReadWriteTest.java b/java_tools/tune-tools/src/test/java/com/rusefi/tune/TuneReadWriteTest.java index 0f91490473..0781382d66 100644 --- a/java_tools/tune-tools/src/test/java/com/rusefi/tune/TuneReadWriteTest.java +++ b/java_tools/tune-tools/src/test/java/com/rusefi/tune/TuneReadWriteTest.java @@ -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);