Skip to content

Commit d6e7403

Browse files
committed
Graphing window now respects bus number. Set to -1 to allow any bus or
to 0 or a positive number to lock a graph to a specific bus.
1 parent 5e7ac12 commit d6e7403

File tree

5 files changed

+89
-19
lines changed

5 files changed

+89
-19
lines changed

config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef CONFIG
22
#define CONFIG
33

4-
#define VERSION 207
4+
#define VERSION 208
55

66
//try to keep this in sync.
77
//SavvyCAN will complain if you connect a GVRET board with a revision

re/graphingwindow.cpp

+58-5
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void GraphingWindow::updatedFrames(int numFrames)
210210
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
211211
{
212212
thisFrame = modelFrames->at(i);
213-
if (graphParams[j].ID == thisFrame.frameId())
213+
if ( graphParams[j].ID == thisFrame.frameId() && ( (graphParams[j].bus == -1) || (graphParams[j].bus == thisFrame.bus) ) )
214214
{
215215
appendToGraph(graphParams[j], thisFrame, x, y);
216216
appendedToGraph = true;
@@ -614,7 +614,8 @@ void GraphingWindow::removeAllGraphs()
614614
QMessageBox::StandardButton confirmDialog;
615615
confirmDialog = QMessageBox::question(this, "Really?", "Remove all graphs?",
616616
QMessageBox::Yes|QMessageBox::No);
617-
if (confirmDialog == QMessageBox::Yes) {
617+
if (confirmDialog == QMessageBox::Yes)
618+
{
618619
ui->graphingView->clearGraphs();
619620
ui->graphingView->clearItems();
620621
graphParams.clear();
@@ -885,7 +886,7 @@ void GraphingWindow::saveDefinitions()
885886
QList<GraphParams>::iterator iter;
886887
for (iter = graphParams.begin(); iter != graphParams.end(); ++iter)
887888
{
888-
outFile->write("X,");
889+
outFile->write("Z,");
889890
outFile->write(QString::number(iter->ID, 16).toUtf8());
890891
outFile->putChar(',');
891892
outFile->write(QString::number(iter->mask, 16).toUtf8());
@@ -904,6 +905,8 @@ void GraphingWindow::saveDefinitions()
904905
outFile->putChar(',');
905906
outFile->write(QString::number(iter->stride).toUtf8());
906907
outFile->putChar(',');
908+
outFile->write(QString::number(iter->bus).toUtf8());
909+
outFile->putChar(',');
907910
outFile->write(QString::number(iter->lineColor.red()).toUtf8());
908911
outFile->putChar(',');
909912
outFile->write(QString::number(iter->lineColor.green()).toUtf8());
@@ -978,7 +981,56 @@ void GraphingWindow::loadDefinitions()
978981

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

981-
if (tokens[0] == "X") //newest format based around signals
984+
//should probably do better at merging all the code that is the same between all these formats instead of duplication...
985+
if (tokens[0] == "Z") //very newest format, adds ability to set bus number
986+
{
987+
gp.ID = tokens[1].toUInt(nullptr, 16);
988+
gp.mask = tokens[2].toULongLong(nullptr, 16);
989+
gp.startBit = tokens[3].toInt();
990+
if (gp.startBit < 0) {
991+
gp.intelFormat = false;
992+
gp.startBit *= -1;
993+
}
994+
else gp.intelFormat = true;
995+
gp.numBits = tokens[4].toInt();
996+
if (tokens[5] == "Y") gp.isSigned = true;
997+
else gp.isSigned = false;
998+
gp.bias = tokens[6].toFloat();
999+
gp.scale = tokens[7].toFloat();
1000+
gp.stride = tokens[8].toInt();
1001+
gp.bus = tokens[9].toInt();
1002+
1003+
gp.lineColor.setRed( tokens[10].toInt() );
1004+
gp.lineColor.setGreen( tokens[11].toInt() );
1005+
gp.lineColor.setBlue( tokens[12].toInt() );
1006+
if (tokens.length() > 13)
1007+
gp.graphName = tokens[13];
1008+
else
1009+
gp.graphName = QString();
1010+
if (tokens.length() > 20) //even newer format with extra graph formatting options
1011+
{
1012+
gp.fillColor.setRed( tokens[14].toInt() );
1013+
gp.fillColor.setGreen( tokens[15].toInt() );
1014+
gp.fillColor.setBlue( tokens[16].toInt() );
1015+
gp.fillColor.setAlpha( tokens[17].toInt() );
1016+
if (tokens[18] == "Y") gp.drawOnlyPoints = true;
1017+
else gp.drawOnlyPoints = false;
1018+
gp.pointType = tokens[19].toInt();
1019+
gp.lineWidth = tokens[20].toInt();
1020+
}
1021+
if (tokens.length() > 22)
1022+
{
1023+
DBC_MESSAGE *msg = dbcHandler->findMessage(QString(tokens[21]));
1024+
if (msg)
1025+
{
1026+
gp.associatedSignal = msg->sigHandler->findSignalByName(tokens[22]);
1027+
}
1028+
else qDebug() << "Couldn't find the message by name! " << tokens[21] << " " << tokens[22];
1029+
}
1030+
1031+
createGraph(gp, true);
1032+
}
1033+
else if (tokens[0] == "X") //second newest format based around signals
9821034
{
9831035
gp.ID = tokens[1].toUInt(nullptr, 16);
9841036
gp.mask = tokens[2].toULongLong(nullptr, 16);
@@ -1271,7 +1323,7 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
12711323
for (int i = 0; i < modelFrames->count(); i++)
12721324
{
12731325
CANFrame thisFrame = modelFrames->at(i);
1274-
if (thisFrame.frameId() == params.ID && thisFrame.frameType() == QCanBusFrame::DataFrame) frameCache.append(thisFrame);
1326+
if (thisFrame.frameId() == params.ID && thisFrame.frameType() == QCanBusFrame::DataFrame && ( ( params.bus == -1) || (params.bus == thisFrame.bus) ) ) frameCache.append(thisFrame);
12751327
}
12761328

12771329
//to fix weirdness where a graph that has no data won't be able to be edited, selected, or deleted properly
@@ -1508,6 +1560,7 @@ GraphParams::GraphParams()
15081560
scale = 1;
15091561
stride = 1;
15101562
strideSoFar = 1;
1563+
bus = -1;
15111564
lineColor = QColor(0,0,0);
15121565
fillColor = QColor(255,255,255,0);
15131566
lineWidth = 1;

re/graphingwindow.h

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class GraphParams
2525
double scale;
2626
int stride;
2727
int strideSoFar;
28+
int bus;
2829
QColor lineColor;
2930
QColor fillColor;
3031
int lineWidth;
@@ -33,6 +34,7 @@ class GraphParams
3334
QCPGraph *ref;
3435
QString graphName;
3536
DBC_SIGNAL *associatedSignal;
37+
3638
//the below stuff is used for internal purposes only - code should be refactored so these can be private
3739
QVector<double> x, y;
3840
double xbias;

re/newgraphdialog.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ void NewGraphDialog::setParams(GraphParams &params)
199199
ui->txtDataLen->setText(QString::number(dataLen));
200200
ui->txtID->setText(Utility::formatCANID(params.ID));
201201
ui->txtName->setText(params.graphName);
202+
ui->editBus->setText(QString::number(params.bus));
202203
QPalette p = ui->colorSwatch->palette();
203204
p.setColor(QPalette::Button, params.lineColor);
204205
ui->colorSwatch->setPalette(p);
@@ -234,6 +235,7 @@ void NewGraphDialog::getParams(GraphParams &params)
234235
params.mask = Utility::ParseStringToNum(ui->txtMask->text());
235236
params.scale = ui->txtScale->text().toFloat();
236237
params.stride = Utility::ParseStringToNum(ui->txtStride->text());
238+
params.bus = Utility::ParseStringToNum(ui->editBus->text());
237239

238240
params.startBit = startBit;
239241
params.numBits = dataLen;

ui/newgraphdialog.ui

+26-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>681</width>
10-
<height>806</height>
10+
<height>828</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -142,38 +142,38 @@
142142
<item row="9" column="1">
143143
<widget class="QLineEdit" name="txtStride"/>
144144
</item>
145-
<item row="11" column="0">
145+
<item row="12" column="0">
146146
<widget class="QLabel" name="label_16">
147147
<property name="text">
148148
<string>Only Points</string>
149149
</property>
150150
</widget>
151151
</item>
152-
<item row="11" column="1">
152+
<item row="12" column="1">
153153
<widget class="QCheckBox" name="cbOnlyPoints">
154154
<property name="text">
155155
<string/>
156156
</property>
157157
</widget>
158158
</item>
159-
<item row="12" column="0">
159+
<item row="13" column="0">
160160
<widget class="QLabel" name="label_17">
161161
<property name="text">
162162
<string>Point Style</string>
163163
</property>
164164
</widget>
165165
</item>
166-
<item row="12" column="1">
166+
<item row="13" column="1">
167167
<widget class="QComboBox" name="coPointStyle"/>
168168
</item>
169-
<item row="13" column="0">
169+
<item row="14" column="0">
170170
<widget class="QLabel" name="label_15">
171171
<property name="text">
172172
<string>Line Thickness</string>
173173
</property>
174174
</widget>
175175
</item>
176-
<item row="13" column="1">
176+
<item row="14" column="1">
177177
<widget class="QSpinBox" name="spinLineWidth">
178178
<property name="maximum">
179179
<number>15</number>
@@ -183,14 +183,14 @@
183183
</property>
184184
</widget>
185185
</item>
186-
<item row="14" column="0">
186+
<item row="15" column="0">
187187
<widget class="QLabel" name="label_8">
188188
<property name="text">
189189
<string>Line Color</string>
190190
</property>
191191
</widget>
192192
</item>
193-
<item row="14" column="1">
193+
<item row="15" column="1">
194194
<widget class="QPushButton" name="colorSwatch">
195195
<property name="autoFillBackground">
196196
<bool>true</bool>
@@ -203,14 +203,14 @@
203203
</property>
204204
</widget>
205205
</item>
206-
<item row="15" column="0">
206+
<item row="16" column="0">
207207
<widget class="QLabel" name="label55">
208208
<property name="text">
209209
<string>Fill Color</string>
210210
</property>
211211
</widget>
212212
</item>
213-
<item row="15" column="1">
213+
<item row="16" column="1">
214214
<widget class="QPushButton" name="fillSwatch">
215215
<property name="autoFillBackground">
216216
<bool>true</bool>
@@ -223,7 +223,7 @@
223223
</property>
224224
</widget>
225225
</item>
226-
<item row="16" column="1">
226+
<item row="17" column="1">
227227
<widget class="QPushButton" name="btnAddGraph">
228228
<property name="text">
229229
<string>Add this graph</string>
@@ -243,6 +243,20 @@
243243
</property>
244244
</spacer>
245245
</item>
246+
<item row="11" column="0">
247+
<widget class="QLabel" name="label_18">
248+
<property name="text">
249+
<string>Associated Bus</string>
250+
</property>
251+
</widget>
252+
</item>
253+
<item row="11" column="1">
254+
<widget class="QLineEdit" name="editBus">
255+
<property name="text">
256+
<string>-1</string>
257+
</property>
258+
</widget>
259+
</item>
246260
</layout>
247261
</item>
248262
<item>
@@ -313,7 +327,6 @@
313327
<property name="font">
314328
<font>
315329
<pointsize>12</pointsize>
316-
<weight>75</weight>
317330
<bold>true</bold>
318331
</font>
319332
</property>

0 commit comments

Comments
 (0)