前言:
The StateMachines package defines a set of concepts that can be used for modeling discrete event-driven Behaviors using a finite state-machine formalism. In addition to expressing the Behavior of parts of a system (e.g., the Behavior of Classifier instances), state machines can also be used to express the valid interaction sequences, called protocols, for parts of a system. These two kinds of StateMachines are referred to as behavior state machines and protocol state machines respectively. The specific form of finite
行为状态机:
行为状态机,就是我平时比较熟悉的,搞的状态机。
协议状态机:
A ProtocolStateMachine is always defined in the context of a Classifier. It specifies which BehavioralFeatures of that Classifier can be invoked in a given protocol state and under what conditions, thereby specifying allowed invocation sequences. In this manner, a specification of the lifecycle of an instance of the Classifier is defined from an external perspective.
协议状态机基本用于定义一个类目的上下文,它规定了在给定的状态和给定的提交下,到底什么样的行为特征会被调用和触发,从而它可以说明一种类目的调用次序。因此,它所体现的一个类目实例的生命周期是基本从外部视觉出发所形成的;
ProtocolStateMachines help define the order in which BehavioralFeatures of a Classifier are invoked by specifying:
- the behavioral context (i.e., which states and pre-conditions) in which they can be validly invoked,
- the valid orderings of invocations
- the expected outcomes (post-conditions) of invocations.
ProtocolStateMachine present an external view of the owning Classifier as perceived by its collaborators. This extends beyond what can be captured via pre- and post-conditions on individual BehavioralFeatures, as ProtocolStateMachines also specify the valid orderings of invocations of the different features. This is achieved by a state machine specification in which the transition triggers are feature invocations and the guards of the transitions (ProtocolTransitions) specify the pre-condition that must apply for the invocation to be valid. The states (ProtocolStates) of this state machine, being a consequence of past invocation sequences, capture the state of the protocol and are also a form of pre-condition.
NOTE. Because ProtocolStateMachines provide a “black box” view of the behavior of a Classifier, their States may not necessarily correspond to the States of internal behavioral StateMachines.
因为协议状态机提供了一个类目行为的黑盒子的视觉,所以它的状态是不需要和内部行为状态一一对应的。
上图所示,只有在S1状态下的C1条件,才可以出发m1,只要触发了m1,那么就必然会使得类目的状态变成S2,而且条件C2成立。
参考资料:
《OMG Unified Modeling Language TM (OMG UML) Version 2.5》
URL:http://www.omg.org/spec/UML/2.5