rtmlib
Classes | Public Member Functions | Protected Member Functions | Private Types | Static Private Member Functions | Private Attributes | List of all members
RTML_monitor Class Referenceabstract

#include <periodicmonitor.h>

Classes

struct  Monitor_state
 

Public Member Functions

 RTML_monitor (const useconds_t period)
 
 RTML_monitor (const useconds_t period, unsigned int policy, unsigned int priority)
 
int enable ()
 
int disable ()
 
bool isRunning () const
 
const useconds_t & getPeriod () const
 
void setPeriod (const useconds_t &p)
 

Protected Member Functions

virtual void run ()=0
 

Private Types

enum  mon_status {
  ACTIVATION, RUNNING, DELAY, ABORT,
  ABORTED, UNACTIVATE
}
 

Static Private Member Functions

static void * loop (void *)
 

Private Attributes

pthread_t thread
 
struct RTML_monitor::Monitor_state m_state
 

Detailed Description

Periodic monitor.

This class implements a periodic monitor that can execute with the system tasks using a Posix-compliant interface. The monitoring task is seen like any other task in the system.

Warning
The function pointer for the monitor body must be assigned before activating the periodic monitor, failure to do so will result in undefined behavior.
Author
André Pedro
Date

Member Enumeration Documentation

◆ mon_status

Enumeration type for monitor status.

Enumerator
ACTIVATION 
RUNNING 
DELAY 
ABORT 
ABORTED 
UNACTIVATE 

Constructor & Destructor Documentation

◆ RTML_monitor() [1/2]

RTML_monitor::RTML_monitor ( const useconds_t  period)

Instantiates a new monitor with a given period.

The schedule policy will be SCHED_OTHER with priority 0.

Parameters
periodthe monitors period.

◆ RTML_monitor() [2/2]

RTML_monitor::RTML_monitor ( const useconds_t  period,
unsigned int  policy,
unsigned int  priority 
)

Instantiates a new monitor with a given period, a schedule policy and a priority.

Parameters
periodthe RTML_monitor period.
policythe posix schedule policy for this monitor.
prioritythe priority for this RTML_monitor.

Member Function Documentation

◆ disable()

int RTML_monitor::disable ( )

Disables the monitor

Parameters
fthe function to start the thread with.

◆ enable()

int RTML_monitor::enable ( )

Enables the monitor

◆ getPeriod()

const useconds_t & RTML_monitor::getPeriod ( ) const

Gets the period.

Returns
the monitor period.

◆ isRunning()

bool RTML_monitor::isRunning ( ) const

Checks whether this RTML_monitor is running.

Returns
true if the monitor is running.

◆ loop()

void * RTML_monitor::loop ( void *  ptr)
staticprivate

A function pointer for the monitor body. The body content is executed in the run loop and there is also synchronization and deadline miss detection there.

Parameters
ptrpointer to the monitor to be executed.

◆ run()

virtual void RTML_monitor::run ( )
protectedpure virtual

The monitor execution control body.

Users should overwrite this function with their monitoring function. It will be called periodically as defined by the users scheduling policy.

◆ setPeriod()

void RTML_monitor::setPeriod ( const useconds_t &  p)

Sets new monitor period.

Member Data Documentation

◆ m_state

struct RTML_monitor::Monitor_state RTML_monitor::m_state
private

◆ thread

pthread_t RTML_monitor::thread
private

Points to the monitor thread in the OS.


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