8#ifndef VRPN_CLIENT_ONLY
44 printf(
"Analog Report: ");
72 const struct timeval time)
75 vrpn_int32 change = 0;
84 fprintf(stderr,
"No change.\n");
95 const struct timeval time)
99 char *msgbuf = (
char *)fbuf;
118 msgbuf, class_of_service)) {
119 fprintf(stderr,
"vrpn_Analog: cannot write message: tossing\n");
123#ifndef VRPN_CLIENT_ONLY
125 const char *port,
int baud,
int bits,
137 fprintf(stderr,
"vrpn_Serial_Analog: NULL port name\n");
149 fprintf(stderr,
"vrpn_Serial_Analog: Cannot Open serial port\n");
169 vrpn_int32 numChannels)
176 fprintf(stderr,
"vrpn_Analog_Server: Can't get connection!\n");
182 const struct timeval time)
189 const struct timeval time)
196 if (sizeRequested < 0) sizeRequested = 0;
204 vrpn_int32 numChannels)
225 double lowzero,
double highzero,
231 "vrpn_Clipping_Analog_Server::setClipValues: Bad channel (%d)\n",
235 if ((lowzero <
min) || (highzero < lowzero) || (max < highzero)) {
236 fprintf(stderr,
"vrpn_Clipping_Analog_Server::setClipValues: Out of "
257 "vrpn_Clipping_Analog_Server::setChannelValue: Bad channel (%d)\n",
309 fprintf(stderr,
"vrpn_Analog_Remote: can't register handler\n");
314 fprintf(stderr,
"vrpn_Analog_Remote: Can't get connection!\n");
338 const char *bufptr = p.
buffer;
339 vrpn_float64 numchannelD;
vrpn_Callback_List< vrpn_ANALOGCB > d_callback_list
static int VRPN_CALLBACK handle_change_message(void *userdata, vrpn_HANDLERPARAM p)
vrpn_Analog_Remote(const char *name, vrpn_Connection *c=NULL)
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Makes public the protected base class function.
vrpn_Analog_Server(const char *name, vrpn_Connection *c, vrpn_int32 numChannels=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.
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 ...
vrpn_int32 getNumChannels(void) const
vrpn_float64 last[vrpn_CHANNEL_MAX]
vrpn_float64 channel[vrpn_CHANNEL_MAX]
virtual int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
virtual vrpn_int32 encode_to(char *buf)
vrpn_Analog(const char *name, vrpn_Connection *c=NULL)
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report whether something has changed or not (for servers) Optionally, tell what time to stamp ...
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report only if something has changed (for servers) Optionally, tell what time to stamp the val...
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.
vrpn_Connection * d_connection
Connection that this object talks to.
void client_mainloop(void)
Handles functions that all clients should provide in their mainloop() (warning of no server,...
vrpn_int32 d_sender_id
Sender ID registered with the connection.
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...
virtual int init(void)
Initialize things that the constructor can't. Returns 0 on success, -1 on failure.
void call_handlers(const CALLBACK_STRUCT &info)
This will pass the referenced parameter as a const to all the callbacks.
clipvals_struct clipvals[vrpn_CHANNEL_MAX]
int setChannelValue(int channel, double value)
This method should be used to set the value of a channel. It will be scaled and clipped as described ...
int setClipValues(int channel, double min, double lowzero, double highzero, double max)
Set the clipping values for the specified channel. min maps to -1, values between lowzero and highzer...
vrpn_Clipping_Analog_Server(const char *name, vrpn_Connection *c, vrpn_int32 numChannels=vrpn_CHANNEL_MAX)
Generic connection class not specific to the transport mechanism.
virtual vrpn_int32 register_message_type(const char *name)
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...
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...
unsigned char buffer[1024]
vrpn_Serial_Analog(const char *name, vrpn_Connection *connection, const char *port, int baud=9600, int bits=8, vrpn_SER_PARITY parity=vrpn_SER_PARITY_NONE, bool rts_flow=false)
vrpn_float64 channel[vrpn_CHANNEL_MAX]
This structure is what is passed to a vrpn_Connection message callback.
const int vrpn_ANALOG_FAIL
const struct timeval vrpn_ANALOG_NOW
const int vrpn_ANALOG_RESETTING
int vrpn_close_commport(int comm)
int vrpn_open_commport(const char *portname, long baud, int charsize, vrpn_SER_PARITY parity, bool rts_flow)
Open a serial port, given its name and baud rate.
vrpn_Serial: Pulls all the serial port routines into one file to make porting to new operating system...
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_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.
void vrpn_strcpy(char(&to)[charCount], const char *pSrc)
Null-terminated-string copy function that both guarantees not to overrun the buffer and guarantees th...
#define vrpn_gettimeofday