-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAOWriteThread.cpp
52 lines (44 loc) · 1.53 KB
/
AOWriteThread.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* AOWriteThread.cpp
* SpikeGL
*
* Created by calin on 11/14/10.
* Copyright 2010 Calin Culianu <[email protected]>. All rights reserved.
*
*/
#ifdef HAVE_NIDAQmx
#include "AOWriteThread.h"
#include "SpikeGL.h"
#include "NI/NIDAQmx.h"
namespace DAQ {
const unsigned AOWriteThread::QueueSz(5);
AOWriteThread::AOWriteThread(QObject *parent, const QString & aoChanString, const Params & params, AOWriteThread *oldToDelete)
: QThread(parent), SampleBufQ("AOWriteThread", QueueSz), aoChanString(aoChanString), params(params), old2Delete(oldToDelete)
{
dequeueWarnThresh = 10;
pleaseStop = false;
}
AOWriteThread::~AOWriteThread()
{
stop();
if (old2Delete) delete old2Delete, old2Delete = 0;
}
void AOWriteThread::stop()
{
if (isRunning()) {
pleaseStop = true;
std::vector<int16> empty;
enqueueBuffer(empty, 0); // forces a wake-up
wait(); // wait for thread to join
}
}
void AOWriteThread::overflowWarning()
{
Warning() << name << " overflow! Buffer queue full, dropping a buffer (capacity: " << dataQueueMaxSize << " buffers)!\n"
<< "This may be due to one or more of the following:\n"
<< "(1) the system not being able to handle the specified AI/AO rate(s)\n"
<< "(2) the AI and AO clocks are drifting with respect to each other, they may need to be linked physically (eg AI & AO should use PFI as clock, with AO samplerate = NUM_MUX_CHANS * AI Samplerate [if in MUX mode])\n"
<< "(3) the AI sample rate specified is not accurate and you are using external clock (PFI) for AI, and OnBoard for AO";
}
}
#endif