EA&UML日拱一卒-活动图::14.2 Behavior StateMachines (5)

来源:互联网 发布:淘宝抠图兼职怎么找 编辑:程序博客网 时间:2024/05/18 20:33

英文原文来自UML2.5,作者提供中文翻译。


14.2.3.5 ConnectionPointReference(连接点引用)


As noted above, a connection point reference represents a usage (as part of a submachine State) of an entry/exit point defined in the StateMachine referenced by the submachine State. Connection point references of a submachine State can be used as sources/targets of Transitions. They represent entries into or exits out of the submachine StateMachine referenced by the submachine State.

就像前面提到的那样,连接点引用表现的是子状态机状态对于定义在状态机中的进入/退出点的引用。子状态机状态的连接点引用可以用作迁移源和迁移目标。连接点引用表现的是被子状态机状态引用的进入子状态机的入口和离开子状态机的出口。


Connection point references are sources/targets of Transitions implying exits out of/entries into the submachine StateMachine referenced by a submachine State.

连接点引用是迁移源或迁移目标意味着离开子状态机的出口的和进入子状态机的入口被子状态机状态引用。


An entry point connection point reference as the target of a Transition implies that the target of the Transition is the entryPoint Pseudostate as defined in the submachine of the submachine State. As a result, the Regions of the submachine StateMachine are entered through the corresponding entryPoint Pseudostates.

进入点连接点引用作为迁移的目标意味着迁移目标是定义在子状态机状态中的状态机的进入点伪状态。作为结果,子状态机的区域通过对应的进入点伪状态被进入。


An exit point connection point reference as the source of a Transition implies that the source of the Transition is the exit point Pseudostate as defined in the submachine of the submachine State that has the exit point connection point defined. When a Region of the submachine StateMachine reaches the corresponding exit point, the submachine state is exited via this exit point.

退出点连接点引用作为迁移的源意味着迁移的源是定义在子状态机状态中里的状态机中的退出点伪状态。当子状态机到达了对应的退出点,子状态机状态也从退出点退出。


14.2.3.6 FinalState(完了状态)


FinalState is a special kind of State signifying that the enclosing Region has completed. Thus, a Transition to a FinalState represents the completion of the behaviors of the Region containing the FinalState.

完了状态是一种特殊的状态,表明包含它的区域已经结束。就是说,迁移到完了状态表示包含完了状态的区域的行为已经结束。


14.2.3.7 Pseudostate and PseudostateKind(伪状态和伪状态种类)


A Pseudostate is an abstraction that encompasses different types of transient Vertices in the StateMachine graph. Pseudostates are generally used to chain multiple Transitions into more complex compound transitions (see below). For
example, by combining a Transition entering a fork Pseudostate with a set of Transitions exiting that Pseudostate, we get a compound Transition that can enter a set of orthogonal Regions.


伪状态是一种抽象,它包括了状态机图中各种瞬间通过的顶点。伪顶点通常被用于将多个迁移连接成更加复杂的复合迁移(参考下面的说明)。例如,利用将一个进入分叉伪状态的迁移和一组离开该分叉伪状态的迁移组合起来,可以得到用来进入正交区域的复合迁移。


The specific semantics of a Pseudostate depend on the kind of Pseudostate, which is defined by its kind attribute of type PseudostateKind. The following describes the different kinds and their semantics:

伪状态的具体语义依赖于伪状态的种类,这是通过状态的类型为PsudostateKind的种类属性来定义的。


• initial - An initial Pseudostate represents a starting point for a Region; that is, it is the point from which execution of its contained behavior commences when the Region is entered via default activation. It is the source for at most one Transition, which may have an associated effect Behavior, but not an associated trigger or guard. There can be at most one initial Vertex in a Region.

初始-初始伪状态表现了区域的开始点;也就是说,当以默认激活的方式进入区域时,它是区域中包含的活动开始执行的位置。它最多是一个迁移的源,这个迁移可以有效果行为,但不能有关联的触发条件或监护条件。一个区域中最多只能有一个初始顶点。


• deepHistory – This type of Pseudostate is a kind of variable that represents the most recent active state configuration of its owning Region. As explained above, a Transition terminating on this Pseudostate implies restoring the Region to that same state configuration, but with all the semantics of entering a State (see the sub clause describing State entry). The entry Behaviors of all States in the restored state configuration are performed in the appropriate order starting with the outermost State. A deepHistory Pseudostate can only be
defined for composite States and, at most one such Pseudostate can be contained in a Region of a composite State.

深 历史-这种伪状态是一种变量,保存的是包含它的区域在最近被激活时的状态构成。如前面所讲,迁移进入这个伪状态就意味着将区域恢复到与最近离开时相同的状 态构成,伴随着所有进入状态的语义(参见状态进入的小节)。被恢复状态的所有进入行为被从最外层状态开始按照恰当的顺序执行。深历史伪状态只能在组合状态 中被定义,而且组合状态的一个区域中最多只能定义一个。


• shallowHistory – As explained above, this type of Pseudostate is a kind of variable that represents the most recent active substate of its containing Region, but not the substates of that substate. A Transition terminating on this Pseudostate implies restoring the Region to that substate with all the semantics of entering a State. A single outgoing Transition from this Pseudostate may be defined terminating on a substate of the composite State. This substate is the default shallow history state of the composite State. A shallowHistory Pseudostate can only be defined for composite States and, at most one such Pseudostate can be included in a Region of a composite State.

浅历史-如前面所讲,这类伪状态是一个变量,保存了包含它的区域的最近的活动子 状态。但不包含这个子状态的(下级)子状态。迁移到这个伪状态意味着将区域恢复到该子状态,同时伴随着进入状态的语义。可以有一条离开该伪状态指向组合状 态里的某个子状态的迁移。这个子状态是组合状态的默认浅历史状态。浅历史伪状态只能在组合状态中被定义,而且组合状态的一个区域中最多只能定义一个。


• join – This type of Pseudostate serves as a common target Vertex for two or more Transitions originating from Vertices in different orthogonal Regions. Transitions terminating on a join Pseudostate cannot have a guard or a 
trigger. Similar to junction points in Petri nets, join Pseudostates perform a synchronization function, whereby all incoming Transitions have to complete before execution can continue through an outgoing Transition. 

汇合-这种类型的伪状态为两个或多个来自不同顶点的迁移提供目 标顶点,而这些源顶点处于不同的正交区域中。终止于汇合伪状态的迁移不允许有监护条件和触发条件。类似于Petri网络中的接合点,汇合伪节点实现同步功 能,只有在所有的进入迁移都完成以后,才能继续进行离开迁移。


• fork – fork Pseudostates serve to split an incoming Transition into two or more Transitions terminating on Vertices in orthogonal Regions of a composite State. The Transitions outgoing from a fork Pseudostate cannot have a guard or a trigger.

分叉-分叉伪状态将一个进入迁移分成两个或多个迁移,它们终止于组合状态的(不同的)正交区域。离开分叉伪状态的迁移不可以有监护条件和触发条件。


• junction – This type of Pseudostate is used to connect multiple Transitions into compound paths between States. For example, a junction Pseudostate can be used to merge multiple incoming Transitions into a single outgoing Transition representing a shared continuation path. Or, it can be used to split an incoming Transition into multiple outgoing Transition segments with different guard Constraints.

连接点-这种类型的伪状态用于将状态之间的多个迁移连接成复合路径。例如,合并伪状态可以用来将多个进入迁移合并成一个离开迁移,通过这种方式表现后续路径分享。也可以用于将一个进入迁移分成多个离开迁移,这些离开迁移通过不同的监护约束选择。


NOTE. Such guard Constraints are evaluated before any compound transition containing this Pseudostate is executed, which is why this is referred to as a static conditional branch. 

注意:这样的监护约束的演算是在包含这个伪状态的复合迁移执行之前进行的,这就是为什么它被称为静态条件路径。


It may happen that, for a particular compound transition, the configuration of Transition paths and guard values is such that the compound transition is prevented from reaching a valid state configuration. In those cases, the entire compound transition is disabled even though its Triggers are enabled. (As a way of avoiding this situation in some cases, it is possible to associate a predefined guard denoted as “else” with at most one outgoing Transition. This Transition is enabled if all the guards attached to the other Transitions evaluate to false). If more than one guard evaluates to true, one of these is chosen. The algorithm for making this selection is not defined.

可能发生这样的事情,对于一个具体的复合迁移,迁移路径和监护条件的构成导致无法到达某个有效的状态构成。在这 种情况下,即使触发条件的是有效的,整个复合迁移也是无效的。(作为避免某种情况下出现这种局面的方法,可以为最多一个离开迁移关联事先定义的表示为 “else”的监护条件,这个迁移在所有其他迁移的监护条件的结果为假时有效)。如果多于一个监护条件的结果为真,其中一个会被选中,但做出这种选择的算 法无定义。


• choice – This type of Pseudostate is similar to a junction Pseudostate (see above) and serves similar purposes, with the difference that the guard Constraints on all outgoing Transitions are evaluated dynamically, when the compound transition traversal reaches this Pseudostate. Consequently, choice is used to realize a dynamic conditional branch. It allows splitting of compound transitions into multiple alternative paths such that the decision on which path to take may depend on the results of Behavior executions performed in the same compound transition prior to reaching the choice point. If more than one guard evaluates to true, one of the corresponding Transitions is selected. The algorithm for making this selection is not defined. If none of the guards evaluates to true, then the model is considered ill formed. To avoid this, it is recommended to define one outgoing Transition with the predefined “else” guard for every choice Pseudostate.

选择-这种类型的伪状态和连接点伪状态(参见前面)相似,而且具有类似的用途。有一点 不同就是离开迁移上的监护约束是当复合迁移到达这个伪状态时动态演算的。因此,选择用于识别动态条件分支。它允许将复合迁移分成多个可选的分支,判断采用 那条路径时可以根据处于同一个复合迁移中的行为在迁移到达该选择点之前的执行结果。如果多于一个监护条件的演算结果为真,其中的一个迁移会被选中,但是进 行这个选择的算法无定义。如果没有监护条件的演算结果为真,那么这个模型被认为是病态。为了避免这种情况,推荐为所有的选择伪状态设置一个预先定义的 “else”离开迁移。


• entryPoint – An entryPoint Pseudostate represents an entry point for a StateMachine or a composite State that provides encapsulation of the insides of the State or StateMachine. In each Region of the StateMachine or
composite State owning the entryPoint, there is at most a single Transition from the entry point to a Vertex within that Region.

进入点-进入点伪状态表示的是状态机或者封装了内部状态/状态机的组合状态的入口点。在包含入口点的状态机或者组合状态的每个区域中,最多可以有一个从入口点到区域内顶点的迁移。


NOTE. If the owning State has an associated entry Behavior, this Behavior is executed before any behavior associated with the outgoing Transition. If multiple Regions are involved, the entry point acts as a fork Pseudostate.

注意:如果拥有入口点的状态关联了入口行为,这个行为在离开迁移的任何关联行为之前执行。如果多个区域被调用,入口点的行为和分叉伪状态一样。


• exitPoint – An exitPoint Pseudostate is an exit point of a StateMachine or composite State that provides encapsulation of the insides of the State or StateMachine. Transitions terminating on an exit point within any Region of the composite State or a StateMachine referenced by a submachine State implies exiting of this composite State or submachine State (with execution of its associated exit Behavior). If multiple Transitions from orthogonal Regions within the State terminate on this Pseudostate, then it acts like a join Pseudostate.

退出点-退出点伪状态表示的是状 态机或者封装了内部状态/状态机的组合状态的退出点。迁移到组合状态或者是被子状态机状态引用的状态机中的区域中的退出点意味着组合状态或者是子状态机状 态的退出(伴随着关联退出行为的执行)。如果存在多个从状态机中的正交区域到这个伪状态的迁移,那么它的行为像汇合点伪状态一样。


• terminate – Entering a terminate Pseudostate implies that the execution of the StateMachine is terminated immediately. The StateMachine does not exit any States nor does it perform any exit Behaviors. Any executing doActivity Behaviors are automatically aborted. Entering a terminate Pseudostate is equivalent to invoking a DestroyObjectAction.

终止-进入终止伪状态意味着状态机的执行立即终止。状态机不会退出任何状态,也不会执行任何退出行为。任何执行中的doActivity行为被自动地中止。进入终止伪状态等同于调用删除对象动作。


参考资料:

《OMG Unified Modeling Language TM (OMG UML) Version 2.5》

  URL:http://www.omg.org/spec/UML/2.5\

阅读更多更新文章,请扫描下面二维码,关注微信公众号【面向对象思考】


阅读全文
0 0