Fawkes API
Fawkes Development Version
|
23 #include "control_thread.h"
25 #include "eclipse_thread.h"
27 #include <core/exception.h>
28 #include <interfaces/TestInterface.h>
44 :
Thread(
"AgentControlThread",
Thread::OPMODE_WAITFORWAKEUP),
46 m_eclipse_thread(eclipse_thread)
63 simulation_shutdown_script_ =
"";
64 allow_shutdown_ =
false;
67 allow_shutdown_ =
config->
get_bool(
"/eclipse-clp/gazebo/allow-shutdown");
72 fawkes_path_ = strdup(
config->
get_string(
"/eclipse-clp/gazebo/fawkes-path").c_str());
75 allow_shutdown_ =
false;
79 simulation_shutdown_script_ =
80 strdup(
config->
get_string(
"/eclipse-clp/gazebo/simulation-shutdown-script").c_str());
83 "error reading config value: /eclipse-clp/gazebo/simulation-shutdown-script");
84 allow_shutdown_ =
false;
88 if (allow_shutdown_) {
108 if (allow_shutdown_) {
119 m_eclipse_thread->
post_event(
"check_debug_msg");
133 m_test_iface->
write();
136 if (allow_shutdown_) {
140 "shutting down: %s%s",
141 fawkes_path_.c_str(),
142 simulation_shutdown_script_.c_str());
143 std::string command = fawkes_path_ + simulation_shutdown_script_;
144 int cmd_rv = system(command.c_str());
147 "Failed to execute '%s'. Return value %d",
bool msgq_first_is()
Check if first message has desired type.
void msgq_pop()
Erase first message from queue.
bool msgq_empty()
Check if queue is empty.
AgentControlThread(EclipseAgentThread *eclipse_thread)
Constructor.
ExitSimulationInterface Fawkes BlackBoard Interface.
void set_result(const int32_t new_result)
Set result value.
virtual bool prepare_finalize_user()
Prepare finalization user implementation.
virtual void finalize()
Finalize the thread.
int32_t addend() const
Get addend value.
virtual ~AgentControlThread()
Destructor.
virtual bool get_bool(const char *path)=0
Get value from configuration which is of type bool.
virtual void log_info(const char *component, const char *format,...)=0
Log informational message.
Thread aspect to use blocked timing.
const char * name() const
Get name of thread.
This thread creates an ECLiPSe context in which the ECLiPSe interpreter and the program are loaded.
virtual void loop()
Code to execute in the thread.
Logger * logger
This is the Logger member used to access the logger.
virtual void close(Interface *interface)=0
Close interface.
virtual void log_error(const char *component, const char *format,...)=0
Log error message.
CalculateMessage Fawkes BlackBoard Interface Message.
Fawkes library namespace.
EclipseDebuggerInterface Fawkes BlackBoard Interface.
virtual void log_warn(const char *component, const char *format,...)=0
Log warning message.
bool has_writer() const
Check if there is a writer for the interface.
void post_event(const char *)
Post an event to the ECLiPSe context.
Configuration * config
This is the Configuration member used to access the configuration.
virtual void init()
Initialize the thread.
Thread class encapsulation of pthreads.
BlackBoard * blackboard
This is the BlackBoard instance you can use to interact with the BlackBoard.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for reading.
int32_t summand() const
Get summand value.
TestInterface Fawkes BlackBoard Interface.
Message * msgq_first()
Get the first message from the message queue.
void write()
Write from local copy into BlackBoard memory.
ExitSimulationMessage Fawkes BlackBoard Interface Message.
virtual Interface * open_for_writing(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for writing.