Skip to content

Commit db6f15b

Browse files
authored
Merge pull request #10 from tnowotny/development
Bugfixes & performance monitor
2 parents b512c4d + f54b9f4 commit db6f15b

17 files changed

Lines changed: 2506 additions & 125 deletions

StdpC.pro

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ FORMS += $$PWD/src/gui/MainWin.ui \
6666
$$PWD/src/gui/ComponentFactoryWidget.ui \
6767
$$PWD/src/gui/DaqWidget.ui \
6868
$$PWD/src/gui/DaqFactoryWidget.ui \
69-
$$PWD/src/gui/SpikeGenDlg.ui
69+
$$PWD/src/gui/SpikeGenDlg.ui \
70+
$$PWD/src/gui/PerformanceMonitor.ui
7071

7172
HEADERS += \
7273
$$PWD/src/include/Mainwin.h \
@@ -133,7 +134,8 @@ HEADERS += \
133134
$$PWD/src/include/Model.h \
134135
$$PWD/src/include/ModelOpts.h \
135136
$$PWD/src/include/ModelDlg.h \
136-
$$PWD/src/include/Util.h
137+
$$PWD/src/include/Util.h \
138+
$$PWD/src/include/PerformanceMonitor.h
137139

138140
SOURCES += $$PWD/src/core/Main.cpp \
139141
$$PWD/src/gui/MainWin.cpp \
@@ -191,7 +193,8 @@ SOURCES += $$PWD/src/core/Main.cpp \
191193
$$PWD/src/models/Model.cpp \
192194
$$PWD/src/gui/ModelOpts.cpp \
193195
$$PWD/src/gui/DaqOpts.cpp \
194-
$$PWD/src/core/Util.cpp
196+
$$PWD/src/core/Util.cpp \
197+
$$PWD/src/gui/PerformanceMonitor.cpp
195198

196199
LIBS += $$PWD/staticlib/pt_ioctl_tn.a
197200

manual/manual.pdf

19.5 KB
Binary file not shown.

manual/manual.tex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,16 @@ \subsection{Data display}
15431543
but data will continue to be gathered until the clamp cycle is stopped.
15441544
\end{myitem}
15451545

1546+
\subsection{Performance monitor}
1547+
The performance monitor is a valuable diagnostic tool which displays the
1548+
average clamp cycle duration, as well as best and worst case markers. The performance
1549+
monitor has two control elements; a checkbox to enable the monitor, and an input to
1550+
set the sampling interval. Worst case, best case and mean cycle duration are all
1551+
computed with regards to the sampling interval. \\[0.2cm]
1552+
\parbox{\textwidth}{
1553+
\includegraphics[scale=0.6]{performanceMonitor}
1554+
} \\[0.2cm]
1555+
15461556

15471557
\section{Experiment automation} \label{scriptsect}
15481558

manual/performanceMonitor.eps

Lines changed: 1948 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/AP.cpp

Lines changed: 195 additions & 64 deletions
Large diffs are not rendered by default.

src/core/ChannelIndex.cpp

Lines changed: 12 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ ChannelIndex::ChannelIndex() :
1717
daqClass(""),
1818
devID(0),
1919
isInChn(true),
20-
chanID(0)
20+
chanID(0),
21+
isLegacy(false)
2122
{
2223

2324
}
@@ -31,7 +32,8 @@ ChannelIndex::ChannelIndex(DAQProxy *proxy, size_t devID, size_t chanID, bool is
3132
daqClass(proxy->daqClass()),
3233
devID(devID),
3334
isInChn(isInChn),
34-
chanID(chanID)
35+
chanID(chanID),
36+
isLegacy(false)
3537
{}
3638

3739
ChannelIndex::ChannelIndex(ModelProxy *proxy, size_t modelID) :
@@ -42,7 +44,8 @@ ChannelIndex::ChannelIndex(ModelProxy *proxy, size_t modelID) :
4244
modelClass(proxy->modelClass()),
4345
modelID(modelID),
4446
instID(0),
45-
isAnalog(false)
47+
isAnalog(false),
48+
isLegacy(false)
4649
{}
4750

4851
ChannelIndex::ChannelIndex(ModelProxy *proxy, size_t modelID, size_t instID) :
@@ -53,7 +56,8 @@ ChannelIndex::ChannelIndex(ModelProxy *proxy, size_t modelID, size_t instID) :
5356
modelClass(proxy->modelClass()),
5457
modelID(modelID),
5558
instID(instID),
56-
isAnalog(false)
59+
isAnalog(false),
60+
isLegacy(false)
5761
{}
5862

5963
ChannelIndex ChannelIndex::toInstance(size_t instID) const
@@ -128,57 +132,6 @@ std::ostream &operator<<(std::ostream &os, const ChannelIndex &dex)
128132
return os;
129133
}
130134

131-
static void legacyRescue_0(QString str, ChannelIndex &dex)
132-
{
133-
// Attempt legacy rescue
134-
// Caveats: - inChn/outChn is unknowable; uses heuristics
135-
// - Graph channels are likely to fail
136-
// - Explicit NONE on pre-2016 collapses onto SG
137-
bool ok = false;
138-
int ch = str.toInt(&ok);
139-
if ( !ok )
140-
return;
141-
DAQData *d =& DeviceManager::Register()[LEGACY_DAQ_CLASS]->param(0);
142-
dex.daqClass = LEGACY_DAQ_CLASS;
143-
dex.devID = 0;
144-
if ( ch >= 0 && ch <= (int)(d->inChn.size()+d->outChn.size()+1) ) { // Pre-2016
145-
dex.chanID = ch;
146-
if ( ch < (int) d->inChn.size() && ch < (int)d->outChn.size() ) {
147-
dex.isAnalog = true;
148-
dex.isInChn = d->inChn.size() > d->outChn.size(); // Statistically...
149-
} else if ( d->inChn.size() >= d->outChn.size() && ch < (int)d->inChn.size() ) {
150-
dex.isAnalog = true;
151-
dex.isInChn = true;
152-
} else if ( d->inChn.size() < d->outChn.size() && ch < (int)d->outChn.size() ) {
153-
dex.isAnalog = true;
154-
dex.isInChn = false;
155-
} else {
156-
dex.isNone = true;
157-
}
158-
dex.isValid = true; // One hopes.
159-
} else if ( ch == -1 ) { // 2016-RC1 : None
160-
dex.isNone = true;
161-
dex.isValid = true;
162-
} else if ( ch == 1000 ) { // 2016-RC1 : SG
163-
dex.isVirtual = true;
164-
dex.modelClass = "SG";
165-
dex.modelID = 0;
166-
dex.instID = 0;
167-
dex.isValid = true;
168-
} else if ( ch >= 1100000000 ) { // 2016-RC1 : HH Proto
169-
dex.isPrototype = true;
170-
dex.modelClass = "HH";
171-
dex.modelID = ((ch - 1100000000) / 100000) - 1;
172-
dex.isValid = true;
173-
} else if ( ch >= 100000000 ) { // 2016-RC1 : HH Inst
174-
dex.isVirtual = true;
175-
dex.modelClass = "HH";
176-
dex.modelID = ((ch - 100000000) / 100000) - 1;
177-
dex.instID = ch % 100000;
178-
dex.isValid = true;
179-
}
180-
}
181-
182135
std::istream &operator>>(std::istream &is, ChannelIndex &dex)
183136
{
184137
ChannelIndex blank;
@@ -236,7 +189,8 @@ std::istream &operator>>(std::istream &is, ChannelIndex &dex)
236189
dex.instID = parts.at(3).toUInt();
237190
dex.isValid = true;
238191
} else if ( parts.size() == 1 && LOADED_PROTOCOL_VERSION == 0 ) {
239-
legacyRescue_0(str, dex);
192+
dex.isLegacy = true;
193+
dex.chanID = parts.at(0).toInt();
240194
} else if ( parts.size() == 1 && LOADED_PROTOCOL_VERSION < 3 ) {
241195
if ( !parts.at(0).compare("SpikeGen", Qt::CaseInsensitive) ) {
242196
dex.isVirtual = true;
@@ -258,5 +212,6 @@ bool operator==(ChannelIndex const& a, ChannelIndex const& b)
258212
(!a.isPrototype || (a.modelClass==b.modelClass && a.modelID==b.modelID)) &&
259213
(!a.isVirtual || (a.modelClass==b.modelClass && a.modelID==b.modelID && a.instID==b.instID)) &&
260214
a.isAnalog==b.isAnalog &&
261-
(!a.isAnalog || (a.daqClass==b.daqClass && a.devID==b.devID && a.isInChn==b.isInChn && a.chanID==b.chanID));
215+
(!a.isAnalog || (a.daqClass==b.daqClass && a.devID==b.devID && a.isInChn==b.isInChn && a.chanID==b.chanID)) &&
216+
a.isLegacy == b.isLegacy;
262217
}

src/core/DCThread.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
#include "DeviceManager.h"
88
#include "ModelManager.h"
99
#include "GraphDlg.h"
10+
#include "PerformanceMonitor.h"
1011

1112
DCThread::DCThread() :
12-
graph(nullptr)
13+
graph(nullptr),
14+
perfmon(nullptr)
1315
{
1416
stopped= true;
1517
finished= true;
@@ -41,6 +43,14 @@ void DCThread::setGraph(GraphDlg *g, double dt)
4143
}
4244
}
4345

46+
void DCThread::setPerformanceMonitor(PerformanceMonitor *pt, double dt)
47+
{
48+
if ( stopped ) {
49+
perfmon = pt;
50+
perfDt = dt;
51+
}
52+
}
53+
4454
void DCThread::setup_and_go()
4555
{
4656
// Initialise devices
@@ -235,6 +245,7 @@ void DCThread::run()
235245
{
236246
int rateCounter = 0;
237247
double lastRateReport = 0.;
248+
PerformanceMonitor::DataPoint perfData { 0, 0, perfDt, 0 };
238249
static int i;
239250
static double evt;
240251
bool SampleHoldOn= false;
@@ -448,6 +459,22 @@ void DCThread::run()
448459
rateCounter = 0;
449460
}
450461

462+
// Performance monitor
463+
if ( perfmon ) {
464+
++perfData.n;
465+
if ( dt < perfData.minDt )
466+
perfData.minDt = dt;
467+
if ( dt > perfData.maxDt )
468+
perfData.maxDt = dt;
469+
if ( t - perfData.t > perfDt ) {
470+
perfData.t = t;
471+
perfmon->q.push(perfData);
472+
// Set min, max to mean rather than boundary to reduce initial flurry of updates
473+
perfData.minDt = perfData.maxDt = perfDt / perfData.n;
474+
perfData.n = 0;
475+
}
476+
}
477+
451478
// Scripting
452479
if (t >= evt) { // event needs doing
453480
scrIter->second();

src/core/Global.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ std::vector<mhHHData> mhHHp;
1414
std::vector<abHHData> abHHp;
1515

1616
PlotData Plotp;
17+
PerformanceMonitorData PerfMonp;
1718

1819
dataSavingParams dataSavingPs;
1920

src/gui/MainWin.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ void MyMainWindow::StartButClicked()
204204

205205
if ( !ui->graphtab->startPlotting(DCT) )
206206
ui->tabWidget->setTabEnabled(1, false);
207+
if ( !ui->performancetab->startPlotting(DCT) )
208+
ui->tabWidget->setTabEnabled(2, false);
207209
rateIndicator->setText("Started");
208210
DCT->setup_and_go();
209211
}
@@ -224,7 +226,9 @@ void MyMainWindow::StopButClicked()
224226
DisplayMessage(QString("Main: Dynamic Clamp stopped."));
225227
}
226228
ui->graphtab->stopPlotting();
229+
ui->performancetab->stopPlotting();
227230
ui->tabWidget->setTabEnabled(1, true);
231+
ui->tabWidget->setTabEnabled(2, true);
228232
}
229233

230234
void MyMainWindow::exportData(bool ignoreDAQ)
@@ -234,6 +238,7 @@ void MyMainWindow::exportData(bool ignoreDAQ)
234238
ui->DAQTable->exportData(ignoreDAQ);
235239
DSDlg->exportData();
236240
ui->graphtab->exportData();
241+
ui->performancetab->exportData();
237242
}
238243

239244
void MyMainWindow::importData()
@@ -243,6 +248,7 @@ void MyMainWindow::importData()
243248
ui->currentTable->importData();
244249
DSDlg->importData();
245250
ui->graphtab->importData();
251+
ui->performancetab->importData();
246252
updateStartButton();
247253
}
248254

src/gui/MainWin.ui

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,11 @@
361361
<string>Graph</string>
362362
</attribute>
363363
</widget>
364+
<widget class="PerformanceMonitor" name="performancetab">
365+
<attribute name="title">
366+
<string>Performance</string>
367+
</attribute>
368+
</widget>
364369
</widget>
365370
</item>
366371
<item row="1" column="0" colspan="2">
@@ -515,6 +520,12 @@
515520
<header>GraphDlg.h</header>
516521
<container>1</container>
517522
</customwidget>
523+
<customwidget>
524+
<class>PerformanceMonitor</class>
525+
<extends>QWidget</extends>
526+
<header>PerformanceMonitor.h</header>
527+
<container>1</container>
528+
</customwidget>
518529
</customwidgets>
519530
<tabstops>
520531
<tabstop>StartBut</tabstop>

0 commit comments

Comments
 (0)