diff --git a/config.h b/config.h index 99412e5..5c4c5be 100644 --- a/config.h +++ b/config.h @@ -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 diff --git a/re/graphingwindow.cpp b/re/graphingwindow.cpp index fdd509f..df8e29f 100644 --- a/re/graphingwindow.cpp +++ b/re/graphingwindow.cpp @@ -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; @@ -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(); @@ -885,7 +886,7 @@ void GraphingWindow::saveDefinitions() QList::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()); @@ -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()); @@ -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); @@ -1271,7 +1323,7 @@ void GraphingWindow::createGraph(GraphParams ¶ms, 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 @@ -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; diff --git a/re/graphingwindow.h b/re/graphingwindow.h index 2cea438..e1c8cac 100644 --- a/re/graphingwindow.h +++ b/re/graphingwindow.h @@ -25,6 +25,7 @@ public: double scale; int stride; int strideSoFar; + int bus; QColor lineColor; QColor fillColor; int lineWidth; @@ -33,6 +34,7 @@ public: 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 x, y; double xbias; diff --git a/re/newgraphdialog.cpp b/re/newgraphdialog.cpp index 6c14a80..59fcde5 100644 --- a/re/newgraphdialog.cpp +++ b/re/newgraphdialog.cpp @@ -199,6 +199,7 @@ void NewGraphDialog::setParams(GraphParams ¶ms) 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); @@ -234,6 +235,7 @@ void NewGraphDialog::getParams(GraphParams ¶ms) 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; diff --git a/ui/newgraphdialog.ui b/ui/newgraphdialog.ui index 28687a6..d0f9e22 100644 --- a/ui/newgraphdialog.ui +++ b/ui/newgraphdialog.ui @@ -7,7 +7,7 @@ 0 0 681 - 806 + 828 @@ -142,38 +142,38 @@ - + Only Points - + - + Point Style - + - + Line Thickness - + 15 @@ -183,14 +183,14 @@ - + Line Color - + true @@ -203,14 +203,14 @@ - + Fill Color - + true @@ -223,7 +223,7 @@ - + Add this graph @@ -243,6 +243,20 @@ + + + + Associated Bus + + + + + + + -1 + + + @@ -313,7 +327,6 @@ 12 - 75 true