vrpn
07.33
Virtual Reality Peripheral Network
|
Go to the documentation of this file.
11 , d_numMessagesQueued(0)
12 , d_numTransmissions(0)
13 , d_isEnabled(VRPN_FALSE)
83 delete[](
char *)qm -> p.buffer;
96 fprintf(stderr,
"vrpn_RedundantTransmission::mainloop(): "
97 "serious internal error.\n");
112 timeval transmissionInterval)
125 vrpn_uint32 len, timeval time, vrpn_uint32 type, vrpn_uint32 sender,
126 const char *buffer, vrpn_uint32 class_of_service,
127 vrpn_int32 numTransmissions, timeval *transmissionInterval)
134 fprintf(stderr,
"vrpn_RedundantTransmission::pack_message: "
135 "Connection not defined!\n");
150 if (numTransmissions < 0) {
153 if (!transmissionInterval) {
161 if (!numTransmissions) {
167 if (!transmissionInterval->tv_sec && !transmissionInterval->tv_usec) {
168 for (i = 0; i < numTransmissions; i++) {
181 "vrpn_RedundantTransmission::pack_message: "
182 "Out of memory; can't queue message for retransmission.\n");
193 "vrpn_RedundantTransmission::pack_message: "
194 "Out of memory; can't queue message for retransmission.\n");
197 memcpy((
char *)qm->
p.
buffer, buffer, len);
224 buflen =
sizeof(vrpn_uint32) +
sizeof(timeval);
226 buffer =
new char[buflen];
228 fprintf(stderr,
"vrpn_RedundantController_Protocol::encode_set: "
254 buflen =
sizeof(vrpn_bool);
256 buffer =
new char[buflen];
258 fprintf(stderr,
"vrpn_RedundantController_Protocol::encode_enable: "
316 const char **bp = &p.
buffer;
331 const char **bp = &p.
buffer;
398 : nextTimestampToReplace(0)
400 , handlerIsRegistered(vrpn_FALSE)
435 pVMCB = pVMCB_Del->
next;
444 pVMCB = pVMCB_Del->
next;
456 void *userdata, vrpn_int32 sender)
460 fprintf(stderr,
"vrpn_RedundantReceiver::register_handler: "
475 fprintf(stderr,
"vrpn_RedundantReceiver::register_handler: "
476 "Negative type passed in.\n");
484 if (!
d_records[type].handlerIsRegistered) {
511 while ((victim != NULL) &&
513 (victim->
sender != sender))) {
514 snitch = &((*snitch)->next);
515 victim = victim->
next;
519 if (victim == NULL) {
521 "vrpn_TypeDispatcher::removeHandler: No such handler\n");
526 *snitch = victim->
next;
540 fprintf(stderr,
"vrpn_RedundantReceiver::writeMemory: "
541 "Memory is empty.\n");
551 fp = fopen(filename,
"wb");
553 fprintf(stderr,
"vrpn_RedundantReceiver::writeMemory: "
554 "Couldn't open %s for writing.\n",
560 fprintf(fp,
"%ld.%ld %d\n", mp->
timestamp.tv_sec,
619 "vrpn_RedundantReceiver::"
620 "handle_possiblyRedundantMessage: Out of memory.\n");
645 fprintf(stderr,
"vrpn_RedundantReceiver::"
646 "handle_possiblyRedundantMessage: "
647 "Nonzero user generic handler return.\n");
657 fprintf(stderr,
"vrpn_RedundantReceiver::"
658 "handle_possiblyRedundantMessage: "
659 "Nonzero user handler return.\n");
vrpn_RedundantController_Protocol d_protocol
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.
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_bool isEnabled(void) const
void client_mainloop(void)
Handles functions that all clients should provide in their mainloop() (warning of no server,...
virtual int register_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
vrpn_bool handlerIsRegistered
static int VRPN_CALLBACK handle_set(void *, vrpn_HANDLERPARAM)
vrpn_RedundantTransmission * d_object
int nextTimestampToReplace
char * encode_set(int *len, vrpn_uint32 num, timeval interval)
void clearMemory(void)
Throws away / resets statistics.
virtual int unregister_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
vrpn_RedundantController(vrpn_RedundantTransmission *, vrpn_Connection *)
vrpn_RedundantController_Protocol d_protocol
Description of a callback entry for a user type.
void record(vrpn_bool)
Turns "memory" (tracking statistics of redundant reception) on and off.
char * encode_enable(int *len, vrpn_bool)
vrpn_MESSAGEHANDLER handler
Routine to call.
void register_types(vrpn_Connection *)
queuedMessage * d_messageList
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
void addReference()
Counting references to this 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.
vrpn_Connection * d_connection
vrpn_RedundantTransmission(vrpn_Connection *c)
vrpn_Connection * d_connection
Connection that this object talks to.
virtual vrpn_int32 register_message_type(const char *name)
const vrpn_uint32 vrpn_CONNECTION_RELIABLE
Classes of service for messages, specify multiple by ORing them together Priority of satisfying these...
This structure is what is passed to a vrpn_Connection message callback.
vrpn_uint32 d_numMessagesQueued
For debugging, mostly.
const int vrpn_CONNECTION_MAX_TYPES
vrpn_int32 d_sender_id
Sender ID registered with the connection.
timeval transmissionInterval
vrpn_uint32 d_numTransmissions
RRRecord d_records[vrpn_CONNECTION_MAX_TYPES]
void decode_set(const char **buf, vrpn_uint32 *num, timeval *interval)
vrpn_uint32 defaultRetransmissions(void) const
static int VRPN_CALLBACK handle_possiblyRedundantMessage(void *, vrpn_HANDLERPARAM)
Generic connection class not specific to the transport mechanism.
const int vrpn_ANY_TYPE
vrpn_ANY_TYPE can be used to register callbacks for any USER type of message from a given sender....
virtual int pack_message(vrpn_uint32 len, timeval time, vrpn_uint32 type, vrpn_uint32 sender, const char *buffer, vrpn_uint32 class_of_service, vrpn_int32 numRetransmissions=-1, timeval *transmissionInterval=NULL)
If !isEnabled(), does a normal pack_message(), but if isEnabled() ignores class_of_service and sends ...
virtual void mainloop(void)
Determines which messages need to be resent and queues them up on the connection for transmission.
vrpn_Connection * d_connection
#define vrpn_gettimeofday
void set(int numRetransmissions, timeval transmissionInterval)
~vrpn_RedundantReceiver(void)
const int vrpn_ANY_SENDER
vrpn_ANY_SENDER can be used to register callbacks on a given message type from any sender.
bool vrpn_TimevalGreater(const timeval &tv1, const timeval &tv2)
~vrpn_RedundantTransmission(void)
virtual int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
int(VRPN_CALLBACK * vrpn_MESSAGEHANDLER)(void *userdata, vrpn_HANDLERPARAM p)
Type of a message handler for vrpn_Connection messages.
virtual void setDefaults(vrpn_uint32 numRetransmissions, timeval transmissionInterval)
Set default values for future calls to pack_message().
void mainloop(void)
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpnMsgCallbackEntry * cb
void mainloop(void)
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
void decode_enable(const char **buf, vrpn_bool *)
virtual int init(void)
Initialize things that the constructor can't. Returns 0 on success, -1 on failure.
static int VRPN_CALLBACK handle_enable(void *, vrpn_HANDLERPARAM)
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.
timeval d_transmissionInterval
int numSeen[VRPN_RR_LENGTH]
~vrpn_RedundantController(void)
timeval vrpn_TimevalSum(const timeval &tv1, const timeval &tv2)
vrpn_RedundantReceiver(vrpn_Connection *)
~vrpn_RedundantRemote(void)
vrpnMsgCallbackEntry * next
Next handler.
void writeMemory(const char *filename)
Writes statistics to the named file: timestamp of every message received and number of copies of that...
virtual int send_pending_reports(void)=0
send pending report, clear the buffer. This function was protected, now is public,...
vrpn_int32 sender
Only if from sender.
timeval timestampSeen[VRPN_RR_LENGTH]
int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
void * userdata
Passed along.
virtual int register_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
Set up (or remove) a handler for a message of a given type. Optionally, specify which sender to handl...
vrpn_RedundantRemote(vrpn_Connection *)
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...
timeval defaultInterval(void) const
vrpn_uint32 remainingTransmissions