UML state machine: How to exit orthogonal child re

2019-05-10 16:29发布

Base on Wikipedia, I can have a hierarchical state decomposition, where I have multiple orthogonal regions, which can change state independently.

The diagram shows how the orthogonal regions are entered. I assume that the entry happens in parallel in all regions. What I want to know is, how do you express the exit? If each region has an exit, does the global parent state exits when the first child region exit, or when they have all exited? I want to express that the exit happens when they have all exited. And how do you express that the global parent state transitions to the next global state because all children regions have exited? Is that always implicit?

My concrete problem is that my FSM starts in the Initializing global state. It sends multiple queries to multiple external systems asynchronously in parallel. Only once it has received the answer to each query, it can then proceed. So I model each asynchronous parallel query as an orthogonal region inside the global Initializing state. Each child region can change state independently. When all child regions have reached an end-state, I can move on.

The FSM will be implemented in an Actor framework, where asynchronous messages (events) are the only way to communicate.

Ideally, I'd like the answer to point to an example image, as such things are difficult to express in words.

1条回答
SAY GOODBYE
2楼-- · 2019-05-10 17:15

A completion transition from the orthogonal state will do the trick, since it will be taken when all of the orthogonal regions have finished.

When an composite state (state with inner states and/or orthogonal regions) is entered, each region starts at its initial state, to a different state in each region using fork pseudonodes, or to the last state of each region if the state is entered through a history pseudostate. Exiting the composite state can be done through a transition that starts at one of the inner states, which exists all of the orthogonal regions from their current state. If you want to exit when a the machine has come to a set of states in different regions, you can also use join pseudostates.

As you can see, the possibilities are almost endless. I can't add an image yet, but I'll do it later when I have a good UML editor at hand.

An now the example. Suppose you have the following state machine: example state machine

  1. If both parallel regions finish (arrive at a final node), then the completion transition will take the machine from S1 to S5. If the
  2. If the machine is currently at S3 and receives e1, it will exit S1 and go to S6.
  3. If the machine is in S7 and S8 and they both finish, it will go to the join and then to S6.

This is the way I know state machines work.

查看更多
登录 后发表回答