Tools.h File Reference

#include <string>
#include <sstream>
#include "Constant.h"
#include <math.h>

Include dependency graph for Tools.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

string itos (int i)
 Tool method to convert a int to a string.
string ltos (long l)
 Tool method to convert a long to a string.
string dtos (double d)
 Tool method to convert a double to a string.
double RadiansToDegres (double dRadians)
 Method to change an angle from radians to degres The equation used is

\[ AngleDegres = \frac{AngleRadians*180.0}{\pi} \]

.

double DegresToRadians (double dDegres)
 Method to change an angle from degres to radians The equation used is

\[ AngleRadians = \frac{AngleDegres*\pi}{180.0} \]

.

double BrasSinus (double dL, double dAngle)
 Method to convert an angle movement to a translation movement
The angle must be in radians !
The equation used is :

\[ x = L*sin(\alpha) \]

with :
$ x $ the translation movement value,
$ L $ the length of the sinus arm,
$ \alpha $ the angle movement value in radians.

double InverseBrasSinus (double dL, double dTranslation)
 Method to convert a translation movement to a angle movement
The angle computed is given in radians !
The equation used is :

\[ \alpha = arcsin(frac{x}{L}) \]

with :
$ x $ the translation movement value,
$ L $ the length of the sinus arm,
$ \alpha $ the angle movement value in radians

Exceptions:
This method throw a DivideByZeroException exception if the mirror angle is equal to zero
This method throw a TrigonometricValueOutOfBoundException exception if the value to compute the $ \arcsin $ is not in the range $ [-1;1] $.

double BrasTangente (double dL, double dAngle)
 Method to convert an angle movement to a translation movement
The angle must be in radians !
The equation used is :

\[ x = L*tan(\alpha) \]

with :
$ x $ the translation movement value,
$ L $ the length of the tangent arm,
$ \alpha $ the angle movement value in radians.

double InverseBrasTangente (double dL, double dTranslation)
 Method to convert a translation movement to a angle movement
The angle computed is given in radians !
The equation used is :

\[ \alpha = arctan(frac{x}{L}) \]

with :
$ x $ the translation movement value,
$ L $ the length of the tangent arm,
$ \alpha $ the angle movement value in radians

Exceptions:
This method throw a DivideByZeroException exception if the mirror angle is equal to zero
This method throw a TrigonometricValueOutOfBoundException exception if the value to compute the $ \arcsin $ is not in the range $ [-1;1] $.

std::string GetDeviceState (int iDeviceState)
template<class ObjectType>
void DESTRUCTION (ObjectType *&objectName)
 Method to make the destruction of a dynamic object.
template<class ObjectType>
ObjectType Maximum (ObjectType &obj1, ObjectType &obj2)
 Return the maximum object of obj1 and obj2.
template<class ObjectType>
ObjectType Minimum (ObjectType &obj1, ObjectType &obj2)
 Return the minimum object of obj1 and obj2.
template<class ObjectType>
bool isGreaterThan (ObjectType &obj1, ObjectType &obj2)
 Return true if the obj1 is greater than the obj2.
template<class ObjectType>
bool isStrictlyGreaterThan (ObjectType &obj1, ObjectType &obj2)
 Return true if the obj1 is stricktly greater than the obj2.
template<class ObjectType>
bool isLessThan (ObjectType &obj1, ObjectType &obj2)
 Return true if the obj1 is less than the obj2.
template<class ObjectType>
bool isStrictlyLessThan (ObjectType &obj1, ObjectType &obj2)
 Return true if the obj1 is stricktly less than the obj2.
template<class ObjectType>
bool areEquals (ObjectType &obj1, ObjectType &obj2)
 Return true if the obj1 is equal to obj2.


Function Documentation

template<class ObjectType>
bool areEquals ObjectType &  obj1,
ObjectType &  obj2
 

Return true if the obj1 is equal to obj2.

Definition at line 108 of file Tools.h.

00109 {
00110         return obj1 == obj2;
00111 }

double BrasSinus double  dL,
double  dAngle
 

Method to convert an angle movement to a translation movement
The angle must be in radians !
The equation used is :

\[ x = L*sin(\alpha) \]

with :
$ x $ the translation movement value,
$ L $ the length of the sinus arm,
$ \alpha $ the angle movement value in radians.

Definition at line 100 of file Tools.cpp.

00101 {
00102         return dL*sin(dAngle);
00103 }

double BrasTangente double  dL,
double  dAngle
 

Method to convert an angle movement to a translation movement
The angle must be in radians !
The equation used is :

\[ x = L*tan(\alpha) \]

with :
$ x $ the translation movement value,
$ L $ the length of the tangent arm,
$ \alpha $ the angle movement value in radians.

Definition at line 132 of file Tools.cpp.

00133 {
00134         return dL*tan(dAngle);
00135 }

double DegresToRadians double  dDegres  ) 
 

Method to change an angle from degres to radians The equation used is

\[ AngleRadians = \frac{AngleDegres*\pi}{180.0} \]

.

Definition at line 89 of file Tools.cpp.

References MATH_CONSTANT::PI.

00090 {
00091         return dDegres * MATH_CONSTANT::PI / 180.0;
00092 }

template<class ObjectType>
void DESTRUCTION ObjectType *&  objectName  ) 
 

Method to make the destruction of a dynamic object.

Definition at line 54 of file Tools.h.

00055 {
00056         if(objectName)  
00057         {
00058                 delete objectName;
00059                 objectName = 0;
00060         }
00061 }

string dtos double  d  ) 
 

Tool method to convert a double to a string.

Definition at line 75 of file Tools.cpp.

References XString< T >::convertToString().

Referenced by ValueOutOfBoundException::makeDescription(), TrigonometricValueOutOfBoundException::makeDescription(), SquareRootException::makeDescription(), and IllegalArgumentException::makeDescription().

00076 {
00077         return XString<double>::convertToString(d);
00078 }

Here is the call graph for this function:

std::string GetDeviceState int  iDeviceState  ) 
 

Definition at line 8 of file Tools.cpp.

00009 {
00010 
00011         switch (iDeviceState)
00012         {
00013         case 0:
00014                 return "ON";
00015                 break;
00016         case 1:
00017                 return "OFF";
00018                 break;
00019         case 2:
00020                 return "CLOSE";
00021                 break;
00022         case 3:
00023                 return "OPEN";
00024                 break;
00025         case 4:
00026                 return "INSERT";
00027                 break;
00028         case 5:
00029                 return "EXTRACT";
00030                 break;
00031         case 6:
00032                 return "MOVING";
00033                 break;
00034         case 7:
00035                 return "STANDBY";
00036                 break;
00037         case 8:
00038                 return "FAULT";
00039                 break;
00040         case 9:
00041                 return "INIT";
00042                 break;
00043         case 10:
00044                 return "RUNNING";
00045                 break;
00046         case 11:
00047                 return "ALARM";
00048                 break;
00049         case 12:
00050                 return "DISABLE";
00051                 break;
00052         case 13:
00053                 return "UNKNOW";
00054                 break;
00055         default:
00056                 return "NO COMMUNICATION / UNDEFINED";
00057                 break;
00058         }
00059 }

double InverseBrasSinus double  dL,
double  dTranslation
 

Method to convert a translation movement to a angle movement
The angle computed is given in radians !
The equation used is :

\[ \alpha = arcsin(frac{x}{L}) \]

with :
$ x $ the translation movement value,
$ L $ the length of the sinus arm,
$ \alpha $ the angle movement value in radians

Exceptions:
This method throw a DivideByZeroException exception if the mirror angle is equal to zero
This method throw a TrigonometricValueOutOfBoundException exception if the value to compute the $ \arcsin $ is not in the range $ [-1;1] $.

Definition at line 114 of file Tools.cpp.

00115 {
00116 //      if (dL == 0.0) throw DivideByZeroException("Inverse Bras Sinus","L","InverseBrasSinus()",__FILE__,__LINE__);
00117         double dQuotient                = dTranslation/dL;
00118 //      if ((-1.0 > dQuotient) || (dQuotient > 1.0)) throw TrigonometricValueOutOfBoundException("Inverse Bras Sinus",dQuotient,-1.0,1.0,"Arcsin","InverseBrasSinus()",__FILE__,__LINE__);
00119 
00120         return asin(dQuotient);
00121 }

double InverseBrasTangente double  dL,
double  dTranslation
 

Method to convert a translation movement to a angle movement
The angle computed is given in radians !
The equation used is :

\[ \alpha = arctan(frac{x}{L}) \]

with :
$ x $ the translation movement value,
$ L $ the length of the tangent arm,
$ \alpha $ the angle movement value in radians

Exceptions:
This method throw a DivideByZeroException exception if the mirror angle is equal to zero
This method throw a TrigonometricValueOutOfBoundException exception if the value to compute the $ \arcsin $ is not in the range $ [-1;1] $.

Definition at line 146 of file Tools.cpp.

00147 {
00148 //      if (dL == 0.0) throw DivideByZeroException("Inverse Bras Sinus","L","InverseBrasSinus()",__FILE__,__LINE__);
00149         
00150 //      double dQuotient                = dTranslation/dL;
00151 
00152         //      if ((-1.0 > dQuotient) || (dQuotient > 1.0)) throw TrigonometricValueOutOfBoundException("Inverse Bras Sinus",dQuotient,-1.0,1.0,"Arcsin","InverseBrasSinus()",__FILE__,__LINE__);
00153 
00154         double dQuotient                = dTranslation/dL;
00155         return atan(dQuotient);
00156 
00157 //      double dQuotient                = dTranslation/dL;
00158 //      return atan2(dTranslation,dL);
00159 
00160 
00161 }

template<class ObjectType>
bool isGreaterThan ObjectType &  obj1,
ObjectType &  obj2
 

Return true if the obj1 is greater than the obj2.

Definition at line 80 of file Tools.h.

00081 {
00082         return obj1 >= obj2;
00083 }

template<class ObjectType>
bool isLessThan ObjectType &  obj1,
ObjectType &  obj2
 

Return true if the obj1 is less than the obj2.

Definition at line 94 of file Tools.h.

00095 {
00096         return obj1 <= obj2;
00097 }

template<class ObjectType>
bool isStrictlyGreaterThan ObjectType &  obj1,
ObjectType &  obj2
 

Return true if the obj1 is stricktly greater than the obj2.

Definition at line 87 of file Tools.h.

00088 {
00089         return obj1 > obj2;
00090 }

template<class ObjectType>
bool isStrictlyLessThan ObjectType &  obj1,
ObjectType &  obj2
 

Return true if the obj1 is stricktly less than the obj2.

Definition at line 101 of file Tools.h.

00102 {
00103         return obj1 < obj2;
00104 }

string itos int  i  ) 
 

Tool method to convert a int to a string.

Definition at line 63 of file Tools.cpp.

References XString< T >::convertToString().

00064 {
00065         return XString<int>::convertToString(i);
00066 }

Here is the call graph for this function:

string ltos long  l  ) 
 

Tool method to convert a long to a string.

Definition at line 69 of file Tools.cpp.

References XString< T >::convertToString().

Referenced by IndexOutOfBoundException::makeDescription(), ValueOutOfBoundException::makeOrigin(), TrigonometricValueOutOfBoundException::makeOrigin(), SquareRootException::makeOrigin(), ParseException::makeOrigin(), NullPointerException::makeOrigin(), NotAllowedOperationException::makeOrigin(), NoSuchElementException::makeOrigin(), InfinityException::makeOrigin(), IndexOutOfBoundException::makeOrigin(), IllegalArgumentException::makeOrigin(), FileNotFoundException::makeOrigin(), and DivideByZeroException::makeOrigin().

00070 {
00071         return XString<long>::convertToString(l);
00072 }

Here is the call graph for this function:

template<class ObjectType>
ObjectType Maximum ObjectType &  obj1,
ObjectType &  obj2
 

Return the maximum object of obj1 and obj2.

Definition at line 65 of file Tools.h.

00066 {
00067         return obj1 <= obj2 ? obj2 : obj1;
00068 }

template<class ObjectType>
ObjectType Minimum ObjectType &  obj1,
ObjectType &  obj2
 

Return the minimum object of obj1 and obj2.

Definition at line 72 of file Tools.h.

00073 {
00074         return obj1 <= obj2 ? obj1 : obj2;
00075 }

double RadiansToDegres double  dRadians  ) 
 

Method to change an angle from radians to degres The equation used is

\[ AngleDegres = \frac{AngleRadians*180.0}{\pi} \]

.

Definition at line 82 of file Tools.cpp.

References MATH_CONSTANT::PI.

00083 {
00084         return dRadians * 180.0 / MATH_CONSTANT::PI;
00085 }


Generated on Fri Jul 10 10:32:09 2009 for Utils Library by  doxygen 1.4.5