1#ifndef VRPN_FUNCTIONGENERATOR_H
2#define VRPN_FUNCTIONGENERATOR_H
46 vrpn_float32 startTime, vrpn_float32 sampleRate,
55 virtual vrpn_int32
encode_to(
char** buf, vrpn_int32& len )
const = 0;
63 virtual vrpn_int32
decode_from(
const char** buf, vrpn_int32& len ) = 0;
90 vrpn_float32 generateValues( vrpn_float32* buf, vrpn_uint32 nValues,
91 vrpn_float32 startTime, vrpn_float32 sampleRate,
94 vrpn_int32 encode_to(
char** buf, vrpn_int32& len )
const;
95 vrpn_int32 decode_from(
const char** buf, vrpn_int32& len );
112 virtual vrpn_float32
generateValues( vrpn_float32* buf, vrpn_uint32 nValues,
113 vrpn_float32 startTime, vrpn_float32 sampleRate,
116 vrpn_int32
encode_to(
char** buf, vrpn_int32& len )
const;
117 vrpn_int32
decode_from(
const char** buf, vrpn_int32& len );
127 vrpn_bool setScript(
char* script );
149 vrpn_int32 encode_to(
char** buf, vrpn_int32& len )
const;
150 vrpn_int32 decode_from(
const char** buf, vrpn_int32& len );
258 vrpn_int32
decode_channel(
const char* buf,
const vrpn_int32 len, vrpn_uint32& channelNum,
264 vrpn_int32
encode_start_reply(
char** buf, vrpn_int32& len,
const vrpn_bool isStarted );
265 vrpn_int32
encode_stop_reply(
char** buf, vrpn_int32& len,
const vrpn_bool isStopped );
279typedef struct _vrpn_FUNCTION_CHANNEL_REPLY_CB
291typedef struct _vrpn_FUNCTION_START_REPLY_CB
302typedef struct _vrpn_FUNCTION_STOP_REPLY_CB
313typedef struct _vrpn_FUNCTION_SAMPLE_RATE_REPLY_CB
325typedef struct _vrpn_FUNCTION_INTERPRETER_REPLY_CB
337typedef struct _vrpn_FUNCTION_ERROR_CB
354 int requestChannel(
const vrpn_uint32 channelNum );
355 int requestAllChannels( );
358 int requestSampleRate(
const vrpn_float32 rate );
359 int requestInterpreterDescription( );
361 virtual void mainloop( );
364 virtual int register_channel_reply_handler(
void *userdata,
366 virtual int unregister_channel_reply_handler(
void *userdata,
370 virtual int register_start_reply_handler(
void *userdata,
372 virtual int unregister_start_reply_handler(
void *userdata,
376 virtual int register_stop_reply_handler(
void *userdata,
378 virtual int unregister_stop_reply_handler(
void *userdata,
382 virtual int register_sample_rate_reply_handler(
void *userdata,
384 virtual int unregister_sample_rate_reply_handler(
void *userdata,
388 virtual int register_interpreter_reply_handler(
void *userdata,
390 virtual int unregister_interpreter_reply_handler(
void *userdata,
393 virtual int register_error_handler(
void* userdata,
395 virtual int unregister_error_handler(
void* userdata,
414 vrpn_int32
decode_channel_reply(
const char* buf,
const vrpn_int32 len, vrpn_uint32& channelNum );
415 vrpn_int32
decode_start_reply(
const char* buf,
const vrpn_int32 len, vrpn_bool& isStarted );
416 vrpn_int32
decode_stop_reply(
const char* buf,
const vrpn_int32 len, vrpn_bool& isStopped );
421 vrpn_int32
encode_channel(
char** buf, vrpn_int32& len,
const vrpn_uint32 channelNum,
vrpn_BaseClass(const char *name, vrpn_Connection *c=NULL)
Names the device and assigns or opens connection, calls registration methods.
Generic connection class not specific to the transport mechanism.
vrpn_int32 decode_channel_reply(const char *buf, const vrpn_int32 len, vrpn_uint32 &channelNum)
vrpn_FunctionGenerator_Remote(const char *name, vrpn_Connection *c=NULL)
vrpn_int32 encode_channel_request(char **buf, vrpn_int32 &len, const vrpn_uint32 channelNum)
vrpn_int32 decode_stop_reply(const char *buf, const vrpn_int32 len, vrpn_bool &isStopped)
vrpn_Callback_List< vrpn_FUNCTION_ERROR_CB > error_list
vrpn_int32 decode_start_reply(const char *buf, const vrpn_int32 len, vrpn_bool &isStarted)
vrpn_Callback_List< vrpn_FUNCTION_STOP_REPLY_CB > stop_reply_list
vrpn_int32 decode_error_reply(const char *buf, const vrpn_int32 len, FGError &error, vrpn_int32 &channel)
vrpn_Callback_List< vrpn_FUNCTION_START_REPLY_CB > start_reply_list
vrpn_Callback_List< vrpn_FUNCTION_CHANNEL_REPLY_CB > channel_reply_list
vrpn_Callback_List< vrpn_FUNCTION_INTERPRETER_REPLY_CB > interpreter_reply_list
virtual ~vrpn_FunctionGenerator_Remote()
vrpn_Callback_List< vrpn_FUNCTION_SAMPLE_RATE_REPLY_CB > sample_rate_reply_list
vrpn_int32 decode_sampleRate_reply(const char *buf, const vrpn_int32 len)
vrpn_int32 decode_interpreterDescription_reply(const char *buf, const vrpn_int32 len, char **desc)
vrpn_int32 encode_channel(char **buf, vrpn_int32 &len, const vrpn_uint32 channelNum, const vrpn_FunctionGenerator_channel *channel)
vrpn_int32 encode_sampleRate_request(char **buf, vrpn_int32 &len, const vrpn_float32 sampleRate)
virtual void setSampleRate(vrpn_float32 rate)=0
virtual const char * getInterpreterDescription()=0
int sendSampleRateReply()
vrpn_int32 decode_sampleRate_request(const char *buf, const vrpn_int32 len, vrpn_float32 &sampleRate)
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
int sendError(FGError error, vrpn_int32 channel)
vrpn_int32 decode_channel(const char *buf, const vrpn_int32 len, vrpn_uint32 &channelNum, vrpn_FunctionGenerator_channel &channel)
int sendStopReply(vrpn_bool stopped)
int sendInterpreterDescription()
static int VRPN_CALLBACK handle_allChannelRequest_message(void *userdata, vrpn_HANDLERPARAM p)
int sendChannelReply(vrpn_uint32 channelNum)
static int VRPN_CALLBACK handle_start_message(void *userdata, vrpn_HANDLERPARAM p)
vrpn_FunctionGenerator_Server(const char *name, vrpn_uint32 numChannels=vrpn_FUNCTION_CHANNELS_MAX, vrpn_Connection *c=NULL)
static int VRPN_CALLBACK handle_stop_message(void *userdata, vrpn_HANDLERPARAM p)
vrpn_int32 encode_stop_reply(char **buf, vrpn_int32 &len, const vrpn_bool isStopped)
vrpn_int32 encode_error_report(char **buf, vrpn_int32 &len, const FGError err, const vrpn_int32 channel)
int sendStartReply(vrpn_bool started)
vrpn_int32 encode_start_reply(char **buf, vrpn_int32 &len, const vrpn_bool isStarted)
vrpn_int32 encode_channel_reply(char **buf, vrpn_int32 &len, const vrpn_uint32 channelNum)
static int VRPN_CALLBACK handle_channel_message(void *userdata, vrpn_HANDLERPARAM p)
static int VRPN_CALLBACK handle_channelRequest_message(void *userdata, vrpn_HANDLERPARAM p)
vrpn_int32 encode_sampleRate_reply(char **buf, vrpn_int32 &len, const vrpn_float32 sampleRate)
static int VRPN_CALLBACK handle_sample_rate_message(void *userdata, vrpn_HANDLERPARAM p)
static int VRPN_CALLBACK handle_interpreter_request_message(void *userdata, vrpn_HANDLERPARAM p)
vrpn_uint32 setNumChannels(vrpn_uint32 numChannels)
vrpn_int32 decode_channel_request(const char *buf, const vrpn_int32 len, vrpn_uint32 &channelNum)
vrpn_int32 encode_interpreterDescription_reply(char **buf, vrpn_int32 &len, const char *desc)
virtual void setChannel(vrpn_uint32 channelNum, vrpn_FunctionGenerator_channel *channel)=0
const vrpn_FunctionGenerator_function * getFunction() const
vrpn_FunctionGenerator_channel()
vrpn_FunctionGenerator_function * function
vrpn_FunctionGenerator_function_NULL()
FunctionCode getFunctionCode() const
virtual ~vrpn_FunctionGenerator_function_NULL()
FunctionCode getFunctionCode() const
virtual vrpn_float32 generateValues(vrpn_float32 *buf, vrpn_uint32 nValues, vrpn_float32 startTime, vrpn_float32 sampleRate, vrpn_FunctionGenerator_channel *channel) const
vrpn_FunctionGenerator_function * clone() const
const char * getConstScript() const
vrpn_FunctionGenerator_function_script()
vrpn_int32 encode_to(char **buf, vrpn_int32 &len) const
vrpn_int32 decode_from(const char **buf, vrpn_int32 &len)
virtual vrpn_FunctionGenerator_function * clone() const =0
virtual vrpn_int32 encode_to(char **buf, vrpn_int32 &len) const =0
virtual vrpn_float32 generateValues(vrpn_float32 *buf, vrpn_uint32 nValues, vrpn_float32 startTime, vrpn_float32 sampleRate, vrpn_FunctionGenerator_channel *channel) const =0
virtual FunctionCode getFunctionCode() const =0
virtual vrpn_int32 decode_from(const char **buf, vrpn_int32 &len)=0
vrpn_int32 channelReplyMessageID
vrpn_float32 getSampleRate()
vrpn_int32 requestInterpreterMessageID
vrpn_int32 errorMessageID
@ INVALID_RESULT_QUANTITY
char msgbuf[vrpn_CONNECTION_TCP_BUFLEN]
vrpn_int32 stopFunctionMessageID
vrpn_int32 requestAllChannelsMessageID
vrpn_int32 interpreterReplyMessageID
vrpn_int32 requestChannelMessageID
vrpn_FunctionGenerator_channel * channels[vrpn_FUNCTION_CHANNELS_MAX]
vrpn_int32 startFunctionMessageID
vrpn_FunctionGenerator(const char *name, vrpn_Connection *c=NULL)
virtual int register_types()
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
vrpn_int32 sampleRateReplyMessageID
vrpn_int32 channelMessageID
vrpn_int32 startFunctionReplyMessageID
vrpn_int32 stopFunctionReplyMessageID
const vrpn_FunctionGenerator_channel * getChannel(vrpn_uint32 channelNum)
vrpn_int32 sampleRateMessageID
vrpn_uint32 getNumChannels() const
vrpn_int32 gotConnectionMessageID
vrpn_FunctionGenerator_channel * channel
vrpn_FunctionGenerator::FGError err
This structure is what is passed to a vrpn_Connection message callback.
All types of client/server/peer objects in VRPN should be derived from the vrpn_BaseClass type descri...
const int vrpn_CONNECTION_TCP_BUFLEN
const char * vrpn_FUNCTION_MESSAGE_TYPE_SAMPLE_RATE_REPLY
const char * vrpn_FUNCTION_MESSAGE_TYPE_CHANNEL_REPLY
const char * vrpn_FUNCTION_MESSAGE_TYPE_CHANNEL_REQUEST
const char * vrpn_FUNCTION_MESSAGE_TYPE_INTERPRETER_REQUEST
const char * vrpn_FUNCTION_MESSAGE_TYPE_ALL_CHANNEL_REQUEST
const char * vrpn_FUNCTION_MESSAGE_TYPE_SAMPLE_RATE
const char * vrpn_FUNCTION_MESSAGE_TYPE_CHANNEL
const char * vrpn_FUNCTION_MESSAGE_TYPE_ERROR
const char * vrpn_FUNCTION_MESSAGE_TYPE_INTERPRETER_REPLY
const char * vrpn_FUNCTION_MESSAGE_TYPE_START
const char * vrpn_FUNCTION_MESSAGE_TYPE_START_REPLY
const char * vrpn_FUNCTION_MESSAGE_TYPE_STOP_REPLY
const char * vrpn_FUNCTION_MESSAGE_TYPE_STOP
const vrpn_uint32 vrpn_FUNCTION_CHANNELS_MAX
void(VRPN_CALLBACK * vrpn_FUNCTION_CHANGE_REPLY_HANDLER)(void *userdata, const vrpn_FUNCTION_CHANNEL_REPLY_CB info)
void(VRPN_CALLBACK * vrpn_FUNCTION_INTERPRETER_REPLY_HANDLER)(void *userdata, const vrpn_FUNCTION_INTERPRETER_REPLY_CB info)
void(VRPN_CALLBACK * vrpn_FUNCTION_SAMPLE_RATE_REPLY_HANDLER)(void *userdata, const vrpn_FUNCTION_SAMPLE_RATE_REPLY_CB info)
class VRPN_API vrpn_FunctionGenerator_channel
void(VRPN_CALLBACK * vrpn_FUNCTION_ERROR_HANDLER)(void *userdata, const vrpn_FUNCTION_ERROR_CB info)
void(VRPN_CALLBACK * vrpn_FUNCTION_START_REPLY_HANDLER)(void *userdata, const vrpn_FUNCTION_START_REPLY_CB info)
void(VRPN_CALLBACK * vrpn_FUNCTION_STOP_REPLY_HANDLER)(void *userdata, const vrpn_FUNCTION_STOP_REPLY_CB info)