Fawkes API  Fawkes Development Version
exec_thread.h
1 
2 /***************************************************************************
3  * exec_thread.h - Fawkes Skiller: Execution Thread
4  *
5  * Created: Mon Feb 18 10:28:38 2008
6  * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_SKILLER_EXEC_THREAD_H_
24 #define __PLUGINS_SKILLER_EXEC_THREAD_H_
25 
26 #include <core/threading/thread.h>
27 #include <aspect/blocked_timing.h>
28 #include <aspect/logging.h>
29 #include <aspect/configurable.h>
30 #include <aspect/clock.h>
31 #include <aspect/blackboard.h>
32 #ifdef HAVE_TF
33 # include <aspect/tf.h>
34 #endif
35 #include <utils/system/fam.h>
36 #include <blackboard/interface_listener.h>
37 
38 #include <string>
39 #include <cstdlib>
40 
41 namespace fawkes {
42  class ComponentLogger;
43  class Mutex;
44  class LuaContext;
45  class LuaInterfaceImporter;
46  class Interface;
47  class SkillerInterface;
48  class SkillerDebugInterface;
49 #ifdef SKILLER_TIMETRACKING
50  class TimeTracker;
51 #endif
52 }
53 
55 : public fawkes::Thread,
57  public fawkes::LoggingAspect,
60  public fawkes::ClockAspect,
61 #ifdef HAVE_TF
63 #endif
65 {
66  public:
68  virtual ~SkillerExecutionThread();
69 
70  virtual void init();
71  virtual void loop();
72  virtual void finalize();
73 
74  /* BlackBoardInterfaceListener */
76  unsigned int instance_serial) throw();
77 
78  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
79  protected: virtual void run() { Thread::run(); }
80 
81  private: /* methods */
82  void init_failure_cleanup();
83  void publish_skill_status(std::string &curss);
84  void publish_skdbg();
85  void publish_error();
86  void process_skdbg_messages();
87  void lua_loop_reset();
88 
89  private: /* members */
91 
92  unsigned int __last_exclusive_controller;
93  bool __reader_just_left;
94 
95  bool __continuous_run;
96  bool __continuous_reset;
97  bool __error_written;
98  bool __sksf_pushed;
99 
100  std::string __skdbg_what;
101  std::string __skdbg_graphdir;
102  bool __skdbg_graphcolored;
103 
104  // config values
105  std::string __cfg_skillspace;
106  bool __cfg_watch_files;
107 
108  fawkes::SkillerInterface *__skiller_if;
109  fawkes::SkillerDebugInterface *__skdbg_if;
110 
111  fawkes::LuaContext *__lua;
112  fawkes::LuaInterfaceImporter *__lua_ifi;
113 
114 #ifdef SKILLER_TIMETRACKING
115  fawkes::TimeTracker *__tt;
116  unsigned int __ttc_total;
117  unsigned int __ttc_msgproc;
118  unsigned int __ttc_luaprep;
119  unsigned int __ttc_luaexec;
120  unsigned int __ttc_publish;
121  unsigned int __tt_loopcount;
122 #endif
123 };
124 
125 #endif
SkillerDebugInterface Fawkes BlackBoard Interface.
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
virtual ~SkillerExecutionThread()
Destructor.
Definition: exec_thread.cpp:71
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
virtual void loop()
Code to execute in the thread.
SkillerExecutionThread()
Constructor.
Definition: exec_thread.cpp:57
void bb_interface_reader_removed(fawkes::Interface *interface, unsigned int instance_serial)
A reading instance has been closed for a watched interface.
Fawkes library namespace.
Thread class encapsulation of pthreads.
Definition: thread.h:42
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
Skiller Execution Thread.
Definition: exec_thread.h:54
Thread aspect to access the transform system.
Definition: tf.h:38
Thread aspect to use blocked timing.
Lua interface importer.
Lua C++ wrapper.
Definition: context.h:47
Time tracking utility.
Definition: tracker.h:38
Thread aspect to log output.
Definition: logging.h:35
Component logger.
Definition: component.h:35
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: exec_thread.h:79
Thread aspect to access configuration data.
Definition: configurable.h:35
virtual void init()
Initialize the thread.
SkillerInterface Fawkes BlackBoard Interface.
virtual void finalize()
Finalize the thread.
BlackBoard interface listener.