00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __GLOVE_DEVICES_LOCAL_LOCALCYBERGLOVE_HPP_
00028 #define __GLOVE_DEVICES_LOCAL_LOCALCYBERGLOVE_HPP_
00029
00030 #include "../../config.hpp"
00031
00032 #include <string>
00033 #include <bitset>
00034
00035 #include <boost/interprocess/sync/interprocess_mutex.hpp>
00036 #include <boost/interprocess/sync/interprocess_semaphore.hpp>
00037 #include <boost/smart_ptr.hpp>
00038
00039 #include "../impl/CGIU.hpp"
00040 #include "../CyberGlove.hpp"
00041 #include "LocalDevice.hpp"
00042
00043 using namespace glove::devices::impl;
00044
00045 namespace glove {
00046 namespace devices {
00047 namespace local {
00048
00049 class LocalDeviceManager;
00050
00057 class API LocalCyberGlove: public CyberGlove, public LocalDevice {
00058 CGIU dev;
00059 std::string port;
00060
00061 boost::scoped_ptr<bool> isRightHanded_;
00062 int numSensors_;
00063 std::string info_;
00064 std::pair<int, int> version_;
00065 boost::scoped_ptr<std::bitset<24> > sensorMask_;
00066
00067 boost::interprocess::interprocess_semaphore mutex;
00068 std::vector<boost::uint8_t> latestSensorValues;
00069 void streamHandler(const std::vector<boost::uint8_t>& v);
00070
00071 public:
00072 friend class LocalDeviceManager;
00073
00079 LocalCyberGlove(const std::string& port);
00083 virtual ~LocalCyberGlove();
00084
00089 virtual bool connect();
00094 virtual bool disconnect();
00098 virtual bool isConnected();
00099
00107 virtual unsigned int numSensors();
00115 virtual bool isRightHanded();
00123 virtual bool isLeftHanded();
00124
00134 virtual void enableSwitch(const bool b = true);
00143 virtual bool isSwitchEnabled();
00144
00153 virtual void requestGloveStatus(const bool b = true);
00162 virtual bool gloveStatusRequested();
00163
00171 virtual const std::bitset<24> getEnabledSensors();
00208 virtual void setSensorMask(std::bitset<24> mask);
00209
00218 virtual void streamSensorValues(bool b);
00223 virtual bool isStreaming();
00224
00233 virtual double getValue(const Sensor s);
00241 virtual const std::vector<double> getValues();
00242
00249 virtual void cancel();
00256 virtual void restart();
00263 virtual void reinitialize();
00264
00272 virtual std::string info();
00280 virtual std::pair<int, int> version();
00281
00289 virtual bool runTest(const bool fullTest = false, std::ostream* s = NULL);
00293 virtual const std::string& getTypeIdentifier() const;
00301 virtual std::string toString();
00302
00303 };
00304
00305 }
00306 }
00307 }
00308
00309 #endif