Projet S5 Info / Mbed 2 deprecated Projet_S5

Dependencies:   mbed PowerControl

Fork of Projet_S5 by Jonathan Tousignant

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers analyzer.h Source File

analyzer.h

Go to the documentation of this file.
00001 /*!
00002  *  \file analyzer.h
00003  *  \brief Class that analyzes the mouvement in C and C++
00004  *  \author Equipe P02
00005  *  \version 0.1
00006  *  \date 02/04/2014
00007  */
00008 
00009 #ifndef ANALYZER_H
00010 #define ANALIZER_H
00011 
00012 #include <mbed.h>
00013 #include <climits>
00014 #include <map>
00015 #include "mouvement.h"
00016 
00017 using namespace std;
00018 
00019 /*!
00020  *  \def SEUIL_DETECTION
00021  *  \brief It's the limit for the detection
00022  */
00023 #define SEUIL_DETECTION 15
00024 
00025 /*! 
00026  *  \class Analyzer analyzer.h "analyzer.h"
00027  *  \brief Class that analyzes the mouvement
00028  *
00029  *  Class in C++ that analyzes data of acceloremeter and find
00030  *  the mouvement
00031  */
00032 class Analyzer
00033 {
00034 public:
00035     
00036     /*!
00037      *  \brief Constructor
00038      */
00039     Analyzer();
00040     
00041     /*!
00042      *  \brief Destructor
00043      */
00044     ~Analyzer();
00045     
00046     /*!
00047      *  \brief Initialize analyzer
00048      */
00049     void initialize();
00050     
00051     /*!
00052      *  \brief Set the minimum and maximum for each axe
00053      *  \param values Values to compare with the min and max
00054      */
00055     void setMinMax(signed char* values);
00056     
00057     /*!
00058      *  \brief Set the initial value for each axe
00059      *  \param value The initial value
00060      */
00061     void setInitial(signed char* value);
00062     
00063     /*!
00064      *  \brief Analyze the mouvement with initial, min and max of each axes
00065      *
00066      *  Create value in hexadecimal and find this value in the map
00067      */
00068     void checkMouvement();
00069     
00070     void setHand(bool l) { hand = l; }
00071     
00072 private:
00073 
00074     /*! 
00075      *  \class Data analyzer.h "analyzer.h"
00076      *  \brief Struct that contains data useful for the analysis
00077      *
00078      *  Struct in C++ that contains minimum, maximum, initial value and orientation
00079      */
00080     struct Data
00081     {
00082         signed char min; /*!< Minimum value of the mouvement */
00083         signed char max; /*!< Maximum value of the mouvement */
00084         signed char initial; /*!< Initial value of the mouvement */
00085         bool sens; /*!< Orientation of the mouvement true =  acceleration, false = deceleration */
00086         
00087         /*!
00088          *  \brief Constructor
00089          */
00090         Data(): min(SCHAR_MAX), max(SCHAR_MIN){}
00091         
00092         /*!
00093          *  \brief Set the minimum and maximum
00094          *  \param value Value to compare with the min and max
00095          */
00096         void setMinMax(signed char value)
00097         {
00098             if (value < min)
00099             {
00100                 min = value;
00101                 sens = true;
00102             }
00103                 
00104             if (value > max)
00105             {
00106                 max = value;
00107                 sens = false;
00108             }
00109         }
00110         
00111         /*!
00112          *  \brief Set the initial value
00113          *  \param value The initial value for initial, min and max
00114          */
00115         void setInitial(signed char init)
00116         {
00117             initial = init;
00118             min = initial;
00119             max = initial;
00120         }
00121 
00122         /*!
00123          *  \brief Determine is there a mouvement
00124          *  \return true if detect mouvement, false if not detect mouvement
00125          */
00126         bool isMouvement()
00127         {
00128             if(sens)
00129                 return (max-initial >= SEUIL_DETECTION);
00130             
00131             else
00132                 return (initial-min >= SEUIL_DETECTION);
00133         }
00134     };
00135     
00136     Data x; /*!< Data for the axe x */
00137     Data y; /*!< Data for the axe y */
00138     Data z; /*!< Data for the axe z */
00139     bool hand; /*!< Char to determine the hand true = left, false = right*/
00140     
00141     map<int, Mouvement*> allMouvement; /*!< map that containts all movement */
00142     Trame *trame; /*!< Object Trame for send information */
00143 };
00144  
00145 // Define function in C for interruption
00146 // The C function call C++ function
00147 #ifdef __cplusplus
00148 extern "C" {
00149 #endif
00150  
00151 extern void *Analyzer_C_new(); /*! Call Constructor \see Analyzer() */
00152 extern void Analyzer_C_delete (void *analyzer); /*! Call Constructor \see ~Analyzer() */
00153 extern void Analyzer_C_Initialize (void *analyzer); /*! Call Initialize \see initialize() */
00154 extern void Analyzer_C_setMinMax (signed char* values, void *analyzer); /*! Call setMinMax \see setMinMax(signed char*) */
00155 extern void Analyzer_C_setInitial (signed char* value, void *analyzer); /*! Call setInitial \see setInitial(signed char*) */
00156 extern void Analyzer_C_checkMouvement (void *analyzer); /*! Call checkMouvement \see checkMouvement() */
00157 extern void Analyzer_C_setHand (bool h, void *analyzer); /*! Call setHand \see setHand(bool left) */
00158  
00159 #ifdef __cplusplus
00160 }
00161 #endif
00162  
00163 #endif