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-2009 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 #include <utils/system/fam.h> 00033 #include <blackboard/interface_listener.h> 00034 00035 #include <string> 00036 #include <cstdlib> 00037 00038 namespace fawkes { 00039 class ComponentLogger; 00040 class Mutex; 00041 class LuaContext; 00042 class LuaInterfaceImporter; 00043 class Interface; 00044 class SkillerInterface; 00045 class SkillerDebugInterface; 00046 #ifdef SKILLER_TIMETRACKING 00047 class TimeTracker; 00048 #endif 00049 } 00050 00051 class SkillerExecutionThread 00052 : public fawkes::Thread, 00053 public fawkes::BlockedTimingAspect, 00054 public fawkes::LoggingAspect, 00055 public fawkes::BlackBoardAspect, 00056 public fawkes::ConfigurableAspect, 00057 public fawkes::ClockAspect, 00058 public fawkes::BlackBoardInterfaceListener 00059 { 00060 public: 00061 SkillerExecutionThread(); 00062 virtual ~SkillerExecutionThread(); 00063 00064 virtual void init(); 00065 virtual void loop(); 00066 virtual void finalize(); 00067 00068 /* BlackBoardInterfaceListener */ 00069 void bb_interface_reader_removed(fawkes::Interface *interface, 00070 unsigned int instance_serial) throw(); 00071 00072 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */ 00073 protected: virtual void run() { Thread::run(); } 00074 00075 private: /* methods */ 00076 void init_failure_cleanup(); 00077 void publish_skill_status(std::string &curss); 00078 void publish_skdbg(); 00079 void publish_error(); 00080 void process_skdbg_messages(); 00081 void lua_loop_reset(); 00082 00083 private: /* members */ 00084 fawkes::ComponentLogger *__clog; 00085 00086 unsigned int __last_exclusive_controller; 00087 bool __reader_just_left; 00088 00089 bool __continuous_run; 00090 bool __continuous_reset; 00091 bool __error_written; 00092 bool __sksf_pushed; 00093 00094 std::string __skdbg_what; 00095 std::string __skdbg_graphdir; 00096 bool __skdbg_graphcolored; 00097 00098 // config values 00099 std::string __cfg_skillspace; 00100 bool __cfg_watch_files; 00101 00102 fawkes::SkillerInterface *__skiller_if; 00103 fawkes::SkillerDebugInterface *__skdbg_if; 00104 00105 fawkes::LuaContext *__lua; 00106 fawkes::LuaInterfaceImporter *__lua_ifi; 00107 00108 #ifdef SKILLER_TIMETRACKING 00109 fawkes::TimeTracker *__tt; 00110 unsigned int __ttc_total; 00111 unsigned int __ttc_msgproc; 00112 unsigned int __ttc_luaprep; 00113 unsigned int __ttc_luaexec; 00114 unsigned int __ttc_publish; 00115 unsigned int __tt_loopcount; 00116 #endif 00117 }; 00118 00119 #endif