vrpn  07.33
Virtual Reality Peripheral Network
vrpn_5DT16.h
Go to the documentation of this file.
1 #ifndef vrpn_5dt16_H
2 #define vrpn_5dt16_H
3 
4 #include "vrpn_Analog.h" // for vrpn_ANALOGCB, etc
5 #include "vrpn_Configure.h" // for VRPN_API, VRPN_CALLBACK
6 #include "vrpn_Connection.h" // for vrpn_CONNECTION_LOW_LATENCY, etc
7 #include "vrpn_Shared.h" // for timeval
8 #include "vrpn_Types.h" // for vrpn_uint32
9 
10 // This class will read the finger-pad values of the 5DT glove as analogs
11 // and send them. Use the vrpn_Button_5DT_Server class below if you want
12 // to turn them into buttons by thresholding them.
13 
15 {
16 public:
17  vrpn_5dt16 (const char * name,
18  vrpn_Connection * c,
19  const char * port,
20  int baud = 19200);
21 
22  ~vrpn_5dt16 () {};
23 
25  virtual void mainloop ();
26 
27  protected:
28  int _status; //< Reset, Syncing, or Reading
29  int _numchannels; //< How many analog channels to open
30  int _mode ; //< glove mode for reporting data (see glove manual)
31  unsigned _expected_chars; //< How many characters to expect in the report
32  unsigned char _buffer[512]; //< Buffer of characters in report
33  unsigned _bufcount; //< How many characters we have so far
34  bool _tenbytes; //< Whether there are 10-byte responses (unusual, but seen)
35 
36  struct timeval timestamp; //< Time of the last report from the device
37 
38  virtual int reset(void); //< Set device back to starting config
39  virtual void get_report(void); //< Try to read a report from the device
40 
41  virtual void clear_values(void); //< Clears all channels to 0
42 
44  virtual void report_changes
45  (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
47  virtual void report
48  (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
49 };
50 
51 #include "vrpn_Button.h" // for vrpn_Button_Filter
52 
53 // 5dt16 button server code. This device will listen to a 5dt16 analog server
54 // and report button press and release event when the analog pass a threshold
55 // value.
56 // This class is derived from the vrpn_Button_Filter class, so that it
57 // can be made to toggle its buttons using messages from the client.
59 {
60 public:
61  // Buttons are considered pressed when their analog value exceeds the
62  // threshold value.
63  vrpn_Button_5DT_Server(const char *name, const char *deviceName, vrpn_Connection *c,
64  double threshold[16]);
66 
67  virtual void mainloop();
68 
69 protected:
70  static void VRPN_CALLBACK handle_analog_update (void * userdata, const vrpn_ANALOGCB info);
72  double m_threshold[16];
73 };
74 
75 #endif
76 
vrpn_Serial_Analog
Definition: vrpn_Analog.h:63
vrpn_Button_5DT_Server::d_5dt_button
vrpn_Analog_Remote * d_5dt_button
Definition: vrpn_5DT16.h:71
vrpn_5dt16::_mode
int _mode
Definition: vrpn_5DT16.h:30
vrpn_Types.h
vrpn_5dt16
Definition: vrpn_5DT16.h:15
vrpn_Analog::report
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report whether something has changed or not (for servers) Optionally, tell what time to stamp ...
Definition: vrpn_Analog.C:94
vrpn_Analog_Remote
Definition: vrpn_Analog.h:181
vrpn_Button_5DT_Server
Definition: vrpn_5DT16.h:59
vrpn_5dt16::_numchannels
int _numchannels
Definition: vrpn_5DT16.h:29
vrpn_CONNECTION_LOW_LATENCY
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
Definition: vrpn_Connection.h:122
vrpn_5dt16::~vrpn_5dt16
~vrpn_5dt16()
Definition: vrpn_5DT16.h:22
vrpn_ANALOGCB
Definition: vrpn_Analog.h:168
vrpn_Shared.h
vrpn_Button.h
vrpn_BaseClass::mainloop
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_Connection
Generic connection class not specific to the transport mechanism.
Definition: vrpn_Connection.h:510
vrpn_Connection.h
vrpn_5dt16::_status
int _status
Definition: vrpn_5DT16.h:28
vrpn_Analog.h
VRPN_CALLBACK
#define VRPN_CALLBACK
Definition: vrpn_Configure.h:647
vrpn_Configure.h
vrpn_Analog::report_changes
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
vrpn_5dt16::_expected_chars
unsigned _expected_chars
Definition: vrpn_5DT16.h:31
vrpn_5dt16::_bufcount
unsigned _bufcount
Definition: vrpn_5DT16.h:33
VRPN_API
#define VRPN_API
Definition: vrpn_Configure.h:646
vrpn_Button_Filter
All button servers should derive from this class, which provides the ability to turn any of the butto...
Definition: vrpn_Button.h:65