Main Page   Hardware Class Hierarchy   Hardware API     Mapping Class Hierarchy  Mapping API 

fsm.h

Go to the documentation of this file.
00001 /*
00002 DASI Library Copyright (C) 2004  Derek Jones
00003 This software is free for educational use only--no commercial use allowed.
00004 
00005 This library is  distributed in the hope that it will be useful,
00006 but WITHOUT ANY WARRANTY;  without even the implied warranty of
00007 MERCHANTABILITY or FITNESS FOR A  PARTICULAR PURPOSE.  
00008 
00009  * $Id: fsm.h,v 1.1.1.1 2006/05/11 05:22:39 derek Exp $
00010 */
00011 #ifndef FSM_H
00012 #define FSM_H
00013 //#include "events.h"
00014 #include <types.h> 
00015 using namespace std;
00016 // Finite State Machine Class 
00017 // FSM classes define set of valid states, in conjustion with EVENT valid events,
00018 //     and a transition map from:
00019 // (current state, current event) -> next state
00020 
00021 // Default States:
00022 //    ANY_STATE state is true for all states. (doh)
00023 //    ANY_EVENT event is true for all events.
00024 //    IDENTIY  nextstate signals to leave state in current state.
00025 //    NULL action performs no operation.
00026 // If you add a state, Sn,  be sure to 
00027 //    1) add a (state,event) combination that leads to state Sn; otherwise it should be the initial node (or is code that cannot be reached)
00028 //    2) add a (Sn,event) that leads out of state Sn; otherwise it is a terminal node.
00029 typedef short EVENT;
00030 #define ANY_EVENT 0
00031 enum STATE { ANY_STATE, IDENTITY };
00032 typedef void (*pfv)();
00033 
00034 // transition map State structure specifies:
00035 // 1. current state,
00036 // 2. current event,
00037 // 3. next state 
00038 // 4. action to perform on transition.
00039 class Transition_State
00040 {
00041 public:
00042 //  Drive_Transition_State();
00043   STATE currentState;
00044   EVENT currentEvent;   // sets current event.
00045   STATE nextState;
00046   pfv action;
00047 };
00048 
00049 class FSM
00050 {
00051 public:
00052   STATE NextState(EVENT);
00053   STATE NextState(void);
00054   STATE state(void) const;
00055   void event(EVENT);
00056 protected:
00057   FSM(void);
00058   int _max_state;
00059   Transition_State* _pStatemap;
00060   EVENT _CurrentEvent; 
00061   STATE _CurrentState; 
00062 };
00063 
00064 #endif

Generated on Mon Oct 8 19:32:18 2007 for OOMRM Mapping API by doxygen1.3