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",
virtual void loop()
Code to execute in the thread.
virtual bool prepare_finalize_user()
Prepare finalization user implementation.
virtual void init()
Initialize the thread.
virtual ~AgentControlThread()
Destructor.
AgentControlThread(EclipseAgentThread *eclipse_thread)
Constructor.
virtual void finalize()
Finalize the thread.
This thread creates an ECLiPSe context in which the ECLiPSe interpreter and the program are loaded.
void post_event(const char *)
Post an event to the ECLiPSe context.
BlackBoard * blackboard
This is the BlackBoard instance you can use to interact with the BlackBoard.
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for reading.
virtual Interface * open_for_writing(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for writing.
virtual void close(Interface *interface)=0
Close interface.
Thread aspect to use blocked timing.
Configuration * config
This is the Configuration member used to access the configuration.
virtual bool get_bool(const char *path)=0
Get value from configuration which is of type bool.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
EclipseDebuggerInterface Fawkes BlackBoard Interface.
ExitSimulationMessage Fawkes BlackBoard Interface Message.
ExitSimulationInterface Fawkes BlackBoard Interface.
bool msgq_first_is()
Check if first message has desired type.
void msgq_pop()
Erase first message from queue.
Message * msgq_first()
Get the first message from the message queue.
void write()
Write from local copy into BlackBoard memory.
bool msgq_empty()
Check if queue is empty.
bool has_writer() const
Check if there is a writer for the interface.
virtual void log_warn(const char *component, const char *format,...)=0
Log warning message.
virtual void log_error(const char *component, const char *format,...)=0
Log error message.
virtual void log_info(const char *component, const char *format,...)=0
Log informational message.
Logger * logger
This is the Logger member used to access the logger.
CalculateMessage Fawkes BlackBoard Interface Message.
int32_t summand() const
Get summand value.
int32_t addend() const
Get addend value.
TestInterface Fawkes BlackBoard Interface.
void set_result(const int32_t new_result)
Set result value.
Thread class encapsulation of pthreads.
const char * name() const
Get name of thread.
Fawkes library namespace.