00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00028 #ifndef qep_h
00029 #define qep_h
00030
00037
00038 #include "qevent.h"
00039
00042 class QEP {
00043 public:
00049 static char const Q_ROM * Q_ROM_VAR getVersion(void);
00050 };
00051
00053
00055 typedef uint8_t QState;
00056
00058 typedef QState (*QStateHandler)(void *me, QEvent const *e);
00059
00060
00076 class QFsm {
00077 protected:
00078 QStateHandler m_state;
00079
00080 public:
00081
00093 void init(QEvent const *e = (QEvent *)0);
00094
00104 void dispatch(QEvent const *e);
00105
00106 protected:
00107
00119 QFsm(QStateHandler initial) : m_state(initial) {}
00120 };
00121
00136 class QHsm {
00137 protected:
00138 QStateHandler m_state;
00139
00140 public:
00141
00151 void init(QEvent const *e = (QEvent *)0);
00152
00162 void dispatch(QEvent const *e);
00163
00169 uint8_t isIn(QStateHandler state);
00170
00171 protected:
00172
00185 QHsm(QStateHandler initial) : m_state(initial) {}
00186
00194 static QState top(QHsm *me, QEvent const *e);
00195 };
00196
00199 #define Q_RET_IGNORED ((QState)1)
00200
00207 #define Q_IGNORED() (Q_RET_IGNORED)
00208
00211 #define Q_RET_HANDLED ((QState)0)
00212
00220 #define Q_HANDLED() (Q_RET_HANDLED)
00221
00224 #define Q_RET_TRAN ((QState)2)
00225
00230
00231 #define Q_TRAN(target_) \
00232 (me->m_state = (QStateHandler)(target_), Q_RET_TRAN)
00233
00236 #define Q_RET_SUPER ((QState)3)
00237
00241
00242 #define Q_SUPER(super_) \
00243 (me->m_state = (QStateHandler)(super_), Q_RET_SUPER)
00244
00245
00248 enum QReservedSignals {
00249 Q_ENTRY_SIG = 1,
00250 Q_EXIT_SIG,
00251 Q_INIT_SIG,
00252 Q_USER_SIG
00253 };
00254
00256
00257 #ifdef Q_SPY // QS software tracing enabled?
00258 #ifndef qs_h
00259 #include "qs_port.h"
00260 #endif // qs_h
00261
00262 #if (Q_SIGNAL_SIZE == 1)
00263
00267 #define QS_SIG_(sig_) QS::u8_(sig_)
00268 #elif (Q_SIGNAL_SIZE == 2)
00269 #define QS_SIG_(sig_) QS::u16_(sig_)
00270 #elif (Q_SIGNAL_SIZE == 4)
00271 #define QS_SIG_(sig_) QS::u32_(sig_)
00272 #endif
00273
00274 #else
00275 #ifndef qs_dummy_h
00276 #include "qs_dummy.h"
00277 #endif
00278 #endif // Q_SPY
00279
00280 #endif // qep_h