diff options
author | Julian Oes <julian@oes.ch> | 2014-05-27 21:56:32 +0200 |
---|---|---|
committer | Julian Oes <julian@oes.ch> | 2014-05-27 21:56:32 +0200 |
commit | ed6c2a5168ca891f20594687acfd3c6bbf7e1cf9 (patch) | |
tree | b71c7b12719a3d4535615aee2cf95a034bc87b13 /src/modules/systemlib | |
parent | 063caba36bd2fe26eb4bfa8e546e9551ccc05519 (diff) | |
download | px4-firmware-ed6c2a5168ca891f20594687acfd3c6bbf7e1cf9.tar.gz px4-firmware-ed6c2a5168ca891f20594687acfd3c6bbf7e1cf9.tar.bz2 px4-firmware-ed6c2a5168ca891f20594687acfd3c6bbf7e1cf9.zip |
commander and navigator: lot's of changes, failsafe handling in commander, navigator only for execution (WIP)
Diffstat (limited to 'src/modules/systemlib')
-rw-r--r-- | src/modules/systemlib/state_table.h | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/modules/systemlib/state_table.h b/src/modules/systemlib/state_table.h index 38378651b..e6011fdef 100644 --- a/src/modules/systemlib/state_table.h +++ b/src/modules/systemlib/state_table.h @@ -33,7 +33,7 @@ /** * @file state_table.h - * + * * Finite-State-Machine helper class for state table * @author: Julian Oes <julian@oes.ch> */ @@ -44,32 +44,32 @@ class StateTable { public: - typedef bool (StateTable::*Action)(); + typedef void (StateTable::*Action)(); struct Tran { Action action; unsigned nextState; }; - + StateTable(Tran const *table, unsigned nStates, unsigned nSignals) : myTable(table), myNsignals(nSignals), myNstates(nStates) {} - + #define NO_ACTION &StateTable::doNothing #define ACTION(_target) StateTable::Action(_target) virtual ~StateTable() {} - + void dispatch(unsigned const sig) { /* get transition using state table */ Tran const *t = myTable + myState*myNsignals + sig; - /* first up change state, this allows to do further dispatchs in the state functions */ - - /* now execute state function, if it runs with success, accept new state */ - if ((this->*(t->action))()) { - myState = t->nextState; - } + + /* accept new state */ + myState = t->nextState; + + /* */ + (this->*(t->action))(); } - bool doNothing() { - return true; + void doNothing() { + return; } protected: unsigned myState; @@ -79,4 +79,4 @@ private: unsigned myNstates; }; -#endif
\ No newline at end of file +#endif |