Fawkes API Fawkes Development Version
plexil_thread.h
1
2/***************************************************************************
3 * plexil_thread.h - PLEXIL executive plugin
4 *
5 * Created: Mon Aug 13 11:19:14 2018
6 * Copyright 2006-2018 Tim Niemueller [www.niemueller.de]
7 ****************************************************************************/
8
9/* This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Library General Public License for more details.
18 *
19 * Read the full text in the LICENSE.GPL file in the doc directory.
20 */
21
22#ifndef __PLUGINS_PLEXIL_PLEXIL_THREAD_H_
23#define __PLUGINS_PLEXIL_PLEXIL_THREAD_H_
24
25#include <aspect/blackboard.h>
26#include <aspect/clock.h>
27#include <aspect/configurable.h>
28#include <aspect/logging.h>
29#include <core/threading/thread.h>
30#ifdef HAVE_NAVGRAPH
31# include <aspect/thread_producer.h>
32# include <core/utils/lockptr.h>
33# include <navgraph/navgraph.h>
34#endif
35#include <utils/time/time.h>
36
37#include <AdapterFactory.hh>
38#include <fstream>
39#include <memory>
40
41namespace PLEXIL {
42class ExecApplication;
43}
44
47
52#ifdef HAVE_NAVGRAPH
54#endif
56{
57public:
59 virtual ~PlexilExecutiveThread();
60
61 virtual void init();
62 virtual void once();
63 virtual void loop();
64 virtual bool prepare_finalize_user();
65 virtual void finalize();
66
67 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
68protected:
69 virtual void
71 {
72 Thread::run();
73 }
74
75private:
76 /// @cond INTERNAL
77 // Data structure for config parse result
78 struct plexil_interface_config
79 {
80 std::string type;
81 std::map<std::string, std::string> attr;
82 std::map<std::string, std::string> args;
83
84 struct verbatim_arg
85 {
86 std::string tag;
87 bool has_text;
88 std::string text;
89 std::map<std::string, std::string> attr;
90 };
91 std::map<std::string, verbatim_arg> verbatim_args;
92 pugi::xml_document verbatim;
93 };
94 /// @endcond
95
96 std::map<std::string, plexil_interface_config>
97 read_plexil_interface_configs(const std::string &config_prefix);
98 void add_plexil_interface_configs(
99 pugi::xml_node & parent,
100 const std::map<std::string, PlexilExecutiveThread::plexil_interface_config> &configs,
101 const char * tag_name,
102 const char * type_attr_name);
103 void plexil_compile(const std::string &ple_file);
104
105private:
106 std::string cfg_spec_;
107 std::string cfg_plan_plx_;
108 std::vector<std::string> cfg_plan_ple_;
109 bool cfg_plan_auto_compile_;
110 bool cfg_plan_force_compile_;
111
112 std::unique_ptr<PLEXIL::ExecApplication> plexil_;
113
114#ifdef HAVE_NAVGRAPH
115 PlexilNavgraphAccessThread * navgraph_access_thread_;
117#endif
118
119 std::shared_ptr<PlexilLogStreamBuffer> log_buffer_;
120 std::shared_ptr<std::ostream> log_stream_;
121
122 std::shared_ptr<pugi::xml_document> plan_plx_;
123};
124
125#endif
Main thread of PLEXIL executive.
Definition: plexil_thread.h:56
virtual void init()
Initialize the thread.
virtual ~PlexilExecutiveThread()
Destructor.
PlexilExecutiveThread()
Constructor.
virtual void loop()
Code to execute in the thread.
virtual void finalize()
Finalize the thread.
virtual bool prepare_finalize_user()
Prepare finalization user implementation.
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: plexil_thread.h:70
virtual void once()
Execute an action exactly once.
Log Plexil log output to Fawkes logger.
Definition: log_stream.h:31
Access to internal navgraph for Plexil.
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:34
Thread aspect to access configuration data.
Definition: configurable.h:33
Thread aspect to log output.
Definition: logging.h:33
Aspect for thread producing threads.
Thread class encapsulation of pthreads.
Definition: thread.h:46