00001
00033
00034 #ifndef simplehsmH
00035 #define simplehsmH
00036
00037
00038
00039
00040
00041
00042 #ifndef BOOL
00043 typedef int BOOL;
00044 #endif
00045 #ifndef FALSE
00046 #define FALSE 0
00047 #endif
00048 #ifndef TRUE
00049 #define TRUE 1
00050 #endif
00051
00055 enum simplehsm_signals_t
00056 {
00057 SIG_NULL = 0,
00058 SIG_INIT = 1,
00059 SIG_ENTRY = 2,
00060 #ifdef SHSM_DEEPHIST
00061 SIG_DEEPHIST = 3,
00062 #endif
00063 SIG_EXIT = 4,
00064 SIG_USER = 5,
00065 };
00066
00067
00068
00069
00070
00075 #define stnone NULL
00076
00077 #ifdef SHSM_DEEPHIST
00078
00082 #define stdeephist NULL
00083 #endif
00084
00088 typedef void* stnext;
00089
00095 typedef stnext (*stfunc)(int, void*);
00096
00097 #ifdef SHSM_DEEPHIST
00098
00101 #define MAX_HISTORY 10
00102 #endif
00103
00107 typedef struct
00108 {
00109 stfunc current_state;
00110 stfunc top_state;
00111 #ifdef SHSM_DEEPHIST
00112 stfunc deep_history_parent[MAX_HISTORY];
00113 stfunc deep_history_state[MAX_HISTORY];
00114 #endif
00115 } simplehsm_t;
00116
00117
00118
00119
00120
00121 void simplehsm_initialize(simplehsm_t* hsm, stfunc top_state);
00122 #ifdef SHSM_DEEPHIST
00123 void simplehsm_transition_state_ex(simplehsm_t* hsm, stfunc new_state, BOOL to_deep_hist);
00124 #endif
00125 void simplehsm_transition_state(simplehsm_t* hsm, stfunc new_state);
00126 void simplehsm_init_transition_state(simplehsm_t* hsm, stfunc new_state);
00127 void simplehsm_signal_current_state(simplehsm_t* hsm, int signal, void* param);
00128 BOOL simplehsm_is_in_state(simplehsm_t* hsm, stfunc state);
00129 #ifdef SHSM_DEEPHIST
00130 void simplehsm_record_deephist(simplehsm_t* hsm, stfunc history_parent, stfunc history_state);
00131 stfunc simplehsm_retrieve_deephist(simplehsm_t* hsm, stfunc history_parent);
00132 #endif
00133
00134
00135 #endif //simplehsmH