only:EPIC: Improve toolset for default tune canned tune generation #4871
This commit is contained in:
parent
4b0f0a4f0f
commit
97e60b0266
|
@ -10,7 +10,7 @@ import java.io.BufferedWriter;
|
|||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class CurveData {
|
||||
public class CurveData implements HoHo {
|
||||
private final String curveName;
|
||||
private final float[] rawData;
|
||||
|
||||
|
@ -96,6 +96,7 @@ public class CurveData {
|
|||
return rawData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCsourceMethod(String reference) {
|
||||
return "static void " + getCannedMethod() + " {\n"
|
||||
+ "\t" + getCsourceCode() +
|
||||
|
@ -108,6 +109,7 @@ public class CurveData {
|
|||
return "canned" + curveName + "()";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCinvokeMethod() {
|
||||
return "\t" + getCannedMethod() + ";\n";
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package com.rusefi.tools.tune;
|
||||
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.field.ArrayIniField;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
@ -92,7 +90,7 @@ public class TS2C {
|
|||
|
||||
@NotNull
|
||||
public static String getTableCSourceCode2(String msqFileName, String tableName, IniFileModel model, CurveData xRpmCurve, CurveData yLoadBins) throws IOException {
|
||||
float[][] table = readTable(msqFileName, tableName, model);
|
||||
float[][] table = TableData.readTable(msqFileName, tableName, model);
|
||||
|
||||
return getTableCSourceCode(tableName, yLoadBins, xRpmCurve, table);
|
||||
}
|
||||
|
@ -107,25 +105,6 @@ public class TS2C {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static float[][] readTable(String msqFileName, String tableName, IniFileModel model) throws IOException {
|
||||
ArrayIniField field = (ArrayIniField) model.allIniFields.get(tableName);
|
||||
|
||||
if (field.getRows() != field.getCols())
|
||||
throw new UnsupportedOperationException("Not square table not supported yet");
|
||||
// todo: replace with loadCount & rpmCount
|
||||
int size = field.getRows();
|
||||
|
||||
float[][] table = new float[size][];
|
||||
for (int i = 0; i < size; i++) {
|
||||
table[i] = new float[size];
|
||||
}
|
||||
|
||||
BufferedReader reader = readAndScroll(msqFileName, tableName);
|
||||
readTable(table, reader, size);
|
||||
return table;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getMethodName(String methodName) {
|
||||
return methodName.toUpperCase().charAt(0) + methodName.substring(1);
|
||||
|
@ -184,32 +163,4 @@ public class TS2C {
|
|||
float getValue(int loadIndex, int rpmIndex);
|
||||
}
|
||||
|
||||
private static void readTable(float[][] table, BufferedReader r, int size) throws IOException {
|
||||
int index = 0;
|
||||
|
||||
while (index < size) {
|
||||
String line = r.readLine();
|
||||
if (line == null)
|
||||
throw new IOException("End of file?");
|
||||
line = line.trim();
|
||||
if (line.isEmpty())
|
||||
continue;
|
||||
|
||||
String[] values = line.split("\\s");
|
||||
if (values.length != size)
|
||||
throw new IllegalStateException("Expected " + size + " but got " + Arrays.toString(values) + ". Unexpected line: " + line);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
String str = values[i];
|
||||
try {
|
||||
table[index][i] = Float.parseFloat(str);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IllegalStateException("While reading " + str, e);
|
||||
}
|
||||
}
|
||||
System.out.println("Got line " + index + ": " + Arrays.toString(table[index]));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -176,6 +176,11 @@ public class TuneCanTool {
|
|||
}
|
||||
|
||||
if (cf.isArray()) {
|
||||
if (cf.getArraySizes().length == 2) {
|
||||
//float[][] tableData = TableData.readTable(currentTuneFileName, name, ini);
|
||||
//System.out.printf(" " + name);
|
||||
continue;
|
||||
}
|
||||
|
||||
CurveData data = CurveData.valueOf(currentTuneFileName, name, ini);
|
||||
if (data == null)
|
||||
|
|
Loading…
Reference in New Issue