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

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 
00025 // Start of apo namespace
00026 // The above functions must be in the global
00027 // namespace for c++ to function properly
00028 namespace apo
00029 {
00030 
00031 class Loop
00032 {
00033 public:
00034     Loop() : _fptr(), _data(), _period(), _subLoops(), _timeStamp(), _load(), _dt() {};
00035     Loop(float frequency, void (*fptr)(void *) = NULL, void * data = NULL);
00036     void update();
00037     Vector<Loop *> & subLoops() {
00038         return _subLoops;
00039     }
00040     uint32_t frequency() {
00041         return 1.0e6/_period;
00042     }
00043     void frequency(float frequency) {
00044         _period = 1e6/frequency;
00045     }
00046     uint32_t timeStamp() {
00047         return _timeStamp;
00048     }
00049     float dt() {
00050         return _dt;
00051     }
00052     uint8_t load() {
00053         return _load;
00054     }
00055 private:
00056     void (*_fptr)(void *);
00057     void * _data;
00058     uint32_t _period;
00059     Vector<Loop *> _subLoops;
00060     uint32_t _timeStamp;
00061     uint8_t _load;
00062     float _dt;
00063 };
00064 
00065 } // apo
00066 
00067 #endif
00068 
00069 // vim:ts=4:sw=4:expandtab

Generated for ArduPilot Libraries by doxygen