0% found this document useful (0 votes)
17 views34 pages

7) State Machine and Timing Diagram

Uploaded by

kaifali532
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)
17 views34 pages

7) State Machine and Timing Diagram

Uploaded by

kaifali532
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
You are on page 1/ 34

Department of Computer Science & Engineering (AIML)

Course Code : BCS 054 Course Name: OOSD with C++

State Machine Diagrams

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

• A state diagram (also called state machine diagram, statchart


and start transition diagram) is a type of diagram behavior
diagram in UML. In most OO techniques, state diagrams are
drawn for a single class to show the lifetime behavior of a
single object. They describe all of the possible states that a
particular object (or even the entire system) can get into. State
Machines give us the means to control decisions and each state
is like a 'mode of operation' for the object which behaves
differently depending on its state.
Program Name: B.Tech CSE-AIML/AIML Program Code:
Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

• How to draw a State Machine diagram in UML?

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Step1. Identify the System:


• Understand what your diagram is representing.
• Whether it’s a machine, a process, or any object, know what
different situations or conditions it might go through.

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Step2. Identify Initial and Final States:


• Figure out where your system starts (initial state) and where it
ends (final state).
• These are like the beginning and the end points of your
system’s journey.

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Step3. Identify Possible States:


• Think about all the different situations your system can be in.
• These are like the various phases or conditions it experiences.
• Use boundary values to guide you in defining these states.

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Step4. Label Triggering Events:


• Understand what causes your system to move from one state to
another.
• These causes or conditions are the events.
• Label each transition with what makes it happen.

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Step5. Draw the Diagram with appropriate notations:


• Now, take all this information and draw it out.
• Use rectangles for states, arrows for transitions, and circles or
rounded rectangles for initial and final states.
• Be sure to connect everything in a way that makes sense.

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Understand State Machine diagram with the help of an example, ie for an online order :

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

The UML diagrams we draw depend on the system we aim to represent. Here is
just an example of how an online ordering system might look like :
1. On the event of an order being received, we transit from our initial state to
Unprocessed order state.
2. The unprocessed order is then checked.
3. If the order is rejected, we transit to the Rejected Order state.
4. If the order is accepted and we have the items available we transit to the fulfilled
order state.
5. However if the items are not available we transit to the Pending Order state.
6. After the order is fulfilled, we transit to the final state. In this example, we merge the
two states i.e. Fulfilled order and Rejected order into one final state.
Program Name: B.Tech CSE-AIML/AIML Program Code:
Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

State Machine Diagram vs Activity Diagram

UML State machine diagram and activity diagram are both


behavioral diagrams but have different emphases. Activity
diagram is flow of functions without trigger (event)
mechanism, state machine is consist of triggered states.

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

• A state machine diagram in the Figure on the left above


performs actions in response to explicit events. In contrast, the
Activity diagram in the Figure of the right above does not need
explicit events but rather transitions from node to node in its
graph automatically upon completion of activities.

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

• Take a look at the Activity Diagram which models the flow of


actions for an incident. Such an Activity Diagram focuses on
the flow of data within a system.

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

• Take a look at the State Machine Diagram below. It models the


transitioning of states for an incident. Such a state diagram
focuses on a set of attributes of a single abstraction (object,
system).

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

• ref,. …
• https://www.uml-diagrams.org/

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Timing Diagram

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

• Lifeline
• As the name suggests, the lifeline portrays an
individual element in the interaction. It represents
a single entity, which is a part of the interaction. It
is represented by the classifier's name that it
depicts. A lifeline can be placed within a
"swimlane" or a diagram frame.

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

• States or conditions

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Duration Constraint
• The duration constraint is a constraint of an interval,
which refers to duration interval. It is used to determine
if the constraint is satisfied for a duration or not. The
duration constraint semantics inherits from the
constraints.
• The negative trace defines the violated constraints,
which means the system is failed. A graphical
association between duration interval and the construct,
which it constrains, may represent a duration constraint.
Program Name: B.Tech CSE-AIML/AIML Program Code:
Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

• Draw timing diagram for Water (H2O ) where ice should melt
into water in 1 to 6 minutes?

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

• Time Constraint
• It is an interval constraint, which refers to the time
interval. Since it is a time expression, it depicts if
the constraint is satisfied or not. The constraints
dispense its time constraints semantics.
The graphical association is mainly represented by a small line in between a time
interval and an occurrence specification.

A person should wakeup in between 5:40 am, and 6 am

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

• Examples

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

• In a Unified Modeling Language (UML) diagram, the namespace type "sd" is used
for timing diagrams, communication diagrams, and interaction overview
diagrams. The "sd" is used for historical reasons, even though the namespace type is
an interaction in the diagram header.

Program Name: B.Tech CSE-AIML/AIML Program Code:


Department of Computer Science & Engineering (AIML)
Course Code : BCS 054 Course Name: OOSD with C++

• Benefits of Timing Diagram


1.It depicts the state of an object at a particular
point in time.
2.It implements forward and reverses engineering.
3.It keeps an eye on every single change that
happens within the system.
• Drawbacks of Timing Diagram
1.It is hard to maintain and understand.
Program Name: B.Tech CSE-AIML/AIML Program Code:

You might also like