SD card bit datapoints #7227

only:problem
This commit is contained in:
rusefillc 2025-01-07 20:09:19 -05:00
parent 6823bacade
commit 95f0c183d6
3 changed files with 59 additions and 9 deletions

View File

@ -25,16 +25,32 @@ public class SdCardFieldsGeneratorTest {
"\tfloat autoscale internalMcuTemperature\n" +
"uint16_t autoscale RPMValue;@@GAUGE_NAME_RPM@@;\"RPM\",1, 0, 0, 8000, 2, \"myCategory\"\n" +
"\n" +
"\t\tfloat fu2elAdd;Lua: Fuel add;\"g\", 1, 0, 0, 1, 3\n" +
"\t\tfloat fue2lMult;Lua: Fuel mult;\n" +
"uint16_t rpmAcceleration;dRPM;\"RPM/s\",1, 0, 0, 5, 2\n" +
"\tstruct LuaAdjustments\n" +
"\t\tfloat fuelMult;Lua: Fuel mult;\n" +
"\n" +
"\t\tbit clutchUpState\n" +
"\t\tbit brakePedalState\n" +
"\t\tbit disableDecelerationFuelCutOff\n" +
"\t\tbit torqueReductionState\n" +
"\tend_struct\n" +
"LuaAdjustments lua\n" +
"\tuint16_t autoscale speedToRpmRatio;@@GAUGE_NAME_GEAR_RATIO@@;\"value\",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0\n" +
"end_struct";
processAndAssert(test, "\t{test->reference.internalMcuTemperature, \"internalMcuTemperature\", \"\", 0},\n" +
"\t{test->reference.RPMValue, \"hello\", \"RPM\", 2, \"myCategory\"},\n" +
"\t{test->reference.fu2elAdd, \"Lua: Fuel add\", \"g\", 3},\n" +
"\t{test->reference.fue2lMult, \"Lua: Fuel mult\", \"\", 0},\n" +
"\t{test->reference.rpmAcceleration, \"dRPM\", \"RPM/s\", 2},\n" +
"\t{test->reference.speedToRpmRatio, \"ra\", \"value\", 0},\n" +
"", actor, false);
"\t{test->reference.lua.fuelMult, \"Lua: Fuel mult\", \"\", 0},\n" +
"// structureStartingTsPosition 0 test->reference/\"lua.clutchUpState\", skipping bit at 4 4@0\n" +
"// structureStartingTsPosition 0 test->reference/\"lua.brakePedalState\", skipping bit at 4 4@1\n" +
"// structureStartingTsPosition 0 test->reference/\"lua.disableDecelerationFuelCutOff\", skipping bit at 4 4@2\n" +
"// structureStartingTsPosition 0 test->reference/\"lua.torqueReductionState\", skipping bit at 4 4@3\n" +
"\t{test->reference.speedToRpmRatio, \"ra\", \"value\", 0},\n", actor, false);
}
@Test

View File

@ -72,10 +72,13 @@ public class SdCardFieldsContent {
}
private static String getLine(ConfigField configField, String prefix, String namePrefix, String name, String expression, Boolean isPtr, String conditional, int currentPosition, PerFieldWithStructuresIterator perFieldWithStructuresIterator, int structureStartingTsPosition) {
String humanName = DataLogConsumer.getHumanGaugeName(prefix, configField, namePrefix);
if (configField.isBit()) {
// 'structureStartingTsPosition' is about fragment list see fragments.h
int offsetWithinCurrentStructure = currentPosition - structureStartingTsPosition;
return "// structureStartingTsPosition " + structureStartingTsPosition + " " + expression + "/" + DataLogConsumer.getHumanGaugeName(prefix, configField, namePrefix) + ", skipping bit " + namePrefix + " at " + currentPosition + " " + offsetWithinCurrentStructure + "@" + perFieldWithStructuresIterator.bitState.get() + "\n";
// if (offsetWithinCurrentStructure < 0)
// throw new IllegalStateException(humanName + " seems broken: " + currentPosition + " vs " + structureStartingTsPosition);
return "// structureStartingTsPosition " + structureStartingTsPosition + " " + expression + "/" + humanName + ", skipping bit " + namePrefix + " at " + currentPosition + " " + offsetWithinCurrentStructure + "@" + perFieldWithStructuresIterator.bitState.get() + "\n";
}
String categoryStr = configField.getCategory();
@ -97,7 +100,7 @@ public class SdCardFieldsContent {
+ "\t{" +
expression + (isPtr ? "->" : ".") + name +
", "
+ DataLogConsumer.getHumanGaugeName(prefix, configField, namePrefix) +
+ humanName +
", " +
quote(configField.getUnits()) +
", " +

View File

@ -41,6 +41,15 @@ public class LiveDataProcessorTest {
return new StringReader("struct_no_prefix output_state_s\n" +
"\tuint16_t oootempC;Temperature;\"C\", 1, 0, 500, 1000, 0\n" +
"\tuint16_t oooesr;ESR;\"ohm\", 1, 0, 0, 10000, 0\n" +
"\tstruct LuaAdjustments\n" +
"\t\tfloat fuelMult;Lua: Fuel mult;\n" +
"\n" +
"\t\tbit clutchUpState\n" +
"\t\tbit brakePedalState\n" +
"\t\tbit disableDecelerationFuelCutOff\n" +
"\t\tbit torqueReductionState\n" +
"\tend_struct\n" +
"LuaAdjustments lua\n" +
"end_struct");
} else {
return new StringReader("struct_no_prefix wideband_state_s\n" +
@ -68,7 +77,12 @@ public class LiveDataProcessorTest {
"; total TS size = 24\n" +
"oootempC = scalar, U16, 24, \"C\", 1, 0\n" +
"oooesr = scalar, U16, 26, \"ohm\", 1, 0\n" +
"; total TS size = 28\n", liveDataProcessor.getOutputsSectionFileName());
"lua_fuelMult = scalar, F32, 28, \"\", 1, 0\n" +
"lua_clutchUpState = bits, U32, 32, [0:0]\n" +
"lua_brakePedalState = bits, U32, 32, [1:1]\n" +
"lua_disableDecelerationFuelCutOff = bits, U32, 32, [2:2]\n" +
"lua_torqueReductionState = bits, U32, 32, [3:3]\n" +
"; total TS size = 36\n", liveDataProcessor.getOutputsSectionFileName());
captor.assertOutput("entry = tempC0, \"WBO: Temperature0\", int, \"%d\"\n" +
"entry = bitName10, \"bitName10\", int, \"%d\"\n" +
@ -79,7 +93,12 @@ public class LiveDataProcessorTest {
"entry = bitName21, \"bitName21\", int, \"%d\"\n" +
"entry = esr1, \"WBO: ESR1\", int, \"%d\"\n" +
"entry = oootempC, \"Temperature\", int, \"%d\"\n" +
"entry = oooesr, \"ESR\", int, \"%d\"\n", liveDataProcessor.getDataLogFileName());
"entry = oooesr, \"ESR\", int, \"%d\"\n" +
"entry = lua_fuelMult, \"Lua: Fuel mult\", float, \"%.3f\"\n" +
"entry = lua_clutchUpState, \"lua_clutchUpState\", int, \"%d\"\n" +
"entry = lua_brakePedalState, \"lua_brakePedalState\", int, \"%d\"\n" +
"entry = lua_disableDecelerationFuelCutOff, \"lua_disableDecelerationFuelCutOff\", int, \"%d\"\n" +
"entry = lua_torqueReductionState, \"lua_torqueReductionState\", int, \"%d\"\n", liveDataProcessor.getDataLogFileName());
captor.assertOutput("// generated by gen_live_documentation.sh / LiveDataProcessor.java\n" +
@ -107,11 +126,18 @@ public class LiveDataProcessorTest {
"\t\tgraphLine = tempC1\n" +
"\t\tgraphLine = esr1\n" +
"\n" +
"indicatorPanel = output_channelsIndicatorPanel, 2\n" +
"\tindicator = {lua_clutchUpState}, \"clutchUpState No\", \"clutchUpState Yes\"\n" +
"\tindicator = {lua_brakePedalState}, \"brakePedalState No\", \"brakePedalState Yes\"\n" +
"\tindicator = {lua_disableDecelerationFuelCutOff}, \"disableDecelerationFuelCutOff No\", \"disableDecelerationFuelCutOff Yes\"\n" +
"\tindicator = {lua_torqueReductionState}, \"torqueReductionState No\", \"torqueReductionState Yes\"\n" +
"\n" +
"dialog = output_channelsDialog, \"output_channels\"\n" +
"\tpanel = output_channelsIndicatorPanel\n" +
"\tliveGraph = output_channels_1_Graph, \"Graph\", South\n" +
"\t\tgraphLine = oootempC\n" +
"\t\tgraphLine = oooesr\n" +
"\t\tgraphLine = lua_fuelMult\n" +
"\n", liveDataProcessor.getFancyContentIni());
captor.assertOutput("\t\t\tsubMenu = wbo_channels0Dialog, \"wbo_channels0\"\n" +
@ -137,6 +163,11 @@ public class LiveDataProcessorTest {
"\t{engine->wbo2.esr, \"WBO: ESRwb2\", \"ohm\", 0},\n" +
"\t{engine->outputChannels.oootempC, \"Temperature\", \"C\", 0},\n" +
"\t{engine->outputChannels.oooesr, \"ESR\", \"ohm\", 0},\n" +
"\t{engine->outputChannels.lua.fuelMult, \"Lua: Fuel mult\", \"\", 0},\n" +
"// structureStartingTsPosition 24 engine->outputChannels/\"lua.clutchUpState\", skipping bit at 4 -20@0\n" +
"// structureStartingTsPosition 24 engine->outputChannels/\"lua.brakePedalState\", skipping bit at 4 -20@1\n" +
"// structureStartingTsPosition 24 engine->outputChannels/\"lua.disableDecelerationFuelCutOff\", skipping bit at 4 -20@2\n" +
"// structureStartingTsPosition 24 engine->outputChannels/\"lua.torqueReductionState\", skipping bit at 4 -20@3\n" +
"};\n",
destinationFolder + SdCardFieldsContent.SD_CARD_OUTPUT_FILE_NAME);