0% found this document useful (0 votes)
35 views42 pages

Dynamic Modeling: Events and States Overview

Uploaded by

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

Dynamic Modeling: Events and States Overview

Uploaded by

vaishnavi todkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Dynamic Modeling

Unit II
Events & States
• The attribute values and links held by an object
are called its state.
• Overtime, the objects stimulate each other,
resulting in a series of changes to their states.
• An individual stimulus from one object to
another is an event.
• The pattern of events, states and state
transitions for a given class can be abstracted
and represented as a state diagram.
Events
• The dynamic model consist of multiple state
diagrams, one state diagram for each class with
important dynamic behavior.
• An event is something that happens at a point in a
time, such as user depresses left button or Flight
123 departs from Mumbai
• An event has no duration.
• One event may logically precede or follow another
or two events may be unrelated.
• Flight 123 must depart Mumbai before it can
arrive in Delhi; two events are casually related.
Events

• Flight 123 may depart before or after Flight


456 departs Pune ; the two events are casually
unrelated.
• Two events that are casually unrelated are
said to be concurrent; they have no effect on
each other.
• An event is a one way transmission of
information from one object to another.
Events

• Every event is unique occurrence, but we group


them into event classes and give each event class a
name to indicate common structure and behavior.
This structure is hierarchical.
• An event conveys information from one object to
another. some classes of events may be simply
signals that something has occurred, while other
classes of events convey data values.
• The data values conveyed by an event are its
attributes.
• Attributes are shown in parentheses after the event
class name.
Event classes & attributes
Scenarios and Event Traces
• A scenario is a sequence of events that occurs
during one particular execution of system.
• The scope of scenario can vary; it may include
all events in the system, or it may include only
those events generated by certain objects in
the system.
Scenario for phone call
Event trace diagram
• The sequence of events and the objects
exchanging events can both be shown in an
augmented scenario called an events trace
diagram.
• This diagram shows each object as a vertical
line and each event as a horizontal arrow from
sender object to the receiver object.
Event trace for phone call
States
• A State is an abstraction of the attribute values
and links of an object.
• Set of values & links are grouped together into a
state according to the gross behavior of objects.
• State often correspond to verbs with a suffix of
“ing”(Waiting, Dialing) or the duration of some
condition.
• A state corresponds to the interval between two
events received by an object. Event represents
points in time; states represents intervals of time.
s

• A state has duration; it occupies an interval of


time.
• A state is often associated with a continuous
activity.
• A state is often associated with the value of
an object satisfying some condition.
State Diagrams
• A state diagram relates events and states. When an
event is received, the next state depends on the
current state as well as event; a change of state
caused by an event is called a transition.
• A state diagram is a graph whose nodes are states
and whose directed arcs are transitions labeled by
event names.
• A state is drawn as a rounded box containing an
optional name.
• A transition is drawn as an arrow from the receiving
state to the target state;
s
One shot state diagram
• State diagram can represent one-shot life cycles or
continuous loop.
• One shot diagram has initial and final states.
• The initial state is entered on creation an object;
entering the final state implies destruction of the
object.
• An initial state is shown by a solid circle. A final state is
shown by bull’s-eye.
• One shot state diagram can be considered a state
diagram “subroutine” that can be referenced from
various places
s
Conditions

• A condition is a Boolean function of object


values.
• A Condition is valid over an interval of time.
• Conditions can be used as guards on transitions.
A guarded transition fires when its event occurs,
but only if the guard condition is true.
• A guard condition on a transition is shown as a
Boolean expression in brackets following the
event name.
S
Operations
• An activity is an operation that takes time to
complete. An activity is associated with a state.
• The notation “ do:A” within a state box indicates that
activity A starts on entry to the state and stops on
exit.
• An action is an instantaneous operation. An action is
associated with an event.
• Actions can also represents internal control operations
such as setting attributes or generating other events.
• The notation for an action on transition is a slash(‘/’)
& name of the action, following the name of the event
that causes it.
S
s
Nesting state Diagram
• An activity in a state diagram can be expanded
as a lower level state diagram ,each state
representing one step of the activity.
• Nested activities are one shot state diagrams
with input and output transitions, similar to
subroutines.
• The set of nested state diagrams forms a
lattice.
s
s
s
State Generalization
• A nested state diagram is actually form of
generalization on states.
• An object in a state in the high-level diagram
must be in exactly one state in the nested
diagram.
• The states in the nested diagram are all
refinements of the state in the high level
diagram
• States may have substates that inherit the
transitions of their superstates.
State Generalization
Event generalization
• Events can be organized into a generalization
hierarchy with inheritance of event attributes.
Event generalization
Concurrency
1]Aggregation Concurrency

• A state diagram for an assembly is a collection of


state diagrams, one for each component.
• The aggregate state corresponds to the
combined states of all the component diagrams..
• The aggregate state is one state from the first
diagram, and a state from the second diagram,
and a state from each other diagram.
• Guarded transition for one object can depend on
another object being in a given state. This allows
interaction between the state diagram, while
preserving modularity.
example
2]Concurrency within an Object

• We can partition some objects into subsets of


attributes or links, each of which has its own
subdiagram.
• The state of object consist of one state from
each subdiagram.
• The concurrency within an object is shown by
partitioning the composite state into
subdiagrams with dotted lines.
example
Advanced dynamic Modeling concept
1]Entry and Exit Actions
• As an alternative to showing actions on
transitions, actions can be associated with
entering or exiting a state.
• An entry action is shown inside the state box
following the keyword entry and a “/”
character.
• Exit action is shown inside the state box
following the keyword exit and a “/” character.
s
2]Internal Actions
• An event can cause an action to be performed
without causing a state change.
• There is a difference between an internal
action and a self-transition; the self transition
causes the exit and entry actions for the state
to be executed.
example
3]Automatic Transition
• When the activity is completed, a transition to
another state fires.
• An arrow without an event name indicates an
automatic transition that fires when the
activity associated with the source state is
completed.
• Such unlabeled transition are called lamda
transition.
4]Sending Events
• An object can perform the action of sending an
event to another object. A system of objects
interacts by exchanging events.
• The action “send E(attributes)” sends event E with
the given attributes to the target object or objects.
• E.g. the phone line sends a connect(phone number)
event to the switcher when a complete phone
number has been dialed.
• Race condition:- If a state can accept events from
more than one object, the order in which concurrent
events are received may affect the final state.
5]Synchronization of Concurrent Activities
• Sometimes one object must perform two(or
more)activities but must complete both
activities before it can progress to its next
state.
• E.g. a cash dispensing machine dispenses cash
and returns the user’s card at the end of a
transaction. The machine must not reset itself
until the user takes both the cash and the
card, but the user may take them in either
order or even simultaneously.
Concurrent state diagram for emitting activity

You might also like