Saltware / Mbed 2 deprecated Water Play

Dependencies:   mbed DRV88255 TextLCD Ping mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Controller Class Reference

The base class for everything which interfaces with sensors or actuators. More...

#include <Controller.h>

Inherited by PIDController, SensorAlarmController, and SensorController.

Public Member Functions

 Controller (bool threaded, int interval_ms)
 Initializes the Controller.
virtual std::string getName ()=0
 Returns the name of this Controller.
bool isThreaded ()
 Returns whether or not this Controller is being threaded.
void run ()
 If this Controller is not threaded, update() is called.
int getIntervalMs ()
 Returns the interval between each iteration if threaded.
void setPriority (osPriority priority)
 Sets the underlying RTOS thread priority.
osPriority getPriority ()
 Returns the thread priority.

Protected Member Functions

virtual void update ()=0
 Updates the Controller.

Protected Attributes

unsigned long num_iters
 The number of times run() is called.

Detailed Description

The base class for everything which interfaces with sensors or actuators.

Extending classes must implement std::string getName() and void update()

Definition at line 11 of file Controller.h.


Constructor & Destructor Documentation

Controller ( bool  threaded = false,
int  interval_ms = 0 
)

Initializes the Controller.

Parameters:
threadedwhether or not the controller should be threaded.
interval_msdelay between each iteration, only if threaded is set to true.

Definition at line 5 of file Controller.cpp.


Member Function Documentation

int getIntervalMs (  )

Returns the interval between each iteration if threaded.

Returns:
interval_ms as specified in the constructor.

Definition at line 29 of file Controller.cpp.

virtual std::string getName (  ) [pure virtual]

Returns the name of this Controller.

Must be implemented by extending classes.

Returns:
The name of this Controller.

Implemented in SensorAlarmController, and TemperatureController.

osPriority getPriority (  )

Returns the thread priority.

Returns:
the thread priority.

Definition at line 39 of file Controller.cpp.

bool isThreaded (  )

Returns whether or not this Controller is being threaded.

Returns:
true if this Controller is being threaded, false otherwise.

Definition at line 13 of file Controller.cpp.

void run (  )

If this Controller is not threaded, update() is called.

Otherwise, the first time a thread is spawned which repeatedly calls update(). When the thread has already been spawned no action is taken.

Definition at line 17 of file Controller.cpp.

void setPriority ( osPriority  priority )

Sets the underlying RTOS thread priority.

See also:
cmis_os.h

Definition at line 33 of file Controller.cpp.

virtual void update (  ) [protected, pure virtual]

Updates the Controller.

This is called once every interval_ms if threaded is set to true.

Implemented in SensorAlarmController, and TemperatureController.


Field Documentation

unsigned long num_iters [protected]

The number of times run() is called.

Definition at line 66 of file Controller.h.