STRING support for java fields
This commit is contained in:
parent
103a44052c
commit
5630aa1963
|
@ -803,7 +803,6 @@ custom maf_sensor_type_e 4 bits, S32, @OFFSET@, [0:1], @@maf_sensor_type_e_enum@
|
|||
! same length used for critical and soft error messages
|
||||
#define ERROR_BUFFER_SIZE 120
|
||||
|
||||
|
||||
custom vehicle_info_t @@VEHICLE_INFO_SIZE@@ string, ASCII, @OFFSET@, @@VEHICLE_INFO_SIZE@@
|
||||
|
||||
custom error_message_t @@ERROR_BUFFER_SIZE@@ string, ASCII, @OFFSET@, @@ERROR_BUFFER_SIZE@@
|
||||
|
|
|
@ -18,6 +18,7 @@ public class Field {
|
|||
|
||||
private final String name;
|
||||
private final int offset;
|
||||
private final int stringSize;
|
||||
private final FieldType type;
|
||||
private final int bitOffset;
|
||||
private final String[] options;
|
||||
|
@ -36,8 +37,13 @@ public class Field {
|
|||
}
|
||||
|
||||
public Field(String name, int offset, FieldType type, int bitOffset, String[] options) {
|
||||
this(name, offset, 0, type, bitOffset, options);
|
||||
}
|
||||
|
||||
public Field(String name, int offset, int stringSize, FieldType type, int bitOffset, String[] options) {
|
||||
this.name = name;
|
||||
this.offset = offset;
|
||||
this.stringSize = stringSize;
|
||||
this.type = type;
|
||||
this.bitOffset = bitOffset;
|
||||
this.options = options;
|
||||
|
|
Binary file not shown.
|
@ -79,7 +79,10 @@ public abstract class JavaFieldsConsumer implements ConfigurationConsumer {
|
|||
|
||||
writeJavaFieldName(nameWithPrefix, tsPosition);
|
||||
if (isStringField(configField)) {
|
||||
javaFieldsWriter.write("FieldType.STRING");
|
||||
String custom = state.tsCustomLine.get(configField.getType());
|
||||
String[] tokens = custom.split(",");
|
||||
String stringSize = tokens[3].trim();
|
||||
javaFieldsWriter.write(stringSize + ", FieldType.STRING");
|
||||
} else if (configField.getElementSize() == 1) {
|
||||
javaFieldsWriter.write("FieldType.INT8");
|
||||
} else if (configField.getElementSize() == 2) {
|
||||
|
|
|
@ -115,7 +115,7 @@ public class ConfigFieldParserTest {
|
|||
JavaFieldsConsumer javaFieldsConsumer = new TestJavaFieldsConsumer(state);
|
||||
state.readBufferedReader(reader, Arrays.asList(javaFieldsConsumer));
|
||||
|
||||
assertEquals("\tpublic static final Field VAR = Field.create(\"VAR\", 0, FieldType.STRING);\n" +
|
||||
assertEquals("\tpublic static final Field VAR = Field.create(\"VAR\", 0, 120, FieldType.STRING);\n" +
|
||||
"\tpublic static final Field PERIODMS = Field.create(\"PERIODMS\", 120, FieldType.INT16);\n",
|
||||
javaFieldsConsumer.getJavaFieldsWriter());
|
||||
|
||||
|
|
Loading…
Reference in New Issue