Improve toolset for default tune canned tune generation #4871
This commit is contained in:
parent
dce88c34e4
commit
d77ca5da5e
|
@ -1,6 +1,7 @@
|
|||
package com.opensr5.ini;
|
||||
|
||||
import com.devexperts.logging.Logging;
|
||||
import com.devexperts.util.IndexedSet;
|
||||
import com.opensr5.ini.field.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -35,6 +36,10 @@ public class IniFileModel {
|
|||
public Map<String, String> protocolMeta = new TreeMap<>();
|
||||
private boolean isConstantsSection;
|
||||
private String currentSection;
|
||||
private String currentYBins;
|
||||
private String currentXBins;
|
||||
private final Map<String, String> xBinsByZBins = new HashMap<>();
|
||||
private final Map<String, String> yBinsByZBins = new HashMap<>();
|
||||
|
||||
public static void main(String[] args) {
|
||||
log.info("Dialogs: " + IniFileModel.getInstance().dialogs);
|
||||
|
@ -162,14 +167,51 @@ public class IniFileModel {
|
|||
|
||||
if ("dialog".equals(first)) {
|
||||
handleDialog(list);
|
||||
} else if ("field".equals(first)) {
|
||||
handleField(list);
|
||||
} else if ("table".equals(first)) {
|
||||
handleTable(list);
|
||||
} else if ("xBins".equals(first)) {
|
||||
handleXBins(list);
|
||||
} else if ("yBins".equals(first)) {
|
||||
handleYBins(list);
|
||||
} else if ("zBins".equals(first)) {
|
||||
handleZBins(list);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
throw new IllegalStateException("While [" + rawText + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleZBins(LinkedList<String> list) {
|
||||
list.removeFirst();
|
||||
String zBins = list.removeFirst();
|
||||
if (currentXBins == null || currentYBins == null)
|
||||
throw new IllegalStateException("X or Y missing for " + zBins);
|
||||
xBinsByZBins.put(zBins, currentXBins);
|
||||
yBinsByZBins.put(zBins, currentYBins);
|
||||
}
|
||||
|
||||
public String getXBin(String tableName) {
|
||||
return xBinsByZBins.get(tableName);
|
||||
}
|
||||
|
||||
public String getYBin(String tableName) {
|
||||
return yBinsByZBins.get(tableName);
|
||||
}
|
||||
|
||||
private void handleYBins(LinkedList<String> list) {
|
||||
list.removeFirst();
|
||||
currentYBins = list.removeFirst();
|
||||
}
|
||||
|
||||
private void handleXBins(LinkedList<String> list) {
|
||||
list.removeFirst();
|
||||
currentXBins = list.removeFirst();
|
||||
}
|
||||
|
||||
private void handleTable(LinkedList<String> list) {
|
||||
list.removeFirst();
|
||||
}
|
||||
|
||||
private void handleFieldDefinition(LinkedList<String> list) {
|
||||
if (list.get(1).equals(FIELD_TYPE_SCALAR)) {
|
||||
registerField(ScalarIniField.parse(list));
|
||||
|
|
|
@ -29,6 +29,13 @@ public class TuneReadWriteTest {
|
|||
IniFileModel.getInstance().readIniFile(TEST_INI);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIniReader() {
|
||||
IniFileModel model = IniFileModel.getInstance();
|
||||
assertEquals("fuelRpmBins", model.getXBin("fuelTable"));
|
||||
assertEquals("fuelLoadBins", model.getYBin("fuelTable"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareBinaryToTSTune() throws Exception {
|
||||
Msq tsTune = Msq.readTune(PATH + "CurrentTune.msq");
|
||||
|
|
Loading…
Reference in New Issue