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)
111 _spin_rate(spin_rate)
113 _update_rate(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;
virtual int mainloop(const struct timeval *timeout=NULL)=0
Call each time through program main loop to handle receiving any incoming messages and sending any pa...
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
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.
virtual void report_changes(void)
const vrpn_uint32 vrpn_CONNECTION_RELIABLE
Classes of service for messages, specify multiple by ORing them together Priority of satisfying these...
void client_mainloop(void)
Handles functions that all clients should provide in their mainloop() (warning of no server,...
Generic connection class not specific to the transport mechanism.
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_Dial(const char *name, vrpn_Connection *c=NULL)
virtual int init(void)
Initialize things that the constructor can't. Returns 0 on success, -1 on failure.
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
virtual void report(void)
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_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_Connection * d_connection
Connection that this object talks to.
This structure is what is passed to a vrpn_Connection message callback.
virtual int pack_message(vrpn_uint32 len, struct timeval time, vrpn_int32 type, vrpn_int32 sender, const char *buffer, vrpn_uint32 class_of_service)
Pack a message that will be sent the next time mainloop() is called. Turn off the RELIABLE flag if yo...
vrpn_float64 _update_rate
virtual vrpn_int32 encode_to(char *buf, vrpn_int32 buflen, vrpn_int32 dial, vrpn_float64 delta)
#define vrpn_gettimeofday
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.
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...
vrpn_int32 d_sender_id
Sender ID registered with the connection.
virtual int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
unsigned long vrpn_TimevalDuration(struct timeval endT, struct timeval startT)
Return number of microseconds between startT and endT.
vrpn_Callback_List< vrpn_DIALCB > d_callback_list
virtual vrpn_int32 register_message_type(const char *name)
static int VRPN_CALLBACK handle_change_message(void *userdata, vrpn_HANDLERPARAM p)
void call_handlers(const CALLBACK_STRUCT &info)
This will pass the referenced parameter as a const to all the callbacks.
vrpn_Dial_Remote(const char *name, vrpn_Connection *c=NULL)
vrpn_float64 dials[vrpn_DIAL_MAX]