1 #ifndef CARMA_LINELENGTH_COMEDIDEVICE_H
2 #define CARMA_LINELENGTH_COMEDIDEVICE_H
4 #include <carma/util/PthreadMutex.h>
5 #include <carma/util/PthreadCond.h>
7 #include <boost/circular_buffer.hpp>
8 #include <boost/shared_ptr.hpp>
13 namespace linelength {
33 ComediSample(
const unsigned int nchannels,
const unsigned int nsamples);
34 std::vector<double> calculateAverage()
const;
36 const unsigned int nchannels;
37 const unsigned int nsamples;
39 std::vector<double> samples;
40 std::vector<bool> dio;
43 typedef boost::shared_ptr<struct ComediSample> ComediSamplePtr;
66 ComediDevice(
const std::string &name);
71 int findRange(
const double min,
const double max);
74 void setupExternalReference(
unsigned int period_ns = 100);
77 void startCapture(comedi_cmd *cmd,
unsigned int nsamples);
82 ComediSamplePtr waitForNextSample(
const struct timespec &ts);
85 static void thread(ComediDevice &This) { This.run(); };
93 void clearExistingData();
94 void restartCapture();
98 void readDIO(ComediSamplePtr buf);
99 void convertSamples(ComediSamplePtr buf);
101 const std::string filename_;
104 bool capture_started_;
107 std::vector<comedi_range *> ranges_;
108 std::vector<lsampl_t> maxdatas_;
111 unsigned int nchannels_;
112 unsigned int nsamples_;
113 std::vector<sampl_t> samples_;
116 boost::circular_buffer<ComediSamplePtr> circbuf_;
A simple wrapper class that makes use of ::pthread_cond_t easier in a C++ world.
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...