Eaagles::Basic::LcStMach Class Reference

Inherits Eaagles::Basic::LcComponent.

Inheritance diagram for Eaagles::Basic::LcStMach:

Inheritance graph
[legend]
Collaboration diagram for Eaagles::Basic::LcStMach:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 LcStMach (LcObject *userValue)
 LcStMach ()
int state () const
int substate () const
void reqState (const int newState)
void setStateTable (StateEntry table[], const int numEntries)
void setBeforeProc (StMachProc procName)
void setAfterProc (StMachProc procName)
void call (const int newState)
void rtn ()
void jump (const int newState, const int newSubstate=0)
int next ()
int goSubstate (const int newSubstate)
int hold () const
bool lock (const bool flg)
int findState (const int state)
virtual void updateTC (const LCreal dt=0.0f)
virtual void reset ()

Static Public Attributes

static const unsigned int STACK_SIZE = 10
static const int INVALID_STATE = -1
static const int RESET_STATE = 0

Private Attributes

LcObjectthisValue
StMachProc beforeProc
StMachProc afterProc
StateEntrystateTable
int stateTableSize
int cstate
int csubstate
int reqstate
int stateStack [STACK_SIZE]
int substateStack [STACK_SIZE]
int sp

Classes

struct  StateEntry

Detailed Description

        State Machine; various instances of state machines are used
                 to control the sequencing of events, modes, and submodes
                 throughout the radar simulation.  All state machines 
                 contain a state table that identifies the procedure
                 that is to be called for each state.  All state values must be
                 greater than or equal zero.  All state tables must use
                 state zero as the RESET_STATE.

                 A state is defined by the current state number, 'state',
                 and a substate number, 'substate'.  Routines may use
                 state() and substate() to get the current values
                 of 'state' and 'substate'.

                 Routines may use reqState() to request that the state machine
                 switch to a given state.  The sequencer will switch states
                 during the next iteration unless the locked flag for the
                 current state is true.  Reset() may be used to reset the
                 state machine to the RESET_STATE state.

                 A state table will contain one or more StateEntry(s).
                 A StateEntry consists of a state number, state procedure,
                 and locked flag.  Whenever the current state number matches
                 the StatEntry's state number, the corresponding state
                 procedure is called.  The locked flag is used to inhibit
                 the switching from the current state to the requested state.
                 The locked flag can be controlled by lock().

                 State procedues may use various member functions to control
                 the sequencing from one state to the next: reset(), jump(),
                 call(), rtn(), next(), goSubstate(), hold(), and lock().
                 These functions should only be used by the state procedues.
                 External routines that control the state machine should only
                 use reqState() and reset() to control the state machine.  
    


Constructor & Destructor Documentation

Eaagles::Basic::LcStMach::LcStMach ( LcObject userValue  ) 

Constructor: where 'userValue' is an item that is passed to all user provided, StMachProc type procedures. The userValue is not duplicated; only a pointer to the original values is kept.

Eaagles::Basic::LcStMach::LcStMach (  ) 


Member Function Documentation

int Eaagles::Basic::LcStMach::state (  )  const

Returns the current state number.

int Eaagles::Basic::LcStMach::substate (  )  const

Returns the current substate number.

void Eaagles::Basic::LcStMach::reqState ( const int  newState  ) 

Requests the state machine to goto state, 'newState'.

void Eaagles::Basic::LcStMach::setStateTable ( StateEntry  table[],
const int  numEntries 
)

Defines the state table used by this state machine.

void Eaagles::Basic::LcStMach::setBeforeProc ( StMachProc  procName  ) 

Sets the address of a procedure that is called BEFORE the current state dependent procedure. This is useful in handling things that are common to all states.

void Eaagles::Basic::LcStMach::setAfterProc ( StMachProc  procName  ) 

Sets the address of a procedure that is called AFTER the current state dependent procedure. This is useful in handling things that are common to all states.

void Eaagles::Basic::LcStMach::call ( const int  newState  ) 

Pushes the current state and the next substate on to the stack and jumps to the new state, 'newState', at substate zero.

void Eaagles::Basic::LcStMach::rtn (  ) 

Pops the state/substate off the stack.

void Eaagles::Basic::LcStMach::jump ( const int  newState,
const int  newSubstate = 0 
)

Jump to state 'newStates' substate 'newSubstate'; or state newStates' substate zero.

int Eaagles::Basic::LcStMach::next (  ) 

Sequence to the next substate in the current state; the new substate number is returned.

int Eaagles::Basic::LcStMach::goSubstate ( const int  newSubstate  ) 

Go to substate 'newSubstate'; the new substate number is returned.

int Eaagles::Basic::LcStMach::hold (  )  const

Maintain current state/substate; the current substate number is returned.

bool Eaagles::Basic::LcStMach::lock ( const bool  flg  ) 

Sets/clears the value of the locked flag in the state table. Returns the old value of the lock flag.

int Eaagles::Basic::LcStMach::findState ( const int  state  ) 

Returns the state table index of state 'state'. Returns -1 if 's' is not found in the table.

void Eaagles::Basic::LcStMach::updateTC ( const LCreal  dt = 0.0f  )  [virtual]

LcComponent interface. Updates the state machine.

Reimplemented from Eaagles::Basic::LcComponent.

void Eaagles::Basic::LcStMach::reset (  )  [virtual]

Resets the state machine to state zero.

Reimplemented from Eaagles::Basic::LcComponent.


Member Data Documentation

const unsigned int Eaagles::Basic::LcStMach::STACK_SIZE = 10 [static]

const int Eaagles::Basic::LcStMach::INVALID_STATE = -1 [static]

const int Eaagles::Basic::LcStMach::RESET_STATE = 0 [static]

LcObject* Eaagles::Basic::LcStMach::thisValue [private]

User value.

StMachProc Eaagles::Basic::LcStMach::beforeProc [private]

Address of a procedure called before the current state procedure.

StMachProc Eaagles::Basic::LcStMach::afterProc [private]

Address of a procedure called after the current state procedure.

StateEntry* Eaagles::Basic::LcStMach::stateTable [private]

Points to the state table.

int Eaagles::Basic::LcStMach::stateTableSize [private]

Number of entries in table.

int Eaagles::Basic::LcStMach::cstate [private]

Current state number.

int Eaagles::Basic::LcStMach::csubstate [private]

Current substate number.

int Eaagles::Basic::LcStMach::reqstate [private]

Requested state number.

int Eaagles::Basic::LcStMach::stateStack[STACK_SIZE] [private]

State number stack.

int Eaagles::Basic::LcStMach::substateStack[STACK_SIZE] [private]

Substate stack.

int Eaagles::Basic::LcStMach::sp [private]

Stack pointer.


Generated on Tue Dec 19 16:26:26 2006 for Eaagles by  doxygen 1.5.0