• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/home/jgoppert/Projects/ap/libraries/AP_Common/AP_Loop.h

Go to the documentation of this file.
00001 /*
00002  * AP_Loop.h
00003  * Copyright (C) James Goppert 2010 <james.goppert@gmail.com>
00004  *
00005  * This file is free software: you can redistribute it and/or modify it
00006  * under the terms of the GNU General Public License as published by the
00007  * Free Software Foundation, either version 3 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This file is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00013  * See the GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 #ifndef AP_Loop_H
00020 #define AP_Loop_H
00021 
00022 #include "AP_Vector.h"
00023 
00029 namespace apo
00030 {
00031 
00032 class Loop
00033 {
00034 public:
00035     Loop() : _fptr(), _data(), _period(), _subLoops(), _timeStamp(), _load(), _dt() {};
00036     Loop(float frequency, void (*fptr)(void *) = NULL, void * data = NULL);
00037     void update();
00038     Vector<Loop *> & subLoops() {
00039         return _subLoops;
00040     }
00041     uint32_t frequency() {
00042         return 1.0e6/_period;
00043     }
00044     void frequency(float frequency) {
00045         _period = 1e6/frequency;
00046     }
00047     uint32_t timeStamp() {
00048         return _timeStamp;
00049     }
00050     float dt() {
00051         return _dt;
00052     }
00053     uint8_t load() {
00054         return _load;
00055     }
00056 private:
00057     void (*_fptr)(void *);
00058     void * _data;
00059     uint32_t _period;
00060     Vector<Loop *> _subLoops;
00061     uint32_t _timeStamp;
00062     uint8_t _load;
00063     float _dt;
00064 };
00065 
00066 } // apo
00067 
00068 #endif
00069 
00070 // vim:ts=4:sw=4:expandtab

Generated for ArduPilot Libraries by doxygen