vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Nidaq.h
Go to the documentation of this file.
1 /*****************************************************************************\
2  vrpn_Nidaq.h
3  --
4  NOTICE: This class is superceded by vrpn_NationalInstruments.h and is
5  now deprecated.
6 
7  Description : This class reads from a National Instruments D/A Card
8  (NIDAQ). To compile this class, you must have the
9  following directories in your include path:
10  ~tracker/hiball/nidaq/
11  ~tracker/hiball/src/libs/libgb (for uptime.h)
12  ~tracker/hiball/src/hybrid/ (for daq.h)
13  And you must link in:
14  ~tracker/hiball/src/libs/libgb/uptime.cpp
15  ~tracker/hiball/src/hybrid/daq.cpp
16  ~tracker/hiball/nidaq/nidaq32.lib
17 
18  ----------------------------------------------------------------------------
19  Author: weberh
20  Created: Fri Jan 29 10:00:00 1999
21  Revised: Fri Mar 19 14:45:55 1999 by weberh
22 \*****************************************************************************/
23 
24 #ifndef VRPN_NIDAQ
25 #define VRPN_NIDAQ
26 #if defined(_WIN32) || defined(WIN32)
27 #if defined(VRPN_USE_NIDAQ)
28 #include "vrpn_Analog.h"
29 #include <daq.h>
30 #include <windows.h>
31 
32 class VRPN_API vrpn_Nidaq : public vrpn_Analog {
33 public:
34  // see daq.h for more info on the args
35  // fNice says whether these threads should use 100% of the cpu or
36  // whether they should sleep for 1 ms each time through their loops
37  // (the net effect is that they add 1 ms of uncertainty to the
38  // existing 1 or 1/2 ms of uncertainty in time-stamps across a
39  // synchronized vrpn connection). If fNice is set, then
40  // the max theoretical reporting rate is 1000 hz.
41  vrpn_Nidaq(char * pchName, vrpn_Connection * pConnection,
42  double dSamplingRate=100.0, double dInterChannelRate=100000.0,
43  short sDeviceNumber=DAQ::DEF_DEVICE, int cChannels=10,
44  short rgsChan[]=DAQ::DEF_CHANS_DIFF,
45  short rgsGain[]=DAQ::DEF_GAINS,
46  short sInputMode=DAQ::DIFFERENTIAL,
47  short sPolarity=DAQ::BIPOLAR,
48  int fNice=0);
49 
50  ~vrpn_Nidaq();
51  void mainloop();
52  int doing_okay();
53 
54 protected:
55  void report_changes();
56 
57 private:
58  DAQSample daqSample;
59  DAQ *pDAQ;
60  // value to add to UpTime calls to get into vrpn_gettimeofday timeframe
61  struct timeval tvOffset;
62 
63  // Data, threadshell, and function used by extra daq getSample thread.
64  // the crit section is used to protect the analog buffer from simultaneous
65  // access by the two nidaq threads.
66  CRITICAL_SECTION csAnalogBuffer;
67  HANDLE hDAQThread;
68  static unsigned __stdcall vrpn_Nidaq::runThread(void *pVrpnNidaq);
69  void runNidaq();
70  int fStop;
71  int fNewData;
72  double dSampleTime;
73 
74  // this controls whether we give up about 1 ms worth of timestamp accuracy
75  // in exchange for cpu utilization going from 100% to 4% (or so)
76  int fNice;
77 };
78 
79 #endif // def(VRPN_USE_NIDAQ)
80 #endif // def(_WIN32) || def(WIN32)
81 #endif // ndef(VRPN_NIDAQ)
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report only if something has changed (for servers) Optionally, tell what time to stamp the val...
Definition: vrpn_Analog.C:71
Generic connection class not specific to the transport mechanism.
#define VRPN_API
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...