diff --git a/mainwindow.cpp b/mainwindow.cpp index ae07bed..8077f80 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -84,6 +84,8 @@ MainWindow::MainWindow(QWidget *parent) : connect(worker, &SerialWorker::connectionFailure, this, &MainWindow::connectionFailed, Qt::QueuedConnection); connect(worker, &SerialWorker::deviceInfo, this, &MainWindow::gotDeviceInfo, Qt::QueuedConnection); connect(this, &MainWindow::closeSerialPort, worker, &SerialWorker::closeSerialPort, Qt::QueuedConnection); + connect(this, &MainWindow::startFrameCapturing, worker, &SerialWorker::startFrameCapture); + connect(this, &MainWindow::stopFrameCapturing, worker, &SerialWorker::stopFrameCapture); serialWorkerThread.start(); graphingWindow = NULL; @@ -113,6 +115,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->cbInterpret, SIGNAL(toggled(bool)), this, SLOT(interpretToggled(bool))); connect(ui->cbOverwrite, SIGNAL(toggled(bool)), this, SLOT(overwriteToggled(bool))); connect(ui->actionEdit_Messages_Signals, SIGNAL(triggered(bool)), this, SLOT(showDBCEditor())); + connect(ui->btnCaptureToggle, SIGNAL(clicked(bool)), this, SLOT(toggleCapture())); lbStatusConnected.setText(tr("Not connected")); updateBaudLabel(0,0); @@ -125,6 +128,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->lbNumFrames->setText("0"); isConnected = false; + allowCapture = true; //create a temporary frame to be able to capture the correct //default height of an item in the table. Need to do this in case @@ -731,6 +735,21 @@ void MainWindow::connButtonPress() } } +void MainWindow::toggleCapture() +{ + allowCapture = !allowCapture; + if (allowCapture) + { + ui->btnCaptureToggle->setText("Suspend Capturing"); + emit startFrameCapturing(); + } + else + { + ui->btnCaptureToggle->setText("Restart Capturing"); + emit stopFrameCapturing(); + } +} + void MainWindow::connectionSucceeded(int baud0, int baud1) { lbStatusConnected.setText(tr("Connected to GVRET")); diff --git a/mainwindow.h b/mainwindow.h index d5e5f7d..ce33f4e 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -14,7 +14,7 @@ #include "dbchandler.h" #include "dbcmaineditor.h" -#define VERSION 105 +#define VERSION 106 namespace Ui { class MainWindow; @@ -49,6 +49,7 @@ private slots: void interpretToggled(bool); void overwriteToggled(bool); void showDBCEditor(); + void toggleCapture(); public slots: void gotFrames(int, int); @@ -59,6 +60,9 @@ signals: void closeSerialPort(); void updateBaudRates(int, int); void sendCANFrame(const CANFrame *, int); + void stopFrameCapturing(); + void startFrameCapturing(); + private: Ui::MainWindow *ui; @@ -69,6 +73,7 @@ private: QList ports; QThread serialWorkerThread; QByteArray inputBuffer; + bool allowCapture; //References to other windows we can display GraphingWindow *graphingWindow; diff --git a/mainwindow.ui b/mainwindow.ui index 570310a..bc6d436 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -194,6 +194,13 @@ + + + + Suspend Capturing + + + diff --git a/serialworker.cpp b/serialworker.cpp index bab78a2..612831c 100644 --- a/serialworker.cpp +++ b/serialworker.cpp @@ -15,6 +15,7 @@ SerialWorker::SerialWorker(CANFrameModel *model, QObject *parent) : QObject(pare ticker = NULL; elapsedTime = NULL; framesPerSec = 0; + capturing = true; } SerialWorker::~SerialWorker() @@ -246,10 +247,11 @@ void SerialWorker::procRXChar(unsigned char c) rx_state = IDLE; rx_step = 0; //qDebug() << "emit from serial handler to main form id: " << buildFrame->ID; - //emit receivedFrame(buildFrame); - canModel->addFrame(*buildFrame, false); - gotFrames++; - //buildFrame = new CANFrame; + if (capturing) + { + canModel->addFrame(*buildFrame, false); + gotFrames++; + } } break; } @@ -368,3 +370,16 @@ void SerialWorker::closeSerialPort() delete serial; serial = NULL; } + +void SerialWorker::stopFrameCapture() +{ + qDebug() << "Stopping frame capture"; + capturing = false; +} + +void SerialWorker::startFrameCapture() +{ + qDebug() << "Starting up frame capture"; + capturing = true; +} + diff --git a/serialworker.h b/serialworker.h index 10e7704..e987abb 100644 --- a/serialworker.h +++ b/serialworker.h @@ -48,11 +48,14 @@ public slots: void closeSerialPort(); void sendFrame(const CANFrame *, int); void updateBaudRates(int, int); + void stopFrameCapture(); + void startFrameCapture(); //only need to call this if previously stopped. Otherwise it's the default private: QString portName; bool quit; bool connected; + bool capturing; QSerialPort *serial; CANFrameModel *canModel; QTimer *ticker;