"digits" support for rusEFI tune XML files

This commit is contained in:
rusefi 2020-07-19 12:24:36 -04:00
parent f503f35e56
commit 36bd3961f3
11 changed files with 104 additions and 9 deletions

View File

@ -0,0 +1,21 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="TuneReadWriteTest.testCompareBinaryToTSTune" type="JUnit" factoryName="JUnit" nameIsGenerated="true">
<module name="ui" />
<useClassPathOnly />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.rusefi.ui.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="com.rusefi.ui" />
<option name="MAIN_CLASS_NAME" value="com.rusefi.ui.TuneReadWriteTest" />
<option name="METHOD_NAME" value="testCompareBinaryToTSTune" />
<option name="TEST_OBJECT" value="method" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@ -0,0 +1,21 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="TuneReadWriteTest.testWriteAndReadTSTune" type="JUnit" factoryName="JUnit" nameIsGenerated="true">
<module name="ui" />
<useClassPathOnly />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.rusefi.ui.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="com.rusefi.ui" />
<option name="MAIN_CLASS_NAME" value="com.rusefi.ui.TuneReadWriteTest" />
<option name="METHOD_NAME" value="testWriteAndReadTSTune" />
<option name="TEST_OBJECT" value="method" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@ -13,13 +13,15 @@ public class ArrayIniField extends IniField {
private final int cols;
private final int rows;
private final double multiplier;
private final String digits;
public ArrayIniField(String name, int offset, FieldType type, int cols, int rows, String unit, double multiplier) {
public ArrayIniField(String name, int offset, FieldType type, int cols, int rows, String unit, double multiplier, String digits) {
super(name, offset);
this.type = type;
this.cols = cols;
this.rows = rows;
this.multiplier = multiplier;
this.digits = digits;
}
public FieldType getType() {
@ -34,6 +36,11 @@ public class ArrayIniField extends IniField {
return rows;
}
@Override
public String getDigits() {
return digits;
}
@Override
public int getSize() {
return type.getStorageSize() * cols * rows;
@ -90,6 +97,7 @@ public class ArrayIniField extends IniField {
int offset = Integer.parseInt(list.get(3));
String size = list.get(4);
String unit = list.get(5);
String digits = list.get(10);
double multiplier = Double.parseDouble(list.get(6));
size = size.replaceAll("[\\]\\[x]", " ").trim();
@ -106,6 +114,6 @@ public class ArrayIniField extends IniField {
throw new IllegalStateException("Unexpected " + size);
}
return new ArrayIniField(name, offset, type, cols, rows, unit, multiplier);
return new ArrayIniField(name, offset, type, cols, rows, unit, multiplier, digits);
}
}

View File

@ -20,6 +20,10 @@ public abstract class IniField {
return null;
}
public String getDigits() {
return null;
}
public int getOffset() {
return offset;
}

View File

@ -13,17 +13,24 @@ import static com.rusefi.config.FieldType.*;
public class ScalarIniField extends IniField {
private final String unit;
private final FieldType type;
private final String digits;
private final double multiplier;
public ScalarIniField(String name, int offset, String unit, FieldType type, double multiplier) {
public ScalarIniField(String name, int offset, String unit, FieldType type, double multiplier, String digits) {
super(name, offset);
this.unit = unit;
this.type = type;
this.digits = digits;
if (multiplier == 0)
throw new IllegalArgumentException("Multiplier should not be zero");
this.multiplier = multiplier;
}
@Override
public String getDigits() {
return digits;
}
@Override
public String getUnits() {
return unit;
@ -86,10 +93,11 @@ public class ScalarIniField extends IniField {
String name = list.get(0);
FieldType type = FieldType.parseTs(list.get(2));
int offset = Integer.parseInt(list.get(3));
String digits = list.get(9);
String unit = list.get(4);
double multiplier = Double.parseDouble(list.get(5));
return new ScalarIniField(name, offset, unit, type, multiplier);
return new ScalarIniField(name, offset, unit, type, multiplier, digits);
}
}

View File

@ -7,14 +7,16 @@ public class Constant {
private String name;
private String units;
private String value;
private String digits;
public Constant() {
}
public Constant(String name, String units, String value) {
public Constant(String name, String units, String value, String digits) {
this.name = name;
this.units = units;
this.value = value;
this.digits = digits;
}
@XmlAttribute
@ -32,6 +34,15 @@ public class Constant {
return value;
}
@XmlAttribute
public String getDigits() {
return digits;
}
public void setDigits(String digits) {
this.digits = digits;
}
public void setName(String name) {
this.name = name;
}

View File

@ -80,7 +80,7 @@ public class Msq {
System.out.println("Msq: No page");
return;
}
page.constant.add(new Constant(field.getName(), field.getUnits(), value));
page.constant.add(new Constant(field.getName(), field.getUnits(), value, field.getDigits()));
}
public Page findPage() {

View File

@ -37,6 +37,15 @@ public class Page {
this.size = size;
}
public Constant findParameter(String name) {
for (Constant parameter : constant) {
if (parameter.getName().equals(name)) {
return parameter;
}
}
return null;
}
@Override
public String toString() {
return "Page{" +

View File

@ -23,14 +23,14 @@ public class TestHelper {
@NotNull
public static ScalarIniField createIniField(Field field) {
return new ScalarIniField(field.getName(), field.getOffset(), "", field.getType(), 1);
return new ScalarIniField(field.getName(), field.getOffset(), "", field.getType(), 1, "0");
}
@NotNull
public static ConfigurationImage prepareImage(int input, ScalarIniField scalarIniField) {
ConfigurationImage ci = new ConfigurationImage(Fields.TOTAL_CONFIG_SIZE);
scalarIniField.setValue(ci, new Constant(scalarIniField.getName(), "", Integer.toString(input)));
scalarIniField.setValue(ci, new Constant(scalarIniField.getName(), "", Integer.toString(input), scalarIniField.getDigits()));
return ci;
}

View File

@ -6,6 +6,7 @@ import com.opensr5.ini.field.IniField;
import com.opensr5.io.ConfigurationImageFile;
import com.rusefi.binaryprotocol.MsqFactory;
import com.rusefi.config.generated.Fields;
import com.rusefi.tune.xml.Constant;
import com.rusefi.tune.xml.Msq;
import org.junit.Before;
import org.junit.Test;
@ -35,6 +36,10 @@ public class TuneReadWriteTest {
System.out.println(tsTune);
assertNotNull("signature", tsTune.getVersionInfo().getSignature());
Constant flow = tsTune.findPage().findParameter("injector_flow");
assertNotNull(flow);
assertEquals("2", flow.getDigits());
ConfigurationImage tsBinaryData = tsTune.asImage(IniFileModel.getInstance(), Fields.TOTAL_CONFIG_SIZE);
System.out.println("Reading " + TEST_BINARY_FILE);
@ -55,6 +60,14 @@ public class TuneReadWriteTest {
Msq tuneFromBinary = MsqFactory.valueOf(fileBinaryData);
tuneFromBinary.writeXmlFile(fileName);
Constant batteryCorrection = tuneFromBinary.findPage().findParameter("injector_battLagCorrBins");
assertNotNull(batteryCorrection);
assertEquals("2", batteryCorrection.getDigits());
Constant flow = tuneFromBinary.findPage().findParameter("injector_flow");
assertNotNull(flow);
assertEquals("2", flow.getDigits());
// and now reading that XML back
Msq tuneFromFile = Msq.readTune(fileName);
assertNotNull(tuneFromFile.getVersionInfo().getSignature());

View File

@ -849,7 +849,7 @@ page = 1
cj125CsPinMode = bits, U08, 2225, [0:7], "default", "default inverted", "open collector", "open collector inverted"
dizzySparkOutputPin = bits, U08, 2226, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","TLE6240_1", "TLE6240_2", "TLE6240_3", "TLE6240_4", "TLE6240_5", "TLE6240_6", "TLE6240_7", "TLE6240_8", "TLE6240_9", "TLE6240_10", "TLE6240_11", "TLE6240_12", "TLE6240_13", "TLE6240_14", "TLE6240_15", "TLE6240_16", "MC33972_1", "MC33972_2", "MC33972_3", "MC33972_4", "MC33972_5", "MC33972_6", "MC33972_7", "MC33972_8", "MC33972_9", "MC33972_10", "MC33972_11", "MC33972_12", "MC33972_13", "MC33972_14", "MC33972_15", "MC33972_16", "MC33972_17", "MC33972_18", "MC33972_19", "MC33972_20", "MC33972_21", "MC33972_22", "TLE8888_1", "TLE8888_2", "TLE8888_3", "TLE8888_4", "TLE8888_5", "TLE8888_6", "TLE8888_7", "TLE8888_8", "TLE8888_9", "TLE8888_10", "TLE8888_11", "TLE8888_12", "TLE8888_13", "TLE8888_14", "TLE8888_15", "TLE8888_16", "TLE8888_17", "TLE8888_18", "TLE8888_19", "TLE8888_20", "TLE8888_21", "TLE8888_22", "TLE8888_23", "TLE8888_24", "TLE8888_25", "TLE8888_26", "TLE8888_27", "TLE8888_28", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
dizzySparkOutputPinMode = bits, U08, 2227, [0:7], "default", "default inverted", "open collector", "open collector inverted"
crankingIACposition = scalar, S32, 2228, "percent", 1, 0, -100.0, 100,
crankingIACposition = scalar, S32, 2228, "percent", 1, 0, -100.0, 100, 0
tChargeMinRpmMinTps = scalar, F32, 2232, "mult", 1, 0, 0, 3, 4
tChargeMinRpmMaxTps = scalar, F32, 2236, "mult", 1, 0, 0, 3, 4
tChargeMaxRpmMinTps = scalar, F32, 2240, "mult", 1, 0, 0, 3, 4