Allow for decoded DBC signal output without attaching the name to the

resulting string. Used by CSV output.
This commit is contained in:
Collin Kidder
2023-07-11 20:36:17 -04:00
parent 627ac8b899
commit e2438efac5
3 changed files with 18 additions and 11 deletions
+7 -5
View File
@@ -118,7 +118,7 @@ s 5 47 46 45 44 43 42 41 40
So, the bits are 12, 11, 10, 9, 8, 23, 22, 21. Yes, that's confusing. They now go in reverse value order too.
Bit 12 is worth 128, 11 is worth 64, etc until bit 21 is worth 1.
*/
bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool outputName)
bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool outputName, bool outputUnit)
{
int64_t result = 0;
bool isSigned = false;
@@ -170,7 +170,7 @@ bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool o
endResult = (*((double *)(&result)) * factor) + bias;
}
outString = makePrettyOutput(endResult, result, outputName, isInteger);
outString = makePrettyOutput(endResult, result, outputName, isInteger, outputUnit);
cachedValue = endResult;
return true;
}
@@ -191,7 +191,7 @@ bool DBC_SIGNAL::getValueString(int64_t intVal, QString &outString)
return false;
}
QString DBC_SIGNAL::makePrettyOutput(double floatVal, int64_t intVal, bool outputName, bool isInteger)
QString DBC_SIGNAL::makePrettyOutput(double floatVal, int64_t intVal, bool outputName, bool isInteger, bool outputUnit)
{
QString outputString;
@@ -209,11 +209,13 @@ QString DBC_SIGNAL::makePrettyOutput(double floatVal, int64_t intVal, bool outpu
break;
}
}
if (!foundVal) outputString += QString::number(intVal) + unitName;
if (!foundVal) outputString += QString::number(intVal);
if (outputUnit) outputString += unitName;
}
else //otherwise display the actual number and unit (if it exists)
{
outputString += (isInteger ? QString::number(intVal) : QString::number(floatVal)) + unitName;
outputString += (isInteger ? QString::number(intVal) : QString::number(floatVal));
if (outputUnit) outputString += unitName;
}
return outputString;
}
+2 -2
View File
@@ -114,11 +114,11 @@ public: //TODO: this is sloppy. It shouldn't all be public!
DBC_SIGNAL *self;
DBC_SIGNAL();
bool processAsText(const CANFrame &frame, QString &outString, bool outputName = true);
bool processAsText(const CANFrame &frame, QString &outString, bool outputName = true, bool outputUnit = true);
bool processAsInt(const CANFrame &frame, int32_t &outValue);
bool processAsDouble(const CANFrame &frame, double &outValue);
bool getValueString(int64_t intVal, QString &outString);
QString makePrettyOutput(double floatVal, int64_t intVal, bool outputName = true, bool isInteger = false);
QString makePrettyOutput(double floatVal, int64_t intVal, bool outputName = true, bool isInteger = false, bool outputUnit = true);
QString processSignalTree(const CANFrame &frame);
DBC_ATTRIBUTE_VALUE *findAttrValByName(QString name);
DBC_ATTRIBUTE_VALUE *findAttrValByIdx(int idx);