From e0db7e83fd35dda9d3eb70fa18400045f74b9a9c Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Sun, 13 Sep 2015 19:37:28 -0400 Subject: [PATCH] Added a trigger ability to flowview. The playback will stop automatically if a trigger value is found. This allows for moving quickly through the data looking for a given value. Also change the hotkeys to R,T,Y because they aren't really needed for anything else on the form. --- flowviewwindow.cpp | 37 ++- flowviewwindow.h | 2 + flowviewwindow.ui | 604 ++++++++++++++++++++++++++++++++++++++++----- utility.h | 3 +- 4 files changed, 582 insertions(+), 64 deletions(-) diff --git a/flowviewwindow.cpp b/flowviewwindow.cpp index 3e87d44..7a42058 100644 --- a/flowviewwindow.cpp +++ b/flowviewwindow.cpp @@ -24,6 +24,7 @@ FlowViewWindow::FlowViewWindow(const QVector *frames, QWidget *parent) memset(refBytes, 0, 8); memset(currBytes, 0, 8); + memset(triggerValues, -1, sizeof(int) * 8); //ui->graphView->setInteractions(); @@ -69,6 +70,14 @@ FlowViewWindow::FlowViewWindow(const QVector *frames, QWidget *parent) connect(ui->listFrameID, SIGNAL(currentTextChanged(QString)), this, SLOT(changeID(QString))); connect(playbackTimer, SIGNAL(timeout()), this, SLOT(timerTriggered())); connect(ui->graphView, SIGNAL(plottableDoubleClick(QCPAbstractPlottable*,QMouseEvent*)), this, SLOT(plottableDoubleClick(QCPAbstractPlottable*,QMouseEvent*))); + connect(ui->txtTrigger0, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); + connect(ui->txtTrigger1, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); + connect(ui->txtTrigger2, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); + connect(ui->txtTrigger3, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); + connect(ui->txtTrigger4, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); + connect(ui->txtTrigger5, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); + connect(ui->txtTrigger6, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); + connect(ui->txtTrigger7, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int))); @@ -157,14 +166,14 @@ bool FlowViewWindow::eventFilter(QObject *obj, QEvent *event) QKeyEvent *keyEvent = static_cast(event); switch (keyEvent->key()) { - case Qt::Key_E: + case Qt::Key_R: if (playbackActive) btnPauseClick(); else btnPlayClick(); break; - case Qt::Key_Q: + case Qt::Key_T: btnBackOneClick(); break; - case Qt::Key_W: + case Qt::Key_Y: btnFwdOneClick(); break; } @@ -175,6 +184,18 @@ bool FlowViewWindow::eventFilter(QObject *obj, QEvent *event) } } +void FlowViewWindow::updateTriggerValues() +{ + triggerValues[0] = Utility::ParseStringToNum(ui->txtTrigger0->text()); + triggerValues[1] = Utility::ParseStringToNum(ui->txtTrigger1->text()); + triggerValues[2] = Utility::ParseStringToNum(ui->txtTrigger2->text()); + triggerValues[3] = Utility::ParseStringToNum(ui->txtTrigger3->text()); + triggerValues[4] = Utility::ParseStringToNum(ui->txtTrigger4->text()); + triggerValues[5] = Utility::ParseStringToNum(ui->txtTrigger5->text()); + triggerValues[6] = Utility::ParseStringToNum(ui->txtTrigger6->text()); + triggerValues[7] = Utility::ParseStringToNum(ui->txtTrigger7->text()); +} + void FlowViewWindow::plottableDoubleClick(QCPAbstractPlottable* plottable, QMouseEvent* event) { int id = 0; @@ -590,6 +611,16 @@ void FlowViewWindow::updateDataView() ui->flowView->setReference(refBytes, false); ui->flowView->updateData(currBytes, true); + for (int i = 0; i < 8; i++) + { + if (currBytes[i] == triggerValues[i]) + { + playbackActive = false; + playbackTimer->stop(); + break; //once any trigger is hit we can stop looking + } + } + updateGraphLocation(); updateFrameLabel(); diff --git a/flowviewwindow.h b/flowviewwindow.h index 2953aa6..78f5b71 100644 --- a/flowviewwindow.h +++ b/flowviewwindow.h @@ -36,6 +36,7 @@ private slots: void saveFileGraph(); void plottableDoubleClick(QCPAbstractPlottable* plottable, QMouseEvent* event); void gotCenterTimeID(int32_t ID, double timestamp); + void updateTriggerValues(); signals: void sendCenterTimeID(int32_t ID, double timestamp); @@ -47,6 +48,7 @@ private: const QVector *modelFrames; unsigned char refBytes[8]; unsigned char currBytes[8]; + int triggerValues[8]; int currentPosition; QTimer *playbackTimer; bool playbackActive; diff --git a/flowviewwindow.ui b/flowviewwindow.ui index 2ea56f3..a3b3ddf 100644 --- a/flowviewwindow.ui +++ b/flowviewwindow.ui @@ -13,7 +13,7 @@ Flow View - + @@ -797,66 +797,224 @@ - - - Data Byte Colors: - - - - - - - 0 = Blue - - - - - - - 1 = Green - - - - - - - 2 = Black - - - - - - - 3 = Red - - - - - - - 4 = Gray - - - - - - - 5 = Yellow - - - - - - - 6 = Cyan - - - - - - - 7 = Dark Magenta + + + Trigger Values + + + + + + + 0 + + + + + + + 1 + + + + + + + 2 + + + + + + + 3 + + + + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + -1 + + + + + + + + 0 + 0 + + + + + 40 + 16777215 + + + + -1 + + + + + + + + 0 + 0 + + + + + 40 + 16777215 + + + + -1 + + + + + + + + 0 + 0 + + + + + 40 + 16777215 + + + + -1 + + + + + + + + + + + 4 + + + + + + + 5 + + + + + + + 6 + + + + + + + 7 + + + + + + + + + + + + 0 + 0 + + + + + 40 + 16777215 + + + + -1 + + + + + + + + 40 + 16777215 + + + + -1 + + + + + + + + 40 + 16777215 + + + + -1 + + + + + + + + 40 + 16777215 + + + + -1 + + + + + + @@ -872,6 +1030,332 @@ + + + + Data Byte Colors: + + + + + + + + + + + + + + 0 + 0 + 255 + + + + + + + + + 0 + 0 + 255 + + + + + + + + + 120 + 120 + 120 + + + + + + + + 0 = Blue + + + + + + + 2 = Black + + + + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 120 + 120 + 120 + + + + + + + + 3 = Red + + + + + + + + + + + + 133 + 133 + 199 + + + + + + + + + 133 + 133 + 199 + + + + + + + + + 120 + 120 + 120 + + + + + + + + 4 = Gray + + + + + + + + + + + + 0 + 170 + 0 + + + + + + + + + 0 + 170 + 0 + + + + + + + + + 120 + 120 + 120 + + + + + + + + 1 = Green + + + + + + + + + + + + 203 + 203 + 0 + + + + + + + + + 203 + 203 + 0 + + + + + + + + + 120 + 120 + 120 + + + + + + + + 5 = Yellow + + + + + + + + + + + + 68 + 204 + 204 + + + + + + + + + 68 + 204 + 204 + + + + + + + + + 120 + 120 + 120 + + + + + + + + 6 = Cyan + + + + + + + + + + + + 180 + 0 + 180 + + + + + + + + + 180 + 0 + 180 + + + + + + + + + 120 + 120 + 120 + + + + + + + + 7 = Dk Magenta + + + + + diff --git a/utility.h b/utility.h index 5e07664..0197899 100644 --- a/utility.h +++ b/utility.h @@ -21,7 +21,8 @@ public: input = input.toUpper(); if (input.startsWith("0X") || input.startsWith("X")) //hex number { - temp = input.right(input.size() - 2).toInt(NULL, 16); + if (input.length() < 3) temp = 0; + else temp = input.right(input.size() - 2).toInt(NULL, 16); } else if (input.startsWith("B")) //binary number {