vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Tng3.h
Go to the documentation of this file.
1 #ifndef VRPN_TNG3B_H
2 #include "vrpn_Analog.h" // for vrpn_Serial_Analog
3 #include "vrpn_Button.h" // for vrpn_Button_Filter
4 #include "vrpn_Configure.h" // for VRPN_API
5 #include "vrpn_Connection.h" // for vrpn_CONNECTION_LOW_LATENCY, etc
6 #include "vrpn_Shared.h" // for timeval
7 #include "vrpn_Types.h" // for vrpn_uint32
8 
9 // TNG stands for "Totally Neat Gadget."
10 // The TNG3 is an interface device from Mindtel <www.mindtel.com>.
11 // It is powered by the serial control lines and offers 8 digital
12 // and 8 analog inputs. It costs about $150.
13 // Written by Rob King at Navy Research Labs.
14 
16  public vrpn_Button_Filter
17 {
18  public:
19  vrpn_Tng3 (const char * name,
20  vrpn_Connection * c,
21  const char * port,
22  int baud = 19200, // only speed
23  const int numbuttons = 8,
24  const int numchannels = 8);
25 
26  ~vrpn_Tng3 () {};
27 
28  // Called once through each main loop iteration to handle
29  // updates.
30  virtual void mainloop (void);
31 
32  protected:
33  int _status;
34  int _numbuttons; // How many buttons to open
35  int _numchannels; // How many analog channels to open
36 
37  unsigned _num_read; // How many characters have been read on this report?
38  unsigned _expected_chars; // How many characters to expect in the report
39  unsigned char _buffer[512]; // Buffer of characters in report
40  unsigned _bufcount; // How many characters we have so far
41 
42  struct timeval _timestamp; // Time of the last report from the device
43 
44  virtual void clear_values(void); // Set all buttons, analogs back to 0
45  virtual int reset(void); // Set device back to starting config
46  virtual int get_report(void); // Try to read a report from the device
47 
48  // send report iff changed
49  virtual void report_changes (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
50  // send report whether or not changed
51  virtual void report (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
52 
53  // NOTE: class_of_service is only applied to vrpn_Analog
54  // values, not vrpn_Button or vrpn_Dial
55 
56  private:
57 
58 // utility routine to sync up the data stream
59  int syncDatastream (double seconds);
60 
61  unsigned char bDataPacketStart;
62 };
63 
64 #define VRPN_TNG3B_H
65 #endif
vrpn_Serial_Analog
Definition: vrpn_Analog.h:63
vrpn_Button_Filter::report_changes
virtual void report_changes(void)
Definition: vrpn_Button.C:382
vrpn_Tng3::_numchannels
int _numchannels
Definition: vrpn_Tng3.h:35
vrpn_Types.h
vrpn_Tng3::~vrpn_Tng3
~vrpn_Tng3()
Definition: vrpn_Tng3.h:26
vrpn_Tng3::_expected_chars
unsigned _expected_chars
Definition: vrpn_Tng3.h:38
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_CONNECTION_LOW_LATENCY
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
Definition: vrpn_Connection.h:122
vrpn_Shared.h
vrpn_Button.h
vrpn_Tng3::_status
int _status
Definition: vrpn_Tng3.h:33
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_Tng3::_numbuttons
int _numbuttons
Definition: vrpn_Tng3.h:34
vrpn_Tng3::_num_read
unsigned _num_read
Definition: vrpn_Tng3.h:37
vrpn_Analog.h
vrpn_Tng3
Definition: vrpn_Tng3.h:17
vrpn_Configure.h
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