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
40namespace fawkes {
41class SwitchInterface;
42}
43
51{
52public:
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() */
61protected:
62 virtual void
64 {
65 Thread::run();
66 }
67
68private:
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
74private:
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
Main thread of CLIPS-based agent.
virtual void finalize()
Finalize the thread.
ClipsAgentThread()
Constructor.
virtual void loop()
Code to execute in the thread.
virtual void init()
Initialize the thread.
virtual void run()
Stub to see name in backtrace for easier debugging.
virtual ~ClipsAgentThread()
Destructor.
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect to use blocked timing.
Thread aspect to get access to a CLIPS environment.
Definition: clips.h:41
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:34
Thread aspect to access configuration data.
Definition: configurable.h:33
Thread aspect to log output.
Definition: logging.h:33
SkillerInterface Fawkes BlackBoard Interface.
SkillStatusEnum
This determines the current status of skill execution.
SwitchInterface Fawkes BlackBoard Interface.
Thread class encapsulation of pthreads.
Definition: thread.h:46
A class for handling time.
Definition: time.h:93
Fawkes library namespace.