[go: up one dir, main page]

0% found this document useful (0 votes)
53 views26 pages

UML Events, Signals, and State Machines

The document discusses different types of events, states, and transitions that can be modeled in UML state machines. It describes signal, call, time, and change events. It also covers states, transitions, guard conditions, and actions. The document discusses sequential and concurrent substates.

Uploaded by

yvdthzbhs9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views26 pages

UML Events, Signals, and State Machines

The document discusses different types of events, states, and transitions that can be modeled in UML state machines. It describes signal, call, time, and change events. It also covers states, transitions, guard conditions, and actions. The document discusses sequential and concurrent substates.

Uploaded by

yvdthzbhs9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Unit 2

Event and Signals ,Process and Threads


Events
• An event is the specification of a significant occurrence that has a
location in time and space.
• Anything that happens is modeled as an event in UML.
• In the context of state machines, an event is an occurrence of a
stimulus that can trigger a state transition.
• Four kinds of events – signals, calls, the passing of time, and a change
in state.
• Events may be external or internal and asynchronous or synchronous.

Fig. Events
Cont..
• Asynchronous events are events that can happen at arbitrary times
eg:- signal, the passing of time, and a change of state.
• Synchronous events, represents the invocation of an operation eg:-
Calls
• External events are those that pass between the system and its
actors.
• Internal events are those that pass among the objects that live inside
the system.
• A signal is an event that represents the specification of an
asynchronous stimulus communicated between instances.
Kinds of Events
• Signal Events
• Call Events
• Time and Change Events
• Sending and Receiving Events
Signal Event

• A signal event represents a named object that is dispatched (thrown)


asynchronously by one object and then received (caught) by another.
Exceptions are an example of internal signal.
• A signal event is an asynchronous event.
• Signal events may have instances, generalization relationships,
attributes and operations. Attributes of a signal serve as its
parameters.
Cont..
• A signal event may be sent as the action of a state transition in a state
machine or the sending of a message in an interaction
• Signals are modeled as stereotyped classes and the relationship
between an operation and the events by using a dependency
relationship, stereotyped as send
Call Events
• A call event represents the dispatch of an operation.
• A call event is a synchronous event
Time and Change Events
• A time event is an event that represents the passage of time.Modeled
by using the keyword ‘after’ followed by some expression that
evaluates to a period of time which can be simple or complex.
• A change event is an event that represents a change in state or the
satisfaction of some condition. Modeled by using the keyword ‘when’
followed by some Boolean expression
Sending or Receiving Signals
• For synchronous events (Sending or Receiving) like call event, the sender
and the receiver are in a rendezvous (the sender dispatches the signal and
wait for a response from the receiver) for the duration of the operation.
When an object calls an operation, the sender dispatches the operation
and then waits for the receiver.
• For asynchronous events (Sending or Receiving) like signal event, the
sender and receiver do not rendezvous ie,the sender dispatches the signal
but does not wait for a response from the receiver. When an object sends a
signal, the sender dispatches the signal and then continues along its flow of
control, not waiting for any return from the receiver.
• Call events can be modeled as operations on the class of the object.
• Named signals can be modeled by naming them in an extra compartment
of the class
Cont…
State Machine
• A state machine is a behavior that specifies the sequences of states
an object goes through during its lifetime in response to events.
• raphically, a state is rendered as a rectangle with rounded corners. A
transition is rendered as a solid directed line.
• State machines are used to specify the behavior of objects that must
respond to asynchronous stimulus or whose current behavior
depends on their past.
• State machines are used to model the behavior of entire systems,
especially reactive systems, which must respond to signals from
actors outside the system.
States
• A state is a condition or situation during the life of an object during
which it satisfies some condition, performs some activity, or waits for
some event.
• An object remains in a state for a finite amount of time. For example,
a Heater in a home might be in any of four states: Idle, Activating,
Active, and Shutting Down.
• A state name must be unique within its enclosing state.
• A state has five parts: Name, Entry/exit actions, Internal transitions –
Transitions that are handled without causing a change in state.
• Substates – nested structure of a state, involving disjoint (sequentially
active) or concurrent (concurrently active) substates.
• Deferred events – A list of events that are not handled in that state
but, rather, are postponed and queued for handling by the object in
another state.
• Initial state indicates the default starting place for the state machine
or substate and is represented as a filled black circle.
• Final state indicates that the execution of the state machine or the
enclosing state has been completed and is represented as a filled
black circle surrounded by an unfilled circle.
• Initial and final states are pseudo-states
Transitions
• A transition is a relationship between two states indicating that an object in
the first state will perform certain actions and enter the second state when
a specified event occurs and specified conditions are satisfied.
• Transition fires means change of state occurs. Until transition fires, the
object is in the source state; after it fires, it is said to be in the target state.
• A transition has five parts:
• Source state – The state affected by the transition.
• Event trigger – a stimulus that can trigger a source state to fire on satisfying guard
condition.
• Guard condition – Boolean expression that is evaluated when the transition is
triggered by the reception of the event trigger.
• Action – An executable atomic computation that may directly act on the object that
owns the state machine, and indirectly on other objects that are visible to the object.
• Target state – The state that is active after the completion of the transition
Cont..

• A transition may have multiple sources as well as multiple targets.


• A self-transition is a transition whose source and target states are the
same
Event Trigger
• An event in the context of state machines is an occurrence of a
stimulus that can trigger a state transition.
• Events may include signals, calls, the passing of time, or a change in
state.
• An event – signal or a call – may have parameters whose values are
available to the transition, including expressions for the guard
condition and action.
• An event trigger may be polymorphic
Guard Condition
• A guard condition is rendered as a Boolean expression enclosed in
square brackets and placed after the trigger event.
• A guard condition is evaluated only after the trigger event for its
transition occurs.
• A guard condition is evaluated just once for each transition at the
time the event occurs, but it may be evaluated again if the transition
is retriggered.
Action
• An action is an executable atomic computation i.e, it cannot be
interrupted by an event and runs to completion.
• Actions may include operation calls, the creation or destruction of
another object, or the sending of a signal to an object.
• An activity may be interrupted by other events.
Advanced States and Transitions
• Entry Actions are those actions that are to be done upon entry of a state and
are shown by the keyword event ‘entry’ with an appropriate action.
• Exit Actions are those actions that are to be done upon exit from a state
marked by the keyword event ‘exit’, together with an appropriate action
• Internal Transitions are events that should be handled internally without
leaving the state.
• Internal transitions may have events with parameters and guard conditions.
• Activities make use of object’s idle time when inside a state. ‘do’ transition
is used to specify the work that’s to be done inside a state after the entry
action is dispatched.
Deferred event
• A deferred event is a list of events whose occurrence in the state is
postponed until a state in which the listed events are not deferred
becomes active, at which time they occur and may trigger transitions
as if they had just occurred. A deferred event is specified by listing the
event with the special action ‘defer’.
Substates
• A substate is a state that’s nested inside another one.
• A state that has substates is called a composite state.
• A composite state may contain either concurrent (orthogonal) or
sequential (disjoint) sub states.
• Substates may be nested to any level
Sequential Substates
• Sequential Substates are those sub states in which an event common
to the composite states can easily be exercised by each states inside it
at any time.
• Sequential substates partition the state space of the composite state
into disjoint states.
• A nested sequential state machine may have at most one initial state
and one final state
History States
• A history state allows composite state that contains sequential substates to
remember the last substate that was active in it prior to the transition from
the composite state.
• a shallow history state is represented as a small circle containing the
symbol H.
• The first time entry to a composite state doesn’t have any history.
• the symbol H designates a shallow history, which remembers only the
history of the immediate nested state machine.
• the symbol H* designates deep history, which remembers down to the
innermost nested state at any depth.
• When only one level of nesting, shallow and deep history states are
semantically equivalent.
Concurrent SUbstate
• concurrent substates specify two or more state machines that
execute in parallel in the context of the enclosing object.
• Execution of these concurrent substates continues in parallel. These
substates waits for each other to finish to joins back into one flow.
• A nested concurrent state machine does not have an initial, final, or
history state

You might also like