docs & better method name
This commit is contained in:
parent
5c1e333ed6
commit
fabb0145d6
|
@ -68,7 +68,7 @@ public class DataLogConsumer implements ConfigurationConsumer {
|
|||
typeString = "int, \"%d\"";
|
||||
}
|
||||
|
||||
String comment = getComment(prefix, configField, state.variableRegistry);
|
||||
String comment = getHumanGaugeName(prefix, configField, state.variableRegistry);
|
||||
|
||||
if (comments.contains(comment))
|
||||
throw new IllegalStateException(comment + " already present in the outputs! " + configField);
|
||||
|
@ -76,11 +76,14 @@ public class DataLogConsumer implements ConfigurationConsumer {
|
|||
return "entry = " + prefix + configField.getName() + ", " + comment + ", " + typeString + "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Short human-readable field summary as used for gauge names and log file keys taken from the first line of the comment
|
||||
* More detailed technical explanation should be placed in consecutive lines
|
||||
*/
|
||||
@NotNull
|
||||
public static String getComment(String prefix, ConfigField configField, VariableRegistry variableRegistry) {
|
||||
public static String getHumanGaugeName(String prefix, ConfigField configField, VariableRegistry variableRegistry) {
|
||||
String comment = variableRegistry.applyVariables(configField.getComment());
|
||||
String[] comments = comment == null ? new String[0] : unquote(comment).split("\\\\n");
|
||||
comment = (comments.length > 0) ? comments[0] : "";
|
||||
comment = getFirstLine(comment);
|
||||
|
||||
if (comment.isEmpty())
|
||||
comment = prefix + unquote(configField.getName());
|
||||
|
@ -90,6 +93,12 @@ public class DataLogConsumer implements ConfigurationConsumer {
|
|||
return comment;
|
||||
}
|
||||
|
||||
private static String getFirstLine(String comment) {
|
||||
String[] comments = comment == null ? new String[0] : unquote(comment).split("\\\\n");
|
||||
comment = (comments.length > 0) ? comments[0] : "";
|
||||
return comment;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return tsWriter.toString();
|
||||
}
|
||||
|
|
|
@ -3,11 +3,10 @@ package com.rusefi.output;
|
|||
import com.rusefi.ConfigField;
|
||||
import com.rusefi.ReaderState;
|
||||
|
||||
import java.io.CharArrayWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.rusefi.output.DataLogConsumer.getComment;
|
||||
import static com.rusefi.output.DataLogConsumer.getHumanGaugeName;
|
||||
import static org.abego.treelayout.internal.util.java.lang.string.StringUtil.quote;
|
||||
|
||||
public class GaugeConsumer implements ConfigurationConsumer {
|
||||
|
@ -36,7 +35,7 @@ public class GaugeConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
private String handle(ReaderState readerState, ConfigField configField, String prefix) {
|
||||
String comment = getComment("", configField, readerState.variableRegistry);
|
||||
String comment = getHumanGaugeName("", configField, readerState.variableRegistry);
|
||||
comment = ConfigField.unquote(comment);
|
||||
if (!prefix.isEmpty()) {
|
||||
comment = prefix + " " + comment;
|
||||
|
|
|
@ -41,7 +41,7 @@ public class SdCardFieldsContent {
|
|||
private String getLine(ReaderState readerState, ConfigField configField, String prefix, String name) {
|
||||
return "\t{" + home + "." + name +
|
||||
", "
|
||||
+ DataLogConsumer.getComment(prefix, configField, readerState.variableRegistry) +
|
||||
+ DataLogConsumer.getHumanGaugeName(prefix, configField, readerState.variableRegistry) +
|
||||
", " +
|
||||
quote(configField.getUnits()) +
|
||||
", " +
|
||||
|
|
Loading…
Reference in New Issue