vrpn
07.33
Virtual Reality Peripheral Network
|
Go to the documentation of this file.
9 fprintf(stderr,
"Button_Server_Remote: button %i state %i\n", b.
button, b.
state);
15 const char *name = (
const char *)userdata;
17 fprintf(stderr,
"Analog:\n %5.2f", a.
channel[0]);
19 fprintf(stderr,
", %5.2f\n", a.
channel[i]);
28 fprintf(stderr,
"C++: vrpn_Android_Server instantiated\n");
30 this->initialize(num_analogs, analog_sizes, num_buttons);
33 void vrpn_Android_Server::initialize(vrpn_int32 num_analogs, vrpn_int32 * analog_sizes, vrpn_int32 num_buttons)
35 ANALOG_SERVER_NAME =
"Analog";
36 BUTTON_SERVER_NAME =
"Button0";
38 this->num_analogs = num_analogs;
39 this->analog_sizes = analog_sizes;
41 fprintf(stderr,
"vrpn_Android_Server: using port %i\n", port);
43 fprintf(stderr,
"vrpn_Android_Server: getting server connection...\n");
45 fprintf(stderr, (connection == 0) ?
"vrpn_Android_Server: Failed to get connection\n" :
"vrpn_Android_Server: Got connection\n");
50 for (
int i = 0; i < num_analogs; i++)
52 std::stringstream name;
53 name << ANALOG_SERVER_NAME << i;
54 analog_server[i] =
new vrpn_Analog_Server(name.str().c_str(), connection, analog_sizes[i]);
56 fprintf(stderr,
"vrpn_Android_Server: instantiated analog server %i\n", i);
61 fprintf(stderr,
"vrpn_Android_Server: instantiated button server\n");
66 for (
int i = 0; i < num_analogs; i++)
68 std::stringstream name;
69 name << ANALOG_SERVER_NAME << i;
79 fprintf(stderr,
"C++: vrpn_Android_Server initialized\n");
84 for (vrpn_int32 i = 0; i < num_analogs; i++)
101 vrpn_float64 * channels = analog_server[analog_id]->
channels();
102 channels[channel] = val;
107 analog_server[analog_id]->
report();
112 for (vrpn_int32 i = 0; i < num_analogs; i++)
114 delete analog_server[i];
115 delete analog_client[i];
117 delete button_server;
118 delete button_client;
120 fprintf(stderr,
"C++: vrpn_Android_Server destroyed\n");
vrpn_int32 setNumChannels(vrpn_int32 sizeRequested)
Sets the size of the array; returns the size actually set. (May be clamped to vrpn_CHANNEL_MAX) This ...
void VRPN_CALLBACK handle_analog(void *userdata, const vrpn_ANALOGCB a)
void VRPN_CALLBACK button_press(void *, const vrpn_BUTTONCB b)
void report_analog_chg(vrpn_int32 analog_id)
Called when changes are made to any of the analog values.
~vrpn_Android_Server()
Destructor.
vrpn_float64 channel[vrpn_CHANNEL_MAX]
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Makes public the protected base class function.
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
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 set_analog(vrpn_int32 analog_id, vrpn_int32 channel, vrpn_float64 val)
Set the value for the given channel of the given vrpn_Analog_Server.
vrpn_Android_Server(vrpn_int32 num_analogs, vrpn_int32 *analog_sizes, vrpn_int32 num_buttons, vrpn_int32 port)
Constructor. Takes an array of integers representing the number of channels for each analog server,...
void set_button(vrpn_int32 button_id, vrpn_int32 state)
Set the value for the given button.
vrpn_float64 * channels(void)
Exposes an array of values for the user to write into.
class VRPN_API vrpn_Button_Server
virtual void mainloop()
For this server, the user must normally call report() or report_changes() directly....
virtual int register_change_handler(void *userdata, vrpn_ANALOGCHANGEHANDLER handler)
void mainloop()
Main loop to be called at every time step. Calls the mainloop() functions of the member servers.
vrpn_Connection * vrpn_create_server_connection(const char *cname, const char *local_in_logfile_name, const char *local_out_logfile_name)
Create a server connection of arbitrary type (VRPN UDP/TCP, TCP, File, Loopback, MPI).