field type into header comment

This commit is contained in:
rusefillc 2021-04-26 17:51:29 -04:00
parent 10a6da8ac0
commit 0594a5b305
6 changed files with 33 additions and 8 deletions

View File

@ -886,7 +886,7 @@ custom uart_device_e 1 bits,U08, @OFFSET@, [0:1], "Off", "UART1", "UART2", "UA
uint16_t tps1SecondaryMin;;"ADC", 1, 0, 0, 1000, 0
uint16_t tps1SecondaryMax;;"ADC", 1, 0, 0, 1000, 0
int16_t antiLagRpmTreshold;;"rpm", 1, 0, 0, 20000, 0
uint16_t startCrankingDuration;Maximum time to crank starter;"Seconds", 1, 0, 0, 30, 0
uint16_t startCrankingDuration;+Maximum time to crank starter when start/stop button is pressed;"Seconds", 1, 0, 0, 30, 0
brain_pin_e triggerErrorPin;+This pin is used for debugging - snap a logic analyzer on it and see if it's ever high
pin_output_mode_e triggerErrorPinMode;

Binary file not shown.

View File

@ -21,6 +21,7 @@ import java.util.zip.ZipInputStream;
/**
* Andrey Belomutskiy, (c) 2013-2020
* 1/12/15
* @see ConfigurationConsumer
*/
@SuppressWarnings("StringConcatenationInsideStringBufferAppend")
public class ConfigDefinition {
@ -465,8 +466,14 @@ public class ConfigDefinition {
}
public static String getComment(String comment, int currentOffset) {
return "\t/**" + EOL + packComment(comment, "\t") + "\t * offset " + currentOffset + EOL + "\t */" + EOL;
public static String getComment(String comment, int currentOffset, String units) {
String start = "\t/**";
String packedComment = packComment(comment, "\t");
String unitsComment = units.isEmpty() ? "" : "\t" + units + EOL;
return start + EOL +
packedComment +
unitsComment +
"\t * offset " + currentOffset + EOL + "\t */" + EOL;
}
public static String packComment(String comment, String linePrefix) {

View File

@ -236,5 +236,22 @@ public class ConfigField {
return fsioVisible;
}
public String getUnits() {
if (tsInfo == null)
return "";
String[] tokens = tsInfo.split("\\,");
if (tokens.length == 0)
return "";
return unquote(tokens[0].trim());
}
private static String unquote(String token) {
int length = token.length();
if (length < 2)
return token;
if (token.charAt(0) == '\"')
return token.substring(1, length - 1);
return token;
}
}

View File

@ -14,7 +14,7 @@ public abstract class BaseCHeaderConsumer implements ConfigurationConsumer {
return comment + "\t" + BOOLEAN_TYPE + " " + configField.getName() + " : 1;" + EOL;
}
String cEntry = ConfigDefinition.getComment(configField.getCommentContent(), currentOffset);
String cEntry = ConfigDefinition.getComment(configField.getCommentContent(), currentOffset, configField.getUnits());
if (!configField.isArray()) {
// not an array

View File

@ -1,9 +1,6 @@
package com.rusefi.test;
import com.rusefi.ConfigField;
import com.rusefi.ReaderState;
import com.rusefi.TypesHelper;
import com.rusefi.VariableRegistry;
import com.rusefi.*;
import com.rusefi.output.*;
import org.junit.Test;
@ -67,6 +64,10 @@ public class ConfigFieldParserTest {
state.readBufferedReader(reader, Arrays.asList(javaFieldsConsumer));
assertEquals(16, TypesHelper.getElementSize(state, "pid_s"));
ConfigStructure structure = state.structures.get("pid_s");
ConfigField firstField = structure.cFields.get(0);
assertEquals("ms", firstField.getUnits());
}
@Test