Tools.cpp

Go to the documentation of this file.
00001 
00002 #ifdef WIN32 
00003 #pragma warning(disable:4786)
00004 #endif
00005 #include "Tools.h"
00006 #include "Xstring.h"
00007 
00008 std::string GetDeviceState(int iDeviceState)
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 }
00060 
00061 
00063 string itos(int i)      
00064 {
00065         return XString<int>::convertToString(i);
00066 }
00067 
00069 string ltos(long l)     
00070 {
00071         return XString<long>::convertToString(l);
00072 }
00073 
00075 string dtos(double d)   
00076 {
00077         return XString<double>::convertToString(d);
00078 }
00079 
00082 double RadiansToDegres(double dRadians) 
00083 {
00084         return dRadians * 180.0 / MATH_CONSTANT::PI;
00085 }
00086 
00089 double DegresToRadians(double dDegres) 
00090 {
00091         return dDegres * MATH_CONSTANT::PI / 180.0;
00092 }
00093 
00100 double BrasSinus(double dL,double dAngle)
00101 {
00102         return dL*sin(dAngle);
00103 }
00104 
00105 
00114 double InverseBrasSinus(double dL,double dTranslation) 
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 }
00122 
00123 
00124 
00125 
00132 double BrasTangente(double dL,double dAngle)
00133 {
00134         return dL*tan(dAngle);
00135 }
00136 
00137 
00146 double InverseBrasTangente(double dL,double dTranslation)
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 }
00162 
00163 
00164 
00165 

Generated on Fri Jul 10 10:31:55 2009 for Utils Library by  doxygen 1.4.5