Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * exec_thread.h - Fawkes Skiller: Execution Thread 00004 * 00005 * Created: Mon Feb 18 10:28:38 2008 00006 * Copyright 2006-2011 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #ifndef __PLUGINS_SKILLER_EXEC_THREAD_H_ 00024 #define __PLUGINS_SKILLER_EXEC_THREAD_H_ 00025 00026 #include <core/threading/thread.h> 00027 #include <aspect/blocked_timing.h> 00028 #include <aspect/logging.h> 00029 #include <aspect/configurable.h> 00030 #include <aspect/clock.h> 00031 #include <aspect/blackboard.h> 00032 #ifdef HAVE_TF 00033 # include <aspect/tf.h> 00034 #endif 00035 #include <utils/system/fam.h> 00036 #include <blackboard/interface_listener.h> 00037 00038 #include <string> 00039 #include <cstdlib> 00040 00041 namespace fawkes { 00042 class ComponentLogger; 00043 class Mutex; 00044 class LuaContext; 00045 class LuaInterfaceImporter; 00046 class Interface; 00047 class SkillerInterface; 00048 class SkillerDebugInterface; 00049 #ifdef SKILLER_TIMETRACKING 00050 class TimeTracker; 00051 #endif 00052 } 00053 00054 class SkillerExecutionThread 00055 : public fawkes::Thread, 00056 public fawkes::BlockedTimingAspect, 00057 public fawkes::LoggingAspect, 00058 public fawkes::BlackBoardAspect, 00059 public fawkes::ConfigurableAspect, 00060 public fawkes::ClockAspect, 00061 #ifdef HAVE_TF 00062 public fawkes::TransformAspect, 00063 #endif 00064 public fawkes::BlackBoardInterfaceListener 00065 { 00066 public: 00067 SkillerExecutionThread(); 00068 virtual ~SkillerExecutionThread(); 00069 00070 virtual void init(); 00071 virtual void loop(); 00072 virtual void finalize(); 00073 00074 /* BlackBoardInterfaceListener */ 00075 void bb_interface_reader_removed(fawkes::Interface *interface, 00076 unsigned int instance_serial) throw(); 00077 00078 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */ 00079 protected: virtual void run() { Thread::run(); } 00080 00081 private: /* methods */ 00082 void init_failure_cleanup(); 00083 void publish_skill_status(std::string &curss); 00084 void publish_skdbg(); 00085 void publish_error(); 00086 void process_skdbg_messages(); 00087 void lua_loop_reset(); 00088 00089 private: /* members */ 00090 fawkes::ComponentLogger *__clog; 00091 00092 unsigned int __last_exclusive_controller; 00093 bool __reader_just_left; 00094 00095 bool __continuous_run; 00096 bool __continuous_reset; 00097 bool __error_written; 00098 bool __sksf_pushed; 00099 00100 std::string __skdbg_what; 00101 std::string __skdbg_graphdir; 00102 bool __skdbg_graphcolored; 00103 00104 // config values 00105 std::string __cfg_skillspace; 00106 bool __cfg_watch_files; 00107 00108 fawkes::SkillerInterface *__skiller_if; 00109 fawkes::SkillerDebugInterface *__skdbg_if; 00110 00111 fawkes::LuaContext *__lua; 00112 fawkes::LuaInterfaceImporter *__lua_ifi; 00113 00114 #ifdef SKILLER_TIMETRACKING 00115 fawkes::TimeTracker *__tt; 00116 unsigned int __ttc_total; 00117 unsigned int __ttc_msgproc; 00118 unsigned int __ttc_luaprep; 00119 unsigned int __ttc_luaexec; 00120 unsigned int __ttc_publish; 00121 unsigned int __tt_loopcount; 00122 #endif 00123 }; 00124 00125 #endif