MKSafeMod.hpp
Go to the documentation of this file.
00001 /*
00002  * MKSafeMod.hpp
00003  *
00004  *  Created on: Dec 7, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 #ifndef MKSAFEMOD_HPP_
00009 #define MKSAFEMOD_HPP_
00010 
00011 #include <telekyb_defines/telekyb_defines.hpp>
00012 #include <telekyb_base/Time.hpp>
00013 
00014 #include <telekyb_base/Options.hpp>
00015 
00016 #include <boost/thread.hpp>
00017 
00018 #include <tk_mkinterface/MKInterfaceConnection.hpp>
00019 
00020 namespace TELEKYB_NAMESPACE {
00021 
00022 class MKSafeModOptions : public OptionContainer
00023 {
00024 public:
00025         Option<int>* tCmdTimeoutUs;
00026         Option<int>* tEmergLandThrust;
00027         Option<double>* tEmergLandDuration;
00028         Option<int>* tEmergLandFreq;
00029 
00030 //      Option<int>* tThreadSleepTimeUs;
00031         MKSafeModOptions();
00032 };
00033 
00034 class MKSafeModDeleagte
00035 {
00036 public:
00037         virtual ~MKSafeModDeleagte() {}
00038         virtual void safeModDidBecomeActive() = 0;
00039         virtual void safeModFinished() = 0;
00040         virtual void handleCommand(double estMass, double roll, double pitch, double thrust, double yaw) = 0;
00041 };
00042 
00043 class MKSafeMod {
00044 protected:
00045         MKSafeModOptions options;
00046         Timer cmdTimer; // Reset with each command;
00047         MKInterfaceConnection* connection;
00048 
00049         bool active;
00050 
00051         MKSafeModDeleagte* delegate;
00052 
00053         // generates Cmds.
00054         void safeModFcn();
00055 
00056         // Independent Threading
00057         boost::thread* mkSafeModThread;
00058 
00059         bool threadStopRequest;
00060         bool emergencyLandingRequest;
00061         //void initReadingThread();
00062         void threadFcn();
00063         void startThread();
00064         void stopThread();
00065 
00066 public:
00067         MKSafeMod(MKSafeModDeleagte* delegate_, MKInterfaceConnection* connection_);
00068         virtual ~MKSafeMod();
00069 
00070         void start();
00071         void stop();
00072 
00073         // returns true if SafeMod has Taken Over
00074         bool isActive() const;
00075         bool isRunning() const;
00076 
00077         void resetCmdTimer();
00078 
00079         void setEmergency();
00080 };
00081 
00082 } /* namespace telekyb */
00083 #endif /* MKSAFEMOD_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines


tk_mkinterface
Author(s): Martin Riedel
autogenerated on Wed Apr 24 2013 11:29:54