he owes me one now

This commit is contained in:
rusefi 2020-02-14 23:03:26 -05:00
parent 7e02210cb8
commit 64c83fa4cd
13 changed files with 50 additions and 25 deletions

View File

@ -340,7 +340,7 @@ bit issue_294_27;
bit issue_294_28;
bit issue_294_29;
bit issue_294_30;
bit issue_294_31;
bit issue_294_31,si_example,nada_example;
int16_t tpsMin;Closed throttle. todo: extract these two fields into a structure\nSee also tps1_1AdcChannel\nset tps_min X;"ADC", 1, 0, 0, 1023, 0

View File

@ -85,7 +85,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Tue Feb 04 13:45:28 EST 2020
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Fri Feb 14 23:02:29 EST 2020
pageSize = 20000
page = 1
@ -124,7 +124,7 @@ page = 1
issue_294_28 = bits, U32, 76, [27:27], "false", "true"
issue_294_29 = bits, U32, 76, [28:28], "false", "true"
issue_294_30 = bits, U32, 76, [29:29], "false", "true"
issue_294_31 = bits, U32, 76, [30:30], "false", "true"
issue_294_31 = bits, U32, 76, [30:30], "nada_example", "si_example"
unusedBit_34_31 = bits, U32, 76, [31:31], "false", "true"
tpsMin = scalar, S16, 80, "ADC", 1, 0, 0, 1023, 0
tpsMax = scalar, S16, 82, "ADC", 1, 0, 0, 1023, 0

View File

@ -85,7 +85,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Tue Feb 04 13:45:35 EST 2020
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Fri Feb 14 23:02:35 EST 2020
pageSize = 20000
page = 1
@ -124,7 +124,7 @@ page = 1
issue_294_28 = bits, U32, 76, [27:27], "false", "true"
issue_294_29 = bits, U32, 76, [28:28], "false", "true"
issue_294_30 = bits, U32, 76, [29:29], "false", "true"
issue_294_31 = bits, U32, 76, [30:30], "false", "true"
issue_294_31 = bits, U32, 76, [30:30], "nada_example", "si_example"
unusedBit_34_31 = bits, U32, 76, [31:31], "false", "true"
tpsMin = scalar, S16, 80, "ADC", 1, 0, 0, 1023, 0
tpsMax = scalar, S16, 82, "ADC", 1, 0, 0, 1023, 0

View File

@ -85,7 +85,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/rusefi_config.txt Wed Feb 12 20:10:22 EST 2020
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/rusefi_config.txt Fri Feb 14 23:02:42 EST 2020
pageSize = 20000
page = 1
@ -124,7 +124,7 @@ page = 1
issue_294_28 = bits, U32, 76, [27:27], "false", "true"
issue_294_29 = bits, U32, 76, [28:28], "false", "true"
issue_294_30 = bits, U32, 76, [29:29], "false", "true"
issue_294_31 = bits, U32, 76, [30:30], "false", "true"
issue_294_31 = bits, U32, 76, [30:30], "nada_example", "si_example"
unusedBit_34_31 = bits, U32, 76, [31:31], "false", "true"
tpsMin = scalar, S16, 80, "ADC", 1, 0, 0, 1023, 0
tpsMax = scalar, S16, 82, "ADC", 1, 0, 0, 1023, 0

View File

@ -85,7 +85,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Tue Feb 04 13:45:31 EST 2020
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Fri Feb 14 23:02:32 EST 2020
pageSize = 20000
page = 1
@ -124,7 +124,7 @@ page = 1
issue_294_28 = bits, U32, 76, [27:27], "false", "true"
issue_294_29 = bits, U32, 76, [28:28], "false", "true"
issue_294_30 = bits, U32, 76, [29:29], "false", "true"
issue_294_31 = bits, U32, 76, [30:30], "false", "true"
issue_294_31 = bits, U32, 76, [30:30], "nada_example", "si_example"
unusedBit_34_31 = bits, U32, 76, [31:31], "false", "true"
tpsMin = scalar, S16, 80, "ADC", 1, 0, 0, 1023, 0
tpsMax = scalar, S16, 82, "ADC", 1, 0, 0, 1023, 0

View File

@ -85,7 +85,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Tue Feb 04 13:45:38 EST 2020
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Fri Feb 14 23:02:37 EST 2020
pageSize = 20000
page = 1
@ -124,7 +124,7 @@ page = 1
issue_294_28 = bits, U32, 76, [27:27], "false", "true"
issue_294_29 = bits, U32, 76, [28:28], "false", "true"
issue_294_30 = bits, U32, 76, [29:29], "false", "true"
issue_294_31 = bits, U32, 76, [30:30], "false", "true"
issue_294_31 = bits, U32, 76, [30:30], "nada_example", "si_example"
unusedBit_34_31 = bits, U32, 76, [31:31], "false", "true"
tpsMin = scalar, S16, 80, "ADC", 1, 0, 0, 1023, 0
tpsMax = scalar, S16, 82, "ADC", 1, 0, 0, 1023, 0

View File

@ -85,7 +85,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Tue Feb 04 13:45:41 EST 2020
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Fri Feb 14 23:02:40 EST 2020
pageSize = 20000
page = 1
@ -124,7 +124,7 @@ page = 1
issue_294_28 = bits, U32, 76, [27:27], "false", "true"
issue_294_29 = bits, U32, 76, [28:28], "false", "true"
issue_294_30 = bits, U32, 76, [29:29], "false", "true"
issue_294_31 = bits, U32, 76, [30:30], "false", "true"
issue_294_31 = bits, U32, 76, [30:30], "nada_example", "si_example"
unusedBit_34_31 = bits, U32, 76, [31:31], "false", "true"
tpsMin = scalar, S16, 80, "ADC", 1, 0, 0, 1023, 0
tpsMax = scalar, S16, 82, "ADC", 1, 0, 0, 1023, 0

Binary file not shown.

View File

@ -13,7 +13,7 @@ import java.util.regex.Pattern;
* 1/15/15
*/
public class ConfigField {
public static final ConfigField VOID = new ConfigField(null, "", null, null, null, 1, null, false, false, null, -1);
public static final ConfigField VOID = new ConfigField(null, "", null, null, null, 1, null, false, false, null, -1, null, null);
private static final String typePattern = "([\\w\\d_]+)(\\[([\\w\\d]+)(\\s([\\w\\d]+))?\\])?";
private static final String namePattern = "[[\\w\\d\\s_]]+";
@ -38,7 +38,12 @@ public class ConfigField {
private boolean fsioVisible;
private final String individualName;
private final int indexWithinArray;
private final String trueName;
private final String falseName;
/**
* todo: one day someone should convert this into a builder
*/
public ConfigField(ReaderState state,
String name,
String comment,
@ -47,10 +52,14 @@ public class ConfigField {
int arraySize,
String tsInfo,
boolean isIterate,
boolean fsioVisible, String individualName, int indexWithinArray) {
boolean fsioVisible,
String individualName,
int indexWithinArray, String trueName, String falseName) {
this.fsioVisible = fsioVisible;
this.individualName = individualName;
this.indexWithinArray = indexWithinArray;
this.trueName = trueName == null ? "true" : trueName;
this.falseName = falseName == null ? "false" : falseName;
Objects.requireNonNull(name, comment + " " + type);
assertNoWhitespaces(name);
this.name = name;
@ -69,6 +78,14 @@ public class ConfigField {
this.isIterate = isIterate;
}
public String getTrueName() {
return trueName;
}
public String getFalseName() {
return falseName;
}
public String getCFieldName() {
return getIndividualName() == null ? getName() : getIndividualName() + "["
+ (getIndexWithinArray() - 1) + "]";
@ -127,7 +144,7 @@ public class ConfigField {
ConfigField field = new ConfigField(state, name, comment, arraySizeAsText, type, arraySize,
tsInfo, isIterate, isFsioVisible, null, -1);
tsInfo, isIterate, isFsioVisible, null, -1, null, null);
SystemOut.println("type " + type);
SystemOut.println("name " + name);
SystemOut.println("comment " + comment);

View File

@ -67,7 +67,7 @@ public class ConfigStructure {
if (fillSize != 0) {
ConfigField fill = new ConfigField(state, "alignmentFill_at_" + totalSize, "need 4 byte alignment",
"" + fillSize,
TypesHelper.UINT8_T, fillSize, null, false, false, null, -1);
TypesHelper.UINT8_T, fillSize, null, false, false, null, -1, null, null);
addBoth(fill);
}
totalSize += fillSize;
@ -91,7 +91,7 @@ public class ConfigStructure {
return;
int sizeAtStartOfPadding = cFields.size();
while (readingBitState.get() < 32) {
ConfigField bitField = new ConfigField(readerState, "unusedBit_" + sizeAtStartOfPadding + "_" + readingBitState.get(), "", null, BOOLEAN_T, 0, null, false, false, null, -1);
ConfigField bitField = new ConfigField(readerState, "unusedBit_" + sizeAtStartOfPadding + "_" + readingBitState.get(), "", null, BOOLEAN_T, 0, null, false, false, null, -1, null, null);
addBitField(bitField);
}
readingBitState.reset();

View File

@ -19,7 +19,7 @@ import static com.rusefi.ConfigField.BOOLEAN_T;
* 12/19/18
*/
public class ReaderState {
private static final String BIT = "bit";
public static final String BIT = "bit";
protected static final String DEFINE = "#define";
private static final String CUSTOM = "custom";
private static final String END_STRUCT = "end_struct";
@ -44,8 +44,12 @@ public class ReaderState {
bitName = line.substring(0, index);
comment = line.substring(index + 1);
}
String bitNameParts[] = bitName.split(",");
ConfigField bitField = new ConfigField(state, bitName, comment, null, BOOLEAN_T, 0, null, false, false, null, -1);
String trueName = bitNameParts.length > 1 ? bitNameParts[1] : null;
String falseName = bitNameParts.length > 2 ? bitNameParts[2] : null;
ConfigField bitField = new ConfigField(state, bitNameParts[0], comment, null, BOOLEAN_T, 0, null, false, false, null, -1, trueName, falseName);
if (state.stack.isEmpty())
throw new IllegalStateException("Parent structure expected");
ConfigStructure structure = state.stack.peek();
@ -210,7 +214,7 @@ public class ReaderState {
structure.addC(cf);
for (int i = 1; i <= cf.getArraySize(); i++) {
ConfigField element = new ConfigField(state, cf.getName() + i, cf.getComment(), null,
cf.getType(), 1, cf.getTsInfo(), false, false, cf.getName(), i);
cf.getType(), 1, cf.getTsInfo(), false, false, cf.getName(), i, null, null);
structure.addTs(element);
}
} else {

View File

@ -49,7 +49,7 @@ public class TSProjectConsumer implements ConfigurationConsumer {
tsHeader.write("= bits, U32, ");
tsHeader.write("\t" + tsPosition + ", [");
tsHeader.write(bitIndex + ":" + bitIndex);
tsHeader.write("], \"false\", \"true\"");
tsHeader.write("], \"" + configField.getFalseName() + "\", \"" + configField.getTrueName() + "\"");
tsHeader.write(EOL);
tsPosition += configField.getSize(next);

View File

@ -2,7 +2,6 @@ package com.rusefi.test;
import com.rusefi.ReaderState;
import com.rusefi.TsFileContent;
import com.rusefi.output.JavaFieldsConsumer;
import com.rusefi.output.TSProjectConsumer;
import com.rusefi.util.Output;
import org.junit.Test;
@ -10,13 +9,16 @@ import org.junit.Test;
import java.io.*;
import java.util.Arrays;
import static org.junit.Assert.assertTrue;
public class BitParsingTest {
@Test
public void testBitParser() throws IOException {
ReaderState state = new ReaderState();
String inputString = "struct pid_s\nbit activateAuxPid1;\n" +
"bit fieldName;\n" +
String inputString = "struct pid_s\n" +
ReaderState.BIT + " fieldName\n" +
ReaderState.BIT + " fieldName2,si,nada;comment\n" +
"end_struct\n";
BufferedReader reader = new BufferedReader(new StringReader(inputString));
@ -32,6 +34,8 @@ public class BitParsingTest {
System.out.printf("start[" + sw.toString() + "]end");
assertTrue(sw.toString().contains("\"false\", \"true\""));
assertTrue(sw.toString().contains("\"nada\", \"si\""));
}
private Output createOutput(StringWriter sw) {