22#include "openprs_agent_thread.h"
24#include <logging/logger.h>
25#include <plugins/openprs/utils/openprs_comm.h>
26#include <utils/time/time.h>
43:
Thread(
"OpenPRSAgentThread",
Thread::OPMODE_WAITFORWAKEUP),
62 openprs->signal_msg_rcvd().connect(
63 boost::bind(&OpenPRSAgentThread::handle_message,
this, _1, _2));
65 "add (! (= @@AGENT_NAME \"%s\"))",
85 "(fawkes-time %lill %lill %lill %lill)",
96OpenPRSAgentThread::handle_message(std::string sender, std::string message)
99 message.erase(std::remove(message.begin(), message.end(),
'\n'), message.end());
101 logger->
log_debug(
name(),
"Received message from %s: %s", sender.c_str(), message.c_str());
111 agent_alive_ =
false;
virtual void finalize()
Finalize the thread.
OpenPRSAgentThread(OpenPRSAspect::Mode oprs_mode, bool gdb_delay)
Constructor.
virtual ~OpenPRSAgentThread()
Destructor.
virtual void loop()
Code to execute in the thread.
virtual void init()
Initialize the thread.
Thread aspect to use blocked timing.
Clock * clock
By means of this member access to the clock is given.
void get_time(struct timeval *tv) const
Returns the time of the selected time source.
void get_systime(struct timeval *tv) const
Returns the system time.
Configuration * config
This is the Configuration member used to access the configuration.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
virtual void log_debug(const char *component, const char *format,...)=0
Log debug message.
virtual void log_error(const char *component, const char *format,...)=0
Log error message.
Logger * logger
This is the Logger member used to access the logger.
OpenPRS kernel creation and communication aspect.
LockPtr< OpenPRSComm > openprs
OpenPRS kernel communication wrapper.
void add_openprs_data_path(const std::string &path)
Add an OpenPRS data path.
Mode
OPRS kernel operation mode.
void set_openprs_gdb_delay(const bool enable_gdb_delay)
Enable/disable GDB delay.
const std::string openprs_kernel_name
The name of the kernel created for this thread.
Thread class encapsulation of pthreads.
const char * name() const
Get name of thread.
A class for handling time.
long get_usec() const
Get microseconds.
long get_sec() const
Get seconds.
Fawkes library namespace.