5DT Data Glove plugin 1.0

D:/SVN/Scol/trunk/plugins/glove5DT/src/GloveObject.h

00001 //###################################################################################
00002 //#                                                           Definition Of Class GloveObject                                                                     #
00003 //#                                                             Used To Handle a 5DT Glove                                                                          #
00004 //#                                                                       Author :                                                                            #
00005 //#                                                                   Aymeric SUTEAU                                                                                    #
00006 //#                                                                    LISA - ANGERS                                                                                    #
00007 //###################################################################################
00008 
00009 #ifndef GLOVE_OBJECT
00010 #define GLOVE_OBJECT
00011 
00012 // Include Standard Libraries
00013 #include <stdio.h>
00014 #include <string>
00015 #include <time.h>
00016 #ifdef WIN32
00017 #include <windows.h> // for Sleep
00018 #else
00019 #include <unistd.h>  // for usleep
00020 #endif
00021 
00022 // Include Glove Library
00023 #include "..\fglove\fglove.h"
00024 
00025 // Include Thread Library
00026 #include "..\lib\ou_thread.h"
00027 using namespace std;
00028 using namespace openutils;
00029 
00030 // Define constants
00031 #define GESTURE_WITHOUT_THUMB 0
00032 #define GESTURE_WITH_THUMB    1
00033 
00034 
00035 // Class Object
00036 class MyThread;
00037 class GloveObject : public Thread
00038 {
00039         // Public Methods and Variables
00040         public:
00041                 // Variables for Sensors Values
00042                 unsigned short *pValues;
00043                 unsigned short *pMax;
00044                 unsigned short *pMin;
00045 
00046     // Constructor / Destructor
00047                 GloveObject();
00048                 ~GloveObject();
00049 
00050                 // Getters
00051                 fdGlove * GetGlove();
00052                 char * GetPort();
00053                 bool IsShowRaw();
00054                 int GetGloveType();
00055                 char * GetType();
00056                 int GetGloveHand();
00057                 char * GetHand();
00058                 int GetNbrOfSensors();
00059                 int GetGestureIndex();              // Return gesture index between 0 and 15 (thumb not handled) 
00060     int GetGestureWithThumbIndex();     // Return gesture index between 0 and 31 (thumb handled)
00061     std::string GetSerialNumber();
00062     bool GetCalibrationDone();
00063     bool GetInitValuesDone();
00064     bool GetInitDone();
00065     int GetUSBIndex();
00066     int GetGestureMode();
00067 
00068                 // Setters
00069                 void SetGlove(fdGlove *);
00070                 void SetPort(char *);
00071                 void SetShowRaw(bool);
00072                 void SetGloveType(int);
00073                 void SetType(char *);
00074                 void SetGloveHand(int);
00075                 void SetHand(char *);
00076                 void SetNbrOfSensors(int);
00077                 void SetGestureIndex(int);
00078     void SetGestureWithThumbIndex(int);
00079     void SetSerialNumber(std::string);
00080     void SetCalibrationDone(bool);
00081     void SetInitValuesDone(bool);
00082     void SetInitDone(bool);
00083     void SetUSBIndex(int);
00084     void SetGestureMode(int);
00085 
00086                 // Init Glove on USB Port and Glove sensors values
00087                 bool Init(int);
00088     void InitValues();
00089 
00090                 // Close Glove
00091                 int Close();
00092 
00093                 // Calibrate Automatically (True) Or Manually (False) The Glove
00094                 void AutoCalibrate(bool);
00095 
00096                 // Set Callback
00097                 void SetCallback();
00098 
00099                 // Delete Callback
00100                 void DeleteCallback();
00101 
00102                 // Called by the Callback Function
00103                 void UpdateGlove();
00104 
00105     // Thread Handling
00106     void run();
00107     bool isRunning;
00108 
00109         // Private Attributes
00110         private:
00111                 fdGlove *pGlove;                          // Pointer to the Glove Object
00112                 char *szPort;                         // COM/USB port
00113                 bool bShowRaw;                      // Boolean to display either raw values or scaled ones
00114                 int iGloveType;                     // Type of glove (index)
00115                 char *szType;                         // Type of glove (string)
00116                 int iGloveHand;                     // Hand Type of glove (index)
00117                 char *szHand;                         // Hand Type of glove (string)
00118                 int iNbrOfSensors;                // Counter for the number of sensors
00119                 int iGestureIndex;                // Index of the current gesture (excluding the thumb)
00120     int iGestureTHIndex;          // Index of the current gesture (including the thumb)
00121     //char *szSerialNumber;   // Serial number of the data glove
00122     std::string szSerialNumber;
00123     bool bCalibrationDone;  // Boolean to indicate the status of the calibration
00124     bool bInitValuesDone;   // Boolean to indicate the status of init values procedure
00125     bool bInitDone;         // Boolean to indicate the status of open glove procedure
00126     int iUSBIndex;          // Index of the USB port on which the data glove is opened
00127     int iGestureMode;       // Gesture mode : with or without taking into account thumb
00128 };
00129 
00130 #endif