Tweaks to the associated signal tracking. Now there is a label that
tells you whether the parameters match the currently selected signal or not.
This commit is contained in:
+61
-4
@@ -29,6 +29,7 @@ NewGraphDialog::NewGraphDialog(DBCHandler *handler, QWidget *parent) :
|
|||||||
connect(ui->txtDataLen, SIGNAL(textChanged(QString)), this, SLOT(handleDataLenUpdate()));
|
connect(ui->txtDataLen, SIGNAL(textChanged(QString)), this, SLOT(handleDataLenUpdate()));
|
||||||
connect(ui->cbIntel, SIGNAL(toggled(bool)), this, SLOT(drawBitfield()));
|
connect(ui->cbIntel, SIGNAL(toggled(bool)), this, SLOT(drawBitfield()));
|
||||||
connect(ui->btnCopySignal, SIGNAL(clicked(bool)), this, SLOT(copySignalToParamsUI()));
|
connect(ui->btnCopySignal, SIGNAL(clicked(bool)), this, SLOT(copySignalToParamsUI()));
|
||||||
|
connect(ui->cbSignals, SIGNAL(currentIndexChanged(int)), this, SLOT(drawBitfield()));
|
||||||
|
|
||||||
startBit = 0;
|
startBit = 0;
|
||||||
dataLen = 1;
|
dataLen = 1;
|
||||||
@@ -86,6 +87,56 @@ void NewGraphDialog::colorSwatchClick()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check whether the current values on the left match the signal selected on the right
|
||||||
|
void NewGraphDialog::checkSignalAgreement()
|
||||||
|
{
|
||||||
|
GraphParams testingParams;
|
||||||
|
bool bAgree = true;
|
||||||
|
bool sigSigned = false;
|
||||||
|
DBC_SIGNAL *sig;
|
||||||
|
DBC_MESSAGE *msg;
|
||||||
|
|
||||||
|
if (dbcHandler == nullptr) return;
|
||||||
|
if (dbcHandler->getFileCount() == 0) return;
|
||||||
|
|
||||||
|
msg = dbcHandler->findMessage(ui->cbMessages->currentText());
|
||||||
|
if (msg)
|
||||||
|
{
|
||||||
|
sig = msg->sigHandler->findSignalByName(ui->cbSignals->currentText());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sig)
|
||||||
|
{
|
||||||
|
if (sig->valType == SIGNED_INT) sigSigned = true;
|
||||||
|
|
||||||
|
testingParams.ID = Utility::ParseStringToNum(ui->txtID->text());
|
||||||
|
testingParams.bias = ui->txtBias->text().toFloat();
|
||||||
|
testingParams.isSigned = ui->cbSigned->isChecked();
|
||||||
|
testingParams.intelFormat = ui->cbIntel->isChecked();
|
||||||
|
testingParams.scale = ui->txtScale->text().toFloat();
|
||||||
|
testingParams.startBit = startBit;
|
||||||
|
testingParams.numBits = dataLen;
|
||||||
|
|
||||||
|
if (testingParams.ID != msg->ID) bAgree = false;
|
||||||
|
if (abs(testingParams.bias - sig->bias) > 0.01) bAgree = false;
|
||||||
|
if (testingParams.isSigned != sigSigned) bAgree = false;
|
||||||
|
if (testingParams.intelFormat != sig->intelByteOrder) bAgree = false;
|
||||||
|
if (abs(testingParams.scale - sig->factor) > 0.01) bAgree = false;
|
||||||
|
if (testingParams.startBit != sig->startBit) bAgree = false;
|
||||||
|
if (testingParams.numBits != sig->signalSize) bAgree = false;
|
||||||
|
}
|
||||||
|
if (bAgree)
|
||||||
|
{
|
||||||
|
ui->lblMsgStatus->setText("Graph params match this signal");
|
||||||
|
//assocSignal = sig;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->lblMsgStatus->setText("Signal and Graph Params do not match");
|
||||||
|
//assocSignal = nullptr; //ya done broke it, null the associated signal since the user is changing things
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NewGraphDialog::clearParams()
|
void NewGraphDialog::clearParams()
|
||||||
{
|
{
|
||||||
ui->txtID->clear();
|
ui->txtID->clear();
|
||||||
@@ -105,9 +156,6 @@ void NewGraphDialog::setParams(GraphParams ¶ms)
|
|||||||
ui->cbSigned->setChecked(params.isSigned);
|
ui->cbSigned->setChecked(params.isSigned);
|
||||||
ui->cbIntel->setChecked(params.intelFormat);
|
ui->cbIntel->setChecked(params.intelFormat);
|
||||||
|
|
||||||
assocSignal = params.associatedSignal;
|
|
||||||
qDebug() << "Signal addr: " << params.associatedSignal;
|
|
||||||
|
|
||||||
startBit = params.startBit;
|
startBit = params.startBit;
|
||||||
dataLen = params.numBits;
|
dataLen = params.numBits;
|
||||||
ui->txtDataLen->setText(QString::number(dataLen));
|
ui->txtDataLen->setText(QString::number(dataLen));
|
||||||
@@ -116,9 +164,13 @@ void NewGraphDialog::setParams(GraphParams ¶ms)
|
|||||||
QPalette p = ui->colorSwatch->palette();
|
QPalette p = ui->colorSwatch->palette();
|
||||||
p.setColor(QPalette::Button, params.color);
|
p.setColor(QPalette::Button, params.color);
|
||||||
ui->colorSwatch->setPalette(p);
|
ui->colorSwatch->setPalette(p);
|
||||||
|
|
||||||
|
assocSignal = params.associatedSignal;
|
||||||
|
|
||||||
loadMessages();
|
loadMessages();
|
||||||
loadSignals(0);
|
loadSignals(0);
|
||||||
drawBitfield();
|
drawBitfield();
|
||||||
|
checkSignalAgreement();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewGraphDialog::getParams(GraphParams ¶ms)
|
void NewGraphDialog::getParams(GraphParams ¶ms)
|
||||||
@@ -195,6 +247,7 @@ void NewGraphDialog::loadSignals(int idx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
checkSignalAgreement();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewGraphDialog::bitfieldClicked(int x,int y)
|
void NewGraphDialog::bitfieldClicked(int x,int y)
|
||||||
@@ -203,7 +256,7 @@ void NewGraphDialog::bitfieldClicked(int x,int y)
|
|||||||
|
|
||||||
qDebug() << "Clicked bit: " << bit;
|
qDebug() << "Clicked bit: " << bit;
|
||||||
startBit = bit;
|
startBit = bit;
|
||||||
drawBitfield();
|
drawBitfield();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewGraphDialog::drawBitfield()
|
void NewGraphDialog::drawBitfield()
|
||||||
@@ -241,6 +294,8 @@ void NewGraphDialog::drawBitfield()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui->gridData->updateData((unsigned char *)&bitField, true);
|
ui->gridData->updateData((unsigned char *)&bitField, true);
|
||||||
|
|
||||||
|
checkSignalAgreement();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewGraphDialog::handleDataLenUpdate()
|
void NewGraphDialog::handleDataLenUpdate()
|
||||||
@@ -249,6 +304,7 @@ void NewGraphDialog::handleDataLenUpdate()
|
|||||||
if (dataLen < 1) dataLen = 1;
|
if (dataLen < 1) dataLen = 1;
|
||||||
if (dataLen > 63) dataLen = 63;
|
if (dataLen > 63) dataLen = 63;
|
||||||
drawBitfield();
|
drawBitfield();
|
||||||
|
checkSignalAgreement();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewGraphDialog::copySignalToParamsUI()
|
void NewGraphDialog::copySignalToParamsUI()
|
||||||
@@ -271,4 +327,5 @@ void NewGraphDialog::copySignalToParamsUI()
|
|||||||
else ui->cbSigned->setChecked(false);
|
else ui->cbSigned->setChecked(false);
|
||||||
drawBitfield();
|
drawBitfield();
|
||||||
assocSignal = sig;
|
assocSignal = sig;
|
||||||
|
checkSignalAgreement();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool eventFilter(QObject *obj, QEvent *event);
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
|
void checkSignalAgreement();
|
||||||
|
|
||||||
Ui::NewGraphDialog *ui;
|
Ui::NewGraphDialog *ui;
|
||||||
DBCHandler *dbcHandler;
|
DBCHandler *dbcHandler;
|
||||||
|
|||||||
@@ -241,6 +241,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lblMsgStatus">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|||||||
Reference in New Issue
Block a user