Main Page | Modules | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

Module Class Reference
[Module manager facilities]

#include <ModuleManager.hh>

Inherited by AnalogOutput, APModule, CommModule, DataLogger, DBModule, EncoderReader, Filter, LogServer, ModeSupervisor, MotorControl, MsgLogModule, SerialPort, SpeedFilter, StallSensor, and StateMachine.

List of all members.


Detailed Description

Interface class for periodic tasks.

The Module abstract base class is used to encapsulate periodic tasks within a control system. This can be done by derived classes defining five methods Module::init, Module::uninit, Module::activate, Module::deactivate and Module::update.

The Module Manager is responsible from maintaining a database of modules currently known to the system, each uniquely identified by the combination of a string name and an integer index, specified during construction. Furthermore, the execution properties of a module are specified by three parameters, the period, the offset and the order, which are set when the module is added into the ModuleManager's database.

ModuleLifeCycle.gif

Life cycle of a module

At any given time, a module can be in one of three states: UNINIT, INACTIVE, ACTIVE (see Figure). All newly created modules are in the UNINIT state. Once the module is added into the module manager's database, it becomes INACTIVE and stays idle. When it is in the ACTIVE state, however, the module's update method gets called periodically until explicitly deactivated. Module states can only be changed indirectly through the module manager's utility functions.


Public Types

enum  ModuleState { UNINIT, INACTIVE, ACTIVE }

Public Member Functions

 Module (char *name, int index, bool singleUser)
char * getName (void)
int getIndex (void)
ModuleState getState (void)
MM_STEP getPeriod (void)
MM_STEP getOffset (void)
int getOrder (void)
ModulegetOwner (void)
bool isSingleUser (void)
virtual void init (void)=0
virtual void uninit (void)=0
virtual void activate (void)=0
virtual void deactivate (void)=0
virtual void update (void)=0
virtual bool updateable ()

Public Attributes

double max_offset
double min_offset
double cum_offset
double max_exec_time
double min_exec_time
double cum_exec_time
double max_act_time
double min_act_time
double cum_act_time
long num_updates
long num_activates

Protected Member Functions

void setName (char *str)


Constructor & Destructor Documentation

Module::Module char *  name,
int  index,
bool  singleUser
 

Inherited classes must call the Module class constructor to set the name and index of the module instance. The singleUser is a configuraion flag which determines whether this module can be used (grabbed) by more than one other module


Member Function Documentation

virtual void Module::activate void   )  [pure virtual]
 

This method is called when the module manager receives a request to activate a module object. Following activation, the module manager will start scheduling the calls to the Module::update method. Usually, this method grabs necessary for module updates and performs final steps before activation. Derived classes must provide an implementation.

virtual void Module::deactivate void   )  [pure virtual]
 

This method is called when the module manager receives a request to deactivate a module object. When deactivated, the module's update function will no longer be called. This method is expected to release any resources held by the module and perform cleanup following deactivation. Derived classes must provide an implementation.

int Module::getIndex void   )  [inline]
 

This method returns the index of the module instance. The index of the module, in conjunction with its name, is used to uniquely identify the module in the module manager's database.

char* Module::getName void   )  [inline]
 

This method returns the name of the module instance. The name of the module, in conjunction with its index, is used to uniquely identify the module in the module manager's database.

MM_STEP Module::getOffset void   )  [inline]
 

This method returns the current offset setting of the module.

int Module::getOrder void   )  [inline]
 

This method returns the current order setting of the module.

MM_STEP Module::getPeriod void   )  [inline]
 

This method returns the current period setting of the module.

ModuleState Module::getState void   )  [inline]
 

This method returns the current state of the module.

virtual void Module::init void   )  [pure virtual]
 

This method is called by the module manager when a module is added to the module manager's database. Usually, it is only called once and is expected to initialize internal data and configuration and prepare the module for activation. Derived classes must provide an implementation.

virtual void Module::uninit void   )  [pure virtual]
 

This method is called by the module manager when a module is removed from the module manager's database. Usually, it is only called once and is expected to perform cleanup. The module instance will be destroyed following the call to this method. Derived classes must provide an implementation.

virtual void Module::update void   )  [pure virtual]
 

This method defines the task that the module represents. It is periodically called by the module manager based on the scheduling parameters specified at the time the module is added to the system. Derived classes must provide an implementation.


RHexLib Reference Documentation