generate SD log category correctly (#5023)

This commit is contained in:
Matthew Kennedy 2023-02-01 03:45:18 -08:00 committed by GitHub
parent 2474b04c85
commit f2441a6688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 15 deletions

Binary file not shown.

View File

@ -1,5 +1,7 @@
package com.rusefi.output;
import com.rusefi.core.SensorCategory;
import com.rusefi.ConfigField;
import com.rusefi.ReaderState;
@ -39,6 +41,14 @@ public class SdCardFieldsContent {
}
private String getLine(ConfigField configField, String prefix, String name) {
String categoryStr = configField.getCategory();
if(categoryStr == null) {
categoryStr = "";
} else {
categoryStr = ", " + categoryStr;
}
return "\t{" + home + "." + name +
", "
+ DataLogConsumer.getHumanGaugeName(prefix, configField) +
@ -46,9 +56,7 @@ public class SdCardFieldsContent {
quote(configField.getUnits()) +
", " +
configField.getDigits() +
", " +
configField.getCategory() +
categoryStr +
"},\n";
}

View File

@ -24,17 +24,17 @@ public class SdCardFieldsGeneratorTest {
String test = "struct_no_prefix output_channels_s\n" +
"\tfloat autoscale internalMcuTemperature\n" +
"uint16_t autoscale RPMValue;@@GAUGE_NAME_RPM@@;\"RPM\",1, 0, 0, 8000, 2\n" +
"uint16_t autoscale RPMValue;@@GAUGE_NAME_RPM@@;\"RPM\",1, 0, 0, 8000, 2, \"myCategory\"\n" +
"\n" +
"uint16_t rpmAcceleration;dRPM;\"RPM/s\",1, 0, 0, 5, 2\n" +
"\n" +
"\tuint16_t autoscale speedToRpmRatio;@@GAUGE_NAME_GEAR_RATIO@@;\"value\",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0\n" +
"end_struct";
processAndAssert(test, "\t{engine->outputChannels.internalMcuTemperature, \"internalMcuTemperature\", \"\", 0, null},\n" +
"\t{engine->outputChannels.RPMValue, \"hello\", \"RPM\", 2, null},\n" +
"\t{engine->outputChannels.rpmAcceleration, \"dRPM\", \"RPM/s\", 2, null},\n" +
"\t{engine->outputChannels.speedToRpmRatio, \"ra\", \"value\", 0, null},\n" +
processAndAssert(test, "\t{engine->outputChannels.internalMcuTemperature, \"internalMcuTemperature\", \"\", 0},\n" +
"\t{engine->outputChannels.RPMValue, \"hello\", \"RPM\", 2, \"myCategory\"},\n" +
"\t{engine->outputChannels.rpmAcceleration, \"dRPM\", \"RPM/s\", 2},\n" +
"\t{engine->outputChannels.speedToRpmRatio, \"ra\", \"value\", 0},\n" +
"", actor);
}
@ -43,7 +43,7 @@ public class SdCardFieldsGeneratorTest {
processAndAssert("struct_no_prefix output_channels_s\n" +
"uint16_t autoscale RPMValue;feee;\"RPM\",1, 0, 0, 8000, 2\n" +
"bit sd_logging_internal\n" +
"end_struct", "\t{engine->outputChannels.RPMValue, \"feee\", \"RPM\", 2, null},\n", readerState -> {
"end_struct", "\t{engine->outputChannels.RPMValue, \"feee\", \"RPM\", 2},\n", readerState -> {
});
}
@ -52,10 +52,10 @@ public class SdCardFieldsGeneratorTest {
public void array() {
processAndAssert("struct_no_prefix output_channels_s\n" +
"uint16_t[4 iterate] recentErrorCode;;\"error\", 1, 0, 0, 0, 0\n" +
"end_struct", "\t{engine->outputChannels.recentErrorCode[0], \"recentErrorCode 1\", \"error\", 0, null},\n" +
"\t{engine->outputChannels.recentErrorCode[1], \"recentErrorCode 2\", \"error\", 0, null},\n" +
"\t{engine->outputChannels.recentErrorCode[2], \"recentErrorCode 3\", \"error\", 0, null},\n" +
"\t{engine->outputChannels.recentErrorCode[3], \"recentErrorCode 4\", \"error\", 0, null},\n", readerState -> {
"end_struct", "\t{engine->outputChannels.recentErrorCode[0], \"recentErrorCode 1\", \"error\", 0},\n" +
"\t{engine->outputChannels.recentErrorCode[1], \"recentErrorCode 2\", \"error\", 0},\n" +
"\t{engine->outputChannels.recentErrorCode[2], \"recentErrorCode 3\", \"error\", 0},\n" +
"\t{engine->outputChannels.recentErrorCode[3], \"recentErrorCode 4\", \"error\", 0},\n", readerState -> {
});
}
@ -68,7 +68,7 @@ public class SdCardFieldsGeneratorTest {
" end_struct\n" +
"\tpid_status_s alternatorStatus\n" +
"end_struct",
"\t{engine->outputChannels.alternatorStatus.pTerm, \"alternatorStatus.pTerm\", \"\", 2, null},\n",
"\t{engine->outputChannels.alternatorStatus.pTerm, \"alternatorStatus.pTerm\", \"\", 2},\n",
readerState -> {
});
@ -86,4 +86,4 @@ public class SdCardFieldsGeneratorTest {
state.readBufferedReader(input, consumer);
assertEquals(expectedOutput, consumer.getBody());
}
}
}