最佳答案
问题 1:
... not sure .. how exactly deep and shallow history works?
答案 1:
注意这一点:
A shallow history is indicated by a small circle containing an "H". It applies to the state region that directly encloses it.
Shallow history pseudostate represents the most recent active substate of its containing state (but not the substates of that substate). ...
Source: http://www.uml-diagrams.org/state-machine-diagrams.html#shallow-history-pseudostate
问题 2:
... I'm not sure if I always should start from initial point, which is outside of all composites?
答案 2:
是的。您从根状态的初始伪状态(本例中为 A)开始。
示例:
对于给定的状态图和事件链,您将得到以下结果(用 Rhapsody 模拟):
默认转换到 A 后
- x 的值(转换到 A):
x = 3
- x 的值(条目 A):
x = x * 2 = 6
- 新状态:A
默认转换到 A::B 后
- 新状态:A::B
- x 的值:
x = 6
e1之后
- x 的值(条目 A::C):
x = x + 1 = 7
- 新状态:A::C
默认转换为 A::C::G
- x 的值(条目 A::C::G):
x = x + 1 = 8
- 新状态:A::C::G
e3之后
- x 的值(出口 A::C::G):
x = x - 2 = 6
- x 的值(条目 A::C::H):
x = x/2 = 3
- 新状态:A::C::H
e4之后
- x 的值(条目 A::C::G):
x = x + 1 = 4
- 新状态:A::C::G
e6之后
- x 的值(出口 A::C::G):
x = x - 2 = 2
- x 的值(出口 A::C):
x = x - 1 = 1
- x 的值(出口 A):
x = x - 1 = 0
- x 的值(转换到 Y):
x = (x * 4) + 2 = 2
- 新状态:Y
e7之后
- x 的值(条目 A::C 请参阅上面的注释):
x = x + 1 = 3
- x 的值(条目 A::C::G):
x = x + 1 = 4
- 新状态:A::C::G
e4 被丢弃
关于uml - 状态图中的转换顺序是什么?如何使用历史伪状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34734278/