diff --git a/java_console/models/src/main/java/com/rusefi/tools/tune/TS2C.java b/java_console/models/src/main/java/com/rusefi/tools/tune/TS2C.java index b5c88aeaf6..824d530946 100644 --- a/java_console/models/src/main/java/com/rusefi/tools/tune/TS2C.java +++ b/java_console/models/src/main/java/com/rusefi/tools/tune/TS2C.java @@ -161,6 +161,17 @@ public class TS2C { return sb.toString(); } + @NotNull + public static String getCopyMethodBody(String tableReference, IniFileModel model, String tableName) { + String xRpmBinsName = model.getXBin(tableName); + String yLoadBinsName = model.getYBin(tableName); + + String x = "\tcopyArray(" + tableReference + "LoadBins, hardCoded" + xRpmBinsName + ");\n" + + "\tcopyArray(" + tableReference + "RpmBins, hardCoded" + yLoadBinsName + ");\n" + + "\tcopyTable(" + tableReference + "Table, hardCoded" + tableName + ");\n"; + return x; + } + interface ValueSource { float getValue(int loadIndex, int rpmIndex); } diff --git a/java_console/ui/src/test/java/com/rusefi/ui/TuneReadWriteTest.java b/java_console/ui/src/test/java/com/rusefi/ui/TuneReadWriteTest.java index 2574d8ed92..5294a6c565 100644 --- a/java_console/ui/src/test/java/com/rusefi/ui/TuneReadWriteTest.java +++ b/java_console/ui/src/test/java/com/rusefi/ui/TuneReadWriteTest.java @@ -78,6 +78,41 @@ public class TuneReadWriteTest { "\n", actual); } + @Test + public void testALotTogether() throws IOException { + String expected = "static void cannedveTable() {\n" + + "\tstatic const float hardCodedveRpmBins[16] = {650.0, 800.0, 1100.0, 1400.0, 1700.0, 2000.0, 2300.0, 2600.0, 2900.0, 3200.0, 3500.0, 3800.0, 4100.0, 4400.0, 4700.0, 7000.0};\n" + + "\n" + + "\tstatic const float hardCodedveLoadBins[16] = {10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0, 120.0, 130.0, 140.0, 150.0, 160.0};\n" + + "\n" + + "}\n"; + + String tableReference = "config->ve"; + IniFileModel model = IniFileModel.getInstance(); + String tableName = "veTable"; + + String copyMethodBody = TS2C.getCopyMethodBody(tableReference, model, tableName); + + CurveData xRpmCurve = CurveData.valueOf(TUNE_NAME, model.getXBin(tableName), model); + CurveData yLoadCurve = CurveData.valueOf(TUNE_NAME, model.getYBin(tableName), model); + + TS2C.getTableCSourceCode2(TUNE_NAME, tableName, model, yLoadCurve, xRpmCurve).toString(); + + String completeMethod = "static void canned" + tableName + "() {\n" + + "\t" + xRpmCurve.getCsourceCode() + + "\t" + yLoadCurve.getCsourceCode() + + "}\n" + ; + + assertEquals(expected, completeMethod); + } + + @Test + public void testCopyCode() { + + } + + @Test public void testCompareBinaryToTSTune() throws Exception { Msq tsTune = Msq.readTune(TUNE_NAME);