uml - 状态图中的转换顺序是什么?如何使用历史伪状态?

标签 uml state diagrams

我读了很多相关内容,但仍然不确定状态执行的顺序(在复合状态中)以及深度和浅层历史究竟如何工作?有人可以帮助我吗? 我有一个例子,我不知道如何解决,这里是: enter image description here

如果有任何帮助,我将不胜感激!

最佳答案

问题 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

enter image description here

e1之后

  • x 的值(条目 A::C):x = x + 1 = 7
  • 新状态:A::C

默认转换为 A::C::G

  • x 的值(条目 A::C::G):x = x + 1 = 8
  • 新状态:A::C::G

enter image description here

e3之后

  • x 的值(出​​口 A::C::G):x = x - 2 = 6
  • x 的值(条目 A::C::H):x = x/2 = 3
  • 新状态:A::C::H

enter image description here

e4之后

  • x 的值(条目 A::C::G):x = x + 1 = 4
  • 新状态:A::C::G

enter image description here

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

enter image description here

e7之后

  • x 的值(条目 A::C 请参阅上面的注释):x = x + 1 = 3
  • x 的值(条目 A::C::G):x = x + 1 = 4
  • 新状态:A::C::G

enter image description here

e4 被丢弃

enter image description here

关于uml - 状态图中的转换顺序是什么?如何使用历史伪状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34734278/

相关文章:

c++ - C++ 中是否存在 MOF 实现?

java - 计算器的用例建模

javascript - Chrome 扩展程序 : Remembering a checkbox value when popup is reopened

json - 描述 JSON 模式的工具

class - 用户界面是否应该包含在类图和序列图中?

uml - 如何在 uml 类图中表示多对多关系

java - java类的类图的实现

android - 如何在 Arraylist 中使用 onSaveInstanceState 方法

reactjs - 编辑数组后在 React 中重新渲染子组件数组

java - 正确使用图表