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

来源:互联网 发布:安广网络含山分公司 编辑:程序博客网 时间:2024/05/18 00:46

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


14.2.1 Summary(概要)


Behavior StateMachines can be used to specify any of the following:
• The classifierBehavior of an active Class.
• An ownedBehavior of a BehavioredClassifier that is not the classifierBehavior of that BehavioredClassifier.
• A stand-alone Behavior, that is, one that does not have a corresponding BehavioredClassifier.
• A method corresponding to a BehavioralFeature (i.e., an Operation or a Reception).

行为状态机可以用于定义下面的场景

  • 主动类的类目行为

  • 一个行为化类目的除了类目行为以外的拥有行为。

  • 没有对应的行为化类目的独立行为

  • 对应行为特征的方法(即操作或接受)


14.2.2 Abstract Syntax(抽象语法)



14.2.3 Semantics(语义)


14.2.3.1 StateMachine(状态机)


A behavior StateMachine comprises one or more Regions, each Region containing a graph (possibly hierarchical) comprising a set of Vertices interconnected by arcs representing Transitions. State machine execution is triggered by appropriate Event occurrences. A particular execution of a StateMachine is represented by a set of valid path traversals through one or more Region graphs, triggered by the dispatching of an Event occurrence that match active Triggers in these graphs. The rules for matching Triggers are described below. In the course of such a traversal, a StateMachine instance may execute a potentially complex sequence of Behaviors associated with the particular elements of the graphs that are being traversed (transition effects, state entry and state exit Behaviors, etc.)

行为状态机包含了一个或多个区域,每个区域包含一个图(可能是分层的),图中又包 含一组被被圆弧形迁移相互连接的顶点。当适当的事件发生时,状态机会被触发执行。状态机的特定执行表现为一组经过一个或多个区域有效路径的遍历,触发的方 式是发行一个与图中有效触发条件相匹配的事件发生。触发条件匹配的原则会在后面描述。在这样一个遍历过程中,状态机实例可能会执行一个隐含的复杂的行为序 列,这些行为和图中被通过的特定元素联系在一起(迁移效果,状态入口,状态出口行为等)


If the StateMachine has a kind of BehavioredClassifier context, then that Classifier defines which Signal and CallEvent triggers are applicable to that StateMachine, and which Features are available to the Behaviors owned by the StateMachine. Signal Triggers and CallEvent Triggers for the StateMachine are defined according to the Receptions and Operations of this Classifier respectively. These Features may be used to define message event Triggers of the StateMachine.

如果状态机有某种行为类目上下文,那么这个类目定义了哪些信号和调用事件可以适用于那个状态机,也定义了哪些特征对状态机拥有的行为可用。状态机的信号触发条件和调用事件触发条件根据这个类目的接受和操作被分别定义。这些特征可以被用于定义状态机的消息事件触发条件。


If the StateMachine has no BehavioredClassifier context (i.e., it is a stand-alone Behavior), then its Triggers do not need to be tied to any Receptions or Operations of some Classifier. For example, such a StateMachine might be defined as a Template with its Triggers defined as TemplateParameters. Such a StateMachine can then be reused with different context Classifiers by binding appropriate CallEvent or SignalEvent Triggers to these TemplateParameters.

如果状态机没有行为类目上下文(即它是一个独立行为),那么它的触发条件不需要绑定到类目的接受和操作上。例如,这样的状态机可能被定义为以触发条件为模板参数的模板,这样,状态机可以通过为模板参数绑定合适的调用事件和信号事件来配合不同的上下文类目一起使用。


In situations where a StateMachine specifies the method of a BehavioralFeature (Operation or Reception), the Parameters of the StateMachine shall match the Parameters of the BehavioralFeature (see sub clause 13.2.3). This is the means by which the StateMachine execution accesses the Parameters of the BehavioralFeature. Otherwise, the method by which an executing StateMachine instance accesses the dispatched Event occurrence and its associated data is not defined (see Clause 13).

如果状态机定义了一个行为特征(操作或接受)的方法,那么状态机的参数应该和行为特征(参见13.2.3小节)的参数相匹配。这意味着通过参数,状态机执行可以参照行为特征的参数。否则,执行中的状态机实例访问分发的事件发生和它的关联数据的方法无定义(参见13小节)。


By definition, invocations of StateMachine executions result in triggered effects (see sub clause 13.3.3) and, hence,there is an associated event pool with such an execution. The event pool for a StateMachine execution belongs to either its context Classifier object or, if the StateMachine defines a method of a BehavioralFeature, to the instance of the Classifier owning the BehavioralFeature.

按照定义,状态机执行的调用导致被触发的效果(参见13.3.3小节)和一个因此而存在的,与这个执行相关联的事件池。状态机的这个事件池可能属于它的上下文类目对象,或者当状态机定义了一个行为特征的方法时,属于拥有的这个行为特征的类目的实例。


Due to its event-driven nature, a StateMachine execution is either in transit or in state, alternating between the two. It is in transit when an event is dispatched that matches at least one of its associated Triggers. While in transit, it may execute a number of Behaviors associated with the paths it is taking.

由于它的事件驱动性质,状态机执行可以是迁移中或状态内,在两者之间交替。当分发的某个事件和某个迁移的至少一个触发条件匹配时,它处在迁移中。在迁移中,它可能会执行若干与选中路径想关联的行为。


NOTE. A StateMachine execution may be executing Behaviors even when it has settled in a stable state configuration, in cases where there are doActivity Behaviors associated with its active state configuration.

注意:当存在与活动状态构成相关联的doActivity行为时,即使它存在于稳定状态构成中,状态机执行也可以是执行中行为。


14.2.3.2 Regions(区域)


A Region denotes a behavior fragment that may execute concurrently with its orthogonal Regions. Two or more Regions are orthogonal to each other if they are either owned by the same State or, at the topmost level, by the same StateMachine. A Region becomes active (i.e., it begins executing) either when its owning State is entered or, if it is directly owned by a StateMachine (i.e., it is a top level Region), when its owning StateMachine starts executing. Each Region owns a set of Vertices and Transitions, which determine the behavioral flow within that Region. It may have its own initial Pseudostate as well as its own FinalState.

区域表示一个行为片段,它可以和其他的正交区域并发执行。如果两个或多个的区域被同一个状态拥有,或者在顶层时被同 一个状态机拥有,那么就说它们彼此正交。一个区域变成活动状态(即开始执行)有两种情况,一种是它拥有的状态被进入,另一种情况是直接拥有它的状态机开始 执行。每个区域包含一组顶点和迁移,由它们决定区域中的行为流程。它可以拥有自己的起始伪状态,也可以拥有自己的终止状态。


A default activation of a Region occurs if the Region is entered implicitly, that is, it is not entered through an incoming Transition that terminates on one of its component Vertices (e.g., a State or a history Pseudostate), but either 

区域的缺省激活发生在它被隐含进入的时候,就是说,它不是被一个终止于区域元素顶点(例如状态或历史伪节点)的输入迁移进入的。但是应该


· through a (local or external) Transition that terminates on the containing State or,

通过一个终止于包含区域的状态的(局部或外部)迁移,或者

· in case of a top level Region, when the StateMachine starts executing.

如果是顶层区域,当状态机开始执行时。


Default activation means that execution starts with the Transition originating from the initial Pseudostate of the Region,if one is defined. However, no specific approach is defined if there is no initial Pseudostate that exists within the Region. One possible approach is to deem the model ill defined. An alternative is that the Region remains inactive,although the State that contains it is active. In other words, the containing composite State is treated as a simple (leaf)
State.

缺省的激活意味着从起 始于区域中的初始伪状态的迁移开始执行,如果定义了一个的话。如果区域中不存在初始伪状态,那么就没有特定的动作。一个可能的处理是将模式视为病态。也可 以认为区域维持非激活状态,哪怕包含它的状态处于有活动状态。换句话说,包含区域的状态可以被认为是简单(叶子)状态。


Conversely, an explicit activation occurs when a Region is entered by a Transition terminating on one of the Region’s contained Vertices. When one Region of an orthogonal State is activated explicitly, this will result in the default activation of all of its orthogonal Regions, unless those Regions are also entered explicitly (multiple orthogonal Regions can be entered explicitly in parallel through Transitions originating from the same fork Pseudostate).


相反地,明确的激活是在终止于区域包含的顶点的迁移进入区域时发生的。当正交状态的一个区域被明确地激活后,将导致它所有的正交区域被缺省激活。除非那些区域也是被明确进入的(多个正交区域可以通过开始于同一个分叉伪状态的迁移被明确的并发激活)。


14.2.3.3 Vertices(顶点)


Vertex is an abstract class that captures the common characteristics for a variety of different concrete kinds of nodes in the StateMachine graph (States, Pseudostates, or ConnectionPointReferences). With certain exceptions described below, a Vertex can be the source and/or target of any number of Transitions. The semantics of a Vertex depend on the concrete kind of node it represents. In general, Pseudostates and ConnectionPointReferences are transitive, in the sense that a compound transition execution simply passes through them, arriving on an incoming Transition and leaving on an outgoing Transition without pause. State and FinalState, however, represent stable Vertices, such that, when a StateMachine execution enters them it remains in them until either some Event occurs that triggers a transition that moves it to a different State or the StateMachine is terminated.


顶点是一个抽象类,它抽取了状态图中各种的不 同种类的具体节点(状态,伪状态或连接点参照)的特征。除了下面的例外,顶点可以作为任意数量的迁移的目的而且/或者源。顶点的语义依赖于它所表现的具体 类型。通常,伪状态和连接点参照是过渡性的,意思是一个混合迁移执行只是简单地通过它们,作为输入迁移到达,作为输出迁移离开而不作停留。然而状态和终止 状态表现为稳定顶点,当状态机执行进入它们以后,将停留在这些状态的内部,直到某些可以引起迁移的事件发生,或者状态机被终止执行。


The semantics of individual types of Vertices are described below.

个别种类的顶点的语义在后面讲述。


参考资料:

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

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

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


原创粉丝点击