DavidDurman / statechart

Statechart implementation in JavaScript
MIT License
100 stars 16 forks source link

Orthogonal regions example? #5

Closed noah closed 10 years ago

noah commented 10 years ago

I'm interested in implementing concurrent regions using Statechart.

However, it's not clear to me how to do this cleanly.

I considered using a queue of some kind - postal.js or the like.

Still doesn't seem quite right.

Can you shed any light on it?

gregwebs commented 10 years ago

What are Semantic concurrent regions ?

noah commented 10 years ago

Copy-paste error. I'm looking for an example of concurrent/orthogonal regions.

E.g., I have a state A that has 2 sub-states B and C. States B and C may -- but need not -- be active simultaneously.

A real-life scenario is a web app that has a S_LOGGED_IN state. Once logged in, one can be in one or more of S_PLAYING, S_OBSERVING, and/or S_LURKING states.

Is there a "right" way to represent that using @DavidDurman's library?

gregwebs commented 10 years ago

I don't know how to in this library, but you can simply use the configuration function concurrentSubStates() with StateTree

noah commented 10 years ago

Yeah ... I'm aware of StateTree and maybe I should take another look.

But my original question remains -- is there a "right" way to represent orthogonal regions using @DavidDurman's library?

DavidDurman commented 10 years ago

Hi, sorry for the delay, it was a busy day. Orthogonal states are not supported by this library. The Statechart library is an implementation of the QHsm framework by Miro Samek that does not offer concurrent states. However, there is a way to simulate that using more machines one for each concurrent region and delegate events to all the concurrent machines.

I'd suggest to first take a look at the Miro Samek's presentation about QHsm concepts: http://www.cis.upenn.edu/~lee/06cse480/lec-HSM.pdf and then look at the following article that specifically targets orthogonal regions using QHsm including diagrams and sample code (though in C++ but the ideas can be translated): http://staging.embedded.com/design/prototyping-and-development/4025964/Supporting-orthogonal-regions-in-practical-large-scale-projects

noah commented 10 years ago

there is a way to simulate that using more machines one for each concurrent region and delegate events to all the concurrent machines

That's what I suspected.

I'd suggest to first take a look at...

Thanks, will do.