Wiselib
wiselib.stable/external_interface/tinyos/tinyos_position.h
Go to the documentation of this file.
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_TINYOS_POSITION_H
00021 #define CONNECTOR_TINYOS_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 TinyOsPositionModel
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 TinyOsPositionModel<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       TinyOsPositionModel( )
00071 
00072       {}
00073       // --------------------------------------------------------------------
00074       int init()
00075       {
00076          return SUCCESS;
00077       }
00078       // --------------------------------------------------------------------
00079       int destruct()
00080       {
00081          return SUCCESS;
00082       }
00083       // --------------------------------------------------------------------
00084       int state()
00085       {
00086          return READY;
00087       }
00088       // --------------------------------------------------------------------
00089       value_t operator()()
00090       {
00091          return position();
00092       }
00093       // --------------------------------------------------------------------
00096       value_t position()
00097       {
00098         //if(gps) {...} else
00099         /*switch(node_id){
00100         case 0x0581:
00101            return position_t(3,11,0);
00102         case 0x0582:
00103            return position_t(0,12,0);
00104         case 0x0583:
00105            return position_t(2,5,0);
00106         case 0x0584:
00107            return position_t(2,9,1);
00108         case 0x059c:
00109            return position_t(4,3,0);
00110         case 0x0615:
00111            return position_t(1,5,0);
00112         case 0x0b19:
00113            return position_t(2,9,0);
00114         case 0x0b47:
00115            return position_t(0,2,0);
00116         case 0x0c98:
00117            return position_t(0,3,0);
00118         case 0x0cb8:
00119            return position_t(0,9,0);
00120         case 0x0cbf:
00121            return position_t(1,2,0);
00122         case 0x0cc1:
00123            return position_t(6,11,0);
00124         case 0x0cc5:
00125            return position_t(3,9,0);
00126         case 0x0cc9:
00127            return position_t(0,7,0);
00128         case 0x0cd4:
00129            return position_t(5,11,1);
00130         case 0x0cd7:
00131            return position_t(0,5,0);
00132         case 0x0ce3:
00133            return position_t(-1,9,0);
00134         case 0x0ce6:
00135            return position_t(4,5,0);
00136         case 0x94a3:
00137            return position_t(1,9,0);
00138         }*/
00139         return UNKNOWN_POSITION;
00140       };
00141       // --------------------------------------------------------------------
00142 
00143    private:
00144 
00145    };
00146    // -----------------------------------------------------------------------
00147    // -----------------------------------------------------------------------
00148    // -----------------------------------------------------------------------
00149    template<typename OsModel_P,
00150             typename block_data_P,
00151             typename Float>
00152    typename TinyOsPositionModel<OsModel_P, block_data_P, Float>::value_t
00153       TinyOsPositionModel<OsModel_P, block_data_P, Float>::UNKNOWN_POSITION =
00154             Vec<Float>( DBL_MIN, DBL_MIN, DBL_MIN );
00155 }
00156 
00157 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines