Skip to content

Commit

Permalink
Added cycle frequency diagnostic into GraphDlg
Browse files Browse the repository at this point in the history
  • Loading branch information
kernfel committed Oct 13, 2016
1 parent 6e47c82 commit 1398c1e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/gui/GraphDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,27 @@ void GraphDlg::replot()
QCPRange range = ui->plot->graph()->getKeyRange(rangeFound);

DataPoint point;

if ( initial && q[0]->pop(point) ) {
initial = false;
t0 = point.t;
}

int i = 0;
double fac;
double tNow;
for ( auto &queue : q ) {
if ( Graphp[i].isVoltage )
fac = 1e3;
else
fac = 1e9;
while ( queue->pop(point) ) {
ui->plot->graph(i)->addData(point.t, point.value * fac);
if ( !i )
++nPoints;
}
if ( !i )
tNow = point.t;
++i;
}

Expand All @@ -182,4 +193,6 @@ void GraphDlg::replot()
ui->plot->xAxis->moveRange(point.t - xUpper);
}
ui->plot->replot(QCustomPlot::rpQueuedReplot);

ui->cycleFreq->setText(QString::number(nPoints / (tNow - t0)));
}
14 changes: 14 additions & 0 deletions src/gui/GraphDlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ color: rgb(170, 0, 0);</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Mean true sampling frequency (Hz):</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLabel" name="cycleFreq">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
Expand Down
4 changes: 4 additions & 0 deletions src/include/GraphDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class GraphDlg : public QDialog

QTimer dataTimer;

bool initial;
long long nPoints;
double t0;

private slots:
void replot();
void channelIndexChanged();
Expand Down

0 comments on commit 1398c1e

Please sign in to comment.