22 #include "clips_rm_trigger.h" 24 #include <core/threading/mutex_locker.h> 29 using namespace mongo;
43 this->assert_name = assert_name;
44 this->robot_memory = robot_memory;
46 this->logger = logger;
49 ClipsRmTrigger::~ClipsRmTrigger()
52 robot_memory->remove_trigger(trigger);
63 this->trigger = trigger;
75 clips->assert_fact_f(
"( %s)", assert_name.c_str());
76 CLIPS::Template::pointer temp = clips->get_template(
"robmem-trigger");
80 CLIPS::Fact::pointer fact = CLIPS::Fact::create(**clips, temp);
81 fact->set_slot(
"name", assert_name.c_str());
82 CLIPS::Values rcvd_at(2, CLIPS::Value(CLIPS::TYPE_INTEGER));
83 rcvd_at[0] = tv.tv_sec;
84 rcvd_at[1] = tv.tv_usec;
85 fact->set_slot(
"rcvd-at", rcvd_at);
86 BSONObjBuilder *b =
new BSONObjBuilder();
87 b->appendElements(update);
89 fact->set_slot(
"ptr", CLIPS::Value(ptr));
90 CLIPS::Fact::pointer new_fact = clips->assert_fact(fact);
93 logger->
log_warn(
"CLIPS-RobotMemory",
"Asserting robmem-trigger fact failed");
94 delete static_cast<BSONObjBuilder *>(ptr);
97 logger->
log_warn(
"CLIPS-RobotMemory",
"Did not get template, did you load robot-memory.clp?");
Fawkes library namespace.
Class holding all information about an EventTrigger.
void callback(mongo::BSONObj update)
Callback function for the trigger.
ClipsRmTrigger(std::string assert_name, RobotMemory *robot_memory, fawkes::LockPtr< CLIPS::Environment > &clips, fawkes::Logger *logger)
Constructor with references to objects of the plugin.
virtual void log_warn(const char *component, const char *format,...)
Log warning message.
void set_trigger(EventTrigger *trigger)
Set the trigger object given by the robot memory.
Access to the robot memory based on mongodb.