25 fprintf(stderr,
"vrpn_Dial: Can't register type IDs\n");
34 vrpn_int32 buflensofar = buflen;
41 fprintf(stderr,
"vrpn_Dial::encode_to: Can't buffer delta\n");
45 fprintf(stderr,
"vrpn_Dial::encode_to: Can't buffer dial\n");
48 return sizeof(vrpn_float64) +
sizeof(vrpn_int32);
69 "vrpn_Dial: can't write message: tossing\n");
95 fprintf(stderr,
"vrpn_Dial: can't write message: tossing\n");
107 vrpn_float64 spin_rate,
108 vrpn_float64 update_rate)
117 fprintf(stderr,
"vrpn_Dial_Example_Server: Only using %d dials\n",
130 struct timeval current_time;
146 timestamp.tv_usec = current_time.tv_usec;
177 fprintf(stderr,
"vrpn_Dial_Remote: can't register handler\n");
182 fprintf(stderr,
"vrpn_Dial_Remote: Can't get connection!\n");
209 const char *bufptr = p.
buffer;
int register_autodeleted_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
Registers a handler with the connection, and remembers to delete at destruction.
vrpn_Connection * d_connection
Connection that this object talks to.
void client_mainloop(void)
Handles functions that all clients should provide in their mainloop() (warning of no server,...
vrpn_int32 d_sender_id
Sender ID registered with the connection.
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
vrpn_BaseClass(const char *name, vrpn_Connection *c=NULL)
Names the device and assigns or opens connection, calls registration methods.
virtual int init(void)
Initialize things that the constructor can't. Returns 0 on success, -1 on failure.
void call_handlers(const CALLBACK_STRUCT &info)
This will pass the referenced parameter as a const to all the callbacks.
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_Dial_Example_Server(const char *name, vrpn_Connection *c, vrpn_int32 numdials=1, vrpn_float64 spin_rate=1.0, vrpn_float64 update_rate=10.0)
vrpn_float64 _update_rate
vrpn_Callback_List< vrpn_DIALCB > d_callback_list
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_Dial_Remote(const char *name, vrpn_Connection *c=NULL)
static int VRPN_CALLBACK handle_change_message(void *userdata, vrpn_HANDLERPARAM p)
virtual void report_changes(void)
vrpn_float64 dials[vrpn_DIAL_MAX]
virtual void report(void)
vrpn_Dial(const char *name, vrpn_Connection *c=NULL)
virtual vrpn_int32 encode_to(char *buf, vrpn_int32 buflen, vrpn_int32 dial, vrpn_float64 delta)
virtual int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
This structure is what is passed to a vrpn_Connection message callback.
const vrpn_uint32 vrpn_CONNECTION_RELIABLE
Classes of service for messages, specify multiple by ORing them together Priority of satisfying these...
class VRPN_API vrpn_Connection
VRPN_API int vrpn_unbuffer(const char **buffer, timeval *t)
Utility routine for taking a struct timeval from a buffer that was sent as a message.
unsigned long vrpn_TimevalDuration(struct timeval endT, struct timeval startT)
Return number of microseconds between startT and endT.
VRPN_API int vrpn_buffer(char **insertPt, vrpn_int32 *buflen, const timeval t)
Utility routine for placing a timeval struct into a buffer that is to be sent as a message.
#define vrpn_gettimeofday