mirror of https://github.com/rusefi/rusefi-1.git
XML tune export progress
This commit is contained in:
parent
793d8134ee
commit
db62eb21d3
|
@ -1,5 +1,8 @@
|
||||||
package com.opensr5.ini;
|
package com.opensr5.ini;
|
||||||
|
|
||||||
|
import com.opensr5.ini.field.BitIniField;
|
||||||
|
import com.opensr5.ini.field.IniField;
|
||||||
|
import com.opensr5.ini.field.ScalarIniField;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
@ -25,6 +28,7 @@ public class IniFileModel {
|
||||||
private Map<String, DialogModel.Field> allFields = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
private Map<String, DialogModel.Field> allFields = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
// this is only used while reading model - TODO extract reader
|
// this is only used while reading model - TODO extract reader
|
||||||
private List<DialogModel.Field> fieldsOfCurrentDialog = new ArrayList<>();
|
private List<DialogModel.Field> fieldsOfCurrentDialog = new ArrayList<>();
|
||||||
|
public Map<String, IniField> allIniFields = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
|
|
||||||
public Map<String, String> tooltips = new TreeMap<>();
|
public Map<String, String> tooltips = new TreeMap<>();
|
||||||
|
|
||||||
|
@ -134,17 +138,23 @@ public class IniFileModel {
|
||||||
|
|
||||||
private void handleFieldDefinition(LinkedList<String> list) {
|
private void handleFieldDefinition(LinkedList<String> list) {
|
||||||
if (list.get(1).equals(FIELD_TYPE_SCALAR)) {
|
if (list.get(1).equals(FIELD_TYPE_SCALAR)) {
|
||||||
|
ScalarIniField field = ScalarIniField.parse(list);
|
||||||
|
registerField(field);
|
||||||
} else if (list.get(1).equals(FIELD_TYPE_STRING)) {
|
} else if (list.get(1).equals(FIELD_TYPE_STRING)) {
|
||||||
} else if (list.get(1).equals(FIELD_TYPE_ARRAY)) {
|
} else if (list.get(1).equals(FIELD_TYPE_ARRAY)) {
|
||||||
} else if (list.get(1).equals(FIELD_TYPE_BITS)) {
|
} else if (list.get(1).equals(FIELD_TYPE_BITS)) {
|
||||||
|
BitIniField field = BitIniField.parse(list);
|
||||||
|
registerField(field);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Unexpected " + list);
|
throw new IllegalStateException("Unexpected " + list);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerField(IniField field) {
|
||||||
|
allIniFields.put(field.getName(), field);
|
||||||
|
}
|
||||||
|
|
||||||
private void handleField(LinkedList<String> list) {
|
private void handleField(LinkedList<String> list) {
|
||||||
list.removeFirst(); // "field"
|
list.removeFirst(); // "field"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.opensr5.ini.field;
|
||||||
|
|
||||||
|
import com.rusefi.config.FieldType;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BitIniField extends IniField {
|
||||||
|
private final FieldType type;
|
||||||
|
private final List<String> enums;
|
||||||
|
|
||||||
|
public BitIniField(String name, int offset, FieldType type, List<String> enums) {
|
||||||
|
super(name, offset);
|
||||||
|
this.type = type;
|
||||||
|
this.enums = enums;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getEnums() {
|
||||||
|
return enums;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BitIniField parse(LinkedList<String> list) {
|
||||||
|
String name = list.get(0);
|
||||||
|
FieldType type = FieldType.parseTs(list.get(2));
|
||||||
|
int offset = Integer.parseInt(list.get(3));
|
||||||
|
|
||||||
|
List<String> enums = list.subList(5, list.size() - 1);
|
||||||
|
|
||||||
|
return new BitIniField(name, offset, type, enums);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.opensr5.ini.field;
|
||||||
|
|
||||||
|
import com.opensr5.ConfigurationImage;
|
||||||
|
|
||||||
|
public class IniField {
|
||||||
|
private final String name;
|
||||||
|
private final int offset;
|
||||||
|
|
||||||
|
public IniField(String name, int offset) {
|
||||||
|
this.name = name;
|
||||||
|
this.offset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnits() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOffset() {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue(ConfigurationImage image) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.opensr5.ini.field;
|
||||||
|
|
||||||
|
import com.opensr5.ConfigurationImage;
|
||||||
|
import com.rusefi.config.Field;
|
||||||
|
import com.rusefi.config.FieldType;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
public class ScalarIniField extends IniField {
|
||||||
|
private final String unit;
|
||||||
|
private final FieldType type;
|
||||||
|
|
||||||
|
public ScalarIniField(String name, int offset, String unit, FieldType type) {
|
||||||
|
super(name, offset);
|
||||||
|
this.unit = unit;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnits() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValue(ConfigurationImage image) {
|
||||||
|
Field f = new Field(getName(), getOffset(), getType());
|
||||||
|
return f.getValue(image).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ScalarIniField parse(LinkedList<String> list) {
|
||||||
|
String name = list.get(0);
|
||||||
|
FieldType type = FieldType.parseTs(list.get(2));
|
||||||
|
int offset = Integer.parseInt(list.get(3));
|
||||||
|
|
||||||
|
String unit = list.get(4);
|
||||||
|
|
||||||
|
return new ScalarIniField(name, offset, unit, type);
|
||||||
|
}
|
||||||
|
}
|
|
@ -96,7 +96,7 @@ public class IniFileReaderTest {
|
||||||
RawIniFile lines = IniFileReader.read(new ByteArrayInputStream(string.getBytes()));
|
RawIniFile lines = IniFileReader.read(new ByteArrayInputStream(string.getBytes()));
|
||||||
IniFileModel model = new IniFileModel().readIniFile(lines);
|
IniFileModel model = new IniFileModel().readIniFile(lines);
|
||||||
|
|
||||||
assertEquals(0, model.getAllFields().size());
|
assertEquals(2, model.allIniFields.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package com.rusefi.config;
|
package com.rusefi.config;
|
||||||
|
|
||||||
import com.opensr5.ConfigurationImage;
|
import com.opensr5.ConfigurationImage;
|
||||||
import com.rusefi.config.generated.Fields;
|
|
||||||
import com.rusefi.core.Pair;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
@ -15,9 +13,6 @@ import static com.rusefi.config.FieldType.*;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Field {
|
public class Field {
|
||||||
private static final String BIT_VALUE_PREFIX = "bit" + Fields.CONSOLE_DATA_PROTOCOL_TAG;
|
|
||||||
private static final String INT_VALUE_PREFIX = INT_TYPE_STRING + Fields.CONSOLE_DATA_PROTOCOL_TAG;
|
|
||||||
private static final String FLOAT_VALUE_PREFIX = FLOAT_TYPE_STRING + Fields.CONSOLE_DATA_PROTOCOL_TAG;
|
|
||||||
public static final int NO_BIT_OFFSET = -1;
|
public static final int NO_BIT_OFFSET = -1;
|
||||||
private static final int FIELD_PRECISION = 3;
|
private static final int FIELD_PRECISION = 3;
|
||||||
|
|
||||||
|
@ -125,49 +120,6 @@ public class Field {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isIntValueMessage(String message) {
|
|
||||||
return message.startsWith(INT_VALUE_PREFIX) || message.startsWith(BYTE_TYPE_STRING) || message.startsWith(SHORT_TYPE_STRING);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isBitValueMessage(String message) {
|
|
||||||
return message.startsWith(BIT_VALUE_PREFIX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isFloatValueMessage(String message) {
|
|
||||||
return message.startsWith(FLOAT_VALUE_PREFIX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Pair<Integer, ?> parseResponse(String message) {
|
|
||||||
try {
|
|
||||||
int atPosition = message.indexOf(Fields.CONSOLE_DATA_PROTOCOL_TAG);
|
|
||||||
if (atPosition == -1)
|
|
||||||
return null;
|
|
||||||
String firstToken = message.substring(0, atPosition);
|
|
||||||
if (firstToken.equals(INT_TYPE_STRING) || firstToken.equals(BYTE_TYPE_STRING) || firstToken.equals(SHORT_TYPE_STRING)) {
|
|
||||||
message = message.substring(atPosition + Fields.CONSOLE_DATA_PROTOCOL_TAG.length());
|
|
||||||
String[] a = message.split(" is ");
|
|
||||||
if (a.length != 2)
|
|
||||||
return null;
|
|
||||||
int index = Integer.parseInt(a[0]);
|
|
||||||
int value = Integer.parseInt(a[1]);
|
|
||||||
return new Pair<>(index, value);
|
|
||||||
}
|
|
||||||
if (isFloatValueMessage(message)) {
|
|
||||||
message = message.substring(FLOAT_VALUE_PREFIX.length());
|
|
||||||
String[] a = message.split(" is ");
|
|
||||||
if (a.length != 2)
|
|
||||||
return null;
|
|
||||||
int index = Integer.parseInt(a[0]);
|
|
||||||
double value = Double.parseDouble(a[1]);
|
|
||||||
return new Pair<>(index, value);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Field{" +
|
return "Field{" +
|
|
@ -13,6 +13,7 @@ public enum FieldType {
|
||||||
BIT(/*bits are stored in 4 byte packs */4),
|
BIT(/*bits are stored in 4 byte packs */4),
|
||||||
FLOAT(4);
|
FLOAT(4);
|
||||||
|
|
||||||
|
// todo: this is used for text protocol parsing - constant should be reused between firmware and console
|
||||||
public static final String INT_TYPE_STRING = "int";
|
public static final String INT_TYPE_STRING = "int";
|
||||||
public static final String FLOAT_TYPE_STRING = "float";
|
public static final String FLOAT_TYPE_STRING = "float";
|
||||||
public static final String BYTE_TYPE_STRING = "byte";
|
public static final String BYTE_TYPE_STRING = "byte";
|
||||||
|
@ -44,6 +45,22 @@ public enum FieldType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static FieldType parseTs(String type) {
|
||||||
|
if (type.equalsIgnoreCase("f32"))
|
||||||
|
return FLOAT;
|
||||||
|
if (type.equalsIgnoreCase("s32") || type.equalsIgnoreCase("u32"))
|
||||||
|
return INT;
|
||||||
|
if (type.equalsIgnoreCase("s16"))
|
||||||
|
return INT16;
|
||||||
|
if (type.equalsIgnoreCase("u16"))
|
||||||
|
return UINT16;
|
||||||
|
if (type.equalsIgnoreCase("s08"))
|
||||||
|
return INT8;
|
||||||
|
if (type.equalsIgnoreCase("u08"))
|
||||||
|
return UINT8;
|
||||||
|
throw new IllegalStateException(type);
|
||||||
|
}
|
||||||
|
|
||||||
public String getLoadCommand() {
|
public String getLoadCommand() {
|
||||||
return "get_" + getTypeForCommand();
|
return "get_" + getTypeForCommand();
|
||||||
}
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.rusefi.config;
|
||||||
|
|
||||||
|
import com.rusefi.config.generated.Fields;
|
||||||
|
import com.rusefi.core.Pair;
|
||||||
|
|
||||||
|
import static com.rusefi.config.FieldType.*;
|
||||||
|
|
||||||
|
public class FieldCommandResponse {
|
||||||
|
private static final String BIT_VALUE_PREFIX = "bit" + Fields.CONSOLE_DATA_PROTOCOL_TAG;
|
||||||
|
private static final String INT_VALUE_PREFIX = INT_TYPE_STRING + Fields.CONSOLE_DATA_PROTOCOL_TAG;
|
||||||
|
private static final String FLOAT_VALUE_PREFIX = FLOAT_TYPE_STRING + Fields.CONSOLE_DATA_PROTOCOL_TAG;
|
||||||
|
|
||||||
|
public static Pair<Integer, ?> parseResponse(String message) {
|
||||||
|
try {
|
||||||
|
int atPosition = message.indexOf(Fields.CONSOLE_DATA_PROTOCOL_TAG);
|
||||||
|
if (atPosition == -1)
|
||||||
|
return null;
|
||||||
|
String firstToken = message.substring(0, atPosition);
|
||||||
|
if (firstToken.equals(INT_TYPE_STRING) || firstToken.equals(BYTE_TYPE_STRING) || firstToken.equals(SHORT_TYPE_STRING)) {
|
||||||
|
message = message.substring(atPosition + Fields.CONSOLE_DATA_PROTOCOL_TAG.length());
|
||||||
|
String[] a = message.split(" is ");
|
||||||
|
if (a.length != 2)
|
||||||
|
return null;
|
||||||
|
int index = Integer.parseInt(a[0]);
|
||||||
|
int value = Integer.parseInt(a[1]);
|
||||||
|
return new Pair<>(index, value);
|
||||||
|
}
|
||||||
|
if (isFloatValueMessage(message)) {
|
||||||
|
message = message.substring(FLOAT_VALUE_PREFIX.length());
|
||||||
|
String[] a = message.split(" is ");
|
||||||
|
if (a.length != 2)
|
||||||
|
return null;
|
||||||
|
int index = Integer.parseInt(a[0]);
|
||||||
|
double value = Double.parseDouble(a[1]);
|
||||||
|
return new Pair<>(index, value);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isIntValueMessage(String message) {
|
||||||
|
return message.startsWith(INT_VALUE_PREFIX) || message.startsWith(BYTE_TYPE_STRING) || message.startsWith(SHORT_TYPE_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isBitValueMessage(String message) {
|
||||||
|
return message.startsWith(BIT_VALUE_PREFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFloatValueMessage(String message) {
|
||||||
|
return message.startsWith(FLOAT_VALUE_PREFIX);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.rusefi.config.test;
|
package com.rusefi.config.test;
|
||||||
|
|
||||||
import com.rusefi.config.Field;
|
import com.rusefi.config.Field;
|
||||||
|
import com.rusefi.config.FieldCommandResponse;
|
||||||
import com.rusefi.core.Pair;
|
import com.rusefi.core.Pair;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -12,16 +13,16 @@ public class FieldTest {
|
||||||
@Test
|
@Test
|
||||||
public void testParse() {
|
public void testParse() {
|
||||||
{
|
{
|
||||||
assertNull(Field.parseResponse("notint @768 is 21"));
|
assertNull(FieldCommandResponse.parseResponse("notint @768 is 21"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Pair<Integer, ?> p = Field.parseResponse("int @768 is 21");
|
Pair<Integer, ?> p = FieldCommandResponse.parseResponse("int @768 is 21");
|
||||||
assertNotNull(p);
|
assertNotNull(p);
|
||||||
assertEquals(new Integer(768), p.first);
|
assertEquals(new Integer(768), p.first);
|
||||||
assertEquals(21, p.second);
|
assertEquals(21, p.second);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Pair<Integer, ?> p = Field.parseResponse("float @808 is 1.00");
|
Pair<Integer, ?> p = FieldCommandResponse.parseResponse("float @808 is 1.00");
|
||||||
assertNotNull(p);
|
assertNotNull(p);
|
||||||
assertEquals(new Integer(808), p.first);
|
assertEquals(new Integer(808), p.first);
|
||||||
assertEquals(1.0, p.second);
|
assertEquals(1.0, p.second);
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.rusefi.tools;
|
||||||
|
|
||||||
import com.fathzer.soft.javaluator.DoubleEvaluator;
|
import com.fathzer.soft.javaluator.DoubleEvaluator;
|
||||||
import com.opensr5.ConfigurationImage;
|
import com.opensr5.ConfigurationImage;
|
||||||
import com.opensr5.ini.DialogModel;
|
|
||||||
import com.opensr5.ini.IniFileModel;
|
import com.opensr5.ini.IniFileModel;
|
||||||
|
import com.opensr5.ini.field.IniField;
|
||||||
import com.opensr5.io.ConfigurationImageFile;
|
import com.opensr5.io.ConfigurationImageFile;
|
||||||
import com.rusefi.*;
|
import com.rusefi.*;
|
||||||
import com.rusefi.autodetect.PortDetector;
|
import com.rusefi.autodetect.PortDetector;
|
||||||
|
@ -214,20 +214,25 @@ public class ConsoleTools {
|
||||||
|
|
||||||
IniFileModel ini = IniFileModel.getInstance(Launcher.INI_FILE_PATH);
|
IniFileModel ini = IniFileModel.getInstance(Launcher.INI_FILE_PATH);
|
||||||
|
|
||||||
handle(tune, ini, "tpsMin");
|
handle(tune, ini, "tpsMin", image);
|
||||||
|
handle(tune, ini, "tpsMax", image);
|
||||||
|
handle(tune, ini, "primingSquirtDurationMs", image);
|
||||||
// handle(tune, ini, "injector_battLagCorrBins");
|
// handle(tune, ini, "injector_battLagCorrBins");
|
||||||
|
|
||||||
|
|
||||||
XmlUtil.writeXml(tune, Msq.class, "a.xml");
|
XmlUtil.writeXml(tune, Msq.class, "a.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handle(Msq tune, IniFileModel ini, String key) {
|
private static void handle(Msq tune, IniFileModel ini, String key, ConfigurationImage image) {
|
||||||
DialogModel.Field field = ini.getField(key);
|
IniField field = ini.allIniFields.get(key);
|
||||||
tune.getPage().constants.add(prepareConstant(field));
|
tune.getPage().constants.add(prepareConstant(field, image));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Constant prepareConstant(DialogModel.Field field) {
|
private static Constant prepareConstant(IniField field, ConfigurationImage image) {
|
||||||
return new Constant(field.getKey(), null);
|
|
||||||
|
String value = field.getValue(image);
|
||||||
|
|
||||||
|
return new Constant(field.getName(), field.getUnits(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ConsoleTool {
|
interface ConsoleTool {
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
package com.rusefi.tune.xml;
|
package com.rusefi.tune.xml;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlValue;
|
||||||
|
|
||||||
public class Constant {
|
public class Constant {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String units;
|
private final String units;
|
||||||
|
private final String value;
|
||||||
|
|
||||||
public Constant(String name, String units) {
|
public Constant(String name, String units, String value) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.units = units;
|
this.units = units;
|
||||||
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
|
@ -20,4 +23,10 @@ public class Constant {
|
||||||
public String getUnits() {
|
public String getUnits() {
|
||||||
return units;
|
return units;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.ui.config;
|
||||||
|
|
||||||
import com.opensr5.ConfigurationImage;
|
import com.opensr5.ConfigurationImage;
|
||||||
import com.rusefi.config.Field;
|
import com.rusefi.config.Field;
|
||||||
|
import com.rusefi.config.FieldCommandResponse;
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.core.MessagesCentral;
|
import com.rusefi.core.MessagesCentral;
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ public class BitConfigField extends BaseConfigField {
|
||||||
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(Class clazz, String message) {
|
public void onMessage(Class clazz, String message) {
|
||||||
if (Field.isBitValueMessage(message)) {
|
if (FieldCommandResponse.isBitValueMessage(message)) {
|
||||||
String expectedPrefix = "bit" +
|
String expectedPrefix = "bit" +
|
||||||
Fields.CONSOLE_DATA_PROTOCOL_TAG + field.getOffset() + "/" + field.getBitOffset() + " is ";
|
Fields.CONSOLE_DATA_PROTOCOL_TAG + field.getOffset() + "/" + field.getBitOffset() + " is ";
|
||||||
if (message.startsWith(expectedPrefix) && message.length() == expectedPrefix.length() + 1) {
|
if (message.startsWith(expectedPrefix) && message.length() == expectedPrefix.length() + 1) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.ui.config;
|
||||||
|
|
||||||
import com.opensr5.ConfigurationImage;
|
import com.opensr5.ConfigurationImage;
|
||||||
import com.rusefi.config.Field;
|
import com.rusefi.config.Field;
|
||||||
|
import com.rusefi.config.FieldCommandResponse;
|
||||||
import com.rusefi.core.MessagesCentral;
|
import com.rusefi.core.MessagesCentral;
|
||||||
import com.rusefi.core.Pair;
|
import com.rusefi.core.Pair;
|
||||||
import com.rusefi.ui.util.JTextFieldWithWidth;
|
import com.rusefi.ui.util.JTextFieldWithWidth;
|
||||||
|
@ -24,8 +25,8 @@ public class ConfigField extends BaseConfigField {
|
||||||
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(Class clazz, String message) {
|
public void onMessage(Class clazz, String message) {
|
||||||
if (Field.isIntValueMessage(message) || Field.isFloatValueMessage(message)) {
|
if (FieldCommandResponse.isIntValueMessage(message) || FieldCommandResponse.isFloatValueMessage(message)) {
|
||||||
Pair<Integer, ?> p = Field.parseResponse(message);
|
Pair<Integer, ?> p = FieldCommandResponse.parseResponse(message);
|
||||||
if (p != null && p.first == field.getOffset()) {
|
if (p != null && p.first == field.getOffset()) {
|
||||||
Object value = p.second;
|
Object value = p.second;
|
||||||
setValue(value);
|
setValue(value);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.ui.config;
|
||||||
|
|
||||||
import com.opensr5.ConfigurationImage;
|
import com.opensr5.ConfigurationImage;
|
||||||
import com.rusefi.config.Field;
|
import com.rusefi.config.Field;
|
||||||
|
import com.rusefi.config.FieldCommandResponse;
|
||||||
import com.rusefi.config.FieldType;
|
import com.rusefi.config.FieldType;
|
||||||
import com.rusefi.core.MessagesCentral;
|
import com.rusefi.core.MessagesCentral;
|
||||||
import com.rusefi.core.Pair;
|
import com.rusefi.core.Pair;
|
||||||
|
@ -37,8 +38,8 @@ public class EnumConfigField extends BaseConfigField {
|
||||||
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(Class clazz, String message) {
|
public void onMessage(Class clazz, String message) {
|
||||||
if (Field.isIntValueMessage(message)) {
|
if (FieldCommandResponse.isIntValueMessage(message)) {
|
||||||
Pair<Integer, ?> p = Field.parseResponse(message);
|
Pair<Integer, ?> p = FieldCommandResponse.parseResponse(message);
|
||||||
if (p != null && p.first == field.getOffset()) {
|
if (p != null && p.first == field.getOffset()) {
|
||||||
int ordinal = (Integer) p.second;
|
int ordinal = (Integer) p.second;
|
||||||
setValue(ordinal);
|
setValue(ordinal);
|
||||||
|
|
Loading…
Reference in New Issue