Elma
An event loop manager for embedded systems
|
An abstract base class for processes. More...
#include <process.h>
Public Types | |
enum | status_type { UNINITIALIZED, STOPPED, RUNNING } |
Public Member Functions | |
Process (int n=0) | |
Default constructor. Names process "no name". | |
Process (std::string name, int n=0) | |
Constructor that takes a name for the process. More... | |
virtual void | init ()=0 |
virtual void | start ()=0 |
virtual void | update ()=0 |
virtual void | stop ()=0 |
string | name () |
void | set_name (std::string str) |
status_type | status () |
high_resolution_clock::duration | period () |
int | num_updates () |
time_point< high_resolution_clock > | start_time () |
high_resolution_clock::duration | last_update () |
high_resolution_clock::duration | previous_update () |
Channel & | channel (string name) |
Access a channel with the given name. More... | |
double | milli_time () |
The time since the last update in millisconds, as a double. More... | |
double | delta () |
The most recent amount of time between updates. More... | |
void | watch (string event_name, std::function< void(Event &)> handler) |
void | emit (const Event &event) |
void | http_get (std::string url, std::function< void(json &)> handler) |
void | halt () |
void | set_manager (Manager *m_ptr) |
Protected Attributes | |
Manager * | _manager_ptr |
Friends | |
class | Manager |
An abstract base class for processes.
Derived classes should imlement the init, start, update, and stop methods. For example, here is a process that prints out a message every time its update method is called.
|
inline |
Channel & elma::Process::channel | ( | string | name | ) |
Access a channel with the given name.
name | The name of the channel |
Definition at line 11 of file process.cc.
double elma::Process::delta | ( | ) |
The most recent amount of time between updates.
A common use of this method is in the update() method for Euler integration as in xnew = x + delta() * f(x)
Definition at line 54 of file process.cc.
|
pure virtual |
Initialization method. This method should be overridden by derived classes. It will usually be called once, after all processes and communication objects have been added to the manager, but before the Manager starts running.
Implemented in driving_example::Driver, feedback_example::CruiseControl, driving_example::CruiseControl, elma::StateMachine, basic_example::BasicProcess, driving_example::Car, feedback_example::Car, microwave_example::Power, and toggle_switch_example::Trigger.
|
inline |
double elma::Process::milli_time | ( | ) |
The time since the last update in millisconds, as a double.
Definition at line 43 of file process.cc.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
pure virtual |
Start method. This method should be overridden by derived classes. It will be called just before the manager starts running. It may be called multiple times, if the manager is started and stopped.
Implemented in driving_example::Driver, driving_example::CruiseControl, feedback_example::CruiseControl, elma::StateMachine, microwave_example::Power, driving_example::Car, feedback_example::Car, basic_example::BasicProcess, and toggle_switch_example::Trigger.
|
inline |
|
inline |
|
pure virtual |
Stop method. This method should be overridden by derived classes. It will be called just after the manager stops running. It may be called multiple times, if the manager is started and stopped.
Implemented in driving_example::Driver, driving_example::CruiseControl, feedback_example::CruiseControl, elma::StateMachine, feedback_example::Car, driving_example::Car, microwave_example::Power, basic_example::BasicProcess, and toggle_switch_example::Trigger.
|
pure virtual |
Update method. This method should be overridden by derived classes. It will be called repeatedly by the manager at a frequency determined by the period used when the process is scheduled with the Manager (see Manager::schedule).
Implemented in driving_example::Driver, driving_example::CruiseControl, feedback_example::CruiseControl, elma::StateMachine, microwave_example::Power, driving_example::Car, feedback_example::Car, basic_example::BasicProcess, and toggle_switch_example::Trigger.