vrpn
07.35
Virtual Reality Peripheral Network
Toggle main menu visibility
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
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
9
vrpn_File_Controller::vrpn_File_Controller
(
vrpn_Connection
*c)
10
:
d_connection
(c)
11
{
12
13
if
(!c)
return
;
14
15
d_myId
= c->
register_sender
(
"vrpn File Controller"
);
16
17
d_set_replay_rate_type
=
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
23
vrpn_File_Controller::~vrpn_File_Controller
(
void
) {}
24
25
void
vrpn_File_Controller::set_replay_rate
(vrpn_float32 rate)
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
43
void
vrpn_File_Controller::reset
(
void
)
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
53
void
vrpn_File_Controller::play_to_time
(
struct
timeval t)
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
};
vrpn_Connection::register_message_type
virtual vrpn_int32 register_message_type(const char *name)
Definition
vrpn_Connection.C:5199
vrpn_Connection::register_sender
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...
Definition
vrpn_Connection.C:5158
vrpn_File_Controller::d_set_replay_rate_type
vrpn_int32 d_set_replay_rate_type
Definition
vrpn_FileController.h:41
vrpn_File_Controller::set_replay_rate
void set_replay_rate(vrpn_float32=1.0)
Definition
vrpn_FileController.C:25
vrpn_File_Controller::d_play_to_time_type
vrpn_int32 d_play_to_time_type
Definition
vrpn_FileController.h:43
vrpn_File_Controller::vrpn_File_Controller
vrpn_File_Controller(vrpn_Connection *)
Definition
vrpn_FileController.C:9
vrpn_File_Controller::~vrpn_File_Controller
~vrpn_File_Controller(void)
Definition
vrpn_FileController.C:23
vrpn_File_Controller::d_connection
vrpn_Connection * d_connection
Definition
vrpn_FileController.h:37
vrpn_File_Controller::play_to_time
void play_to_time(struct timeval t)
Definition
vrpn_FileController.C:53
vrpn_File_Controller::reset
void reset(void)
Definition
vrpn_FileController.C:43
vrpn_File_Controller::d_myId
vrpn_int32 d_myId
Definition
vrpn_FileController.h:39
vrpn_File_Controller::d_reset_type
vrpn_int32 d_reset_type
Definition
vrpn_FileController.h:42
vrpn_Connection.h
vrpn_CONNECTION_RELIABLE
const vrpn_uint32 vrpn_CONNECTION_RELIABLE
Classes of service for messages, specify multiple by ORing them together Priority of satisfying these...
Definition
vrpn_Connection.h:118
vrpn_FileController.h
vrpn_Connection
class VRPN_API vrpn_Connection
Definition
vrpn_FileController.h:6
vrpn_buffer
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:250
vrpn_Shared.h
vrpn_gettimeofday
#define vrpn_gettimeofday
Definition
vrpn_Shared.h:99
vrpn_FileController.C
Generated by
1.17.0