Wiselib
|
00001 /*************************************************************************** 00002 ** This file is part of the generic algorithm library Wiselib. ** 00003 ** Copyright (C) 2008,2009 by the Wisebed (www.wisebed.eu) project. ** 00004 ** ** 00005 ** The Wiselib is free software: you can redistribute it and/or modify ** 00006 ** it under the terms of the GNU Lesser General Public License as ** 00007 ** published by the Free Software Foundation, either version 3 of the ** 00008 ** License, or (at your option) any later version. ** 00009 ** ** 00010 ** The Wiselib is distributed in the hope that it will be useful, ** 00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** 00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 00013 ** GNU Lesser General Public License for more details. ** 00014 ** ** 00015 ** You should have received a copy of the GNU Lesser General Public ** 00016 ** License along with the Wiselib. ** 00017 ** If not, see <http://www.gnu.org/licenses/>. ** 00018 ***************************************************************************/ 00019 #ifndef CONNECTOR_ISENSE_POSITION_H 00020 #define CONNECTOR_ISENSE_POSITION_H 00021 00022 #include "internal_interface/position/position.h" 00023 #include "algorithms/localization/distance_based/math/vec.h" 00024 #include <float.h> 00025 00026 namespace wiselib 00027 { 00033 template<typename OsModel_P, 00034 typename block_data_P, 00035 typename Float_P = double> 00036 class iSensePositionModel 00037 { 00038 public: 00039 typedef OsModel_P OsModel; 00040 00041 typedef block_data_P block_data_t; 00042 typedef Float_P float_t; 00043 00044 typedef iSensePositionModel<OsModel, block_data_t, float_t> self_type; 00045 typedef self_type* self_pointer_t; 00046 00047 // typedef PositionType<Float, block_data_P, OsModel_P > position_t; 00048 typedef Vec<float_t> position_t; 00049 00050 typedef position_t value_t; 00051 // -------------------------------------------------------------------- 00052 static value_t UNKNOWN_POSITION; 00053 // -------------------------------------------------------------------- 00054 enum ErrorCodes 00055 { 00056 SUCCESS = OsModel::SUCCESS, 00057 ERR_UNSPEC = OsModel::ERR_UNSPEC 00058 }; 00059 // -------------------------------------------------------------------- 00060 enum 00061 { 00062 READY = OsModel::READY, 00063 NO_VALUE = OsModel::NO_VALUE, 00064 INACTIVE = OsModel::INACTIVE 00065 }; 00066 // -------------------------------------------------------------------- 00067 iSensePositionModel( isense::Os& os ) 00068 : os_(os) 00069 {} 00070 // -------------------------------------------------------------------- 00071 int init() 00072 { 00073 return SUCCESS; 00074 } 00075 // -------------------------------------------------------------------- 00076 int destruct() 00077 { 00078 return SUCCESS; 00079 } 00080 // -------------------------------------------------------------------- 00081 int state() 00082 { 00083 return READY; 00084 } 00085 // -------------------------------------------------------------------- 00086 value_t operator()() 00087 { 00088 return position(); 00089 } 00090 // -------------------------------------------------------------------- 00093 value_t position() 00094 { 00095 //if(gps) {...} else 00096 /* switch(os().id()){ 00097 case 0x0581: 00098 return position_t(3,11,0); 00099 case 0x0582: 00100 return position_t(0,12,0); 00101 case 0x0583: 00102 return position_t(2,5,0); 00103 case 0x0584: 00104 return position_t(2,9,1); 00105 case 0x059c: 00106 return position_t(4,3,0); 00107 case 0x0615: 00108 return position_t(1,5,0); 00109 case 0x0b19: 00110 return position_t(2,9,0); 00111 case 0x0b47: 00112 return position_t(0,2,0); 00113 case 0x0c98: 00114 return position_t(0,3,0); 00115 case 0x0cb8: 00116 return position_t(0,9,0); 00117 case 0x0cbf: 00118 return position_t(1,2,0); 00119 case 0x0cc1: 00120 return position_t(6,11,0); 00121 case 0x0cc5: 00122 return position_t(3,9,0); 00123 case 0x0cc9: 00124 return position_t(0,7,0); 00125 case 0x0cd4: 00126 return position_t(5,11,1); 00127 case 0x0cd7: 00128 return position_t(0,5,0); 00129 case 0x0ce3: 00130 return position_t(-1,9,0); 00131 case 0x0ce6: 00132 return position_t(4,5,0); 00133 case 0x94a3: 00134 return position_t(1,9,0); 00135 }*/ 00136 return UNKNOWN_POSITION; 00137 }; 00138 // -------------------------------------------------------------------- 00139 00140 private: 00141 isense::Os& os() 00142 { return os_; } 00143 // -------------------------------------------------------------------- 00144 isense::Os& os_; 00145 }; 00146 // ----------------------------------------------------------------------- 00147 // ----------------------------------------------------------------------- 00148 // ----------------------------------------------------------------------- 00149 template<typename OsModel_P, 00150 typename block_data_P, 00151 typename Float> 00152 typename iSensePositionModel<OsModel_P, block_data_P, Float>::value_t 00153 iSensePositionModel<OsModel_P, block_data_P, Float>::UNKNOWN_POSITION = 00154 Vec<Float>( DBL_MIN, DBL_MIN, DBL_MIN ); 00155 } 00156 00157 #endif