fixing at least some issues
This commit is contained in:
rusefi 2020-07-29 20:37:04 -04:00
parent 239eda352c
commit 6353bee0a0
3 changed files with 31 additions and 5 deletions

View File

@ -32,6 +32,8 @@ public class IniFileModel {
public Map<String, IniField> allIniFields = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
public Map<String, String> tooltips = new TreeMap<>();
private boolean isConstantsSection;
private String currentSection;
public static void main(String[] args) {
log.info("Dialogs: " + IniFileModel.getInstance().dialogs);
@ -131,12 +133,20 @@ public class IniFileModel {
if (list.isEmpty())
return;
if (isInsidePageDefinition) {
handleFieldDefinition(list);
String first = list.getFirst();
if (first.startsWith("[") && first.endsWith("]")) {
log.info("Section " + first);
currentSection = first;
isConstantsSection = first.equals("[Constants]");
}
if (isInsidePageDefinition && isConstantsSection) {
if (list.size() > 1)
handleFieldDefinition(list);
return;
}
String first = list.getFirst();
if ("dialog".equals(first)) {
handleDialog(list);

View File

@ -12,6 +12,7 @@ import org.junit.Test;
import java.io.ByteArrayInputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* Andrey Belomutskiy, (c) 2013-2020
@ -105,6 +106,7 @@ public class IniFileReaderTest {
@Test
public void testEasyFields() {
String string = "page = 1\n" +
"[Constants]\n" +
"primingSquirtDurationMs\t\t\t= scalar, F32,\t96,\t\"*C\", 1, 0, -40, 200, 1\n" +
"\tiat_adcChannel\t\t\t\t = bits, U08, 312, [0:7] \"PA0\", \"PA1\", \"PA2\", \"PA3\", \"PA4\", \"PA5\", \"PA6\", \"PA7\", \"PB0\", \"PB1\", \"PC0\", \"PC1\", \"PC2\", \"PC3\", \"PC4\", \"PC5\", \"Disabled\", \"PB12\", \"PB13\", \"PC14\", \"PC15\", \"PC16\", \"PC17\", \"PD3\", \"PD4\", \"PE2\", \"PE6\", \"INVALID\", \"INVALID\", \"INVALID\", \"INVALID\", \"INVALID\"\n";
@ -143,6 +145,7 @@ public class IniFileReaderTest {
@Test
public void testBitField() {
String string = "page = 1\n" +
"[Constants]\n" +
"\tname\t= bits, U32, \t744, [3:5], \"false\", \"true\"";
RawIniFile lines = IniFileReader.read(new ByteArrayInputStream(string.getBytes()));
@ -159,13 +162,19 @@ public class IniFileReaderTest {
@Test
public void testCurveField() {
String string = "page = 1\n" +
" \tname\t\t\t= array, F32,\t108,\t[8],\t\"\", 1, 0, 0.0, 18000, 2\n";
" \tname2\t\t\t= array, F32,\t108,\t[8],\t\"\", 1, 0, 0.0, 18000, 2\n" +
"[Constants]\n" +
" \tname\t\t\t= array, F32,\t108,\t[8],\t\"\", 1, 0, 0.0, 18000, 2\n" +
"[PcVariables]\n" +
" \tname3\t\t\t= array, F32,\t108,\t[8],\t\"\", 1, 0, 0.0, 18000, 2\n"
;
RawIniFile lines = IniFileReader.read(new ByteArrayInputStream(string.getBytes()));
IniFileModel model = new IniFileModel().readIniFile(lines);
assertEquals(1, model.allIniFields.size());
ArrayIniField field = (ArrayIniField) model.allIniFields.get("name");
assertNotNull(field);
assertEquals(1, field.getCols());
assertEquals(8, field.getRows());
}

View File

@ -1,5 +1,6 @@
package com.rusefi.ts_plugin;
import com.devexperts.logging.Logging;
import com.efiAnalytics.plugin.ecu.ControllerAccess;
import com.efiAnalytics.plugin.ecu.ControllerException;
import com.efiAnalytics.plugin.ecu.ControllerParameter;
@ -21,6 +22,8 @@ import java.util.Objects;
import java.util.TreeMap;
public class TuneUploder {
private final static Logging log = Logging.getLogging(TuneUploder.class);
static Msq writeCurrentTune(ControllerAccess controllerAccess, String configurationName) {
Msq msq = grabTune(controllerAccess, configurationName);
if (msq == null)
@ -50,6 +53,10 @@ public class TuneUploder {
try {
String[] parameterNames = controllerParameterServer.getParameterNames(configurationName);
for (String parameterName : parameterNames) {
if (!fileSystemValues.containsKey(parameterName)) {
System.out.println("Skipping " + parameterName + " since not in model, maybe pcVariable?");
continue;
}
applyParameterValue(configurationName, msq, controllerParameterServer, fileSystemValues, parameterName);
}
} catch (ControllerException e) {
@ -83,7 +90,7 @@ public class TuneUploder {
String value;
if (ControllerParameter.PARAM_CLASS_BITS.equals(type)) {
value = cp.getStringValue();
System.out.println("TsPlugin bits " + parameterName + ": " + value);
log.info("bits " + parameterName + ": " + value);
} else if (ControllerParameter.PARAM_CLASS_SCALAR.equals(type)) {
value = toString(cp.getScalarValue(), cp.getDecimalPlaces());
System.out.println("TsPlugin scalar " + parameterName + ": " + cp.getScalarValue() + "/" + cp.getStringValue());