00001 00065 #ifndef _SERIAL_GLOVE_HPP_ 00066 #define _SERIAL_GLOVE_HPP_ 00067 00068 #include <cereal_port/CerealPort.h> 00069 #include <boost/smart_ptr.hpp> 00070 00071 #include <boost/function.hpp> 00072 00073 namespace cyberglove_freq 00074 { 00079 struct CybergloveFreq 00080 { 00085 static const std::string fastest; 00086 static const std::string hundred_hz; 00087 static const std::string fourtyfive_hz; 00088 static const std::string ten_hz; 00089 static const std::string one_hz; 00090 }; 00091 } 00092 00093 namespace cyberglove 00094 { 00099 class CybergloveSerial 00100 { 00101 public: 00109 CybergloveSerial(std::string serial_port, boost::function<void(std::vector<float>, bool)> callback); 00110 ~CybergloveSerial(); 00111 00121 int set_filtering(bool value); 00122 00132 int set_transmit_info(bool value); 00133 00141 int set_frequency(std::string frequency); 00142 00149 int start_stream(); 00150 00156 int get_nb_msgs_received(); 00157 00161 static const unsigned short glove_size; 00162 00163 private: 00168 boost::shared_ptr<cereal::CerealPort> cereal_port; 00169 00180 void stream_callback(char* world, int length); 00181 00182 int nb_msgs_received, glove_pos_index; 00184 std::vector<float> glove_positions; 00185 00186 int current_value; 00187 00192 boost::function<void(std::vector<float>, bool)> callback_function; 00193 00194 bool light_on, button_on; 00195 00197 bool no_errors; 00198 }; 00199 } 00200 00201 /* For the emacs weenies in the crowd. 00202 Local Variables: 00203 c-basic-offset: 2 00204 End: 00205 */ 00206 00207 #endif