Skip to content

Commit

Permalink
Graphing window now respects bus number. Set to -1 to allow any bus or
Browse files Browse the repository at this point in the history
to 0 or a positive number to lock a graph to a specific bus.
  • Loading branch information
collin80 committed Nov 30, 2022
1 parent 5e7ac12 commit d6e7403
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 19 deletions.
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef CONFIG
#define CONFIG

#define VERSION 207
#define VERSION 208

//try to keep this in sync.
//SavvyCAN will complain if you connect a GVRET board with a revision
Expand Down
63 changes: 58 additions & 5 deletions re/graphingwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void GraphingWindow::updatedFrames(int numFrames)
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
{
thisFrame = modelFrames->at(i);
if (graphParams[j].ID == thisFrame.frameId())
if ( graphParams[j].ID == thisFrame.frameId() && ( (graphParams[j].bus == -1) || (graphParams[j].bus == thisFrame.bus) ) )
{
appendToGraph(graphParams[j], thisFrame, x, y);
appendedToGraph = true;
Expand Down Expand Up @@ -614,7 +614,8 @@ void GraphingWindow::removeAllGraphs()
QMessageBox::StandardButton confirmDialog;
confirmDialog = QMessageBox::question(this, "Really?", "Remove all graphs?",
QMessageBox::Yes|QMessageBox::No);
if (confirmDialog == QMessageBox::Yes) {
if (confirmDialog == QMessageBox::Yes)
{
ui->graphingView->clearGraphs();
ui->graphingView->clearItems();
graphParams.clear();
Expand Down Expand Up @@ -885,7 +886,7 @@ void GraphingWindow::saveDefinitions()
QList<GraphParams>::iterator iter;
for (iter = graphParams.begin(); iter != graphParams.end(); ++iter)
{
outFile->write("X,");
outFile->write("Z,");
outFile->write(QString::number(iter->ID, 16).toUtf8());
outFile->putChar(',');
outFile->write(QString::number(iter->mask, 16).toUtf8());
Expand All @@ -904,6 +905,8 @@ void GraphingWindow::saveDefinitions()
outFile->putChar(',');
outFile->write(QString::number(iter->stride).toUtf8());
outFile->putChar(',');
outFile->write(QString::number(iter->bus).toUtf8());
outFile->putChar(',');
outFile->write(QString::number(iter->lineColor.red()).toUtf8());
outFile->putChar(',');
outFile->write(QString::number(iter->lineColor.green()).toUtf8());
Expand Down Expand Up @@ -978,7 +981,56 @@ void GraphingWindow::loadDefinitions()

gp.associatedSignal = nullptr; //might not be saved in the graph definition so default it to nothing

if (tokens[0] == "X") //newest format based around signals
//should probably do better at merging all the code that is the same between all these formats instead of duplication...
if (tokens[0] == "Z") //very newest format, adds ability to set bus number
{
gp.ID = tokens[1].toUInt(nullptr, 16);
gp.mask = tokens[2].toULongLong(nullptr, 16);
gp.startBit = tokens[3].toInt();
if (gp.startBit < 0) {
gp.intelFormat = false;
gp.startBit *= -1;
}
else gp.intelFormat = true;
gp.numBits = tokens[4].toInt();
if (tokens[5] == "Y") gp.isSigned = true;
else gp.isSigned = false;
gp.bias = tokens[6].toFloat();
gp.scale = tokens[7].toFloat();
gp.stride = tokens[8].toInt();
gp.bus = tokens[9].toInt();

gp.lineColor.setRed( tokens[10].toInt() );
gp.lineColor.setGreen( tokens[11].toInt() );
gp.lineColor.setBlue( tokens[12].toInt() );
if (tokens.length() > 13)
gp.graphName = tokens[13];
else
gp.graphName = QString();
if (tokens.length() > 20) //even newer format with extra graph formatting options
{
gp.fillColor.setRed( tokens[14].toInt() );
gp.fillColor.setGreen( tokens[15].toInt() );
gp.fillColor.setBlue( tokens[16].toInt() );
gp.fillColor.setAlpha( tokens[17].toInt() );
if (tokens[18] == "Y") gp.drawOnlyPoints = true;
else gp.drawOnlyPoints = false;
gp.pointType = tokens[19].toInt();
gp.lineWidth = tokens[20].toInt();
}
if (tokens.length() > 22)
{
DBC_MESSAGE *msg = dbcHandler->findMessage(QString(tokens[21]));
if (msg)
{
gp.associatedSignal = msg->sigHandler->findSignalByName(tokens[22]);
}
else qDebug() << "Couldn't find the message by name! " << tokens[21] << " " << tokens[22];
}

createGraph(gp, true);
}
else if (tokens[0] == "X") //second newest format based around signals
{
gp.ID = tokens[1].toUInt(nullptr, 16);
gp.mask = tokens[2].toULongLong(nullptr, 16);
Expand Down Expand Up @@ -1271,7 +1323,7 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
for (int i = 0; i < modelFrames->count(); i++)
{
CANFrame thisFrame = modelFrames->at(i);
if (thisFrame.frameId() == params.ID && thisFrame.frameType() == QCanBusFrame::DataFrame) frameCache.append(thisFrame);
if (thisFrame.frameId() == params.ID && thisFrame.frameType() == QCanBusFrame::DataFrame && ( ( params.bus == -1) || (params.bus == thisFrame.bus) ) ) frameCache.append(thisFrame);
}

//to fix weirdness where a graph that has no data won't be able to be edited, selected, or deleted properly
Expand Down Expand Up @@ -1508,6 +1560,7 @@ GraphParams::GraphParams()
scale = 1;
stride = 1;
strideSoFar = 1;
bus = -1;
lineColor = QColor(0,0,0);
fillColor = QColor(255,255,255,0);
lineWidth = 1;
Expand Down
2 changes: 2 additions & 0 deletions re/graphingwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class GraphParams
double scale;
int stride;
int strideSoFar;
int bus;
QColor lineColor;
QColor fillColor;
int lineWidth;
Expand All @@ -33,6 +34,7 @@ class GraphParams
QCPGraph *ref;
QString graphName;
DBC_SIGNAL *associatedSignal;

//the below stuff is used for internal purposes only - code should be refactored so these can be private
QVector<double> x, y;
double xbias;
Expand Down
2 changes: 2 additions & 0 deletions re/newgraphdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ void NewGraphDialog::setParams(GraphParams &params)
ui->txtDataLen->setText(QString::number(dataLen));
ui->txtID->setText(Utility::formatCANID(params.ID));
ui->txtName->setText(params.graphName);
ui->editBus->setText(QString::number(params.bus));
QPalette p = ui->colorSwatch->palette();
p.setColor(QPalette::Button, params.lineColor);
ui->colorSwatch->setPalette(p);
Expand Down Expand Up @@ -234,6 +235,7 @@ void NewGraphDialog::getParams(GraphParams &params)
params.mask = Utility::ParseStringToNum(ui->txtMask->text());
params.scale = ui->txtScale->text().toFloat();
params.stride = Utility::ParseStringToNum(ui->txtStride->text());
params.bus = Utility::ParseStringToNum(ui->editBus->text());

params.startBit = startBit;
params.numBits = dataLen;
Expand Down
39 changes: 26 additions & 13 deletions ui/newgraphdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>681</width>
<height>806</height>
<height>828</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -142,38 +142,38 @@
<item row="9" column="1">
<widget class="QLineEdit" name="txtStride"/>
</item>
<item row="11" column="0">
<item row="12" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Only Points</string>
</property>
</widget>
</item>
<item row="11" column="1">
<item row="12" column="1">
<widget class="QCheckBox" name="cbOnlyPoints">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="12" column="0">
<item row="13" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Point Style</string>
</property>
</widget>
</item>
<item row="12" column="1">
<item row="13" column="1">
<widget class="QComboBox" name="coPointStyle"/>
</item>
<item row="13" column="0">
<item row="14" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Line Thickness</string>
</property>
</widget>
</item>
<item row="13" column="1">
<item row="14" column="1">
<widget class="QSpinBox" name="spinLineWidth">
<property name="maximum">
<number>15</number>
Expand All @@ -183,14 +183,14 @@
</property>
</widget>
</item>
<item row="14" column="0">
<item row="15" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Line Color</string>
</property>
</widget>
</item>
<item row="14" column="1">
<item row="15" column="1">
<widget class="QPushButton" name="colorSwatch">
<property name="autoFillBackground">
<bool>true</bool>
Expand All @@ -203,14 +203,14 @@
</property>
</widget>
</item>
<item row="15" column="0">
<item row="16" column="0">
<widget class="QLabel" name="label55">
<property name="text">
<string>Fill Color</string>
</property>
</widget>
</item>
<item row="15" column="1">
<item row="16" column="1">
<widget class="QPushButton" name="fillSwatch">
<property name="autoFillBackground">
<bool>true</bool>
Expand All @@ -223,7 +223,7 @@
</property>
</widget>
</item>
<item row="16" column="1">
<item row="17" column="1">
<widget class="QPushButton" name="btnAddGraph">
<property name="text">
<string>Add this graph</string>
Expand All @@ -243,6 +243,20 @@
</property>
</spacer>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Associated Bus</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QLineEdit" name="editBus">
<property name="text">
<string>-1</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -313,7 +327,6 @@
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
Expand Down

0 comments on commit d6e7403

Please sign in to comment.