Fawkes API
Fawkes Development Version
|
21 #include "exec_thread.h"
36 :
Thread(
"SkillerSimulatorExecutionThread",
Thread::OPMODE_WAITFORWAKEUP),
46 skill_starttime_ =
Time();
52 bool skill_enqueued =
false;
53 bool write_interface =
false;
60 "%s is new exclusive controller (ID %u)",
64 write_interface =
true;
69 write_interface =
true;
73 "%s tried to acquire exclusive control, but another controller exists already",
83 "%s tried to release exclusive control, but it's not the controller",
93 "More than one skill string enqueued, ignoring previous string (%s).",
98 if (sender ==
"Unknown") {
102 "%s executed '%s' without any exclusive controller",
109 if (skiller_if_->
status() == SkillerInterface::S_RUNNING) {
111 "Aborting execution of previous skill string '%s' for new goal",
117 skiller_if_->
set_status(SkillerInterface::S_RUNNING);
118 skill_starttime_ =
Time();
119 write_interface =
true;
120 skill_enqueued =
true;
126 "Stopping execution of '%s' on request",
131 skiller_if_->
set_status(SkillerInterface::S_INACTIVE);
134 if (sender ==
"Unknown") {
137 logger->
log_debug(
name(),
"%s sent stop without any exclusive controller", sender.c_str());
145 if (!skill_enqueued) {
146 if (skiller_if_->
status() == SkillerInterface::S_RUNNING) {
148 if (
Time() > skill_starttime_ + skill_runtime_) {
151 skiller_if_->
set_status(SkillerInterface::S_FINAL);
152 write_interface =
true;
157 if (write_interface) {
158 skiller_if_->
write();
bool msgq_first_is()
Check if first message has desired type.
void set_exclusive_controller(const uint32_t new_exclusive_controller)
Set exclusive_controller value.
void msgq_pop()
Erase first message from queue.
bool msgq_empty()
Check if queue is empty.
virtual void loop()
Code to execute in the thread.
bool is_steal_control() const
Get steal_control value.
virtual float get_float_or_default(const char *path, const float &default_val)
SkillerSimulatorExecutionThread()
Constructor.
void set_msgid(const uint32_t new_msgid)
Set msgid value.
virtual void log_info(const char *component, const char *format,...)=0
const char * sender_thread_name() const
Get sender of message.
unsigned int sender_id() const
Get ID of sender.
const char * name() const
void set_error(const char *new_error)
Set error value.
void set_status(const SkillStatusEnum new_status)
Set status value.
virtual void close(Interface *interface)=0
SkillStatusEnum status() const
Get status value.
virtual void log_warn(const char *component, const char *format,...)=0
char * skill_string() const
Get skill_string value.
char * skill_string() const
Get skill_string value.
void set_skill_string(const char *new_skill_string)
Set skill_string value.
virtual void finalize()
Finalize the thread.
unsigned int id() const
Get message ID.
uint32_t exclusive_controller() const
Get exclusive_controller value.
Message * msgq_first()
Get the first message from the message queue.
virtual void log_debug(const char *component, const char *format,...)=0
void write()
Write from local copy into BlackBoard memory.
virtual Interface * open_for_writing(const char *interface_type, const char *identifier, const char *owner=NULL)=0
virtual void init()
Initialize the thread.