only:EPIC: Improve toolset for default tune canned tune generation #4871
This commit is contained in:
parent
664607fb4b
commit
ff196ebf8b
|
@ -198,6 +198,7 @@ public class IniFileModel {
|
||||||
private void handleZBins(LinkedList<String> list) {
|
private void handleZBins(LinkedList<String> list) {
|
||||||
list.removeFirst();
|
list.removeFirst();
|
||||||
String zBins = list.removeFirst();
|
String zBins = list.removeFirst();
|
||||||
|
addField(zBins);
|
||||||
if (currentXBins == null || currentYBins == null)
|
if (currentXBins == null || currentYBins == null)
|
||||||
throw new IllegalStateException("X or Y missing for " + zBins);
|
throw new IllegalStateException("X or Y missing for " + zBins);
|
||||||
xBinsByZBins.put(zBins, currentXBins);
|
xBinsByZBins.put(zBins, currentXBins);
|
||||||
|
@ -236,7 +237,6 @@ public class IniFileModel {
|
||||||
private void handleTable(LinkedList<String> list) {
|
private void handleTable(LinkedList<String> list) {
|
||||||
list.removeFirst();
|
list.removeFirst();
|
||||||
String tableName = list.removeFirst();
|
String tableName = list.removeFirst();
|
||||||
addField(tableName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleFieldDefinition(LinkedList<String> list, RawIniFile.Line line) {
|
private void handleFieldDefinition(LinkedList<String> list, RawIniFile.Line line) {
|
||||||
|
|
|
@ -146,6 +146,9 @@ public class IniFileReaderTest {
|
||||||
IniFileModel model = new IniFileModel().readIniFile(lines);
|
IniFileModel model = new IniFileModel().readIniFile(lines);
|
||||||
assertEquals(3, model.allIniFields.size());
|
assertEquals(3, model.allIniFields.size());
|
||||||
assertEquals(3, model.fieldsInUiOrder.size());
|
assertEquals(3, model.fieldsInUiOrder.size());
|
||||||
|
assertTrue(model.fieldsInUiOrder.containsKey("tpsTpsAccelToRpmBins"));
|
||||||
|
assertFalse(model.fieldsInUiOrder.containsKey("tpsTpsAccelTbl"));
|
||||||
|
assertTrue(model.fieldsInUiOrder.containsKey("tpsTpsAccelTable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.rusefi.tools.tune;
|
||||||
|
|
||||||
|
public interface HoHo {
|
||||||
|
String getCsourceMethod(String reference);
|
||||||
|
|
||||||
|
String getCinvokeMethod();
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.rusefi.tools.tune;
|
||||||
|
|
||||||
|
import com.opensr5.ini.IniFileModel;
|
||||||
|
import com.opensr5.ini.field.ArrayIniField;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class TableData {
|
||||||
|
@NotNull
|
||||||
|
public 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 = TS2C.readAndScroll(msqFileName, tableName);
|
||||||
|
readTable(table, reader, size);
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
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++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue