TRC Library for FRC (2011) 2011
TRC Library Code Project

StateMachine Class Reference

#include <StateMachine.h>

List of all members.

Public Member Functions

 StateMachine (void)
 ~StateMachine (void)
void Start (__in UINT32 state=SMSTATE_STARTED)
void Stop (void)
bool IsEnabled (void)
bool IsReady (void)
UINT32 GetCurrentState (void)
void ClearAllEvents (void)
bool WaitForEvents (__in Event **pEvents, __in UINT32 cEvents, __in UINT32 nextState, __in UINT32 flags)

Detailed Description

This class defines and implements the StateMachine object.

Definition at line 41 of file StateMachine.h.


Constructor & Destructor Documentation

StateMachine::StateMachine ( void  ) [inline]

Constructor: Create an instance of the StateMachine object. It initializes the state machine to disabled mode.

Definition at line 55 of file StateMachine.h.

StateMachine::~StateMachine ( void  ) [inline]

Destructor: Destroy an instance of the StateMachine object.

Definition at line 71 of file StateMachine.h.


Member Function Documentation

void StateMachine::ClearAllEvents ( void  ) [inline]

This function is called to clear all events.

Definition at line 225 of file StateMachine.h.

UINT32 StateMachine::GetCurrentState ( void  ) [inline]

This function is called to get the current state of the state machine.

Returns:
Returns the current state of the state machine.

Definition at line 211 of file StateMachine.h.

bool StateMachine::IsEnabled ( void  ) [inline]

This function is called to check if the state machine is enabled.

Returns:
Returns true if the state machine is enabled, false otherwise.

Definition at line 128 of file StateMachine.h.

bool StateMachine::IsReady ( void  ) [inline]

This function is called periodically when processing the state machine. It checks if the state machine is enabled and ready. If the state machine is enabled but not ready, it will check if all the events it is waiting for are signaled. If so, the state machine is advanced to the next state and transitioned to ready state. If the state machine is enabled and in ready state, the caller will perform the task according to the current state. The task usually involves initiating the next operation and waits for it to complete. While it is waiting, the state machine will be put back in non-ready state.

Returns:
Returns true if the state machine is ready, false otherwise.

Definition at line 153 of file StateMachine.h.

void StateMachine::Start ( __in UINT32  state = SMSTATE_STARTED) [inline]

This function is called to start the state machine.

Parameters:
stateOptionally specifies the initial state to start in.

Definition at line 86 of file StateMachine.h.

void StateMachine::Stop ( void  ) [inline]

This function is called to stop the state machine.

Definition at line 106 of file StateMachine.h.

bool StateMachine::WaitForEvents ( __in Event **  pEvents,
__in UINT32  cEvents,
__in UINT32  nextState,
__in UINT32  flags 
) [inline]

This function specfies an array of events to wait for and sets the state machine to waiting state.

Parameters:
pEventsPoints to the array of event object pointers to wait for.
cEventsSpecifies the number of event pointers in the array.
nextStateSpecifies the next state to advance to once the event(s) occurred.
flagsSpecifies the option flags of the wait. If the SMF_WAIT_ALL flag is set, all the events in the array must be in signaled state before the state machine will move on to the next state. Otherwise, the state machine will advance to the next state if any one of the events is signaled.
Returns:
Success: returns true. Failure: returns false.

Definition at line 257 of file StateMachine.h.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Defines