Fawkes API  Fawkes Development Version
clips_agent_thread.h
1 
2 /***************************************************************************
3  * clips_agent_thread.h - CLIPS-based agent plugin
4  *
5  * Created: Sat Jun 16 14:38:21 2012 (Mexico City)
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_CLIPS_AGENT_CLIPS_AGENT_THREAD_H_
24 #define __PLUGINS_CLIPS_AGENT_CLIPS_AGENT_THREAD_H_
25 
26 #include <core/threading/thread.h>
27 #include <aspect/blackboard.h>
28 #include <aspect/blocked_timing.h>
29 #include <aspect/clock.h>
30 #include <aspect/logging.h>
31 #include <aspect/configurable.h>
32 #include <plugins/clips/aspect/clips.h>
33 #include <utils/time/time.h>
34 
35 #include <interfaces/SkillerInterface.h>
36 
37 #include <clipsmm.h>
38 
39 #include <map>
40 #include <string>
41 
42 namespace fawkes {
43  class SwitchInterface;
44 }
45 
47 : public fawkes::Thread,
49  public fawkes::LoggingAspect,
52  public fawkes::ClockAspect,
53  public fawkes::CLIPSAspect
54 {
55  public:
57  virtual ~ClipsAgentThread();
58 
59  virtual void init();
60  virtual void loop();
61  virtual void finalize();
62 
63  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
64  protected: virtual void run() { Thread::run(); }
65 
66  private:
67  CLIPS::Values clips_now();
68  void clips_call_skill(std::string skill_name, CLIPS::Values args);
69  void clips_skill_call_ext(std::string skill_name, std::string skill_string);
70  const char * status_string(fawkes::SkillerInterface::SkillStatusEnum status);
71 
72  private:
73  bool cfg_auto_start_;
74  bool cfg_assert_time_each_loop_;
75  bool cfg_skill_sim_;
76  float cfg_skill_sim_time_;
77  bool cfg_steal_skiller_control_;
78 
79  fawkes::SkillerInterface *skiller_if_;
80  fawkes::SwitchInterface *switch_if_;
81 
82  bool ctrl_recheck_;
83 
84  /// @cond INTERNALS
85  typedef struct {
86 
87  fawkes::Time start_time;
88  std::string skill_string;
89  } SkillExecInfo;
90  /// @endcond
91 
92  std::map<std::string, SkillExecInfo> active_skills_;
93  bool started_;
94 };
95 
96 #endif
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
Fawkes library namespace.
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:939
Main thread of CLIPS-based agent.
A class for handling time.
Definition: time.h:91
SkillStatusEnum
This determines the current status of skill execution.
Thread class encapsulation of pthreads.
Definition: thread.h:42
virtual void run()
Stub to see name in backtrace for easier debugging.
Thread aspect to use blocked timing.
SwitchInterface Fawkes BlackBoard Interface.
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to access configuration data.
Definition: configurable.h:35
SkillerInterface Fawkes BlackBoard Interface.
Thread aspect to get access to a CLIPS environment.
Definition: clips.h:41