# HG changeset patch # User Hasan Yavuz Ă–ZDERYA # Date 2015-06-24 03:24:03 # Node ID 8fd74552f31766249201754d5ddc20210b693c7d # Parent 882842ce0980cad5bfe383231aa43646ad0b59e8 added sample per second counter diff --git a/mainwindow.cpp b/mainwindow.cpp --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -139,6 +139,14 @@ MainWindow::MainWindow(QWidget *parent) selectNumberFormat(NumberFormat_uint8); } + // Init sps (sample per second) counter + sampleCount = 0; + spsLabel.setText("0sps"); + ui->statusBar->addPermanentWidget(&spsLabel); + spsTimer.start(SPS_UPDATE_TIMEOUT * 1000); + QObject::connect(&spsTimer, &QTimer::timeout, + this, &MainWindow::spsTimerTimeout); + // Init demo mode demoCount = 0; demoTimer.setInterval(100); @@ -157,6 +165,7 @@ MainWindow::MainWindow(QWidget *parent) demoIndicator.hide(); demoIndicator.attach(ui->plot); } + } MainWindow::~MainWindow() @@ -377,6 +386,8 @@ void MainWindow::addChannelData(unsigned // update plot curves[channel]->setSamples(dataX, (*channelDataArray)); ui->plot->replot(); // TODO: replot after all channel data updated + + sampleCount += data.size(); } void MainWindow::clearPlot() @@ -560,6 +571,12 @@ bool MainWindow::isDemoRunning() return ui->actionDemoMode->isChecked(); } +void MainWindow::spsTimerTimeout() +{ + spsLabel.setText(QString::number(sampleCount/SPS_UPDATE_TIMEOUT) + "sps"); + sampleCount = 0; +} + void MainWindow::demoTimerTimeout() { demoCount++; diff --git a/mainwindow.h b/mainwindow.h --- a/mainwindow.h +++ b/mainwindow.h @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -93,6 +94,11 @@ private: bool skipByteRequested; + const int SPS_UPDATE_TIMEOUT = 1; // second + QLabel spsLabel; + unsigned int sampleCount; + QTimer spsTimer; + // demo QTimer demoTimer; int demoCount; @@ -119,6 +125,8 @@ private slots: void clearPlot(); + void spsTimerTimeout(); + void demoTimerTimeout(); void enableDemo(bool enabled);