vrpn  07.33
Virtual Reality Peripheral Network
vrpn_FileController.C
Go to the documentation of this file.
1 #include <stddef.h> // for NULL
2 
3 #include "vrpn_Connection.h" // for vrpn_Connection, etc
4 #include "vrpn_FileController.h"
5 // Include vrpn_Shared.h _first_ to avoid conflicts with sys/time.h
6 // and netinet/in.h and ...
7 #include "vrpn_Shared.h" // for timeval, vrpn_gettimeofday, etc
8 
10  : d_connection(c)
11 {
12 
13  if (!c) return;
14 
15  d_myId = c->register_sender("vrpn File Controller");
16 
18  c->register_message_type("vrpn_File set_replay_rate");
19  d_reset_type = c->register_message_type("vrpn_File reset");
20  d_play_to_time_type = c->register_message_type("vrpn_File play_to_time");
21 }
22 
24 
26 {
27  struct timeval now;
28 
29  char buf[sizeof(vrpn_float32)];
30 
31  vrpn_int32 bufLen = sizeof(vrpn_float32);
32  char *bufPtr = buf;
33 
34  if (vrpn_buffer(&bufPtr, &bufLen, rate)) {
35  return;
36  }
37  vrpn_gettimeofday(&now, NULL);
39  sizeof(vrpn_float32), now, d_set_replay_rate_type, d_myId, buf,
40  vrpn_CONNECTION_RELIABLE); // | vrpn_CONNECTION_LOCAL_ONLY
41 };
42 
44 {
45  struct timeval now;
46 
47  vrpn_gettimeofday(&now, NULL);
49  0, now, d_reset_type, d_myId, NULL,
50  vrpn_CONNECTION_RELIABLE); // | vrpn_CONNECTION_LOCAL_ONLY
51 };
52 
53 void vrpn_File_Controller::play_to_time(struct timeval t)
54 {
55  struct timeval now;
56 
57  vrpn_gettimeofday(&now, NULL);
59  sizeof(struct timeval), now, d_play_to_time_type, d_myId,
60  (const char *)&t,
61  vrpn_CONNECTION_RELIABLE); // | vrpn_CONNECTION_LOCAL_ONLY
62 };
const vrpn_uint32 vrpn_CONNECTION_RELIABLE
Classes of service for messages, specify multiple by ORing them together Priority of satisfying these...
virtual vrpn_int32 register_sender(const char *name)
Get a token to use for the string name of the sender or type. Remember to check for -1 meaning failur...
vrpn_File_Controller(vrpn_Connection *)
Generic connection class not specific to the transport mechanism.
vrpn_Connection * d_connection
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...
void play_to_time(struct timeval t)
void set_replay_rate(vrpn_float32=1.0)
#define vrpn_gettimeofday
Definition: vrpn_Shared.h:89
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.
Definition: vrpn_Shared.C:241
virtual vrpn_int32 register_message_type(const char *name)