#ifndef VRPN_RADAMEC_SPI_H
#define VRPN_RADAMEC_SPI_H
#include "vrpn_Connection.h"
#include "vrpn_Analog.h"
class vrpn_Radamec_SPI: public vrpn_Serial_Analog
{
public:
vrpn_Radamec_SPI (const char * name, vrpn_Connection * c,
const char * port, int baud = 38400);
~vrpn_Radamec_SPI () {};
virtual void mainloop ();
protected:
int _status; //< Reset, Syncing, or Reading
int _camera_id; //< What is our camera ID, queried from device
int _numchannels; //< How many analog channels to open
int _expected_chars; //< How many characters to expect in the report
unsigned char _buffer[512]; //< Buffer of characters in report
int _bufcount; //< How many characters we have so far
struct timeval timestamp; //< Time of the last report from the device
virtual int reset(void); //< Set device back to starting config
virtual int get_report(void); //< Try to read a report from the device
virtual void clear_values(void); //< Clears all channels to 0
unsigned char compute_crc(const unsigned char *head, int len);
vrpn_uint32 convert_24bit_unsigned(const unsigned char *buf);
vrpn_int32 convert_16bit_unsigned(const unsigned char *buf);
double int_to_pan(vrpn_uint32 val); //< Returns pan in degrees
double int_to_tilt(vrpn_uint32 val) //< Returns tilt in degrees
{ return int_to_pan(val); };
double int_to_zoom(vrpn_uint32 val); //< Returns zoom in meters
double int_to_focus(vrpn_uint32 val); //< Returns focal length in meters
double int_to_height(vrpn_uint32 val); //< Returns height in meters
double int_to_X(vrpn_uint32 mm, vrpn_uint32 frac); //< Returns X location in meters
double int_to_Y(vrpn_uint32 mm, vrpn_uint32 frac) //< Returns Y location in meters
{ return int_to_X(mm, frac); };
double int_to_orientation(vrpn_uint32 val); //< Returns orientation in degrees
int send_command(const unsigned char *cmd, int len);
virtual void report_changes
(vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
virtual void report
(vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
};
#endif