pysm icon indicating copy to clipboard operation
pysm copied to clipboard

Entry event on initialization

Open dralex opened this issue 2 years ago • 1 comments

I've started using the pysm implementation of HSM and found interesting issue: the 'entry' handler is not called on initialization (for the initial states). According to this doc https://www.state-machine.com/doc/AN_Crash_Course_in_UML_State_Machines.pdf and the Quantum Leaps initialization the entry should be called while state is initial.

Imagine that the "Complex hierarchical state machine" example has entry program for the states s0, s1, and s11 like "print(state)". During the SM initialization we should get the prints "s0", "s1", "s11".

Is it possible to implement this feature? As I understand the initialize method could be slightly modified.

Right now I have to add an additional state like "initial state" and the explicit transition between this state and the proper initial state (e.g. s11) to make the entries work as it should.

dralex avatar Apr 30 '23 14:04 dralex

@dralex - I've added this feature to a fork of this repo. See: https://github.com/Simplexity-Product-Development/pysm

doug-harriman avatar Mar 10 '24 02:03 doug-harriman