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 <aspect/blackboard.h>
27 #include <aspect/blocked_timing.h>
28 #include <aspect/clock.h>
29 #include <aspect/configurable.h>
30 #include <aspect/logging.h>
31 #include <core/threading/thread.h>
32 #include <interfaces/SkillerInterface.h>
33 #include <plugins/clips/aspect/clips.h>
34 #include <utils/time/time.h>
35 
36 #include <clipsmm.h>
37 #include <map>
38 #include <string>
39 
40 namespace fawkes {
41 class SwitchInterface;
42 }
43 
46  public fawkes::LoggingAspect,
49  public fawkes::ClockAspect,
50  public fawkes::CLIPSAspect
51 {
52 public:
54  virtual ~ClipsAgentThread();
55 
56  virtual void init();
57  virtual void loop();
58  virtual void finalize();
59 
60  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
61 protected:
62  virtual void
63  run()
64  {
65  Thread::run();
66  }
67 
68 private:
69  CLIPS::Values clips_now();
70  void clips_call_skill(std::string skill_name, CLIPS::Values args);
71  void clips_skill_call_ext(std::string skill_name, std::string skill_string);
72  const char * status_string(fawkes::SkillerInterface::SkillStatusEnum status);
73 
74 private:
75  bool cfg_auto_start_;
76  bool cfg_assert_time_each_loop_;
77  bool cfg_skill_sim_;
78  float cfg_skill_sim_time_;
79  bool cfg_steal_skiller_control_;
80 
81  fawkes::SkillerInterface *skiller_if_;
82  fawkes::SwitchInterface * switch_if_;
83 
84  bool ctrl_recheck_;
85 
86  /// @cond INTERNALS
87  typedef struct
88  {
89  fawkes::Time start_time;
90  std::string skill_string;
91  } SkillExecInfo;
92  /// @endcond
93 
94  std::map<std::string, SkillExecInfo> active_skills_;
95  bool started_;
96 };
97 
98 #endif
fawkes::SwitchInterface
Definition: SwitchInterface.h:39
ClipsAgentThread
Definition: clips_agent_thread.h:44
fawkes::BlockedTimingAspect
Definition: blocked_timing.h:56
fawkes::SkillerInterface::SkillStatusEnum
SkillStatusEnum
This determines the current status of skill execution.
Definition: SkillerInterface.h:56
ClipsAgentThread::loop
virtual void loop()
Code to execute in the thread.
Definition: clips_agent_thread.cpp:170
ClipsAgentThread::init
virtual void init()
Initialize the thread.
Definition: clips_agent_thread.cpp:51
ClipsAgentThread::finalize
virtual void finalize()
Finalize the thread.
Definition: clips_agent_thread.cpp:154
fawkes::BlackBoardAspect
Definition: blackboard.h:38
fawkes
fawkes::LoggingAspect
Definition: logging.h:38
ClipsAgentThread::~ClipsAgentThread
virtual ~ClipsAgentThread()
Destructor.
Definition: clips_agent_thread.cpp:46
fawkes::SkillerInterface
Definition: SkillerInterface.h:39
fawkes::CLIPSAspect
Definition: clips.h:40
fawkes::Time
Definition: time.h:98
ClipsAgentThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: clips_agent_thread.h:63
fawkes::Thread
Definition: thread.h:45
fawkes::ConfigurableAspect
Definition: configurable.h:38
ClipsAgentThread::ClipsAgentThread
ClipsAgentThread()
Constructor.
Definition: clips_agent_thread.cpp:38
fawkes::ClockAspect
Definition: clock.h:40