Merge branch 'master' into support_multiple_signal_multiplex_values

This commit is contained in:
Collin Kidder
2025-05-05 20:53:25 -04:00
committed by GitHub
56 changed files with 2312 additions and 865 deletions
+8 -4
View File
@@ -166,12 +166,16 @@ QString DBC_SIGNAL::processSignalTree(const CANFrame &frame)
if (sig->processAsText(frame, sigString))
{
qDebug() << "Returned value: " << sigString;
if (!build.isEmpty() && !sigString.isEmpty())
build.append("\n");
build.append(sigString);
build.append("\n");
if (sig->isMultiplexor)
{
qDebug() << "Spelunkin!";
build.append(sig->processSignalTree(frame));
auto subTreeString = sig->processSignalTree(frame);
if (!build.isEmpty() && !subTreeString.isEmpty())
build.append("\n");
build.append(subTreeString);
}
}
}
@@ -300,12 +304,12 @@ QString DBC_SIGNAL::makePrettyOutput(double floatVal, int64_t intVal, bool outpu
}
}
if (!foundVal) outputString += QString::number(intVal);
if (outputUnit) outputString += unitName;
if (outputUnit) outputString += " " + unitName;
}
else //otherwise display the actual number and unit (if it exists)
{
outputString += (isInteger ? QString::number(intVal) : QString::number(floatVal));
if (outputUnit) outputString += unitName;
if (outputUnit) outputString += " " + unitName;
}
return outputString;
}
+47 -4
View File
@@ -674,6 +674,44 @@ bool DBCFile::parseSignalMultiplexValueLine(QString line)
return false;
}
bool DBCFile::parseSignalValueTypeLine(QString line)
{
QRegularExpression regex;
QRegularExpressionMatch match;
qDebug() << "Found a signal valtype line";
regex.setPattern("^SIG\\_VALTYPE\\_ *(\\d+) *([-\\w]+) *: *(\\d+);");
match = regex.match(line);
// captured 1 is the message id
// captured 2 is the signal name
// captured 3 is the valtype
if (!match.hasMatch()) { return false; }
uint32_t id = match.captured(1).toULong() & 0x1FFFFFFFUL;
DBC_MESSAGE *msg = messageHandler->findMsgByID(match.captured(1).toULong() & 0x1FFFFFFFUL);
if (msg == nullptr) { return false; }
DBC_SIGNAL *thisSignal = msg->sigHandler->findSignalByName(match.captured(2));
if (thisSignal == nullptr) { return false; }
int valType = match.captured(3).toInt();
switch (valType) {
case 1: {
thisSignal->valType = SP_FLOAT;
break;
}
case 2: {
thisSignal->valType = DP_FLOAT;
break;
}
default: {
return false;
}
}
return true;
}
bool DBCFile::parseValueLine(QString line)
{
QRegularExpression regex;
@@ -737,7 +775,7 @@ bool DBCFile::parseAttributeLine(QString line)
if (foundAttr)
{
qDebug() << "That message attribute does exist";
DBC_MESSAGE *foundMsg = messageHandler->findMsgByID(match.captured(2).toUInt() & 0x1FFFFFFFul);
DBC_MESSAGE *foundMsg = messageHandler->findMsgByID(match.captured(2).toULong() & 0x1FFFFFFFul);
if (foundMsg)
{
qDebug() << "It references a valid, registered message";
@@ -769,7 +807,7 @@ bool DBCFile::parseAttributeLine(QString line)
if (foundAttr)
{
qDebug() << "That signal attribute does exist";
DBC_MESSAGE *foundMsg = messageHandler->findMsgByID(match.captured(2).toUInt() & 0x1FFFFFFFUL);
DBC_MESSAGE *foundMsg = messageHandler->findMsgByID(match.captured(2).toULong() & 0x1FFFFFFFUL);
if (foundMsg)
{
qDebug() << "It references a valid, registered message";
@@ -941,6 +979,11 @@ bool DBCFile::loadFile(QString fileName)
if (!parseSignalMultiplexValueLine(line)) numSigFaults++;
}
if (line.startsWith("SIG_VALTYPE_ ")) //defines a signal value type
{
if (!parseSignalValueTypeLine(line)) numSigFaults++;
}
if (line.startsWith("BU_:")) //line specifies the nodes on this canbus
{
qDebug() << "Found a BU line";
@@ -976,7 +1019,7 @@ bool DBCFile::loadFile(QString fileName)
if (match.hasMatch())
{
//qDebug() << "Comment was: " << match.captured(3);
DBC_MESSAGE *msg = messageHandler->findMsgByID(match.captured(1).toUInt());
DBC_MESSAGE *msg = messageHandler->findMsgByID(match.captured(1).toULong() & 0x1FFFFFFFul);
if (msg != nullptr)
{
DBC_SIGNAL *sig = msg->sigHandler->findSignalByName(match.captured(2));
@@ -997,7 +1040,7 @@ bool DBCFile::loadFile(QString fileName)
if (match.hasMatch())
{
//qDebug() << "Comment was: " << match.captured(2);
DBC_MESSAGE *msg = messageHandler->findMsgByID(match.captured(1).toUInt());
DBC_MESSAGE *msg = messageHandler->findMsgByID(match.captured(1).toULong() & 0x1FFFFFFFul);
if (msg != nullptr)
{
msg->comment = match.captured(2);
+1
View File
@@ -106,6 +106,7 @@ private:
bool parseSignalMultiplexValueLine(QString line);
DBC_MESSAGE* parseMessageLine(QString line);
bool parseValueLine(QString line);
bool parseSignalValueTypeLine(QString line);
bool parseAttributeLine(QString line);
bool parseDefaultAttrLine(QString line);
};