#include <iostream>
#include <iomanip>
#include "tic/tap.hxx"
#include "rio/rio.hxx"
#ifdef MMSYS_linux
const char *szDev0 = "/dev/irio/0";
#else
const char *szDev0 = "\\\\.\\INRIO_LCL_0" ;
#endif
#if defined(MMSYS_linux)
#include <sys/select.h>
int kbhit()
{
struct timeval tv = { 0L, 0L };
fd_set fds;
FD_ZERO(&fds);
FD_SET(0, &fds);
return select(1, &fds, NULL, NULL, &tv);
}
#else
#include <conio.h>
int kbhit() { return _kbhit(); }
#endif
int main(int argc, char **argv) {
if (1) {
std::cout << "initializing " << szDev0 << std::endl;
if (!ti0) { std::cerr << "ti0 failed: " << ti0 << std::endl; return 2; }
if (1) {
ti0.
pTip()->
callTicConfig(&tcm);
ti0.
ptp()->
callPulseConfig(&pm);
}
do {
if (1) {
tm.setLog(&std::cout);
ti0.pTip()->
callTicArm();
do {
if (!tm) {
std::cerr << "error: " << tm << std::endl;
return 2;
}
else {
}
std::cout << "freq=" ;
while (tm.
cMeas()) std::cout << std::setprecision(8) << tm.
rdFreq() <<
" ";
std::cout << std::endl;
}
if (1) {
do {
ti0.pTip()->callTicArm();
if (!tm) {
std::cerr << "error: " << tm << std::endl;
return 2;
}
}
while ( tm.
isGood() && !tm.
isDone() && !kbhit() );
std::cout << "width=" ;
double rd=tm.
rdPulseWidth();
std::cout << rd << " ";
if (rd > 0.5) {
std::cerr << "width error" << std::endl;
return 2;
}
}
std::cout << std::endl;
}
if (1) {
int c=0;
do {
ti0.pTip()->callTicArm();
if (!tm) {
std::cerr << "error: " << tm << std::endl;
return 2;
}
}
while ( c++ < 10 && tm.
isGood() && !tm.isDone() && !kbhit() );
std::cout << "pulse=" ;
while (tm.cSamp()) {
std::pair<double, double> pard=tm.
pardPulse();
std::cout << pard.first << "," << pard.second << " ";
}
std::cout << std::endl;
}
if (1) {
do {
ti0.pTip()->callTicArm();
if (!tm) {
std::cerr << "error: " << tm << std::endl;
return 2;
}
else {
}
}
while ( tm.
isGood() && !tm.
isDone() && !kbhit() );
std::cout << "count=" ;
while (tm.
cSamp()) std::cout << tm.
count() <<
" ";
std::cout << std::endl;
}
} while (!kbhit());
}
return 0;
}