diff --git a/canframemodel.cpp b/canframemodel.cpp index 735236b..5f84930 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "utility.h" CANFrameModel::~CANFrameModel() @@ -45,24 +46,29 @@ int CANFrameModel::columnCount(const QModelIndex &index) const CANFrameModel::CANFrameModel(QObject *parent) : QAbstractTableModel(parent) { - + int maxFramesDefault; if (QSysInfo::WordSize > 32) { qDebug() << "64 bit OS detected. Requesting a large preallocation"; - preallocSize = 10000000; + maxFramesDefault = 10000000; } else //if compiling for 32 bit you can't ask for gigabytes of preallocation so tone it down. { qDebug() << "32 bit OS detected. Requesting a much restricted prealloc"; - preallocSize = 2000000; + maxFramesDefault = 2000000; } + QSettings settings; + preallocSize = settings.value("Main/MaximumFrames", maxFramesDefault).toInt(); + + //the goal is to prevent a reallocation from ever happening frames.reserve(preallocSize); - filteredFrames.reserve(preallocSize); //the goal is to prevent a reallocation from ever happening + filteredFrames.reserve(preallocSize); dbcHandler = DBCHandler::getReference(); interpretFrames = false; overwriteDups = false; + filtersPersistDuringClear = false; useHexMode = true; timeSeconds = false; timeOffset = 0; @@ -196,6 +202,11 @@ void CANFrameModel::setOverwriteMode(bool mode) endResetModel(); } +void CANFrameModel::setClearMode(bool mode) +{ + filtersPersistDuringClear = mode; +} + void CANFrameModel::setFilterState(unsigned int ID, bool state) { if (!filters.contains(ID)) return; @@ -370,6 +381,7 @@ void CANFrameModel::recalcOverwrite() //Then replace the old list of frames with just the unique list frames.clear(); frames.append(overWriteFrames.values().toVector()); + frames.reserve(preallocSize); filteredFrames.clear(); filteredFrames.reserve(preallocSize); @@ -404,7 +416,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const const unsigned char *data = reinterpret_cast(thisFrame.payload().constData()); int dataLen = thisFrame.payload().count(); - if (role == Qt::BackgroundColorRole) + if (role == Qt::BackgroundRole) { if (dbcHandler != nullptr && interpretFrames && !ignoreDBCColors) { @@ -437,7 +449,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const } } - if (role == Qt::TextColorRole) + if (role == Qt::ForegroundRole) { if (dbcHandler != nullptr && interpretFrames && !ignoreDBCColors) { @@ -673,13 +685,21 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false) if (!overwriteDups) { - frames.append(tempFrame); - if (filters[tempFrame.frameId()] && busFilters[tempFrame.bus]) + try { - if (autoRefresh) beginInsertRows(QModelIndex(), filteredFrames.count(), filteredFrames.count()); - tempFrame.frameCount = 1; - filteredFrames.append(tempFrame); - if (autoRefresh) endInsertRows(); + frames.append(tempFrame); + + if (filters[tempFrame.frameId()] && busFilters[tempFrame.bus]) + { + if (autoRefresh) beginInsertRows(QModelIndex(), filteredFrames.count(), filteredFrames.count()); + tempFrame.frameCount = 1; + filteredFrames.append(tempFrame); + if (autoRefresh) endInsertRows(); + } + } + catch (const std::exception& ex) + { + qDebug() << "addFrame failed to append. App is probably going to crash. frames.length(): " << frames.length() << " Exception: " << ex.what(); } } else //yes, overwrite dups @@ -728,6 +748,20 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false) void CANFrameModel::addFrames(const CANConnection*, const QVector& pFrames) { + if(frames.length() > frames.capacity() * 0.99) + { + qDebug() << "Frames count: " << frames.length() << " of " << frames.capacity() << " capacity, removing first " << (int)(frames.capacity() * 0.05) << " frames"; + frames.remove(0, (int)(frames.capacity() * 0.05)); + qDebug() << "Frames removed, new count: " << frames.length(); + } + + if(filteredFrames.length() > filteredFrames.capacity() * 0.99) + { + qDebug() << "filteredFrames count: " << filteredFrames.length() << " of " << filteredFrames.capacity() << " capacity, removing first " << (int)(filteredFrames.capacity() * 0.05) << " frames"; + filteredFrames.remove(0, (int)(filteredFrames.capacity() * 0.05)); + qDebug() << "filteredFrames removed, new count: " << filteredFrames.length(); + } + foreach(const CANFrame& frame, pFrames) { addFrame(frame); @@ -754,8 +788,8 @@ void CANFrameModel::sendRefresh() mutex.lock(); beginResetModel(); filteredFrames.clear(); - filteredFrames.reserve(preallocSize); filteredFrames.append(tempContainer); + filteredFrames.reserve(preallocSize); lastUpdateNumFrames = 0; endResetModel(); @@ -779,7 +813,7 @@ int CANFrameModel::sendBulkRefresh() if (lastUpdateNumFrames == 0 && !overwriteDups) return 0; if (filteredFrames.count() == 0) return 0; - qDebug() << "Bulk refresh of " << lastUpdateNumFrames; + //qDebug() << "Bulk refresh of " << lastUpdateNumFrames; beginResetModel(); endResetModel(); @@ -796,8 +830,11 @@ void CANFrameModel::clearFrames() this->beginResetModel(); frames.clear(); filteredFrames.clear(); - filters.clear(); - busFilters.clear(); + if(filtersPersistDuringClear == false) + { + filters.clear(); + busFilters.clear(); + } frames.reserve(preallocSize); filteredFrames.reserve(preallocSize); this->endResetModel(); diff --git a/canframemodel.h b/canframemodel.h index edb65b5..49ad74d 100644 --- a/canframemodel.h +++ b/canframemodel.h @@ -46,6 +46,7 @@ public: bool getInterpretMode(); void setOverwriteMode(bool); void setHexMode(bool); + void setClearMode(bool mode); void setSysTimeMode(bool); void setMillisMode(bool mode); void setIgnoreDBCColors(bool mode); @@ -89,6 +90,7 @@ private: QMutex mutex; bool interpretFrames; //should we use the dbcHandler? bool overwriteDups; //should we display all frames or only the newest for each ID? + bool filtersPersistDuringClear; QString timeFormat; bool useHexMode; bool timeSeconds; diff --git a/connections/canconfactory.cpp b/connections/canconfactory.cpp index 77daf09..43264dd 100644 --- a/connections/canconfactory.cpp +++ b/connections/canconfactory.cpp @@ -14,6 +14,9 @@ CANConnection* CanConFactory::create(type pType, QString pPortName, QString pDri case SERIALBUS: return new SerialBusConnection(pPortName, pDriverName); case GVRET_SERIAL: + if(pPortName.contains(".")) + return new GVRetSerial(pPortName, true); + else return new GVRetSerial(pPortName, false); case REMOTE: return new GVRetSerial(pPortName, true); //it's a special case of GVRET connected over TCP/IP so it uses the same class diff --git a/connections/canconnection.cpp b/connections/canconnection.cpp index dca0490..dc9d775 100644 --- a/connections/canconnection.cpp +++ b/connections/canconnection.cpp @@ -250,11 +250,11 @@ CANCon::type CANConnection::getType() { CANCon::status CANConnection::getStatus() { - return (CANCon::status) mStatus.load(); + return (CANCon::status) mStatus.loadRelaxed(); } void CANConnection::setStatus(CANCon::status pStatus) { - mStatus.store(pStatus); + mStatus.storeRelaxed(pStatus); } bool CANConnection::isCapSuspended() { diff --git a/connections/connectionwindow.cpp b/connections/connectionwindow.cpp index 043bda8..210fcdd 100644 --- a/connections/connectionwindow.cpp +++ b/connections/connectionwindow.cpp @@ -508,8 +508,10 @@ CANConnection* ConnectionWindow::create(CANCon::type pTye, QString pPortName, QS void ConnectionWindow::loadConnections() { +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) qRegisterMetaTypeStreamOperators(); qRegisterMetaTypeStreamOperators>(); +#endif QSettings settings; diff --git a/connections/gvretserial.cpp b/connections/gvretserial.cpp index c7d340f..fb2eaed 100644 --- a/connections/gvretserial.cpp +++ b/connections/gvretserial.cpp @@ -485,6 +485,7 @@ void GVRetSerial::serialError(QSerialPort::SerialPortError err) killConnection = true; piStop(); break; +#if QT_VERSION <= QT_VERSION_CHECK( 6, 0, 0 ) case QSerialPort::ParityError: errMessage = "Parity error on serial port"; break; @@ -494,6 +495,7 @@ void GVRetSerial::serialError(QSerialPort::SerialPortError err) case QSerialPort::BreakConditionError: errMessage = "Break error on serial port"; break; +#endif case QSerialPort::WriteError: errMessage = "Write error on serial port"; piStop(); diff --git a/connections/socketcand.cpp b/connections/socketcand.cpp index 6fbf5e4..df1157d 100644 --- a/connections/socketcand.cpp +++ b/connections/socketcand.cpp @@ -32,6 +32,7 @@ SocketCANd::SocketCANd(QString portName) : for (int i = 0; i < mNumBuses; i++) { rx_state.append(IDLE); + unprocessedData.append(""); } } @@ -249,62 +250,89 @@ void SocketCANd::switchToRawMode(int busNum) QCoreApplication::processEvents(); } -void SocketCANd::decodeFrames(QString data, int busNum) +QString SocketCANd::decodeFrames(QString data, int busNum) { - if (data.indexOf("< frame ") == -1) + if (data.indexOf("<") == -1) + return ""; + else if(data.length() >= 8 && data.indexOf("< frame ") == -1) + return ""; + + int firstIndex = data.indexOf("< frame "); + if(firstIndex > 0) { - qDebug() << "Received datagramm doesn't contain any frame: " << data; - return; + QString framePartial = data.left(firstIndex); + qDebug() << "Received datagramm that starts with fragment (missing '< frame'), this should only occur on startup, removing...: " << framePartial; } - else + QString framePart = data.mid(firstIndex); //remove starting beginning of payload if not < frame > + const QString frameStrConst = framePart.left(framePart.indexOf(">")+1); + QString frameStr = frameStrConst; + QStringList frameParsed = (frameStr.remove(QRegExp("^<")).remove(QRegExp(">$"))).simplified().split(' '); + + if(frameParsed.length() < 3) { - QString framePart = data.mid(data.indexOf("< frame "), data.length()); //remove starting beginning of payload if not < frame > - const QString frameStrConst = framePart.left(framePart.indexOf(">")+1); - QString frameStr = frameStrConst; - QStringList frameParsed = (frameStr.remove(QRegExp("^<")).remove(QRegExp(">$"))).simplified().split(' '); + //qDebug() << "Received datagramm is an incomplete frame: " << data; - buildFrame.setFrameId(frameParsed[1].toUInt(nullptr, 16)); - buildFrame.bus = busNum; + //ok great, need to leave it in the buffer in case it can be combined with what comes next + //but if there was a fragment that did not have a starting token then we don't want it so only return + //known good data...again this should only happen on startup, but just in case we need to remove it + //so the data buffer doesn't grow uncontrolled. + return framePart; + } - if (buildFrame.frameId() > 0x7FF) buildFrame.setExtendedFrameFormat(true); - else buildFrame.setExtendedFrameFormat(false); + buildFrame.setFrameId(frameParsed[1].toUInt(nullptr, 16)); + buildFrame.bus = busNum; - buildFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, frameParsed[2].toDouble() * 1000000l)); - //buildFrame.len = frameParsed[3].length() * 0.5; - int framelength = frameParsed[3].length() * 0.5; + if (buildFrame.frameId() > 0x7FF) buildFrame.setExtendedFrameFormat(true); + else buildFrame.setExtendedFrameFormat(false); - buildData.resize(framelength); + buildFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, frameParsed[2].toDouble() * 1000000l)); + //buildFrame.len = frameParsed[3].length() * 0.5; - int c; - for (c = 0; c < framelength; c++) - { - bool ok; - unsigned char byteVal = frameParsed[3].mid(c*2, 2).toUInt(&ok, 16); - buildData[c] = byteVal; - } - buildFrame.setPayload(buildData); + if(frameParsed.length() < 4) + { + qDebug() << "Received frame doesn't contain any data: " << data; + return data; + } + + int framelength = frameParsed[3].length() * 0.5; + + buildData.resize(framelength); + + int c; + for (c = 0; c < framelength; c++) + { + bool ok; + unsigned char byteVal = frameParsed[3].mid(c*2, 2).toUInt(&ok, 16); + buildData[c] = byteVal; + } + buildFrame.setPayload(buildData); // buildFrame.isReceived = true; - if (!isCapSuspended()) - { - /* get frame from queue */ - CANFrame* frame_p = getQueue().get(); - if(frame_p) { - /* copy frame */ - *frame_p = buildFrame; - //frame_p->remote = false; - frame_p->setFrameType(QCanBusFrame::DataFrame); - checkTargettedFrame(buildFrame); - /* enqueue frame */ - getQueue().queue(); - } + if (!isCapSuspended()) + { + /* get frame from queue */ + CANFrame* frame_p = getQueue().get(); + if(frame_p) { + /* copy frame */ + *frame_p = buildFrame; + //frame_p->remote = false; + frame_p->setFrameType(QCanBusFrame::DataFrame); + checkTargettedFrame(buildFrame); + /* enqueue frame */ + getQueue().queue(); } - else - qDebug() << "can't get a frame, capture suspended"; - - if (framePart.length() > frameStrConst.length()) - decodeFrames(framePart.right(framePart.length() - frameStrConst.length()), busNum); } + else + qDebug() << "can't get a frame, capture suspended"; + + //take out the data that we just processed and anything that is in front of it + //this should keep broken frames from accumulating at in the data buffer + if (framePart.length() > frameStrConst.length()) + { + return decodeFrames(framePart.right(framePart.length() - frameStrConst.length()), busNum); + } + + return ""; } void SocketCANd::disconnectDevice() { @@ -374,6 +402,7 @@ void SocketCANd::procRXData(QString data, int busNum) { switchToRawMode(busNum); rx_state[busNum] = SWITCHING2RAW; + unprocessedData[busNum].clear(); } else qInfo() << hostCanIDs[busNum] << ": Could not open bus. Host did not respond with ""< ok >"": " << data; break; @@ -383,9 +412,30 @@ void SocketCANd::procRXData(QString data, int busNum) { rx_state[busNum] = RAWMODE; } + else if(data.indexOf("< ok >", 0, Qt::CaseSensitivity::CaseInsensitive) == 0) + { + qDebug() << "Ok found at start of compound message, switching to RAW and decoding immediately"; + rx_state[busNum] = RAWMODE; + unprocessedData[busNum] = decodeFrames(data, busNum); + } + else if(data.indexOf("< ok >", 0, Qt::CaseSensitivity::CaseInsensitive) > 0) + { + qDebug() << "Ok found at in middle of compound message, switching to RAW and decoding immediately"; + rx_state[busNum] = RAWMODE; + unprocessedData[busNum] = decodeFrames(data, busNum); + } break; case RAWMODE: - decodeFrames(data, busNum); + unprocessedData[busNum] = decodeFrames(unprocessedData[busNum] + data, busNum); + + if(unprocessedData[busNum].length() > 128) + { + //the buffer has grown too much we need to clear it out, but what is good logic for that? + //the decodeFrames function strips out datat that doesn't have a '< frame' starting token, and in its + //recursive calling of itself it strips out data that preceedes valid frames, so this should never happen + qDebug() << "busNum: " << busNum << "- " << unprocessedData[busNum].length() << " bytes in unprocessedData, something is wrong, clearing..."; + unprocessedData[busNum].clear(); + } break; case ISOTP: break; diff --git a/connections/socketcand.h b/connections/socketcand.h index b5c9376..aa8510a 100644 --- a/connections/socketcand.h +++ b/connections/socketcand.h @@ -57,7 +57,7 @@ private slots: void invokeReadTCPData(); void deviceConnected(int busNum); void switchToRawMode(int busNum); - void decodeFrames(QString, int busNum); + QString decodeFrames(QString, int busNum); private: void procRXData(QString, int busNum); @@ -76,6 +76,7 @@ protected: QByteArray buildData; QVarLengthArray rx_state; CANFrame buildFrame; + QVarLengthArray unprocessedData; }; diff --git a/dbc/dbchandler.cpp b/dbc/dbchandler.cpp index 3bbfe01..8290c10 100644 --- a/dbc/dbchandler.cpp +++ b/dbc/dbchandler.cpp @@ -100,8 +100,15 @@ void DBCSignalHandler::sort() DBC_MESSAGE* DBCMessageHandler::findMsgByID(uint32_t id) { if (messages.count() == 0) return nullptr; + DBC_MESSAGE *bestMatch = nullptr; + for (int i = 0; i < messages.count(); i++) { + if ( messages[i].ID == id ) + { + return &messages[i]; + } + if (matchingCriteria == J1939) { // include data page and extended data page in the pgn @@ -112,7 +119,7 @@ DBC_MESSAGE* DBCMessageHandler::findMsgByID(uint32_t id) pgn &= 0x3FF00; if ((messages[i].ID & 0x3FF0000) == (pgn << 8)) { - return &messages[i]; + bestMatch = &messages[i]; } } else @@ -120,7 +127,7 @@ DBC_MESSAGE* DBCMessageHandler::findMsgByID(uint32_t id) // PDU2 format if ((messages[i].ID & 0x3FFFF00) == (pgn << 8)) { - return &messages[i]; + bestMatch = &messages[i]; } } } @@ -129,17 +136,10 @@ DBC_MESSAGE* DBCMessageHandler::findMsgByID(uint32_t id) // Match the bits 14-26 (Arbitration Id) of GMLAN 29bit header uint32_t arbId = id &0x3FFE000; if ( (arbId != 0) && (messages[i].ID & 0x3FFE000) == arbId ) - return &messages[i]; - } - else - { - if ( messages[i].ID == id ) - { - return &messages[i]; - } + bestMatch = &messages[i]; } } - return nullptr; + return bestMatch; } DBC_MESSAGE* DBCMessageHandler::findMsgByIdx(int idx) @@ -192,6 +192,7 @@ bool DBCMessageHandler::removeMessage(DBC_MESSAGE *msg) { messages.removeAt(i); qDebug() << "Removed message at idx " << i; + break; } } return true; @@ -336,7 +337,26 @@ DBC_NODE* DBCFile::findNodeByName(QString name) if (dbc_nodes.length() == 0) return nullptr; for (int i = 0; i < dbc_nodes.length(); i++) { - if (dbc_nodes[i].name.compare(name, Qt::CaseInsensitive) == 0) + if (name.compare(dbc_nodes[i].name, Qt::CaseInsensitive) == 0) + { + return &dbc_nodes[i]; + } + } + return nullptr; +} + +DBC_NODE* DBCFile::findNodeByNameAndComment(QString fullname) +{ + QString nameAndComment; + if (dbc_nodes.length() == 0) return nullptr; + for (int i = 0; i < dbc_nodes.length(); i++) + { + if(dbc_nodes[i].comment.isEmpty()) + nameAndComment = dbc_nodes[i].name; + else + nameAndComment = dbc_nodes[i].name + " - " + dbc_nodes[i].comment; + + if (fullname.compare(nameAndComment, Qt::CaseInsensitive) == 0) { return &dbc_nodes[i]; } diff --git a/dbc/dbchandler.h b/dbc/dbchandler.h index 304a7a8..9e040cb 100644 --- a/dbc/dbchandler.h +++ b/dbc/dbchandler.h @@ -72,6 +72,7 @@ public: DBCFile(const DBCFile& cpy); DBCFile& operator=(const DBCFile& cpy); DBC_NODE *findNodeByName(QString name); + DBC_NODE *findNodeByNameAndComment(QString fullname); DBC_NODE *findNodeByIdx(int idx); DBC_ATTRIBUTE *findAttributeByName(QString name, DBC_ATTRIBUTE_TYPE type = ATTR_TYPE_ANY); DBC_ATTRIBUTE *findAttributeByIdx(int idx); diff --git a/dbc/dbcmaineditor.cpp b/dbc/dbcmaineditor.cpp index 28e831a..54a046b 100644 --- a/dbc/dbcmaineditor.cpp +++ b/dbc/dbcmaineditor.cpp @@ -631,7 +631,7 @@ void DBCMainEditor::deleteCurrentTreeItem() { QTreeWidgetItem *currItem = ui->treeDBC->currentItem(); int typ = currItem->data(0, Qt::UserRole).toInt(); - QString idString; + QString idString, columnText; int msgID; DBC_MESSAGE *msg; DBC_NODE *node; @@ -642,7 +642,8 @@ void DBCMainEditor::deleteCurrentTreeItem() switch (typ) { case 1: //deleting a node cascades deletion down to messages and signals - node = dbcFile->findNodeByName(currItem->text(0)); + columnText = currItem->text(0); + node = dbcFile->findNodeByNameAndComment(columnText); if (!node) return; for (int x = 0; x < dbcFile->messageHandler->getCount(); x++) { diff --git a/dbc/dbcnodeeditor.cpp b/dbc/dbcnodeeditor.cpp index e8363a3..f553fb4 100644 --- a/dbc/dbcnodeeditor.cpp +++ b/dbc/dbcnodeeditor.cpp @@ -111,8 +111,11 @@ void DBCNodeEditor::showEvent(QShowEvent* event) void DBCNodeEditor::refreshView() { - ui->lineComment->setText(dbcNode->comment); - ui->lineMsgName->setText(dbcNode->name); + if(dbcNode) + { + ui->lineComment->setText(dbcNode->comment); + ui->lineMsgName->setText(dbcNode->name); + } //generateSampleText(); } diff --git a/framesenderwindow.cpp b/framesenderwindow.cpp index 8e796ef..4d66317 100644 --- a/framesenderwindow.cpp +++ b/framesenderwindow.cpp @@ -898,7 +898,11 @@ void FrameSenderWindow::processCellChange(int line, int col) case 6: //Data bytes for (int i = 0; i < 8; i++) sendingData[line].payload().data()[i] = 0; - tokens = ui->tableSender->item(line, 6)->text().split(" "); +#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 ) + tokens = ui->tableSender->item(line, 6)->text().split(" ", Qt::SkipEmptyParts); +#else + tokens = ui->tableSender->item(line, 6)->text().split(" ", QString::SkipEmptyParts); +#endif arr.clear(); arr.reserve(tokens.count()); for (int j = 0; j < tokens.count(); j++) diff --git a/jsedit.cpp b/jsedit.cpp index 5a994d0..edb1eef 100644 --- a/jsedit.cpp +++ b/jsedit.cpp @@ -931,7 +931,8 @@ void JSEdit::resizeEvent(QResizeEvent *e) void JSEdit::wheelEvent(QWheelEvent *e) { if (e->modifiers() == Qt::ControlModifier) { - int steps = e->delta() / 20; + QPoint numDegrees = e->angleDelta(); + int steps = numDegrees.y() / 20; steps = qBound(-3, steps, 3); QFont textFont = font(); int pointSize = textFont.pointSize() + steps; diff --git a/mainsettingsdialog.cpp b/mainsettingsdialog.cpp index 77bf257..7cd1230 100644 --- a/mainsettingsdialog.cpp +++ b/mainsettingsdialog.cpp @@ -48,6 +48,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) : ui->cbLoadConnections->setChecked(settings.value("Main/SaveRestoreConnections", false).toBool()); ui->spinFontSize->setValue(settings.value("Main/FontSize", ui->cbDisplayHex->font().pointSize()).toUInt()); + ui->cbFontFixedWidth->setChecked(settings.value("Main/FontFixedWidth", false).toBool()); bool secondsMode = settings.value("Main/TimeSeconds", false).toBool(); bool clockMode = settings.value("Main/TimeClock", false).toBool(); @@ -90,6 +91,20 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) : ui->cbFilterLabeling->setChecked(settings.value("Main/FilterLabeling", true).toBool()); ui->cbIgnoreDBCColors->setChecked(settings.value("Main/IgnoreDBCColors", false).toBool()); + int maxFramesDefault; + if (QSysInfo::WordSize > 32) + { + qDebug() << "64 bit OS detected. Requesting a large preallocation"; + maxFramesDefault = 10000000; + } + else //if compiling for 32 bit you can't ask for gigabytes of preallocation so tone it down. + { + qDebug() << "32 bit OS detected. Requesting a much restricted prealloc"; + maxFramesDefault = 2000000; + } + + ui->spinMaximumFrames->setValue(settings.value("Main/MaximumFrames", maxFramesDefault).toInt()); + //just for simplicity they all call the same function and that function updates all settings at once connect(ui->cbDisplayHex, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->cbFlowAutoRef, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); @@ -117,6 +132,8 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) : connect(ui->cbHexGraphFlow, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->cbHexGraphInfo, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->cbIgnoreDBCColors, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); + connect(ui->spinMaximumFrames, SIGNAL(valueChanged(int)), this, SLOT(updateSettings())); + connect(ui->cbFontFixedWidth, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); installEventFilter(this); } @@ -183,6 +200,8 @@ void MainSettingsDialog::updateSettings() settings.setValue("Remote/Pass", encPass); settings.setValue("Main/FilterLabeling", ui->cbFilterLabeling->isChecked()); settings.setValue("Main/IgnoreDBCColors", ui->cbIgnoreDBCColors->isChecked()); + settings.setValue("Main/MaximumFrames", ui->spinMaximumFrames->value()); + settings.setValue("Main/FontFixedWidth", ui->cbFontFixedWidth->isChecked()); settings.sync(); emit updatedSettings(); diff --git a/mainwindow.cpp b/mainwindow.cpp index f32125a..e84da30 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -30,8 +30,10 @@ MainWindow::MainWindow(QWidget *parent) : ui(new Ui::MainWindow) { ui->setupUi(this); +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) qRegisterMetaTypeStreamOperators>(); qRegisterMetaTypeStreamOperators>(); +#endif useHex = true; @@ -55,12 +57,18 @@ MainWindow::MainWindow(QWidget *parent) : verticalHeader->setSectionResizeMode(QHeaderView::Fixed); QSettings settings; int fontSize = settings.value("Main/FontSize", 9).toUInt(); - QFont sysFont = QFont(); //get default font + QFont sysFont; + if(settings.value("Main/FontFixedWidth", false).toBool()) + sysFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); //get default fixed width font + else + sysFont = QFont(); //get default font sysFont.setPointSize(fontSize); verticalHeader->setDefaultSectionSize(sysFont.pixelSize()); + verticalHeader->setFont(QFont()); ui->canFramesView->setFont(sysFont); QHeaderView *HorzHdr = ui->canFramesView->horizontalHeader(); + HorzHdr->setFont(QFont()); HorzHdr->setStretchLastSection(true); //causes the data column to automatically fill the tableview connect(HorzHdr, SIGNAL(sectionClicked(int)), this, SLOT(headerClicked(int))); @@ -141,6 +149,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->cbInterpret, &QAbstractButton::toggled, this, &MainWindow::interpretToggled); connect(ui->cbOverwrite, &QAbstractButton::toggled, this, &MainWindow::overwriteToggled); + connect(ui->cbPersistentFilters, &QAbstractButton::toggled, this, &MainWindow::presistentFiltersToggled); connect(ui->listFilters, &QListWidget::itemChanged, this, &MainWindow::filterListItemChanged); connect(ui->listBusFilters, &QListWidget::itemChanged, this, &MainWindow::busFilterListItemChanged); @@ -177,7 +186,7 @@ MainWindow::MainWindow(QWidget *parent) : updateTimer.setInterval(250); updateTimer.start(); - elapsedTime = new QTime; + elapsedTime = new QElapsedTimer; elapsedTime->start(); isConnected = false; @@ -616,6 +625,18 @@ void MainWindow::overwriteToggled(bool state) } } +void MainWindow::presistentFiltersToggled(bool state) +{ + if (state) + { + model->setClearMode(true); + } + else + { + model->setClearMode(false); + } +} + void MainWindow::updateFilterList() { if (model == nullptr) return; @@ -1146,11 +1167,26 @@ void MainWindow::showTemporalGraphWindow() //only create an instance of the object if we dont have one. Otherwise just display the existing one. if (!temporalGraphWindow) { + const QVector *frames; if (!useFiltered) - temporalGraphWindow = new TemporalGraphWindow(model->getListReference()); + frames = model->getListReference(); else - temporalGraphWindow = new TemporalGraphWindow(model->getFilteredListReference()); + frames = model->getFilteredListReference(); + + if(frames->count() > 2000) + { + QMessageBox::StandardButton confirmDialog; + confirmDialog = QMessageBox::question(this, "Danger Will Robinson", "There are a lot of frames (>2000) to plot, this may take a while or crash the app. Crash likely with more than 10k frames. Continue?", + QMessageBox::Yes|QMessageBox::No); + if (confirmDialog == QMessageBox::No) + { + return; + } + } + + temporalGraphWindow = new TemporalGraphWindow(frames); } + temporalGraphWindow->show(); } diff --git a/mainwindow.h b/mainwindow.h index 0b0fd90..9967215 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -99,6 +99,7 @@ private slots: void setupSendToLatestGraphWindow(); void interpretToggled(bool); void overwriteToggled(bool); + void presistentFiltersToggled(bool state); void logReceivedFrame(CANConnection*, QVector); void tickGUIUpdate(); void toggleCapture(); @@ -137,7 +138,7 @@ private: DBCHandler *dbcHandler; QByteArray inputBuffer; QTimer updateTimer; - QTime *elapsedTime; + QElapsedTimer *elapsedTime; int framesPerSec; int rxFrames; bool inhibitFilterUpdate; diff --git a/mqtt/qmqtt_client.h b/mqtt/qmqtt_client.h index da89f01..690319b 100644 --- a/mqtt/qmqtt_client.h +++ b/mqtt/qmqtt_client.h @@ -129,7 +129,7 @@ class Q_MQTT_EXPORT Client : public QObject Q_PROPERTY(quint8 _willQos READ willQos WRITE setWillQos) Q_PROPERTY(bool _willRetain READ willRetain WRITE setWillRetain) Q_PROPERTY(QByteArray _willMessage READ willMessage WRITE setWillMessage) - Q_PROPERTY(QString _connectionState READ connectionState) + Q_PROPERTY(ConnectionState _connectionState READ connectionState) #ifndef QT_NO_SSL Q_PROPERTY(QSslConfiguration _sslConfiguration READ sslConfiguration WRITE setSslConfiguration) #endif // QT_NO_SSL diff --git a/mqtt/qmqtt_socket.cpp b/mqtt/qmqtt_socket.cpp index f0628f0..5805f94 100644 --- a/mqtt/qmqtt_socket.cpp +++ b/mqtt/qmqtt_socket.cpp @@ -41,9 +41,9 @@ QMQTT::Socket::Socket(QObject* parent) connect(_socket.data(), &QTcpSocket::connected, this, &SocketInterface::connected); connect(_socket.data(), &QTcpSocket::disconnected, this, &SocketInterface::disconnected); connect(_socket.data(), - static_cast(&QTcpSocket::error), + SIGNAL(error(QTcpSocket::error)), this, - static_cast(&SocketInterface::error)); + SLOT(errorHandler(SocketInterface::error))); } QMQTT::Socket::~Socket() diff --git a/mqtt/qmqtt_ssl_socket.cpp b/mqtt/qmqtt_ssl_socket.cpp index 2d3a808..9f70434 100644 --- a/mqtt/qmqtt_ssl_socket.cpp +++ b/mqtt/qmqtt_ssl_socket.cpp @@ -46,9 +46,9 @@ QMQTT::SslSocket::SslSocket(const QSslConfiguration& config, QObject* parent) connect(_socket.data(), &QSslSocket::encrypted, this, &SocketInterface::connected); connect(_socket.data(), &QSslSocket::disconnected, this, &SocketInterface::disconnected); connect(_socket.data(), - static_cast(&QSslSocket::error), + SIGNAL(error(QSslSocket::error)), this, - static_cast(&SocketInterface::error)); + SLOT(errorHandler(SocketInterface::error))); connect(_socket.data(), static_cast&)>(&QSslSocket::sslErrors), this, diff --git a/qcustomplot.h b/qcustomplot.h index 8f0f78b..170850b 100644 --- a/qcustomplot.h +++ b/qcustomplot.h @@ -156,26 +156,8 @@ class QCPPolarGraph; It provides QMetaObject-based reflection of its enums and flags via \a QCP::staticMetaObject. */ -#ifndef Q_MOC_RUN namespace QCP { -#else -class QCP { // when in moc-run, make it look like a class, so we get Q_GADGET, Q_ENUMS/Q_FLAGS features in namespace - Q_GADGET - Q_ENUMS(ExportPen) - Q_ENUMS(ResolutionUnit) - Q_ENUMS(SignDomain) - Q_ENUMS(MarginSide) - Q_FLAGS(MarginSides) - Q_ENUMS(AntialiasedElement) - Q_FLAGS(AntialiasedElements) - Q_ENUMS(PlottingHint) - Q_FLAGS(PlottingHints) - Q_ENUMS(Interaction) - Q_FLAGS(Interactions) - Q_ENUMS(SelectionRectMode) - Q_ENUMS(SelectionType) -public: -#endif + Q_NAMESPACE /*! Defines the different units in which the image resolution can be specified in the export @@ -318,6 +300,20 @@ enum SelectionType { stNone ///< The plottable is not selectable ,stMultipleDataRanges ///< Any combination of data points/ranges can be selected }; + Q_ENUM_NS(ExportPen) + Q_ENUM_NS(ResolutionUnit) + Q_ENUM_NS(SignDomain) + Q_ENUM_NS(MarginSide) + Q_FLAG_NS(MarginSides) + Q_ENUM_NS(AntialiasedElement) + Q_FLAG_NS(AntialiasedElements) + Q_ENUM_NS(PlottingHint) + Q_FLAG_NS(PlottingHints) + Q_ENUM_NS(Interaction) + Q_FLAG_NS(Interactions) + Q_ENUM_NS(SelectionRectMode) + Q_ENUM_NS(SelectionType) + /*! \internal Returns whether the specified \a value is considered an invalid data value for plottables (i.e. @@ -386,15 +382,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements) Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints) Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides) Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions) -Q_DECLARE_METATYPE(QCP::ExportPen) -Q_DECLARE_METATYPE(QCP::ResolutionUnit) -Q_DECLARE_METATYPE(QCP::SignDomain) -Q_DECLARE_METATYPE(QCP::MarginSide) -Q_DECLARE_METATYPE(QCP::AntialiasedElement) -Q_DECLARE_METATYPE(QCP::PlottingHint) -Q_DECLARE_METATYPE(QCP::Interaction) -Q_DECLARE_METATYPE(QCP::SelectionRectMode) -Q_DECLARE_METATYPE(QCP::SelectionType) +//no need to use Q_DECLARE_METATYPE on enum since Q_ENUM_NS adds enum as metatype automatically /* end of 'src/global.h' */ diff --git a/re/sniffer/snifferitem.h b/re/sniffer/snifferitem.h index 0995a10..ea0a086 100644 --- a/re/sniffer/snifferitem.h +++ b/re/sniffer/snifferitem.h @@ -2,7 +2,7 @@ #define SNIFFERITEM_H #include -#include +#include #include "can_structs.h" struct fstCan @@ -50,7 +50,7 @@ private: quint64 mCurrentTime; quint64 mCurrSeqVal; - QTime mTime; + QElapsedTimer mTime; }; #endif // SNIFFERITEM_H diff --git a/re/sniffer/sniffermodel.cpp b/re/sniffer/sniffermodel.cpp index 55736b4..293a69d 100644 --- a/re/sniffer/sniffermodel.cpp +++ b/re/sniffer/sniffermodel.cpp @@ -137,7 +137,7 @@ QVariant SnifferModel::data(const QModelIndex &index, int role) const Qt::ItemFlags SnifferModel::flags(const QModelIndex &index) const { if (!index.isValid()) - return 0; + return Qt::NoItemFlags; return QAbstractItemModel::flags(index); } diff --git a/scriptingwindow.cpp b/scriptingwindow.cpp index 1d5f378..1f24dee 100644 --- a/scriptingwindow.cpp +++ b/scriptingwindow.cpp @@ -4,6 +4,9 @@ #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) +#include +#endif #include "connections/canconmanager.h" #include "helpwindow.h" @@ -234,7 +237,13 @@ void ScriptingWindow::createNewScript() container = new ScriptContainer(); - container->fileName = "UNNAMED_" + QString::number((qrand() % 10000)) + ".js"; + QString randomPart; +#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 ) + randomPart = QString::number((qrand() % 10000)); +#else + randomPart = QString::number((QRandomGenerator::global()->bounded(10000))); +#endif + container->fileName = "UNNAMED_" + randomPart + ".js"; container->filePath = QString(); container->scriptText = QString(); container->setScriptWindow(this); diff --git a/signalviewerwindow.cpp b/signalviewerwindow.cpp index c401b49..c061074 100644 --- a/signalviewerwindow.cpp +++ b/signalviewerwindow.cpp @@ -4,6 +4,9 @@ #include "mainwindow.h" #include +#define MSG_COL 1 +#define VALUE_COL 2 + SignalViewerWindow::SignalViewerWindow(const QVector *frames, QWidget *parent) : QDialog(parent), ui(new Ui::SignalViewerWindow) @@ -14,21 +17,41 @@ SignalViewerWindow::SignalViewerWindow(const QVector *frames, QWidget modelFrames = frames; QStringList headers; - headers << "Signal" << "Value"; + headers << "Node" << "Signal" << "Value"; ui->tableViewer->setHorizontalHeaderLabels(headers); - ui->tableViewer->setColumnWidth(0, 150); - ui->tableViewer->setColumnWidth(1, 300); + ui->tableViewer->setColumnWidth(0, 100); + ui->tableViewer->setColumnWidth(1, 150); + + QSettings settings; + QFont sysFont; + int fontSize = settings.value("Main/FontSize", 9).toUInt(); + if(settings.value("Main/FontFixedWidth", false).toBool()) + sysFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); //get default fixed width font + else + sysFont = QFont(); //get default font + sysFont.setPointSize(fontSize); + ui->tableViewer->setFont(sysFont); + QHeaderView *HorzHdr = ui->tableViewer->horizontalHeader(); HorzHdr->setStretchLastSection(true); //causes the data column to automatically fill the tableview + HorzHdr->setFont(QFont()); + + QHeaderView *verticalHeader = ui->tableViewer->verticalHeader(); + verticalHeader->setFont(QFont()); dbcHandler = DBCHandler::getReference(); + connect(ui->cbNodes, SIGNAL(currentIndexChanged(int)), this, SLOT(loadMessages(int))); connect(ui->cbMessages, SIGNAL(currentIndexChanged(int)), this, SLOT(loadSignals(int))); connect(ui->btnAdd, SIGNAL(clicked(bool)), this, SLOT(addSignal())); connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int))); connect(ui->btnRemove, SIGNAL(clicked(bool)), this, SLOT(removeSelectedSignal())); + connect(ui->btnSave, SIGNAL(clicked(bool)), this, SLOT(saveSignalsFile())); + connect(ui->btnLoad, SIGNAL(clicked(bool)), this, SLOT(loadSignalsFile())); + connect(ui->btnAppend, SIGNAL(clicked(bool)), this, SLOT(appendSignalsFile())); + connect(ui->btnClear, SIGNAL(clicked(bool)), this, SLOT(clearSignalsTable())); - loadMessages(); + loadNodes(); } SignalViewerWindow::~SignalViewerWindow() @@ -75,11 +98,11 @@ void SignalViewerWindow::processFrame(CANFrame &frame) { if (sig->processAsText(frame, sigString, false)) //if true we could interpret the signal so update it in the list { - QTableWidgetItem *item = ui->tableViewer->item(i, 1); + QTableWidgetItem *item = ui->tableViewer->item(i, VALUE_COL); if (!item) { item = new QTableWidgetItem(sigString); - ui->tableViewer->setItem(i, 1, item); + ui->tableViewer->setItem(i, VALUE_COL, item); } else item->setText(sigString); } @@ -95,19 +118,67 @@ void SignalViewerWindow::removeSelectedSignal() ui->tableViewer->removeRow(selRow); } -void SignalViewerWindow::loadMessages() +void SetComboBoxItemEnabled(QComboBox * comboBox, int index, bool enabled) +{ + auto * model = qobject_cast(comboBox->model()); + assert(model); + if(!model) return; + + auto * item = model->item(index); + assert(item); + if(!item) return; + item->setEnabled(enabled); +} + +void SignalViewerWindow::loadNodes() { int numFiles; - ui->cbMessages->clear(); + ui->cbNodes->clear(); if (dbcHandler == nullptr) return; if ((numFiles = dbcHandler->getFileCount()) == 0) return; qDebug() << numFiles; for (int f = 0; f < numFiles; f++) { qDebug() << dbcHandler->getFileByIdx(f)->messageHandler->getCount(); + + QList names; + + for (int x = 0; x < dbcHandler->getFileByIdx(f)->dbc_nodes.count(); x++) + { + QString name = dbcHandler->getFileByIdx(f)->dbc_nodes[x].name; + if(name != "Vector__XXX") + names.append(name); + } + + if(names.count() > 0) + { + names.sort(); + ui->cbNodes->addItem("----" + dbcHandler->getFileByIdx(f)->getFilename()); + SetComboBoxItemEnabled(ui->cbNodes, ui->cbNodes->count() -1, false); + for(int i=0; icbNodes->addItem(names[i]); + } + } +} + +void SignalViewerWindow::loadMessages(int idx) +{ + int numFiles; + ui->cbMessages->clear(); + if (dbcHandler == nullptr) return; + if ((numFiles = dbcHandler->getFileCount()) == 0) return; + qDebug() << numFiles; + + QString nodeName = ui->cbNodes->itemText(idx); + + for (int f = 0; f < numFiles; f++) + { + qDebug() << dbcHandler->getFileByIdx(f)->messageHandler->getCount(); + for (int x = 0; x < dbcHandler->getFileByIdx(f)->messageHandler->getCount(); x++) { - ui->cbMessages->addItem(dbcHandler->getFileByIdx(f)->messageHandler->findMsgByIdx(x)->name); + if(dbcHandler->getFileByIdx(f)->messageHandler->findMsgByIdx(x)->sender->name == nodeName) + ui->cbMessages->addItem(dbcHandler->getFileByIdx(f)->messageHandler->findMsgByIdx(x)->name); } } } @@ -136,11 +207,181 @@ void SignalViewerWindow::addSignal() DBC_SIGNAL *sig = msg->sigHandler->findSignalByName(ui->cbSignals->currentText()); if (!sig) return; + addSignal(sig); +} + +void SignalViewerWindow::addSignal(DBC_SIGNAL *sig) +{ signalList.append(sig); int rowIdx = ui->tableViewer->rowCount(); ui->tableViewer->insertRow(rowIdx); - QTableWidgetItem *item = new QTableWidgetItem(sig->name); - ui->tableViewer->setItem(rowIdx, 0, item); + QTableWidgetItem *nodeitem = new QTableWidgetItem(sig->parentMessage->sender->name); + ui->tableViewer->setItem(rowIdx, 0, nodeitem); + QTableWidgetItem *msgitem = new QTableWidgetItem(sig->name); + ui->tableViewer->setItem(rowIdx, 1, msgitem); +} +void SignalViewerWindow::saveSignalsFile() +{ + saveDefinitions(); +} + +void SignalViewerWindow::loadSignalsFile() +{ + loadDefinitions(false); +} + +void SignalViewerWindow::appendSignalsFile() +{ + loadDefinitions(true); +} + +void SignalViewerWindow::clearSignalsTable() +{ + clearSignalsTable(true); +} + +void SignalViewerWindow::clearSignalsTable(bool askForConfirmation) +{ + if(askForConfirmation) + { + QMessageBox::StandardButton confirmDialog; + confirmDialog = QMessageBox::question(this, "Danger Will Robinson", "Are you sure you want to clear all of your signals?", + QMessageBox::Yes|QMessageBox::No); + if (confirmDialog == QMessageBox::No) + { + return; + } + } + + signalList.clear(); + ui->tableViewer->setRowCount(0); +} + +void SignalViewerWindow::saveDefinitions() +{ + QString filename; + QFileDialog dialog(this); + QSettings settings; + + QStringList filters; + filters.append(QString(tr("SignalViewer definition (*.sdf)"))); + + dialog.setFileMode(QFileDialog::AnyFile); + dialog.setNameFilters(filters); + dialog.setViewMode(QFileDialog::Detail); + dialog.setAcceptMode(QFileDialog::AcceptSave); + dialog.setDirectory(settings.value("SignalViewer/LoadSaveDirectory", dialog.directory().path()).toString()); + + if (dialog.exec() == QDialog::Accepted) + { + filename = dialog.selectedFiles()[0]; + settings.setValue("SignalViewer/LoadSaveDirectory", dialog.directory().path()); + + if (!filename.contains('.')) filename += ".sdf"; + + QFile *outFile = new QFile(filename); + + if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text)) + return; + + DBC_SIGNAL *sig; + for (int i = 0; i < signalList.count(); i++) + { + sig = signalList.at(i); + + outFile->write("SV1"); + outFile->putChar(','); + outFile->write(QString::number(sig->parentMessage->ID, 16).toUtf8()); + outFile->putChar(','); + outFile->write(sig->parentMessage->name.toUtf8()); + outFile->putChar(','); + outFile->write(sig->name.toUtf8()); + + outFile->write("\n"); + } + outFile->close(); + } +} + +void SignalViewerWindow::loadDefinitions(bool append) +{ + QString filename; + QFileDialog dialog; + QSettings settings; + + QStringList filters; + filters.append(QString(tr("SignalViewer definition (*.sdf)"))); + + QList loadedSignals; + + if (dbcHandler == nullptr) return; + if (dbcHandler->getFileCount() == 0) dbcHandler->createBlankFile(); + + dialog.setFileMode(QFileDialog::ExistingFile); + dialog.setNameFilters(filters); + dialog.setViewMode(QFileDialog::Detail); + dialog.setDirectory(settings.value("SignalViewer/LoadSaveDirectory", dialog.directory().path()).toString()); + + if (dialog.exec() == QDialog::Accepted) + { + filename = dialog.selectedFiles()[0]; + settings.setValue("SignalViewer/LoadSaveDirectory", dialog.directory().path()); + + QFile *inFile = new QFile(filename); + QByteArray line; + + if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text)) + return; + + while (!inFile->atEnd()) { + line = inFile->readLine().simplified(); + if (line.length() > 2) + { + QList tokens = line.split(','); + + DBC_SIGNAL *sig; + + if (tokens[0] == "SV1") //signal viewer save format v1 + { + // = tokens[1].toUInt(nullptr, 16); + + int msgId = tokens[1].toUInt(nullptr, 16); + QString msgName = QString(tokens[2]); + QString sigName = QString(tokens[3]); + DBC_MESSAGE *msg;; + if (msg = dbcHandler->findMessage(msgName)) + { + sig = msg->sigHandler->findSignalByName(sigName); + loadedSignals.append(sig); + } + else if(msg = dbcHandler->findMessage(msgId)) + { + sig = msg->sigHandler->findSignalByName(sigName); + //fix anything up about the name? + loadedSignals.append(sig); + } + else + { + qDebug() << "Couldn't find the message by name! " << msgName << " " << sigName; + } + } + } + } + inFile->close(); + + if(loadedSignals.count() > 0) + { + if(append == false) + { + clearSignalsTable(false); + } + + for (int i=0; i #include #include +#include +#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) +#include +#endif SimpleCrypt::SimpleCrypt(): m_key(0), @@ -38,7 +42,9 @@ SimpleCrypt::SimpleCrypt(): m_protectionMode(ProtectionChecksum), m_lastError(ErrorNoError) { +#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 ) qsrand(uint(QDateTime::currentMSecsSinceEpoch() & 0xFFFF)); +#endif } SimpleCrypt::SimpleCrypt(quint64 key): @@ -47,7 +53,9 @@ SimpleCrypt::SimpleCrypt(quint64 key): m_protectionMode(ProtectionChecksum), m_lastError(ErrorNoError) { +#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 ) qsrand(uint(QDateTime::currentMSecsSinceEpoch() & 0xFFFF)); +#endif splitKey(); } @@ -113,7 +121,11 @@ QByteArray SimpleCrypt::encryptToByteArray(QByteArray plaintext) } //prepend a random char to the string +#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 ) char randomChar = char(qrand() & 0xFF); +#else + char randomChar = char(QRandomGenerator::global()->bounded(256)); +#endif ba = randomChar + integrityProtection + ba; int pos(0); diff --git a/ui/mainsettingsdialog.ui b/ui/mainsettingsdialog.ui index 586e4e0..cb61d4d 100644 --- a/ui/mainsettingsdialog.ui +++ b/ui/mainsettingsdialog.ui @@ -7,7 +7,7 @@ 0 0 965 - 678 + 713 @@ -80,6 +80,39 @@ + + + + 0 + + + 0 + + + + + Maximum Frames to Capture + + + + + + + 100000 + + + 1000000000 + + + 100000 + + + 10000000 + + + + + @@ -158,9 +191,23 @@ - Font Size + Font + + + + Use fixed-width font in tables + + + + + + + Size + + + diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index 4fb01d8..77e1b5a 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -227,6 +227,13 @@ + + + + Keep Filters When Clearing + + + diff --git a/ui/signalviewerwindow.ui b/ui/signalviewerwindow.ui index b5b5d5d..8f1c75d 100644 --- a/ui/signalviewerwindow.ui +++ b/ui/signalviewerwindow.ui @@ -18,8 +18,11 @@ + + true + - 2 + 3 300 @@ -32,6 +35,7 @@ + @@ -45,6 +49,16 @@ + + + + Node + + + + + + @@ -85,6 +99,34 @@ + + + + Save View + + + + + + + Load View + + + + + + + Append to View + + + + + + + Clear View + + +