1

I am rather unclear about how an event gets processed when a state machine has orthogonal regions. I did read that

With composite states, that an event should be sent to the innermost state, and if that state doesn't handle the event via a transition or action, than it goes up to the parent.

Are ortho regions similar? Should my code keep track of multiple "current states", which would be the innermost of each ortho region we are currently in. When an event comes, send it to each of those current states, in no particular order. If they don't handle it, go up to the parents, until the common parent of one or more ortho regions is reached and then have the event sent once to that parent?

1 Answer 1

3

Orthogonal regions are concurrent. The behavior should be as if they were processed at the same time and the order should therefore not be relevant.

Orthogonal regions are executed concurrently, as soon as the enclosing state is entered (or if at top level, state machine is started). You would therefore have to track multiple parallel substates (i.e. the active state would be a tuple composed of the active state in each orthogonal region). The logic for event dispatching and matching is the same as for a simple composite state (composite state with one region), except that you need to consider all the regions before returning to the parent.


You can find more formal explanation in the UML specs, for example (highlighting by me):

A Region denotes a behavior fragment that may execute concurrently with its orthogonal Regions. Two or more Regions are orthogonal to each other if they are either owned by the same State or, at the topmost level, by the same StateMachine. A Region becomes active (i.e., it begins executing) either when its owning State is entered or, if it is directly owned by a StateMachine (i.e., it is a top level Region), when its owning StateMachine starts executing.

When orthogonal regions are owned by the same state, it's a composite state:

A composite State can be either a simple composite State with exactly one Region or an orthogonal State with multiple Regions.

And for the execution, the following semantic is indicated regarding regions:

A particular execution of a StateMachine is represented by a set of valid path traversals through one or more Region graphs, triggered by the dispatching of an Event occurrence that match active Triggers in these graphs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.