UML State Diagrams: Fritz Bartlett 07-May-1999
UML State Diagrams: Fritz Bartlett 07-May-1999
JFB
29-Apr-99
D
Initial State State 1
JFB
29-Apr-99
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
JFB
29-Apr-99
D
State
Definitions
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
JFB
29-Apr-99
D
Transition
Definitions
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
JFB
Definitions
Self-Transition
A self-transition is a transition whose source and target states are the same
JFB
29-Apr-99
D
Action
Definitions
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).
JFB
29-Apr-99
D
Initial State State 1
JFB
29-Apr-99
Advanced States
Entry and Exit Actions
State Name
JFB
29-Apr-99
D
Substates
Definitions
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
JFB
29-Apr-99
Advanced Transitions
JFB
29-Apr-99
Advanced Transitions
State Name
State 2
State 0
State 1
State 3
Exit
| Exit Action
JFB
29-Apr-99
D
State
An Implementation
State Table
FirstIndex LastIndex EntryAction ExitAction
0 State 1 2
0 2 3
1 2 4
Transition Table
Trans 1 Index 2 3 E1 E1 | E2 * None * 2 * Events E0 & E1
Mask
E0 | E1
Action Act0
NewState 1
JFB
29-Apr-99
D
/*+ typedef void *SsmId_t;
An Implementation
MODULE stateMachine - Sequential State Machine Package Declarations DESCRIPTION: The stateMachine.h header file contains definitions of external interfaces to the state machine package -*/ #define ssmMask(event) (1<<event) enum {SSM_TERMINAL_INDEX = (unsigned short int)-1}; enum {SSM_NULL_ACTION = NULL}; enum {SSM_MAX_EVENT = 31};
typedef int (*SsmAction_t)(const SsmId_t stateId, void const *context, const unsigned short int action); typedef void (*SsmDisplay_t)(char *text); typedef unsigned long int SsmEventSet_t; /* State table element */ typedef struct { unsigned short unsigned short unsigned short unsigned short } SsmState_t;
/* /* /* /*
First index in transition table */ Last index in transition table */ Entry action index */ Exit action index */
/* Transition table element */ typedef struct { SsmEventSet_t events; SsmEventSet_t mask; unsigned short int action; unsigned short int newState; } SsmTransition_t;
/* /* /* /*
extern SsmId_t ssmCreate(const unsigned short int initState, const unsigned short int termState, const unsigned short int maxIndex, const SsmEventSet_t initEvents, const SsmAction_t actionFunct, void const *context, SsmState_t (*stateTable)[], SsmTransition_t (*transTable)[]); extern int ssmDelete(const SsmId_t stateId); extern int ssmEventClear(const SsmId_t stateId, const unsigned int event); extern int ssmEventSet(const SsmId_t stateId, const unsigned int event); extern unsigned int ssmExecute(const SsmId_t stateId); extern unsigned short int ssmCurStateGet(const SsmId_t stateId);
JFB
29-Apr-99
D
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
JFB
29-Apr-99
D
Ramp
Paused
Holding
Average
Tripped
On
Offline
Off
Disabled
JFB
29-Apr-99