00001 // Copyright (C) 2003, 2004, 2005 Pablo Mejia 00002 // Copyright (C) 2004 Joshua Bridevaux 00003 00004 00005 #ifndef CAJUN_COMPASS_H 00006 #define CAJUN_COMPASS_H 00007 00008 00009 #include <vector> 00010 00011 00012 namespace cajun 00013 { 00014 class input_buffer_t; 00015 00016 class compass_t 00017 { 00018 public: 00019 compass_t (unsigned instance_); 00020 ~compass_t (); 00021 00022 void handle_input (int fd); 00023 00024 class observer_t 00025 { 00026 public: 00027 enum compass_honyewell_message_t 00028 { 00029 STATUS_FULL_BUFFER, 00030 STATUS_GARBAGE_DATA 00031 }; 00032 00033 virtual ~observer_t () {} 00034 00035 virtual void publish_status (double tstamp, 00036 unsigned status) {} 00037 virtual void heading (double tstamp, double heading) {} 00038 virtual void motion (double tstamp, double roll, 00039 double pitch, double heading) {} 00040 }; 00041 00042 void register_observer (observer_t *observer) 00043 { m_observer = observer; } 00044 00045 protected: 00046 input_buffer_t *m_ib; 00047 00048 observer_t *m_observer; 00049 00050 double m_tstamp; 00051 00052 struct token_t 00053 { 00054 unsigned char const *beg; 00055 unsigned len; 00056 }; 00057 std::vector<token_t> m_token; 00058 00059 void decode (unsigned char const *beg, 00060 unsigned char const *end); 00061 00062 void decode_hpr (); 00063 }; 00064 }; 00065 00066 00067 #endif