/Users/craigcornelius/Projects/SPRING Mac Release 0.2/bird.h

Go to the documentation of this file.
00001 // $Id: bird.h,v 1.15 2001/10/17 16:49:34 kevin Exp $
00002 // $Copyright: (c)2001 National Biocomputation Center, Stanford University $
00003 
00004 #ifndef Bird_Header
00005 #define Bird_Header
00006 
00007 
00008 #include "point3d.h"
00009 #include "sensor.h"
00010 #include "serialdevice.h"
00011 #include <sys/timeb.h>
00012 
00013 class Bird : public Sensor, public SerialDevice {
00014 public:
00015     enum sync_enum {NO_SYNC=0, SYNC_CRT_LOW=1, SYNC_CRT_HIGH=2, SYNC_HOST=3};
00016     enum button_enum {DOWN=1, PRESSED=2, UP=-1, RELEASED=-2};
00017     enum return_values_enum {POSITION=1,ANGLES=2,MATRIX=3,POSITION_ANGLES=4,
00018         POSITION_MATRIX=5};
00019     
00020 public:
00021     // note: valid baud rates are: 2400, 4800, 9600, 19200, 38400, 57600, 115200
00022     // - if master, set num_birds_if_master to num birds in flock, otherwise=0
00023     // - set has_transmitter if this port is connected to the master bird
00024     // - return_values_flag = POSITION | ANGLES if want pos and ang returned,etc
00025     Bird(char* port_name, int baud, int num_birds_if_master = 0, 
00026         return_values_enum return_values = POSITION_ANGLES);
00027     virtual ~Bird();
00028     static const char* rcsid;
00029     static int debug;
00030     
00031     // overloaded Sensor functions
00032     void Update();
00033     
00034     // other functions
00035     void Sleep();
00036     
00037     // CRT syncing routines
00038     void CRTVoltageTest(double* voltage_p, double* scanrate_p);
00039     void setCRTsync(sync_enum sync_mode);       // can do on the fly now
00040     
00041 private:
00042     enum {BIRD_BUF_SIZE = 1024};
00043     char bird_buffer[BIRD_BUF_SIZE];    // bird data buffer
00044     int is_master;      // whether this is the master bird
00045     int first_update;           // first time flag for update cycle
00046     return_values_enum return_values;   // values to process and return
00047     char port_name[80]; // keep it around just for debugging
00048     
00049     // internal function prototypes
00050     void bird_start_stream();
00051     void sync_bird_crt_low();
00052     void sync_bird_crt_high();
00053     void sync_bird_host();
00054     void bird_prompt();
00055     void turn_off_filters();
00056     void write_bird(unsigned char command);
00057     int get_mic_time();
00058     int get_mic_duration(int last);
00059     int decode_position(char* b_b);
00060     int decode_angles(char* b_b);
00061     int decode_matrix(char* b_b);
00062     int decode_button(char* b_b);
00063     int decode_pos_ang(char* b_b);
00064     int decode_pos_mat(char* b_b);
00065     void read_bird_point();
00066     char* read_bird_stream();
00067     button_enum bird_button_status();
00068     void initialize_flock(int num_birds_in_flock);
00069     int open_bird_port(char *port_name, int baud_rate);
00070     void angle_align(double x_rot, double y_rot, double z_rot);
00071 };
00072 
00073 #endif

Generated on Thu Aug 30 11:03:13 2007 for SPRING Mac by  doxygen 1.5.3