00001
00002
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
00022
00023
00024
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
00032 void Update();
00033
00034
00035 void Sleep();
00036
00037
00038 void CRTVoltageTest(double* voltage_p, double* scanrate_p);
00039 void setCRTsync(sync_enum sync_mode);
00040
00041 private:
00042 enum {BIRD_BUF_SIZE = 1024};
00043 char bird_buffer[BIRD_BUF_SIZE];
00044 int is_master;
00045 int first_update;
00046 return_values_enum return_values;
00047 char port_name[80];
00048
00049
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