Comments (4)
No, I'm not saying TinyFSM is for deterministic FSM only. By using the bool is_in_state<S>()
or S & state()
functions, or by manipulating current_state_ptr
you have all means to make it non-deterministic.
My goal is to keep it "as simple as possible", and adding additional comfort functions like transitIfNotIn<S>()
contradicts to this paradigm, as this functionality is already available by using is_in_state
as described above (which comes with no performance penalty).
Actually, it would be nice to have a simple, meaningful example in TinyFSM which operates non-deterministic.
from tinyfsm.
I don't think this makes sense, as it would break the state machine rules: a transition always exits the current state, then enters the new state (that's why you draw an arrow for self transitions).
Can't you just handle the NoWifiEvent
differently in LostWifiState
:
class LostWifiState
: public MyWifiFsm
{
void react(NoWifiEvent const &) override { };
}
If you really want to break the rules, you could still use:
virtual void react(NoWifiEvent const &) {
if(!is_in_state<LostWifiState>())
transit<LostWifiState>();
}
from tinyfsm.
You are right, that it it possible to model the automata in a fully deterministic way (like in https://en.wikipedia.org/wiki/Finite-state_machine#Determinism).
In my usecase I'm forwarding the wifi state as an event to the FSM, so it is called in every loop cycle. It saves quite some OPs to not enter and exit this state (and the event can be handled in a non virtual function, so no vtable lookop on top).
The transitIfNotIn
allows me to model a non-deterministic automata with no state change for the same event.
If you say, tinyfsm is for deterministic FSM then it would be a bad idea to add it of course.
from tinyfsm.
Makes sense :)
from tinyfsm.
Related Issues (20)
- Passing data into the State machine. HOT 2
- Events double dispatching support HOT 3
- Should FSM_INITIAL_STATE call entry? HOT 1
- Is it possible to query the current state of the State Machine? HOT 4
- How do you pass a SM to a function? HOT 1
- non virtual destructor HOT 3
- State update loop HOT 4
- Linking error HOT 3
- Not able to compile with IAR ARM v8.20.2 HOT 2
- size on Mac doesn't support -B flag HOT 1
- calling dispatch() before start() throws unhandled exception with read access violation HOT 2
- any plan for latest tag release ? HOT 4
- Doesn't compile when debug information is enabled. HOT 2
- How to separate state classes from the state machine class?
- Is it possible to set initial state (at runtime) to something which is different from what was passed in FSM_INITIAL_STATE? HOT 1
- is it possible to instantiate multiple Elevators classes, using the same elevator.hpp and .cpp? HOT 3
- connecting IO class with Tiny FSM HOT 2
- Testing tinyFSM state machines with VectorCAST?
- Calling dispatch() and/or transit() from action function HOT 3
- Handle multiple FSMs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinyfsm.