vrpn 07.35
Virtual Reality Peripheral Network
 
Loading...
Searching...
No Matches
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
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);
38 d_connection->pack_message(
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);
48 d_connection->pack_message(
49 0, now, d_reset_type, d_myId, NULL,
50 vrpn_CONNECTION_RELIABLE); // | vrpn_CONNECTION_LOCAL_ONLY
51};
52
54{
55 struct timeval now;
56
57 vrpn_gettimeofday(&now, NULL);
58 d_connection->pack_message(
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};
virtual vrpn_int32 register_message_type(const char *name)
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...
void set_replay_rate(vrpn_float32=1.0)
vrpn_File_Controller(vrpn_Connection *)
vrpn_Connection * d_connection
void play_to_time(struct timeval t)
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_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
Definition vrpn_Shared.h:99