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 00020 #ifndef CONNECTOR_CONTIKI_POSITION_H 00021 #define CONNECTOR_CONTIKI_POSITION_H 00022 00023 #include "internal_interface/position/position.h" 00024 #include "algorithms/localization/distance_based/math/vec.h" 00025 #include <float.h> 00026 extern "C" { 00027 #include "node-id.h" 00028 } 00029 namespace wiselib 00030 { 00036 template<typename OsModel_P, 00037 typename block_data_P, 00038 typename Float_P = double> 00039 class ContikiPositionModel 00040 { 00041 public: 00042 typedef OsModel_P OsModel; 00043 00044 typedef block_data_P block_data_t; 00045 typedef Float_P float_t; 00046 00047 typedef ContikiPositionModel<OsModel, block_data_t, float_t> self_type; 00048 typedef self_type* self_pointer_t; 00049 00050 // typedef PositionType<Float, block_data_P, OsModel_P > position_t; 00051 typedef Vec<float_t> position_t; 00052 00053 typedef position_t value_t; 00054 // -------------------------------------------------------------------- 00055 static value_t UNKNOWN_POSITION; 00056 // -------------------------------------------------------------------- 00057 enum ErrorCodes 00058 { 00059 SUCCESS = OsModel::SUCCESS, 00060 ERR_UNSPEC = OsModel::ERR_UNSPEC 00061 }; 00062 // -------------------------------------------------------------------- 00063 enum 00064 { 00065 READY = OsModel::READY, 00066 NO_VALUE = OsModel::NO_VALUE, 00067 INACTIVE = OsModel::INACTIVE 00068 }; 00069 // -------------------------------------------------------------------- 00070 ContikiPositionModel( ) 00071 {} 00072 // -------------------------------------------------------------------- 00073 int init() 00074 { 00075 return SUCCESS; 00076 } 00077 // -------------------------------------------------------------------- 00078 int destruct() 00079 { 00080 return SUCCESS; 00081 } 00082 // -------------------------------------------------------------------- 00083 int state() 00084 { 00085 return READY; 00086 } 00087 // -------------------------------------------------------------------- 00088 value_t operator()() 00089 { 00090 return position(); 00091 } 00092 // -------------------------------------------------------------------- 00095 value_t position() 00096 { 00097 //if(gps) {...} else 00098 /*switch(node_id){ 00099 case 0x0581: 00100 return position_t(3,11,0); 00101 case 0x0582: 00102 return position_t(0,12,0); 00103 case 0x0583: 00104 return position_t(2,5,0); 00105 case 0x0584: 00106 return position_t(2,9,1); 00107 case 0x059c: 00108 return position_t(4,3,0); 00109 case 0x0615: 00110 return position_t(1,5,0); 00111 case 0x0b19: 00112 return position_t(2,9,0); 00113 case 0x0b47: 00114 return position_t(0,2,0); 00115 case 0x0c98: 00116 return position_t(0,3,0); 00117 case 0x0cb8: 00118 return position_t(0,9,0); 00119 case 0x0cbf: 00120 return position_t(1,2,0); 00121 case 0x0cc1: 00122 return position_t(6,11,0); 00123 case 0x0cc5: 00124 return position_t(3,9,0); 00125 case 0x0cc9: 00126 return position_t(0,7,0); 00127 case 0x0cd4: 00128 return position_t(5,11,1); 00129 case 0x0cd7: 00130 return position_t(0,5,0); 00131 case 0x0ce3: 00132 return position_t(-1,9,0); 00133 case 0x0ce6: 00134 return position_t(4,5,0); 00135 case 0x94a3: 00136 return position_t(1,9,0); 00137 }*/ 00138 return UNKNOWN_POSITION; 00139 }; 00140 // -------------------------------------------------------------------- 00141 00142 private: 00143 00144 }; 00145 // ----------------------------------------------------------------------- 00146 // ----------------------------------------------------------------------- 00147 // ----------------------------------------------------------------------- 00148 template<typename OsModel_P, 00149 typename block_data_P, 00150 typename Float> 00151 typename ContikiPositionModel<OsModel_P, block_data_P, Float>::value_t 00152 ContikiPositionModel<OsModel_P, block_data_P, Float>::UNKNOWN_POSITION = 00153 Vec<Float>( DBL_MIN, DBL_MIN, DBL_MIN ); 00154 } 00155 00156 #endif