progress towards logging more!

only:f407-discovery
This commit is contained in:
rusefillc 2023-12-06 13:38:19 -05:00
parent 1dc5788a2e
commit ed98d7c4b4
14 changed files with 190 additions and 112 deletions

View File

@ -199,7 +199,7 @@ enable2ndByteCanID = false
egoCorrectionForVeAnalyze = { 100 + fuelPidCorrection1 }
wbo0_hasFault = { enableAemXSeries && (faultCode >= 3) }
wbo0_hasFault = { enableAemXSeries && (faultCode0 >= 3) }
[PcVariables]
tuneCrcPcVariable = continuousChannelValue, tuneCrc16
@ -1658,7 +1658,7 @@ gaugeCategory = GPPWM Outputs
indicator = { isTriggerError}, "Trigger OK", "Trigger ERR", white, black, red, black
indicator = { fuelCutReason != 0 }, "Injection OK", { Fuel cut: bitStringValue(fuelIgnCutCodeList, fuelCutReason)}, white, black, yellow, black
indicator = { sparkCutReason != 0 }, "Ignition OK", { Ign cut: bitStringValue(fuelIgnCutCodeList, sparkCutReason)}, white, black, yellow, black
indicator = { etbErrorCode != 0 }, "ETB OK", { ETB: bitStringValue(etbCutCodeList, etbErrorCode)}, white, black, yellow, black
indicator = { etbErrorCode0 != 0 }, "ETB OK", { ETB: bitStringValue(etbCutCodeList, etbErrorCode0)}, white, black, yellow, black
; minor info
indicator = { isFanOn }, "Fan off", "Fan on", white, black, green, black
@ -1690,9 +1690,9 @@ gaugeCategory = GPPWM Outputs
indicator = { sd_present }, "No SD card", "SD card present", white, black, green, black
indicator = { sd_logging_internal }, "No SD logging", "SD logging", white, black, green, black
indicator = { sd_msd }, "No SD USB", "SD USB", white, black, green, black
indicator = { etbRevLimitActive }, "No ETB RPM Limit", "ETB RPM Limit", white, black, yellow, black
indicator = { etbRevLimitActive0 }, "No ETB RPM Limit", "ETB RPM Limit", white, black, yellow, black
indicator = { wbo0_hasFault }, { WBO0: bitStringValue(wboFaultCodeList, faultCode)}, { WBO0: bitStringValue(wboFaultCodeList, faultCode)}, white, black, red, black
indicator = { wbo0_hasFault }, { WBO0: bitStringValue(wboFaultCodeList, faultCode0)}, { WBO0: bitStringValue(wboFaultCodeList, faultCode0)}, white, black, red, black
indicator = {injectorHwIssue}, "inj", "INJ", white, black, red, black@@if_ts_show_inj_diag
; indicator = { isInjectionEnabled && fuelCutReason == 0 }, { Inj: bitStringValue(injModeList, currentInjectionMode) }, { Inj: bitStringValue(injModeList, currentInjectionMode) }, white, black, white, black

View File

@ -1,7 +1,5 @@
package com.rusefi.util;
import java.io.IOException;
public interface LazyFile extends Output {
interface LazyFileFactory {
LazyFile create(String fileName);

View File

@ -143,9 +143,9 @@ public class TSProjectConsumer implements ConfigurationConsumer {
}
@Override
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) {
state.getVariableRegistry().register(structure.getName() + "_size", structure.getTotalSize());
totalTsSize = tsOutput.run(readerState, structure, 0);
totalTsSize = tsOutput.run(readerState, structure, 0, "", "");
if (state.isStackEmpty()) {
state.getVariableRegistry().register("TOTAL_CONFIG_SIZE", totalTsSize);

View File

@ -34,7 +34,7 @@ public class FragmentDialogConsumerTest {
"\tint8_t autoscale internalMcuTemperature;mcu;\"deg C\",1, 0, 0, 0, 0\n" +
"end_struct\n";
FragmentDialogConsumer fragmentDialogConsumer = new FragmentDialogConsumer("ac_state");
FragmentDialogConsumer fragmentDialogConsumer = new FragmentDialogConsumer("ac_state", "");
state.readBufferedReader(outputChannels, fragmentDialogConsumer);

View File

@ -159,7 +159,7 @@ public class OutputsTest {
ReaderStateImpl state = new ReaderStateImpl();
state.getVariableRegistry().register("GAUGE_CATEGORY", "Alternator");
DataLogConsumer dataLogConsumer = new DataLogConsumer(null, new TestFileCaptor());
GaugeConsumer gaugeConsumer = new GaugeConsumer(null);
GaugeConsumer gaugeConsumer = new GaugeConsumer(null, new TestFileCaptor());
state.readBufferedReader(test, dataLogConsumer, gaugeConsumer);
assertEquals(
"entry = alternatorStatus_iTerm, \"alternatorStatus_iTerm\", float, \"%.3f\"\n" +

View File

@ -9,6 +9,7 @@ import org.yaml.snakeyaml.Yaml;
import java.io.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class LiveDataProcessor {
@ -19,15 +20,18 @@ public class LiveDataProcessor {
private final static String enumContentFileName = "console/binary/generated/live_data_ids.h";
private final static String tsOutputsDestination = "console/binary/";
public static final String GAUGES = tsOutputsDestination + File.separator + "generated/gauges.ini";
public static final String DATA_LOG_FILE_NAME = tsOutputsDestination + File.separator + "generated/data_logs.ini";
public static final String OUTPUTS_SECTION_FILE_NAME = tsOutputsDestination + File.separator + "generated/output_channels.ini";
public static final String DATA_FRAGMENTS_H = "console/binary/generated/live_data_fragments.h";
public static final String STATE_DICTIONARY_FACTORY_JAVA = "../java_console/io/src/main/java/com/rusefi/enums/StateDictionaryFactory.java";
public static final String FANCY_CONTENT_INI = "console/binary/generated/fancy_content.ini";
public static final String FANCY_MENU_INI = "console/binary/generated/fancy_menu.ini";
private final ReaderProvider readerProvider;
private final LazyFile.LazyFileFactory fileFactory;
private final GaugeConsumer gaugeConsumer = new GaugeConsumer(tsOutputsDestination + File.separator + "generated/gauges.ini");
private final GaugeConsumer gaugeConsumer;
private final StringBuilder enumContent = new StringBuilder(header +
"#pragma once\n" +
@ -52,6 +56,7 @@ public class LiveDataProcessor {
this.readerProvider = readerProvider;
this.fileFactory = fileFactory;
stateDictionaryGenerator = new StateDictionaryGenerator(yamlFileName);
gaugeConsumer = new GaugeConsumer(GAUGES, fileFactory);
}
public static void main(String[] args) throws IOException {
@ -65,27 +70,9 @@ public class LiveDataProcessor {
LiveDataProcessor liveDataProcessor = new LiveDataProcessor(yamlFileName, ReaderProvider.REAL, LazyFile.REAL);
int sensorTsPosition = liveDataProcessor.handleYaml(data);
log.info("TS_TOTAL_OUTPUT_SIZE=" + sensorTsPosition);
try (FileWriter fw = new FileWriter("console/binary/generated/total_live_data_generated.h")) {
fw.write(header);
fw.write("#define TS_TOTAL_OUTPUT_SIZE " + sensorTsPosition);
}
try (FileWriter fw = new FileWriter("console/binary/generated/sensors.java")) {
fw.write(liveDataProcessor.totalSensors.toString());
}
try (FileWriter fw = new FileWriter("console/binary/generated/fancy_content.ini")) {
fw.write(liveDataProcessor.fancyNewStuff.toString());
}
try (FileWriter fw = new FileWriter("console/binary/generated/fancy_menu.ini")) {
fw.write(liveDataProcessor.fancyNewMenu.toString());
}
liveDataProcessor.end();
liveDataProcessor.end(sensorTsPosition);
}
public static Map<String, Object> getStringObjectMap(Reader reader) {
@ -100,8 +87,13 @@ public class LiveDataProcessor {
output.write("};\r\n");
}
private void end() throws IOException {
gaugeConsumer.endFile();
private void end(int sensorTsPosition) throws IOException {
log.info("TS_TOTAL_OUTPUT_SIZE=" + sensorTsPosition);
try (FileWriter fw = new FileWriter("console/binary/generated/total_live_data_generated.h")) {
fw.write(header);
fw.write("#define TS_TOTAL_OUTPUT_SIZE " + sensorTsPosition);
}
}
interface EntryHandler {
@ -114,7 +106,7 @@ public class LiveDataProcessor {
OutputsSectionConsumer outputsSections = new OutputsSectionConsumer(OUTPUTS_SECTION_FILE_NAME,
fileFactory);
ConfigurationConsumer dataLogConsumer = new DataLogConsumer(DATA_LOG_FILE_NAME, fileFactory);
DataLogConsumer dataLogConsumer = new DataLogConsumer(DATA_LOG_FILE_NAME, fileFactory);
SdCardFieldsContent sdCardFieldsConsumer = new SdCardFieldsContent();
@ -136,12 +128,24 @@ public class LiveDataProcessor {
state.setDefinitionInputFile(folder + File.separator + name + ".txt");
state.setWithC_Defines(withCDefines);
outputsSections.outputNames = outputNames;
dataLogConsumer.outputNames = outputNames;
gaugeConsumer.outputNames = outputNames;
state.addDestination(javaSensorsConsumer,
outputsSections,
dataLogConsumer
);
FragmentDialogConsumer fragmentDialogConsumer = new FragmentDialogConsumer(name);
state.addDestination(fragmentDialogConsumer);
List<FragmentDialogConsumer> fragmentConsumers = new ArrayList<>();
for (int i = 0; i < tempLimit(outputNames); i++) {
String variableNameSuffix = outputNames.length > 1 ? Integer.toString(i) : "";
FragmentDialogConsumer fragmentDialogConsumer = new FragmentDialogConsumer(name, variableNameSuffix);
fragmentConsumers.add(fragmentDialogConsumer);
state.addDestination(fragmentDialogConsumer);
}
if (extraPrepend != null)
state.addPrepend(extraPrepend);
@ -179,9 +183,10 @@ public class LiveDataProcessor {
state.doJob();
fancyNewStuff.append(fragmentDialogConsumer.getContent());
fancyNewMenu.append(fragmentDialogConsumer.menuLine());
for (FragmentDialogConsumer fragmentDialogConsumer : fragmentConsumers) {
fancyNewStuff.append(fragmentDialogConsumer.getContent());
fancyNewMenu.append(fragmentDialogConsumer.menuLine());
}
log.info("Done with " + name + " at " + javaSensorsConsumer.sensorTsPosition);
}
@ -211,10 +216,9 @@ public class LiveDataProcessor {
String[] outputNamesArr;
if (outputNames == null) {
outputNamesArr = new String[0];
outputNamesArr = new String[]{""};
} else if (outputNames instanceof String) {
outputNamesArr = new String[1];
outputNamesArr[0] = (String) outputNames;
outputNamesArr = new String[]{(String) outputNames};
} else {
ArrayList<String> nameList = (ArrayList<String>) outputNames;
outputNamesArr = new String[nameList.size()];
@ -234,7 +238,7 @@ public class LiveDataProcessor {
.append(">{},\n");
} else {
for (int i = 0; i < outputNamesArr.length; i++) {
if (i != 0) {
if (needComment(i)) {
// TODO: remove once the rest of the handling for multiple copies of one struct is in place.
fragmentsContent.append("// ");
}
@ -258,6 +262,17 @@ public class LiveDataProcessor {
dataLogConsumer.endFile();
outputValueConsumer.endFile();
try (LazyFile fw = fileFactory.create("console/binary/generated/sensors.java")) {
fw.write(totalSensors.toString());
}
try (LazyFile fw = fileFactory.create(FANCY_CONTENT_INI)) {
fw.write(fancyNewStuff.toString());
}
try (LazyFile fw = fileFactory.create(FANCY_MENU_INI)) {
fw.write(fancyNewMenu.toString());
}
GetConfigValueConsumer.writeStringToFile(STATE_DICTIONARY_FACTORY_JAVA, stateDictionaryGenerator.getCompleteClass(), fileFactory);
@ -269,6 +284,7 @@ public class LiveDataProcessor {
}
private void writeFiles() throws IOException {
gaugeConsumer.endFile();
try (LazyFile fw = fileFactory.create(enumContentFileName)) {
fw.write(enumContent.toString());
fw.write(baseAddressCHeader.toString());
@ -278,4 +294,12 @@ public class LiveDataProcessor {
fw.write(fragmentsContent.toString());
}
}
public static int tempLimit(String[] outputs) {
return 1;
}
public static boolean needComment(int index) {
return index > 0;
}
}

View File

@ -13,10 +13,12 @@ import java.io.IOException;
import java.util.TreeSet;
import static com.rusefi.VariableRegistry.unquote;
import static com.rusefi.ldmp.LiveDataProcessor.needComment;
/**
* here we generate [Datalog] section of TS .ini file
* DataLog section in turn references [OutputChannels] entities
*
* @see SdCardFieldsContent
*/
public class DataLogConsumer implements ConfigurationConsumer {
@ -28,6 +30,7 @@ public class DataLogConsumer implements ConfigurationConsumer {
private final LazyFile.LazyFileFactory fileFactory;
private final StringBuilder tsWriter = new StringBuilder();
private final TreeSet<String> comments = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
public String[] outputNames = new String[] {""};
public DataLogConsumer(String fileName, LazyFile.LazyFileFactory fileFactory) {
this.fileName = fileName;
@ -37,22 +40,31 @@ public class DataLogConsumer implements ConfigurationConsumer {
@Override
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
if (readerState.isStackEmpty()) {
PerFieldWithStructuresIterator.Strategy strategy = new PerFieldWithStructuresIterator.Strategy() {
@Override
public String process(ReaderState state, ConfigField configField, String prefix) {
return handle(configField, prefix);
}
@Override
public boolean skip(ConfigField cf) {
return false;
}
};
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(readerState, structure.getTsFields(), "",
strategy);
iterator.loop();
String content = iterator.getContent();
tsWriter.append(content);
for (int i = 0; i < outputNames.length; i++) {
String temporaryLineComment = needComment(i) ? ";" : "";
String variableNameSuffix = outputNames.length > 1 ? Integer.toString(i) : "";
PerFieldWithStructuresIterator.Strategy strategy = new PerFieldWithStructuresIterator.Strategy() {
@Override
public String process(ReaderState state, ConfigField configField, String prefix) {
return handle(configField, prefix, temporaryLineComment, variableNameSuffix);
}
@Override
public boolean skip(ConfigField cf) {
return false;
}
};
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(readerState, structure.getTsFields(), "",
strategy);
iterator.loop();
String content = iterator.getContent();
tsWriter.append(content);
}
}
}
@ -69,7 +81,7 @@ public class DataLogConsumer implements ConfigurationConsumer {
}
}
private String handle(ConfigField configField, String prefix) {
private String handle(ConfigField configField, String prefix, String temporaryLineComment, String variableNameSuffix) {
if (configField.getName().contains(UNUSED))
return "";
@ -88,12 +100,12 @@ public class DataLogConsumer implements ConfigurationConsumer {
typeString = "int, \"%d\"";
}
String comment = getHumanGaugeName(prefix, configField);
String comment = getHumanGaugeName(prefix, configField, variableNameSuffix);
if (comments.contains(comment))
throw new IllegalStateException(comment + " already present in the outputs! " + configField);
comments.add(comment);
return "entry = " + prefix + configField.getName() + ", " + comment + ", " + typeString + "\n";
return temporaryLineComment + "entry = " + prefix + configField.getName() + variableNameSuffix + ", " + comment + ", " + typeString + "\n";
}
/**
@ -101,7 +113,7 @@ public class DataLogConsumer implements ConfigurationConsumer {
* More detailed technical explanation should be placed in consecutive lines
*/
@NotNull
public static String getHumanGaugeName(String prefix, ConfigField configField) {
public static String getHumanGaugeName(String prefix, ConfigField configField, String variableNameSuffix) {
String comment = configField.getCommentTemplated();
comment = getFirstLine(comment);
@ -111,6 +123,7 @@ public class DataLogConsumer implements ConfigurationConsumer {
*/
comment = prefix + unquote(configField.getName());
}
comment = comment + variableNameSuffix;
if (comment.length() > MSQ_LENGTH_LIMIT)
throw new IllegalStateException("[" + comment + "] is too long for log files at " + comment.length());

View File

@ -1,7 +1,6 @@
package com.rusefi.output;
import com.rusefi.ConfigField;
import com.rusefi.ConfigFieldImpl;
import com.rusefi.ReaderState;
import org.jetbrains.annotations.NotNull;
@ -14,24 +13,17 @@ public class FragmentDialogConsumer implements ConfigurationConsumer {
private final StringBuilder indicatorPanel = new StringBuilder();
private final String fragmentName;
private final String variableNameSuffix;
private boolean hasIndicators;
private int graphLinesCounter;
private int linesInCurrentGraph;
private int currentGraphIndex;
public FragmentDialogConsumer(String fragmentName) {
public FragmentDialogConsumer(String fragmentName, String variableNameSuffix) {
this.fragmentName = fragmentName;
this.variableNameSuffix = variableNameSuffix;
}
@Override
public void startFile() {
}
@Override
public void endFile() throws IOException {
}
@Override
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
FieldsStrategy fieldsStrategy = new FieldsStrategy() {
@ -56,7 +48,7 @@ public class FragmentDialogConsumer implements ConfigurationConsumer {
hasIndicators = true;
indicatorPanel.append("indicatorPanel = " + getPanelName() + ", 2\n");
}
indicatorPanel.append("\tindicator = {" + prefix + configField.getName() + "}, " +
indicatorPanel.append("\tindicator = {" + prefix + configField.getName() + variableNameSuffix + "}, " +
"\"" + configField.getName() + " No\", " +
"\"" + configField.getName() + " Yes\"" +
"\n");
@ -72,7 +64,7 @@ public class FragmentDialogConsumer implements ConfigurationConsumer {
startNewGraph();
}
graphList.append("\t\tgraphLine = " + prefix + configField.getName() + "\n");
graphList.append("\t\tgraphLine = " + prefix + configField.getName() + variableNameSuffix + "\n");
linesInCurrentGraph++;
@ -92,13 +84,13 @@ public class FragmentDialogConsumer implements ConfigurationConsumer {
@NotNull
private String getPanelName() {
return fragmentName + "IndicatorPanel";
return getFragmentNameWithSuffix() + "IndicatorPanel";
}
public String menuLine() {
if (getContent().isEmpty())
return "";
return "\t\t\tsubMenu = " + getDialogName() + ", " + quote(fragmentName) + "\n";
return "\t\t\tsubMenu = " + getDialogName() + ", " + quote(getFragmentNameWithSuffix()) + "\n";
}
public String getContent() {
@ -107,7 +99,7 @@ public class FragmentDialogConsumer implements ConfigurationConsumer {
return "";
}
String dialogDeclaration = "dialog = " + getDialogName() + ", " + quote(fragmentName) + "\n";
String dialogDeclaration = "dialog = " + getDialogName() + ", " + quote(getFragmentNameWithSuffix()) + "\n";
String indicatorPanelUsageLine = (indicatorPanel.length() > 0) ? "\tpanel = " + getPanelName() + "\n" : "";
@ -122,11 +114,16 @@ public class FragmentDialogConsumer implements ConfigurationConsumer {
@NotNull
private String getDialogName() {
return fragmentName + "Dialog";
return getFragmentNameWithSuffix() + "Dialog";
}
@NotNull
private String getGraphControlName() {
return fragmentName + "_" + currentGraphIndex + "_Graph";
return getFragmentNameWithSuffix() + "_" + currentGraphIndex + "_Graph";
}
@NotNull
private String getFragmentNameWithSuffix() {
return fragmentName + variableNameSuffix;
}
}

View File

@ -4,42 +4,51 @@ import com.rusefi.ConfigField;
import com.rusefi.ConfigFieldImpl;
import com.rusefi.ReaderState;
import com.rusefi.VariableRegistry;
import com.rusefi.util.LazyFile;
import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import static com.rusefi.ldmp.LiveDataProcessor.tempLimit;
import static com.rusefi.output.DataLogConsumer.getHumanGaugeName;
public class GaugeConsumer implements ConfigurationConsumer {
private final String fileName;
private final LazyFile.LazyFileFactory fileFactory;
private final LinkedHashMap<String, StringBuilder> byCategory = new LinkedHashMap<>();
public String[] outputNames;
public GaugeConsumer(String fileName) {
public GaugeConsumer(String fileName, LazyFile.LazyFileFactory fileFactory) {
this.fileName = fileName;
this.fileFactory = fileFactory;
}
@Override
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
if (readerState.isStackEmpty()) {
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(readerState, structure.getTsFields(), "",
(state, configField, prefix) -> handle(configField, prefix));
iterator.loop();
for (int i = 0; i < tempLimit(outputNames); i++) {
String variableNameSuffix = outputNames.length > 1 ? Integer.toString(i) : "";
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(readerState, structure.getTsFields(), "",
(state, configField, prefix) -> handle(configField, prefix, variableNameSuffix));
iterator.loop();
}
}
}
@Override
public void endFile() throws IOException {
if (fileName != null) {
FileWriter fw = new FileWriter(fileName);
LazyFile fw = fileFactory.create(fileName);
fw.write(getContent());
fw.close();
}
}
private String handle(ConfigField configField, String prefix) {
String comment = getHumanGaugeName("", configField);
private String handle(ConfigField configField, String prefix, String variableNameSuffix) {
String comment = getHumanGaugeName("", configField, "");
comment = ConfigFieldImpl.unquote(comment);
if (!prefix.isEmpty()) {
comment = prefix + " " + comment;
@ -57,7 +66,7 @@ public class GaugeConsumer implements ConfigurationConsumer {
StringBuilder sb = byCategory.computeIfAbsent(category, s -> new StringBuilder());
String fullName = prefix + configField.getName();
String gaugeEntry = fullName + "Gauge = " + fullName + "," + comment +
String gaugeEntry = fullName + variableNameSuffix + "Gauge = " + fullName + variableNameSuffix + "," + comment +
", " + VariableRegistry.quote(configField.getUnits()) +
", " + min + "," + max +
", " + min + "," + max +

View File

@ -4,10 +4,11 @@ import com.devexperts.logging.Logging;
import com.rusefi.ReaderState;
import com.rusefi.util.LazyFile;
import java.io.FileWriter;
import java.io.IOException;
import static com.devexperts.logging.Logging.getLogging;
import static com.rusefi.ldmp.LiveDataProcessor.needComment;
import static com.rusefi.ldmp.LiveDataProcessor.tempLimit;
/**
* TODO: We have to move either forward or backwards with newparse #4441
@ -19,6 +20,7 @@ public class OutputsSectionConsumer implements ConfigurationConsumer {
private final String tsOutputsSectionFileName;
private final LazyFile.LazyFileFactory fileFactory;
private final TsOutput tsOutput;
public String[] outputNames = new String[]{""};
private int sensorTsPosition;
public OutputsSectionConsumer(String tsOutputsSectionFileName, LazyFile.LazyFileFactory fileFactory) {
@ -39,13 +41,20 @@ public class OutputsSectionConsumer implements ConfigurationConsumer {
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
log.info("handleEndStruct");
sensorTsPosition = tsOutput.run(readerState, structure, sensorTsPosition);
for (int i = 0; i < tempLimit(outputNames); i++) {
String temporaryLineComment = needComment(i) ? ";" : "";
if (readerState.isStackEmpty()) {
if (tsOutputsSectionFileName != null) {
LazyFile fos = fileFactory.create(tsOutputsSectionFileName);
fos.write(tsOutput.getContent());
fos.close();
String variableNameSuffix = outputNames.length > 1 ? Integer.toString(i) : "";
sensorTsPosition = tsOutput.run(readerState, structure, sensorTsPosition, temporaryLineComment, variableNameSuffix);
if (readerState.isStackEmpty()) {
if (tsOutputsSectionFileName != null) {
LazyFile fos = fileFactory.create(tsOutputsSectionFileName);
fos.write(tsOutput.getContent());
fos.close();
}
}
}
}

View File

@ -67,7 +67,7 @@ public class SdCardFieldsContent {
+ "\t{" +
home + (isPtr ? "->" : ".") + name +
", "
+ DataLogConsumer.getHumanGaugeName(prefix, configField) +
+ DataLogConsumer.getHumanGaugeName(prefix, configField, "") +
", " +
quote(configField.getUnits()) +
", " +

View File

@ -39,14 +39,14 @@ public class TsOutput {
return settingContextHelp.toString();
}
public int run(ReaderState state, ConfigStructure structure, int sensorTsPosition) {
public int run(ReaderState state, ConfigStructure structure, int sensorTsPosition, String temporaryLineComment, String variableNameSuffix) {
FieldsStrategy strategy = new FieldsStrategy() {
@Override
public int writeOneField(FieldIterator it, String prefix, int tsPosition) {
ConfigField configField = it.cf;
ConfigField next = it.next;
int bitIndex = it.bitState.get();
String nameWithPrefix = prefix + configField.getName();
String nameWithPrefix = prefix + configField.getName() + variableNameSuffix;
/**
* in 'Constants' section we have conditional sections and this check is not smart enough to handle those right
@ -74,7 +74,7 @@ public class TsOutput {
if (configField.getComment() != null && configField.getComment().trim().length() > 0 && cs == null) {
String commentContent = configField.getCommentTemplated();
commentContent = ConfigFieldImpl.unquote(commentContent);
settingContextHelp.append("\t" + nameWithPrefix + " = " + quote(commentContent) + EOL);
settingContextHelp.append(temporaryLineComment + "\t" + nameWithPrefix + " = " + quote(commentContent) + EOL);
}
if (cs != null) {
@ -84,7 +84,7 @@ public class TsOutput {
if (configField.isBit()) {
if (!configField.getName().startsWith(ConfigStructureImpl.UNUSED_BIT_PREFIX)) {
tsHeader.append(nameWithPrefix + " = bits, U32,");
tsHeader.append(temporaryLineComment + nameWithPrefix + " = bits, U32,");
tsHeader.append(" " + tsPosition + ", [");
tsHeader.append(bitIndex + ":" + bitIndex);
tsHeader.append("]");
@ -111,7 +111,7 @@ public class TsOutput {
if (!configField.getName().equals(next.getName()))
tsPosition += configField.getState().getTsCustomSize().get(configField.getType());
} else if (configField.getArraySizes().length == 0) {
tsHeader.append(nameWithPrefix + " = scalar, ");
tsHeader.append(temporaryLineComment + nameWithPrefix + " = scalar, ");
tsHeader.append(TypesHelper.convertToTs(configField.getType()) + ",");
tsHeader.append(" " + tsPosition + ",");
tsHeader.append(" " + handleTsInfo(configField, configField.getTsInfo(), 1));

View File

@ -41,7 +41,8 @@ public class LiveDataProcessorTest {
"end_struct");
} else {
return new StringReader("struct_no_prefix wideband_state_s\n" +
"\tuint16_t tempC;WBO: Temperature;\"C\", 1, 0, 500, 1000, 0\n" +
"\tuint16_t tempC;WBO: Temperature;\"C\", 1, 0, 500, 1000, 0, \"cate\"\n" +
"bit bitName\n" +
"\tuint16_t esr;WBO: ESR;\"ohm\", 1, 0, 0, 10000, 0\n" +
"end_struct");
@ -49,17 +50,22 @@ public class LiveDataProcessorTest {
}
}, captor);
liveDataProcessor.handleYaml(data);
assertEquals(10, captor.fileCapture.size());
assertEquals(14, captor.fileCapture.size());
captor.assertOutput("tempC = scalar, U16, 0, \"C\", 1, 0\n" +
"esr = scalar, U16, 2, \"ohm\", 1, 0\n" +
"; total TS size = 4\n" +
"oootempC = scalar, U16, 4, \"C\", 1, 0\n" +
"oooesr = scalar, U16, 6, \"ohm\", 1, 0\n" +
"; total TS size = 8\n", LiveDataProcessor.OUTPUTS_SECTION_FILE_NAME);
captor.assertOutput("tempC0 = scalar, U16, 0, \"C\", 1, 0\n" +
"bitName0 = bits, U32, 4, [0:0]\n" +
"esr0 = scalar, U16, 8, \"ohm\", 1, 0\n" +
"; total TS size = 12\n" +
"oootempC = scalar, U16, 12, \"C\", 1, 0\n" +
"oooesr = scalar, U16, 14, \"ohm\", 1, 0\n" +
"; total TS size = 16\n", LiveDataProcessor.OUTPUTS_SECTION_FILE_NAME);
captor.assertOutput("entry = tempC, \"WBO: Temperature\", int, \"%d\"\n" +
"entry = esr, \"WBO: ESR\", int, \"%d\"\n" +
captor.assertOutput("entry = tempC0, \"WBO: Temperature0\", int, \"%d\"\n" +
"entry = bitName0, \"bitName0\", int, \"%d\"\n" +
"entry = esr0, \"WBO: ESR0\", int, \"%d\"\n" +
";entry = tempC1, \"WBO: Temperature1\", int, \"%d\"\n" +
";entry = bitName1, \"bitName1\", int, \"%d\"\n" +
";entry = esr1, \"WBO: ESR1\", int, \"%d\"\n" +
"entry = oootempC, \"Temperature\", int, \"%d\"\n" +
"entry = oooesr, \"ESR\", int, \"%d\"\n", LiveDataProcessor.DATA_LOG_FILE_NAME);
@ -68,5 +74,27 @@ public class LiveDataProcessorTest {
"decl_frag<wbo_channels_s, 0>{},\t// wb1\n" +
"// decl_frag<wbo_channels_s, 1>{},\t// wb2\n" +
"decl_frag<output_channels_s>{},\n", LiveDataProcessor.DATA_FRAGMENTS_H);
captor.assertOutput("indicatorPanel = wbo_channels0IndicatorPanel, 2\n" +
"\tindicator = {bitName0}, \"bitName No\", \"bitName Yes\"\n" +
"\n" +
"dialog = wbo_channels0Dialog, \"wbo_channels0\"\n" +
"\tpanel = wbo_channels0IndicatorPanel\n" +
"\tliveGraph = wbo_channels0_1_Graph, \"Graph\", South\n" +
"\t\tgraphLine = tempC0\n" +
"\t\tgraphLine = esr0\n" +
"\n" +
"\n" +
"dialog = output_channelsDialog, \"output_channels\"\n" +
"\tliveGraph = output_channels_1_Graph, \"Graph\", South\n" +
"\t\tgraphLine = oootempC\n" +
"\t\tgraphLine = oooesr\n" +
"\n", LiveDataProcessor.FANCY_CONTENT_INI);
captor.assertOutput("\t\t\tsubMenu = wbo_channels0Dialog, \"wbo_channels0\"\n" +
"\t\t\tsubMenu = output_channelsDialog, \"output_channels\"\n", LiveDataProcessor.FANCY_MENU_INI);
captor.assertOutput("\tgaugeCategory = \"cate\"\n" +
"tempC0Gauge = tempC0,\"WBO: Temperature\", \"C\", 500.0,1000.0, 500.0,1000.0, 500.0,1000.0, 0,0\n", LiveDataProcessor.GAUGES);
}
}

View File

@ -32,7 +32,7 @@ public class StateDictionaryGeneratorTest {
TestFileCaptor captor = new TestFileCaptor();
LiveDataProcessor liveDataProcessor = new LiveDataProcessor("test", fileName -> new StringReader(""), captor);
liveDataProcessor.handleYaml(data);
assertEquals("number of outputs", 10, captor.fileCapture.size());
assertEquals("number of outputs", 14, captor.fileCapture.size());
assertEquals(" stateDictionary.register(live_data_e.LDS_output_channels, TsOutputs.VALUES, \"status_loop\");\n" +
" stateDictionary.register(live_data_e.LDS_fuel_computer, FuelComputer.VALUES, \"fuel_computer\");\n", liveDataProcessor.stateDictionaryGenerator.content.toString());