[erlang-questions] Hierarchical FSMs

Ulf Wiger <>
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.

BR,
Ulf W

Ulf Wiger
CTO, Erlang Solutions, Ltd
http://www.erlang-solutions.com

Avinash Dhumane <> wrote:

>Both gen_fsm and plain_fsm appear to support only "flat", and not hierarchical, 
>FSMs.
>
>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 <>
>To: Avinash Dhumane <>
>Cc: 
>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).
>
>Dan.
>
>
>On Fri, Jun 17, 2011 at 9:48 PM, Avinash Dhumane <> 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)?
>> 
>>Thanks
>>Avinash
>>_______________________________________________
>>erlang-questions mailing list
>>
>>http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>
>
>-- 
>Daniel Goertzen
>-----------------
> (work)
> (home)
>-----------------
>1 204 272 6149 (home/office)
>1 204 470 8360 (mobile)
>-----------------
>_______________________________________________
>erlang-questions mailing list
>
>http://erlang.org/mailman/listinfo/erlang-questions


More information about the erlang-questions mailing list