Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::EventCounter Class Reference

Helper class to count how many events are sent to the topic(s) it is registered to. More...

#include <EventCounter.h>

Inheritance diagram for Boardcore::EventCounter:
Collaboration diagram for Boardcore::EventCounter:

Public Member Functions

 EventCounter (EventBroker &broker)
 Construct a new Event Counter object.
 
 ~EventCounter ()
 
void subscribe (uint8_t topic)
 Subscribes to a topic in the EventBroker.
 
void postEvent (const Event &ev) override
 
unsigned int getCount (const Event &ev)
 Returns the number of times a specific event has been received.
 
unsigned int getTotalCount ()
 Returns how many events have been received in total.
 
uint8_t getLastEvent ()
 Returns the signature of the last event received (ev)
 
- Public Member Functions inherited from Boardcore::EventHandler
 EventHandler (unsigned int stacksize=miosix::STACK_DEFAULT_FOR_PTHREAD, miosix::Priority priority=miosix::MAIN_PRIORITY)
 
virtual ~EventHandler ()
 
void postEvent (const Event &ev) override
 
void stop () override
 Signals the runner thread to terminate and joins the thread.
 
- Public Member Functions inherited from Boardcore::EventHandlerBase
 EventHandlerBase ()
 
virtual ~EventHandlerBase ()
 
- Public Member Functions inherited from Boardcore::ActiveObject
 ActiveObject (unsigned int stacksize=miosix::STACK_DEFAULT_FOR_PTHREAD, miosix::Priority priority=miosix::MAIN_PRIORITY)
 
virtual ~ActiveObject ()
 
virtual bool start ()
 Start the thread associated with this active object.
 
bool isRunning ()
 

Protected Member Functions

void handleEvent (const Event &ev __attribute__((unused))) override
 
- Protected Member Functions inherited from Boardcore::EventHandler
virtual void handleEvent (const Event &ev)=0
 
void run () override
 
- Protected Member Functions inherited from Boardcore::ActiveObject
bool shouldStop ()
 Tells whether or not the ActiveObject should stop its execution.
 

Additional Inherited Members

- Protected Attributes inherited from Boardcore::EventHandler
SynchronizedQueue< EventeventList
 
- Protected Attributes inherited from Boardcore::ActiveObject
miosix::Thread * thread = nullptr
 Gives access to the thread object.
 
std::atomic< bool > stopFlag {false}
 
std::atomic< bool > running {false}
 

Detailed Description

Helper class to count how many events are sent to the topic(s) it is registered to.

Useful if you want to check wether or not events are being effectively posted

Definition at line 38 of file EventCounter.h.

Constructor & Destructor Documentation

◆ EventCounter()

Boardcore::EventCounter::EventCounter ( EventBroker & broker)
inline

Construct a new Event Counter object.

Parameters
brokerEventBroker to listen events to

Definition at line 46 of file EventCounter.h.

◆ ~EventCounter()

Boardcore::EventCounter::~EventCounter ( )
inline

Definition at line 48 of file EventCounter.h.

Member Function Documentation

◆ getCount()

unsigned int Boardcore::EventCounter::getCount ( const Event & ev)
inline

Returns the number of times a specific event has been received.

Definition at line 72 of file EventCounter.h.

◆ getLastEvent()

uint8_t Boardcore::EventCounter::getLastEvent ( )
inline

Returns the signature of the last event received (ev)

Definition at line 90 of file EventCounter.h.

◆ getTotalCount()

unsigned int Boardcore::EventCounter::getTotalCount ( )
inline

Returns how many events have been received in total.

Definition at line 85 of file EventCounter.h.

◆ handleEvent()

void Boardcore::EventCounter::handleEvent ( const Event &ev __attribute__(unused))
inlineoverrideprotected

Definition at line 94 of file EventCounter.h.

◆ postEvent()

void Boardcore::EventCounter::postEvent ( const Event & ev)
inlineoverridevirtual

Implements Boardcore::EventHandlerBase.

Definition at line 59 of file EventCounter.h.

◆ subscribe()

void Boardcore::EventCounter::subscribe ( uint8_t topic)
inline

Subscribes to a topic in the EventBroker.

Parameters
topic

Definition at line 55 of file EventCounter.h.


The documentation for this class was generated from the following file: