[erlang-questions] Hierarchical FSMs

Ulf Wiger ulf.wiger@REDACTED
Sat Jun 18 19:21:03 CEST 2011

It is true that hierarchical state machines are not that common in Erlang. One reason is that erlang's lightweight processes make it easier to split fsms into multiple, smaller fsms, and another is that erlang's selective semantics help to "hide" much of the state-event matrix, simplifying the fsm.

That said, it can be useful with hierarchical state machines sometimes. What one can do is model the subordinate fsms after gen_fsm, but keeping the state as a parameter in the enclosing fsm. If you keep the mapping faithful enough, you can test the subordinate fsm as a real gen_fsm. Only a little care is needed to ensure that the code can work well in both modes.

Ulf W

Ulf Wiger
CTO, Erlang Solutions, Ltd

Avinash Dhumane <avinash@REDACTED> wrote:

>Both gen_fsm and plain_fsm appear to support only "flat", and not hierarchical, 
>Maybe, the mental model of hierarchical FSMs has basic impedance mismatch with 
>Erlang's view of the world - "everything is a process". 
>I need to see "processes" rather than events and states of "objects" in the 
>problem domain.
>Thanks by all means!
>From: Daniel Goertzen <dang@REDACTED>
>To: Avinash Dhumane <avinash@REDACTED>
>Cc: erlang-questions@REDACTED
>Sent: Sat, 18 June, 2011 8:29:45 AM
>Subject: Re: [erlang-questions] Hierarchical FSMs
>Take a look at plain_fsm (not part of OTP).
>On Fri, Jun 17, 2011 at 9:48 PM, Avinash Dhumane <avinash@REDACTED> wrote:
>I'm new entrant in Erlang's world, and have read only Joe's thesis so far, and 
>I'm not a programmer :-(
>>How to realise (implement) FSMs organised as state (superstate, substate) and 
>>event (superevent, subevent) hierarchies using gen_fsm? I see these hierarchies 
>>in dynamic models of Rumbaugh OMT.
>>Thoughts, or a quick example (code)?
>>erlang-questions mailing list
>Daniel Goertzen
>dang@REDACTED (work)
>daniel.goertzen@REDACTED (home)
>1 204 272 6149 (home/office)
>1 204 470 8360 (mobile)
>erlang-questions mailing list

More information about the erlang-questions mailing list