thomasquintana / declarative-fsm

A Python declarative finite state machine.
Apache License 2.0
43 stars 10 forks source link

Support for nested states? #5

Closed fkromer closed 4 months ago

fkromer commented 8 years ago

I did not find any code which seems to handle "declaratives" for nested states. Is it possible to implement Hierarchical State Machines (HSMs) = FSM with nested states with this package somehow?

IuryAlves commented 8 years ago

Interesting! I didn't know about the existence of HSMs.

What are the conditions to enter the inner state ?

@fkromer

fkromer commented 8 years ago

HSMs or NFSMs (Nested Finite State Machines) are common in the domain of embedded systems (some example in C++). In other domains it seems like it is not that often required as i did not find an hierachical implementation example of the state pattern. There is a question on stackoverflow addressing this problem in Ruby (similar scripting language) which has not been solved for a year.

The conditions to enter inner states are application dependent. Events with or without guard condition checking can trigger a transition from one to another state. The challange with HSMs is to manage the transitions because they should be define-able beteen states in every hierarchie level (e.e. state "1.1" -> state "1.2" in the same superstate "1", state "1.1" in superstate "1" -> state "2.1" in superstate "2", etc.). The same should to be considered for entry actions and exit actions.

The UML extensions to the traditional FSM formalism is good further reading...

IuryAlves commented 8 years ago

I am not a developer of this repo, but i will give a look in nested states.

thomasquintana commented 8 years ago

Hey guys,

I apologize for not providing feedback sooner, I have been really pressed for time working on a project with a short deadline. I will spend sometime on this in the next couple of days and update the thread but from a quick gloss over I have some ideas I want to run by you guys.

fkromer commented 8 years ago

Last weekend i tried to implement the C++ HSM example in python but i was not able to get it done completely. I could provide the stuff i came up till now with you guys. Just let me know how i can contribute/provide it to you. Another source for further reading is this python package supporting nested states.