State Machine (stm) = behavior diagram, how a structure within system changes state in response to event occurrences over time. This is not the same as state machine diagram (can have multiple diagrams for single state machine). State machine is the namespace, a set of named elements.
Classifier behavior = behavior that begins executing the moment block is instantiated and finishes when instance is destroyed. State machines are based on block’s classifier behavior, if block don’t have one, cant make state machine. In the example below, the “Attitude Control Subsystem” is the classifier behavior.
States = based on instance or time; composite state is state that has substates, else if no substates, it is a simple state.
Simple state = noted by round cornered rectangle.
Opaque expressions (as discussed in Activity Diagrams) = behavior noted for entry/exit/do
Entry = behavior executed upon first entering the state; atomic (uninterruptible) – guaranteed to finish executing before the state machine can process new event occurrence.
Exit = behavior executed before leaving the state, the last thing it does before leaving. It is also atomic.
Do = behavior executes after Entry but is nonatomic, can be interrupted; leads to exit behavior.
Composite state = like state machine has entry, exit, do – noted in 2nd compartment (first compartment having name); has nested substates which would be displayed in third compartment; can transition between substates. When composite state ends, so does all substates. Can transition out of composite state via the substates.
Final State = marks end of state machine as a whole, noted by filled circle and outer circle
Transition = change from one state to another, including self-transition which is change from one state back to itself. Noted with open arrow solid line with text format:
<trigger> [<guard>] / <effect>
The transition is triggered through event occurrence. If guard results in false, then event occurrence doesn’t change the state.
The effect can be an opaque expression or name of behavior somewhere in system model. These do a run-to-completion step, listed as:
– Exit behavior of source state
– Effect specified in transition itself
– Entry behavior of target state
External vs Internal Transitions
External = one state to another as the Figure 8.5
Internal = within the same state; only fires the effect specified behavior (not the entry or exit). In example below, the purgeOldestDataFiles is behavior executed within as an internal transition, but the state does not change.
An event is an element within system model that defines a type of occurrence that can trigger a behavior. There are 4 types of events:
– Signal events
– Call events
– Time events
– Change events
Signal Events = represents the receipt of a signal instance. In example below the state machine behavior is the classifierbehavior of the Attitude Control Subsystem block (from bdd).
Call event = represents the receipt of a request from a calling structure. In the block of calling structure (bdd), the operation is a behavioral feature that is invoked by a synchronous call (caller waits for execution). Call events and signal events are noted the same, only way to distinguish it is to examine the structure that called it (in bdd).
Time event = represents an instant in time, at which can trigger a transition in state machine. There are two types of time events, relative and absolute. Relative time events always start with keyword “after”, whereas absolute events start with keyword “at”. An external self-transition (external transition drawn from a state back to itself) is considered as exiting and re-entering and therefore resets the relative time clocks. (this is the example below, commLinkRestored is an external signal that causes the self transition to HaveCommLink state) An internal transition within a state does not reset the clock. A relativetimeevent starts its clock after the entry behavior, so it can never interrupt that execution.
Change Event = is Boolean expression that noted with keyword when. It’s a defined event that occurs when expression results to true. When triggered, it executes the transition effect (purgeOldestDataFiles).
State machines have two kinds of vertices: states and pseudostates. The difference is that state machine can rest in a state but not in a pseudostate. Pseudostates impose control logic on the transitions among states. There are two types of pseudostates:
Initial pseudostate = as the name implies, this is the initialization point of the state machine; noted by black filled circle. This is not allowed to have an incoming transition and the outgoing transition cannot have trigger or guard. In the example below, this is the “initialize” transition (which takes zero time) and starts the state machine in the Idle state.
Junction pseudostate = combine multiple transitions between states in to a single compound transition; noted by a smaller filled in circle. These must have one or more incoming and outgoing transitions. (see two in example below). When multiple incoming, it serves as a merge transition. When multiple outgoing, this becomes a decision point and each outgoing transition must have a guard. If all guards fail, then the state machine will remain at its current state.
Regions = own a set of vertices and transitions, each responding to event occurrences independently of others (orthogonal to each other) but works concurrently.