# Presentation: 661204

## UML State Diagrams

**Fritz Bartlett**
**07-May-1999**

## A Simple State Machine

**State 1**

**State 3**

**State 2**

**Initial State**

**Final State**

**Self Transition**

## Definitions

**State Machine**
**   ****A *****state machine***** is a behavior which specifies the sequence of states an object visits during its lifetime in response to events, together with its responses to those events**

## Definitions

**State**
**   ****A *****state***** is a condition during the life of an object during which it satisfies some condition, performs some activity, or waits for some external event**
**Event**
**   ****An *****event***** is the specification of a significant occurrence. For a state machine, an event is the occurrence of a stimulus that can trigger a state transition**

## Definitions

**Transition**
**   ****A *****transition***** is a relationship between two states indicating that an object in the first state will, when a specified set of events and conditions are satisfied, perform certain actions and enter the second state. A transition has:**
**Transition Components**
** ****a source state**
**an event trigger**
**an action**
**a target state**

## Definitions

**Self-Transition**
**   ****A *****self-transition***** is a transition whose source and target states are the same  **

## Definitions

**Action**
**   ****An *****action***** is an executable, atomic (with reference to the state machine) computation. Actions may include operations, the creation or destruction of other objects, or the sending of signals to other objects (events).**

## A Simple State Machine

**State 1**

**State 3**

**State 2**

**Initial State**

**Final State**

**Self Transition**

## Advanced States

**Entry | *****Entry Action***

**Exit    | *****Exit Action***

***State Name***

**Entry and Exit Actions**

## Definitions

**Substates**
**A *****substate***** is a state that is nested in another state**
**A state that has substates is called a *****composite state***
**A state that has no substates is called a *****simple state***
**Substates may be nested to any level**

## Advanced Transitions

**Transitions to a composite state**
**If a transition is to a composite state, the nested state machine must have an initial state**
**If a transition is to a substate, the substate is entered after any entry action for the enclosing composite state is executed followed by any entry action for the substate **

## Advanced Transitions

**Transitions from a composite state**
**If a transition is from a substate within the composite state, any exit action for the substate is executed followed by any exit action for the enclosing composite state**
**A transition from the composite state may occur from any of the substates and takes precedence over any of the transitions for the current substate**

## Advanced State Machine

**Sub-States**

**State 0**

**State 1**

**State 2**

**State 3**

***State Name***

**Entry | *****Entry Action***

**Exit    | *****Exit Action***

**Transition to a**
**composite state**

**Transition from a**
**composite state**

**Transition from**
**a substate**

**Transition to**
**a substate**

## An Implementation

**State Table**

**Transition Table**

## An Implementation

**Problems with UML notation**
**When more than one transition from a state is enabled there is no method for specifying precedence**
**For nested states there is no method for specifying precedence of the enclosing or enclosed state**

## Example: High Voltage Channel

**Off**

**On**

**Offline**

**Disabled**

**Average**

**Ramp**

**Holding**

**Tripped**

**Paused**