Switched code around to better support high/low range for multiplexed
signals
This commit is contained in:
+5
-11
@@ -19,7 +19,8 @@ DBC_SIGNAL::DBC_SIGNAL()
|
||||
isMultiplexor = false;
|
||||
max = 1;
|
||||
min = 0;
|
||||
multiplexValue = 0;
|
||||
multiplexLowValue = 0;
|
||||
multiplexHighValue = 0;
|
||||
factor = 1.0;
|
||||
intelByteOrder = false;
|
||||
parentMessage = nullptr;
|
||||
@@ -30,13 +31,6 @@ DBC_SIGNAL::DBC_SIGNAL()
|
||||
valType = DBC_SIG_VAL_TYPE::UNSIGNED_INT;
|
||||
}
|
||||
|
||||
DBC_MULTIPLEX::DBC_MULTIPLEX()
|
||||
{
|
||||
lowerBound = 0;
|
||||
upperBound = 0;
|
||||
sig = nullptr;
|
||||
}
|
||||
|
||||
/*
|
||||
The way that the DBC file format works is kind of weird... For intel format signals you count up
|
||||
from the start bit to the end bit which is (startbit + signallength - 1). At each point
|
||||
@@ -91,7 +85,7 @@ bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool o
|
||||
{
|
||||
int val;
|
||||
if (!parentMessage->multiplexorSignal->processAsInt(frame, val)) return false;
|
||||
if (val != multiplexValue) return false; //signal not found in this message
|
||||
if (val != multiplexLowValue) return false; //signal not found in this message
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
@@ -182,7 +176,7 @@ bool DBC_SIGNAL::processAsInt(const CANFrame &frame, int32_t &outValue)
|
||||
{
|
||||
int val;
|
||||
if (!parentMessage->multiplexorSignal->processAsInt(frame, val)) return false;
|
||||
if (val != multiplexValue) return false; //signal not found in this message
|
||||
if (val != multiplexLowValue) return false; //signal not found in this message
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
@@ -225,7 +219,7 @@ bool DBC_SIGNAL::processAsDouble(const CANFrame &frame, double &outValue)
|
||||
{
|
||||
int val;
|
||||
if (!parentMessage->multiplexorSignal->processAsInt(frame, val)) return false;
|
||||
if (val != multiplexValue) return false; //signal not found in this message
|
||||
if (val != multiplexLowValue) return false; //signal not found in this message
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
+3
-11
@@ -85,15 +85,6 @@ public:
|
||||
class DBC_MESSAGE; //forward reference so that DBC_SIGNAL can compile before we get to real definition of DBC_MESSAGE
|
||||
class DBC_SIGNAL;
|
||||
|
||||
class DBC_MULTIPLEX
|
||||
{
|
||||
public:
|
||||
int lowerBound, upperBound;
|
||||
DBC_SIGNAL *sig;
|
||||
|
||||
DBC_MULTIPLEX();
|
||||
};
|
||||
|
||||
class DBC_SIGNAL
|
||||
{
|
||||
public: //TODO: this is sloppy. It shouldn't all be public!
|
||||
@@ -103,7 +94,8 @@ public: //TODO: this is sloppy. It shouldn't all be public!
|
||||
bool intelByteOrder; //true is obviously little endian. False is big endian
|
||||
bool isMultiplexor;
|
||||
bool isMultiplexed;
|
||||
int multiplexValue;
|
||||
int multiplexHighValue;
|
||||
int multiplexLowValue;
|
||||
DBC_SIG_VAL_TYPE valType;
|
||||
double factor;
|
||||
double bias;
|
||||
@@ -116,7 +108,7 @@ public: //TODO: this is sloppy. It shouldn't all be public!
|
||||
QVariant cachedValue;
|
||||
QList<DBC_ATTRIBUTE_VALUE> attributes;
|
||||
QList<DBC_VAL_ENUM_ENTRY> valList;
|
||||
QList<DBC_MULTIPLEX> multiplexedChildren;
|
||||
QList<DBC_SIGNAL *> multiplexedChildren;
|
||||
DBC_SIGNAL *multiplexParent;
|
||||
|
||||
DBC_SIGNAL();
|
||||
|
||||
+13
-16
@@ -453,7 +453,8 @@ DBC_SIGNAL* DBCFile::parseSignalLine(QString line, DBC_MESSAGE *msg)
|
||||
//bool isMultiplexed = false;
|
||||
DBC_SIGNAL sig;
|
||||
|
||||
sig.multiplexValue = 0;
|
||||
sig.multiplexLowValue = 0;
|
||||
sig.multiplexHighValue = 0;
|
||||
sig.isMultiplexed = false;
|
||||
sig.isMultiplexor = false;
|
||||
|
||||
@@ -476,7 +477,8 @@ DBC_SIGNAL* DBCFile::parseSignalLine(QString line, DBC_MESSAGE *msg)
|
||||
qDebug() << "Multiplexed signal";
|
||||
//isMultiplexed = true;
|
||||
sig.isMultiplexed = true;
|
||||
sig.multiplexValue = match.captured(2).toInt();
|
||||
sig.multiplexLowValue = match.captured(2).toInt();
|
||||
sig.multiplexHighValue = sig.multiplexLowValue;
|
||||
offset = 1;
|
||||
}
|
||||
else
|
||||
@@ -488,7 +490,8 @@ DBC_SIGNAL* DBCFile::parseSignalLine(QString line, DBC_MESSAGE *msg)
|
||||
qDebug() << "Extended Multiplexor Signal";
|
||||
sig.isMultiplexor = true; //we don't set the local isMultiplexor variable because this isn't the top level multiplexor
|
||||
sig.isMultiplexed = true; //but, it is both a multiplexor and multiplexed
|
||||
sig.multiplexValue = match.captured(2).toInt();
|
||||
sig.multiplexLowValue = match.captured(2).toInt();
|
||||
sig.multiplexHighValue = sig.multiplexLowValue;
|
||||
offset = 1;
|
||||
}
|
||||
else
|
||||
@@ -605,11 +608,7 @@ bool DBCFile::parseSignalMultiplexValueLine(QString line)
|
||||
if (parentSignal != nullptr)
|
||||
{
|
||||
//now need to add "thisSignal" to the children multiplexed signals of "parentSignal"
|
||||
DBC_MULTIPLEX mx;
|
||||
mx.lowerBound = match.captured(4).toInt();
|
||||
mx.upperBound = match.captured(5).toInt();
|
||||
mx.sig = thisSignal;
|
||||
parentSignal->multiplexedChildren.append(mx);
|
||||
parentSignal->multiplexedChildren.append(thisSignal);
|
||||
thisSignal->multiplexParent = parentSignal;
|
||||
return true;
|
||||
}
|
||||
@@ -1102,11 +1101,7 @@ bool DBCFile::loadFile(QString fileName)
|
||||
if (sig->isMultiplexed && (sig->multiplexParent == nullptr) )
|
||||
{
|
||||
sig->multiplexParent = msg->multiplexorSignal;
|
||||
DBC_MULTIPLEX mlt;
|
||||
mlt.sig = sig;
|
||||
mlt.lowerBound = sig->multiplexValue;
|
||||
mlt.upperBound = mlt.lowerBound;
|
||||
msg->multiplexorSignal->multiplexedChildren.append(mlt);
|
||||
msg->multiplexorSignal->multiplexedChildren.append(sig);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1388,7 +1383,7 @@ bool DBCFile::saveFile(QString fileName)
|
||||
if (sig->isMultiplexor) msgOutput.append(" M");
|
||||
if (sig->isMultiplexed)
|
||||
{
|
||||
msgOutput.append(" m" + QString::number(sig->multiplexValue));
|
||||
msgOutput.append(" m" + QString::number(sig->multiplexLowValue));
|
||||
}
|
||||
|
||||
msgOutput.append(" : " + QString::number(sig->startBit) + "|" + QString::number(sig->signalSize) + "@");
|
||||
@@ -1764,12 +1759,14 @@ DBCFile* DBCHandler::loadJSONFile(QString filename)
|
||||
if (!sigObj.find("mux_id")->isUndefined())
|
||||
{
|
||||
QJsonValue muxVal = sigObj.find("mux_id").value();
|
||||
sig.multiplexValue = muxVal.toInt();
|
||||
sig.multiplexLowValue = muxVal.toInt();
|
||||
sig.multiplexHighValue = sig.multiplexLowValue;
|
||||
sig.isMultiplexed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sig.multiplexValue = 0;
|
||||
sig.multiplexLowValue = 0;
|
||||
sig.multiplexHighValue = 0;
|
||||
}
|
||||
QJsonValue muxerVal = sigObj.find("is_muxer").value();
|
||||
if (!muxerVal.isNull())
|
||||
|
||||
@@ -363,7 +363,9 @@ QString DBCMainEditor::createSignalText(DBC_SIGNAL *sig)
|
||||
QString sigInfo;
|
||||
if (sig->isMultiplexed)
|
||||
{
|
||||
sigInfo = "(" + QString::number(sig->multiplexValue) + ") ";
|
||||
sigInfo = "(" + QString::number(sig->multiplexLowValue);
|
||||
if (sig->multiplexHighValue != sig->multiplexLowValue) sigInfo += "-" + QString::number(sig->multiplexHighValue);
|
||||
sigInfo += ") ";
|
||||
}
|
||||
sigInfo.append(sig->name);
|
||||
if (sig->comment.count() > 0) sigInfo.append(" - ").append(sig->comment);
|
||||
@@ -386,7 +388,7 @@ void DBCMainEditor::processSignalToTree(QTreeWidgetItem *parent, DBC_SIGNAL *sig
|
||||
{
|
||||
for (int i = 0; i < sig->multiplexedChildren.count(); i++)
|
||||
{
|
||||
processSignalToTree(sigItem, sig->multiplexedChildren[i].sig);
|
||||
processSignalToTree(sigItem, sig->multiplexedChildren[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+31
-28
@@ -180,15 +180,26 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
|
||||
emit updatedTreeInfo(currentSignal);
|
||||
});
|
||||
|
||||
connect(ui->txtMultiplexValue, &QLineEdit::editingFinished,
|
||||
connect(ui->txtMultiplexLow, &QLineEdit::editingFinished,
|
||||
[=]()
|
||||
{
|
||||
if (currentSignal == nullptr) return;
|
||||
int temp;
|
||||
temp = Utility::ParseStringToNum(ui->txtMultiplexValue->text());
|
||||
if (currentSignal->multiplexValue != temp) dbcFile->setDirtyFlag();
|
||||
temp = Utility::ParseStringToNum(ui->txtMultiplexLow->text());
|
||||
if (currentSignal->multiplexLowValue != temp) dbcFile->setDirtyFlag();
|
||||
//TODO: could look up the multiplexor and ensure that the value is within a range that the multiplexor could return
|
||||
currentSignal->multiplexValue = temp;
|
||||
currentSignal->multiplexLowValue = temp;
|
||||
});
|
||||
|
||||
connect(ui->txtMultiplexHigh, &QLineEdit::editingFinished,
|
||||
[=]()
|
||||
{
|
||||
if (currentSignal == nullptr) return;
|
||||
int temp;
|
||||
temp = Utility::ParseStringToNum(ui->txtMultiplexHigh->text());
|
||||
if (currentSignal->multiplexHighValue != temp) dbcFile->setDirtyFlag();
|
||||
//TODO: could look up the multiplexor and ensure that the value is within a range that the multiplexor could return
|
||||
currentSignal->multiplexHighValue = temp;
|
||||
});
|
||||
|
||||
connect(ui->rbExtended, &QRadioButton::toggled,
|
||||
@@ -201,7 +212,8 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
|
||||
//an extended multi signal cannot be the root multiplexor for a message so make sure to remove it if it was.
|
||||
if (dbcMessage->multiplexorSignal == currentSignal) dbcMessage->multiplexorSignal = nullptr;
|
||||
}
|
||||
ui->txtMultiplexValue->setEnabled(currentSignal->isMultiplexed);
|
||||
ui->txtMultiplexLow->setEnabled(currentSignal->isMultiplexed);
|
||||
ui->txtMultiplexHigh->setEnabled(currentSignal->isMultiplexed);
|
||||
ui->cbMultiplexParent->setEnabled(currentSignal->isMultiplexed);
|
||||
dbcFile->setDirtyFlag();
|
||||
});
|
||||
@@ -216,7 +228,8 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
|
||||
//if the set multiplexor for the message was this signal then clear it
|
||||
if (dbcMessage->multiplexorSignal == currentSignal) dbcMessage->multiplexorSignal = nullptr;
|
||||
}
|
||||
ui->txtMultiplexValue->setEnabled(currentSignal->isMultiplexed);
|
||||
ui->txtMultiplexLow->setEnabled(currentSignal->isMultiplexed);
|
||||
ui->txtMultiplexHigh->setEnabled(currentSignal->isMultiplexed);
|
||||
ui->cbMultiplexParent->setEnabled(currentSignal->isMultiplexed);
|
||||
dbcFile->setDirtyFlag();
|
||||
});
|
||||
@@ -233,7 +246,8 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
|
||||
//we just set that this is the multiplexor so update the message to show that as well.
|
||||
dbcMessage->multiplexorSignal = currentSignal;
|
||||
}
|
||||
ui->txtMultiplexValue->setEnabled(currentSignal->isMultiplexed);
|
||||
ui->txtMultiplexLow->setEnabled(currentSignal->isMultiplexed);
|
||||
ui->txtMultiplexHigh->setEnabled(currentSignal->isMultiplexed);
|
||||
ui->cbMultiplexParent->setEnabled(currentSignal->isMultiplexed);
|
||||
dbcFile->setDirtyFlag();
|
||||
});
|
||||
@@ -247,7 +261,8 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
|
||||
currentSignal->isMultiplexor = false;
|
||||
if (dbcMessage->multiplexorSignal == currentSignal) dbcMessage->multiplexorSignal = nullptr;
|
||||
}
|
||||
ui->txtMultiplexValue->setEnabled(currentSignal->isMultiplexed);
|
||||
ui->txtMultiplexLow->setEnabled(currentSignal->isMultiplexed);
|
||||
ui->txtMultiplexHigh->setEnabled(currentSignal->isMultiplexed);
|
||||
ui->cbMultiplexParent->setEnabled(currentSignal->isMultiplexed);
|
||||
dbcFile->setDirtyFlag();
|
||||
});
|
||||
@@ -259,26 +274,11 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
|
||||
//add it to this one, update this signal's parent multiplexor
|
||||
DBC_SIGNAL *newSig = dbcMessage->sigHandler->findSignalByName(ui->cbMultiplexParent->currentText());
|
||||
DBC_SIGNAL *oldParent = currentSignal->multiplexParent;
|
||||
int low = currentSignal->multiplexValue;
|
||||
int high = low;
|
||||
if (newSig)
|
||||
{
|
||||
for (int i = 0; i < oldParent->multiplexedChildren.count(); i++)
|
||||
{
|
||||
if (oldParent->multiplexedChildren[i].sig == currentSignal)
|
||||
{
|
||||
low = oldParent->multiplexedChildren[i].lowerBound;
|
||||
high = oldParent->multiplexedChildren[i].upperBound;
|
||||
oldParent->multiplexedChildren.removeAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
oldParent->multiplexedChildren.removeOne(currentSignal);
|
||||
currentSignal->multiplexParent = newSig;
|
||||
DBC_MULTIPLEX mlt;
|
||||
mlt.lowerBound = low;
|
||||
mlt.upperBound = high;
|
||||
mlt.sig = currentSignal;
|
||||
newSig->multiplexedChildren.append(mlt);
|
||||
newSig->multiplexedChildren.append(currentSignal);
|
||||
dbcFile->setDirtyFlag();
|
||||
}
|
||||
});
|
||||
@@ -441,7 +441,8 @@ void DBCSignalEditor::fillSignalForm(DBC_SIGNAL *sig)
|
||||
ui->txtMinVal->setText("");
|
||||
ui->txtScale->setText("");
|
||||
ui->txtUnitName->setText("");
|
||||
ui->txtMultiplexValue->setText("");
|
||||
ui->txtMultiplexLow->setText("");
|
||||
ui->txtMultiplexHigh->setText("");
|
||||
ui->rbMultiplexed->setChecked(false);
|
||||
ui->rbMultiplexor->setChecked(false);
|
||||
ui->rbNotMulti->setChecked(true);
|
||||
@@ -460,7 +461,8 @@ void DBCSignalEditor::fillSignalForm(DBC_SIGNAL *sig)
|
||||
ui->txtName->setText(sig->name);
|
||||
ui->txtBias->setText(QString::number(sig->bias));
|
||||
ui->txtBitLength->setText(QString::number(sig->signalSize));
|
||||
ui->txtMultiplexValue->setText(QString::number(sig->multiplexValue));
|
||||
ui->txtMultiplexLow->setText(QString::number(sig->multiplexLowValue));
|
||||
ui->txtMultiplexHigh->setText(QString::number(sig->multiplexHighValue));
|
||||
ui->txtComment->setText(sig->comment);
|
||||
ui->txtMaxVal->setText(QString::number(sig->max));
|
||||
ui->txtMinVal->setText(QString::number(sig->min));
|
||||
@@ -494,7 +496,8 @@ void DBCSignalEditor::fillSignalForm(DBC_SIGNAL *sig)
|
||||
}
|
||||
}
|
||||
|
||||
ui->txtMultiplexValue->setEnabled(sig->isMultiplexed);
|
||||
ui->txtMultiplexLow->setEnabled(sig->isMultiplexed);
|
||||
ui->txtMultiplexHigh->setEnabled(sig->isMultiplexed);
|
||||
ui->cbMultiplexParent->setEnabled(sig->isMultiplexed);
|
||||
|
||||
memset(bitpattern, 0, 8); //clear it out first.
|
||||
|
||||
+16
-6
@@ -190,33 +190,43 @@
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Multiplex Value</string>
|
||||
<string>Multiplex Low Value</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QLineEdit" name="txtMultiplexValue"/>
|
||||
<widget class="QLineEdit" name="txtMultiplexLow"/>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<item row="13" column="0">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>Comment:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1">
|
||||
<item row="13" column="1">
|
||||
<widget class="QLineEdit" name="txtComment"/>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<item row="12" column="1">
|
||||
<widget class="QComboBox" name="cbMultiplexParent"/>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string>Multiplex Parent</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<widget class="QLineEdit" name="txtMultiplexHigh"/>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>Multiplex High Value</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
Reference in New Issue
Block a user