2020-09-22 17:32:00 +00:00
|
|
|
#include "lasp_cppuldaq.h"
|
|
|
|
#include <chrono>
|
|
|
|
#include <iostream>
|
2020-09-27 17:38:49 +00:00
|
|
|
#include <cmath>
|
2020-09-22 17:32:00 +00:00
|
|
|
using std::cout;
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
2020-09-27 17:38:49 +00:00
|
|
|
/* boolvec inChannels = {true, false, false, false}; */
|
|
|
|
boolvec inChannels = {true, true, false, false};
|
2020-09-22 17:32:00 +00:00
|
|
|
boolvec outChannels = {true};
|
|
|
|
double samplerate = 10000;
|
2020-09-27 17:38:49 +00:00
|
|
|
const us samplesPerBlock = 256;
|
2020-09-22 17:32:00 +00:00
|
|
|
|
|
|
|
DT9837A daq(
|
|
|
|
samplesPerBlock,
|
|
|
|
inChannels,
|
|
|
|
outChannels,
|
|
|
|
samplerate,
|
2020-09-27 17:38:49 +00:00
|
|
|
true // monitor Output
|
2020-09-22 17:32:00 +00:00
|
|
|
);
|
|
|
|
|
2020-10-04 20:29:54 +00:00
|
|
|
SafeQueue<void*> inqueue;
|
|
|
|
SafeQueue<void*> outqueue;
|
2020-09-22 17:32:00 +00:00
|
|
|
|
2020-09-27 17:38:49 +00:00
|
|
|
double totalTime = 5;
|
|
|
|
double t = 0;
|
|
|
|
double freq = 1000;
|
|
|
|
us nblocks = ((us) totalTime*samplerate/samplesPerBlock) + 10;
|
|
|
|
|
|
|
|
for(us i=0;i<nblocks;i++) {
|
|
|
|
|
|
|
|
double* data = static_cast<double*>(malloc(sizeof(double)*samplesPerBlock));
|
|
|
|
for(us sample=0;sample<samplesPerBlock;sample++) {
|
|
|
|
|
|
|
|
data[sample] = sin(2*M_PI*freq*t);
|
|
|
|
t+= 1.0/samplerate;
|
|
|
|
|
|
|
|
}
|
|
|
|
outqueue.enqueue(data);
|
|
|
|
}
|
|
|
|
|
2020-09-22 17:32:00 +00:00
|
|
|
daq.start(&inqueue, &outqueue);
|
|
|
|
/* daq.start(NULL, &outqueue); */
|
|
|
|
|
2020-09-27 17:38:49 +00:00
|
|
|
std::this_thread::sleep_for(std::chrono::seconds((int) totalTime));
|
2020-09-22 17:32:00 +00:00
|
|
|
/* std::string a; */
|
|
|
|
/* std::cin >> a; */
|
|
|
|
|
|
|
|
daq.stop();
|
|
|
|
|
|
|
|
while(!inqueue.empty()) {
|
2020-10-04 20:29:54 +00:00
|
|
|
double* buf = (double*) inqueue.dequeue();
|
2020-09-22 17:32:00 +00:00
|
|
|
for(us i=0;i<samplesPerBlock;i++) {
|
|
|
|
for(us ch=0;ch<daq.neninchannels();ch++) {
|
|
|
|
cout << buf[ch*samplesPerBlock+i] << " ";
|
|
|
|
}
|
|
|
|
cout << endl;
|
|
|
|
}
|
|
|
|
free(buf);
|
|
|
|
}
|
2020-09-27 17:38:49 +00:00
|
|
|
while(!outqueue.empty()){
|
2020-10-04 20:29:54 +00:00
|
|
|
void* dat = outqueue.dequeue();
|
2020-09-27 17:38:49 +00:00
|
|
|
free(dat);
|
|
|
|
}
|
2020-09-22 17:32:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|