would this ever end...

This commit is contained in:
rusefillc 2022-04-25 18:02:24 -04:00
parent 3ba6416e54
commit 15c2699e08
6 changed files with 31 additions and 19 deletions

Binary file not shown.

View File

@ -302,7 +302,8 @@ public class ReaderState {
if (cf.isIterate()) {
structure.addC(cf);
for (int i = 1; i <= cf.getArraySizes()[0]; i++) {
ConfigField element = new ConfigField(state, cf.getName() + i, getCommentWithIndex(cf, i), null,
String commentWithIndex = getCommentWithIndex(cf, i);
ConfigField element = new ConfigField(state, cf.getName() + i, commentWithIndex, null,
cf.getType(), new int[0], cf.getTsInfo(), false, false, cf.isHasAutoscale(), null, null);
element.isFromIterate(true);
structure.addTs(element);

View File

@ -4,9 +4,6 @@ import com.opensr5.ini.field.IniField;
import com.rusefi.ConfigField;
import com.rusefi.ReaderState;
import com.rusefi.TypesHelper;
import com.rusefi.VariableRegistry;
import java.io.IOException;
import static com.rusefi.ToolUtil.EOL;
import static com.rusefi.output.JavaSensorsConsumer.quote;
@ -37,7 +34,7 @@ public class TsOutput {
return settingContextHelp;
}
public int run(ReaderState state, ConfigStructure structure, int sensorTsPosition) throws IOException {
public int run(ReaderState state, ConfigStructure structure, int sensorTsPosition) {
FieldsStrategy strategy = new FieldsStrategy() {
@Override
public int writeOneField(FieldIterator it, String prefix, int tsPosition) {
@ -46,6 +43,11 @@ public class TsOutput {
int bitIndex = it.bitState.get();
String nameWithPrefix = prefix + configField.getName();
if (configField.getName().startsWith(ConfigStructure.ALIGNMENT_FILL_AT)) {
tsPosition += configField.getSize(next);
return tsPosition;
}
if (configField.isDirective() && configField.getComment() != null) {
tsHeader.append(configField.getComment());
tsHeader.append(EOL);
@ -56,6 +58,7 @@ public class TsOutput {
if (configField.getComment() != null && configField.getComment().trim().length() > 0 && cs == null) {
String commentContent = configField.getCommentContent();
commentContent = state.variableRegistry.applyVariables(commentContent);
commentContent = ConfigField.unquote(commentContent);
int newLineIndex = commentContent.indexOf("\\n");
if (newLineIndex != -1) {
// we might have detailed long comment for header javadoc but need a short field name for logs/rusEFI online
@ -63,7 +66,7 @@ public class TsOutput {
}
// if (!isConstantsSection && commentContent.length() > MSQ_LENGTH_LIMIT)
// throw new IllegalStateException("[" + commentContent + "] is too long for rusEFI online");
settingContextHelp.append("\t" + nameWithPrefix + " = \"" + commentContent + "\"" + EOL);
settingContextHelp.append("\t" + nameWithPrefix + " = " + quote(commentContent) + EOL);
}
if (registerOffsets) {
state.variableRegistry.register(nameWithPrefix + "_offset", tsPosition);

View File

@ -87,11 +87,10 @@ public class ConfigFieldParserTest {
ReaderState state = new ReaderState();
TestTSProjectConsumer tsProjectConsumer = new TestTSProjectConsumer("", state);
state.readBufferedReader(test, (tsProjectConsumer));
state.readBufferedReader(test, tsProjectConsumer);
assertEquals("afr_type1 = bits, S08, 0, [0:1], \"BPSX\", \"Innovate\", \"14Point7\", \"INVALID\"\n" +
"afr_type2 = bits, S08, 1, [0:1], \"BPSX\", \"Innovate\", \"14Point7\", \"INVALID\"\n" +
"int = scalar, S08, 2, \"\", 1, 0, 0, 100, 0\n" +
"alignmentFill_at_3 = scalar, U08, 3, \"units\", 1, 0, -20, 100, 0\n" +
"; total TS size = 4\n", tsProjectConsumer.getContent());
}
@ -107,12 +106,10 @@ public class ConfigFieldParserTest {
ReaderState state = new ReaderState();
TestTSProjectConsumer tsProjectConsumer = new TestTSProjectConsumer("", state);
state.readBufferedReader(test, (tsProjectConsumer));
state.readBufferedReader(test, tsProjectConsumer);
assertEquals("int = scalar, S08, 0, \"\", 1, 0, 0, 100, 0\n" +
"alignmentFill_at_1 = scalar, U08, 1, \"units\", 1, 0, -20, 100, 0\n" +
"afr_type1 = bits, S16, 2, [0:1], \"BPSX\", \"Innovate\", \"14Point7\", \"INVALID\"\n" +
"afr_type2 = bits, S16, 4, [0:1], \"BPSX\", \"Innovate\", \"14Point7\", \"INVALID\"\n" +
"alignmentFill_at_6 = array, U08, 6, [2], \"units\", 1, 0, -20, 100, 0\n" +
"; total TS size = 8\n", tsProjectConsumer.getContent());
}
@ -127,9 +124,8 @@ public class ConfigFieldParserTest {
ReaderState state = new ReaderState();
TestTSProjectConsumer tsProjectConsumer = new TestTSProjectConsumer("", state);
state.readBufferedReader(test, (tsProjectConsumer));
state.readBufferedReader(test, tsProjectConsumer);
assertEquals("int2 = scalar, S08, 0, \"\", 1, 0, 0, 100, 0\n" +
"alignmentFill_at_1 = array, U08, 1, [3], \"units\", 1, 0, -20, 100, 0\n" +
"afr_type3 = bits, S32, 4, [0:1], \"BPSX\", \"Innovate\", \"14Point7\", \"INVALID\"\n" +
"; total TS size = 8\n", tsProjectConsumer.getContent());
}
@ -223,7 +219,7 @@ public class ConfigFieldParserTest {
ReaderState state = new ReaderState();
TSProjectConsumer tsProjectConsumer = new TestTSProjectConsumer("", state);
state.readBufferedReader(test, (tsProjectConsumer));
state.readBufferedReader(test, tsProjectConsumer);
assertEquals("periodMs = scalar, S16, 0, \"ms\", 0.1, 0, 0, 3000, 0\n" +
"periodMs2 = scalar, S16, 2, \"ms\", 1, 0, 0, 3000, 0\n" +
@ -697,7 +693,7 @@ public class ConfigFieldParserTest {
ReaderState state = new ReaderState();
TestTSProjectConsumer tsProjectConsumer = new TestTSProjectConsumer("", state);
state.readBufferedReader(test, (tsProjectConsumer));
state.readBufferedReader(test, tsProjectConsumer);
assertEquals("pid_afr_type = scalar, F32, 0, \"ms\", 1, 0, 0, 3000, 0\n" +
"pid_afr_typet = scalar, F32, 4, \"\", 1, 0, 0, 100, 0\n" +
"pid_isForcedInduction = bits, U32, 8, [0:0], \"false\", \"true\"\n" +

View File

@ -29,7 +29,6 @@ public class OutputsTest {
assertEquals("afr_type = scalar, F32, 0, \"ms\", 1, 0\n" +
"afr_typet = scalar, U08, 4, \"ms\", 1, 0\n" +
"alignmentFill_at_5 = array, U08, 5, [3], \"units\", 1, 0\n" +
"isForcedInduction = bits, U32, 8, [0:0]\n" +
"enableFan1WithAc = bits, U32, 8, [1:1]\n" +
"unusedBit_5_2 = bits, U32, 8, [2:2]\n" +
@ -79,7 +78,7 @@ public class OutputsTest {
ReaderState state = new ReaderState();
OutputsSectionConsumer tsProjectConsumer = new OutputsSectionConsumer(null);
state.readBufferedReader(test, (tsProjectConsumer));
state.readBufferedReader(test, tsProjectConsumer);
}
@Test
@ -229,7 +228,7 @@ public class OutputsTest {
"end_struct\n" +
"\n" +
"injector_s injector\n" +
"\tint[12 iterate] ignitionPins;\n" +
"\tint[12 iterate] ignitionPins;\n" +
"\tfloat bias_resistor;+Pull-up resistor value on your board;\"Ohm\", 1, 0, 0, 200000, 1\n" +
"end_struct\n" +
"struct ThermistorConf @brief Thermistor curve parameters\n" +
@ -319,4 +318,18 @@ public class OutputsTest {
gaugeConsumer.getContent());
}
@Test
public void testLongIterate() throws IOException {
ReaderState state = new ReaderState();
String test = "struct total\n" +
"\tint[3 iterate] triggerSimulatorPins;Each rusEFI piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEFI board.\\nSee also directSelfStimulation which is different.\n" +
"end_struct\n";
TestTSProjectConsumer tsProjectConsumer = new TestTSProjectConsumer("", state);
state.readBufferedReader(test, tsProjectConsumer);
assertEquals(
"\ttriggerSimulatorPins1 = \"Each rusEFI piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEFI board.\"\n" +
"\ttriggerSimulatorPins2 = \"Each rusEFI piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEFI board.\"\n" +
"\ttriggerSimulatorPins3 = \"Each rusEFI piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEFI board.\"\n", tsProjectConsumer.getSettingContextHelp().toString());
}
}

View File

@ -59,7 +59,6 @@ public class TSProjectConsumerTest {
"afrTable = array, U08, 4, [4x4],\"deg\", 0.1, 0, 0, 25.0, 1\n" +
"#endif\n" +
"periodMs = scalar, S16, 20, \"ms\", 0.1, 0, 0, 3000, 0\n" +
"alignmentFill_at_22 = array, U08, 22, [2], \"units\", 1, 0, -20, 100, 0\n" +
"; total TS size = 24\n", tsProjectConsumer.getContent());
assertEquals("\tpublic static final Field PERIODMS2 = Field.create(\"PERIODMS2\", 0, FieldType.INT).setScale(1.0);\n" +