UML 状态图中具有多个事件的一次转换

One transition with multiple events in UML State diagram

我们在学校学习行为状态图的转换语法:

list of events [guard condition] / list of actions

但是我在 Internet 上找不到任何使用 transition with multiple events 的例子。真的可能吗?如果是,它的行为如何?这是否意味着当其中一个事件发生时(当然条件满足),交易就实现了?

不幸的是,UML 规范在这方面并不具体(我认为,但 Jim 的答案是正确的)。总之:

14.2.4.9 Transition

The default textual notation for a Transition is defined by the following BNF expression:

[<trigger> [‘,’ <trigger>]* [‘[‘ <guard>’]’] [‘/’ <behavior-expression>]]

Where is the standard notation for Triggers (see sub clause 13.3.4), is a Boolean expression for a guard, and the optional is an expression specifying the effect Behavior written in some vendor- specific or standard textual surface language (see sub clause 16.1). The trigger may be any of the standard trigger types. SignalEvent triggers and CallEvent triggers are not distinguishable by syntax and must be discriminated by their declaration elsewhere.

规范中的其他地方也以类似的方式出现了这一段,但没有解释如何处理多个触发器。我假设这是一个OR条件。但这只是一个假设。 las,由于您还没有看到示例(我也没有),这可能是一个未知的事实。只是不要使用它 - 这确实是可能的 ;-) 如果你碰巧找到了一个例子,只要问问作者他的意思。 UML 是关于彼此交谈。

是的,转换可以由列表中的许多事件之一触发。您将使用这样的构造来避免状态之间的多行,从而制作更整洁的图表。

这是 2.5 规范的内容:

14.2.3.9.2 Enabled Transitions

A Transition is enabled if and only if:

  • [ . . . ]

  • At least one of the triggers of the Transition has an Event that is matched by the Event type of the dispatched Event occurrence.

这些逻辑或转换在文本上指定为转换中的逗号分隔列表,如 §14.2.4.9 中所述:

[<trigger> [‘,’ <trigger>]* [‘[‘ <guard>’]’] [‘/’ <behavior-expression>]]