Unit-3 Unit-5 - Relatable Topic - Lecture
Unit-3 Unit-5 - Relatable Topic - Lecture
Presented By
DEEPTI GOUR
FSM – Finite State Machine
2
Finite State Machines come from a branch of Computer Science called “automata
theory”. The family of data structure belonging to this domain also includes
the Turing Machine.
A Finite State Machine, or FSM, is a computation model that can be used to simulate
sequential logic, or, in other words, to represent and control execution flow.
A Finite State Machine is any device storing the state of something at a given time.
The state will change based on inputs, providing the resulting output for the
implemented changes.
Finite State Machines can be used to model problems in many fields, including
mathematics, artificial intelligence, games or linguistics.
3
Coin-operated turnstile
States: locked, unlocked
Transitions: pointing a coin in the slot will unlock the turnstile, pushing the arm of the unlocked turnstile will let
the costumer pass and lock the turnstile again
Traffic Light
States: Red, Yellow, Green
Transitions: After a given time, Red will change to Green, Green to Yellow, and Yellow to Red
Programming example
Knowing what we know, let’s make a simple and basic programming example. Let’s say we have our friend
Mario in our favorite video game. So, Mario can do the following actions:
• Stand still
• Run
• Jump
• Duck
For example,(Mario Game) - Mario can stand still then run when we push the corresponding button, but cannot
run while he is jumping. So, an input that doesn’t cause a change of state is ignored.
FSM Model in detail 4
In a system, when numbers of states are finite, then the system is called a Finite State
Machine.
The main design tool for FSM is the State Transition Diagram (STD). Also called a
state diagram or bubble diagram, the depicts the relationship between the system
state.
5
6
UML is a standard language for specifying , visualizing, constructing , and documenting the
artifacts of software systems.
UML was created by Object Management Group and UML specification draft (1st Version ) was
proposed in OMG in January 1997.
UML is a graphical notation for modeling various aspects of software systems.
UML Diagram Types 10
UML Diagram Types (UML Diagrams are divide into two types )
1. Structural UML Diagram 2. Behavioral UML Diagram
• represent the static aspects of the • represent the dynamic aspects of the
system system.
• show the things in the modeled • show what should happen in a system.
system. In a more technical term, They describe how the objects interact
they show different objects in a with each other to create a functioning
system. system.
1. Class Diagram 1. Activity Diagram
2. Object Diagram 2. Use Case Diagram
3. Component Diagram 3. Interaction Overview Diagram
4. Composite Structure Diagram 4. Timing Diagram
5. Deployment Diagram 5. State Machine Diagram
6. Package Diagram 6. Communication Diagram
7. Profile Diagram 7. Sequence Diagram
11
1. Class Diagram
Component UML
diagrams can help break
down the (Project or
Software ) system into
smaller components
when dealing with the
documentation of quite
complex systems. Often
it is quite hard to predict
the architecture of a
system since it might
encompass various
departments or employ
different technologies.
4.Deployment Diagram 14
Distributed systems that have multiple servers and can host multiple
versions of software artifacts, some of which might even migrate from node
to node
15
16
5. Package Diagram
Packages group related model elements of all types, including other packages.
User can group model elements in packages for the following reasons: Organize
the model elements so that the model is easier to understand and to navigate in the
Project Explorer.
Model the architecture of your system by using packages to represent the various
layers or subsystems (that must be unique)
Packages also represent namespaces, which means that the model elements within
a package must have unique names.
For example, if you validate a model that has an actor named Customer and a class
named Customer in the same package, you will receive a warning that conflicting
names appear in the same package. To prevent the warning, you can put the
Customer actor in another package.
You can use packages in several diagrams, including class, component, and use-
case diagrams. Each package has a unique name that describes its content.
17
18
19
20
6. Composite Structure Diagram
composite structure diagram depicts the internal structure of structured
classifiers by using parts, ports, and connectors. A structured classifier defines
the implementation of a classifier and can include a class, a component, or a
deployment node.
You can use the composite structure diagram to show the internal details of a
classifier and to describe the objects and roles that work together to perform the
behavior of the containing classifier.
Ports: In composite structure diagrams, a port defines the interaction point between a
classifier instance and its environment or behavior of the classifier and its internal parts.
Profiles provide a means of extending the UML. They are based on additional
stereotypes and Tagged Values that are applied to UML elements, connectors and their
components. A Profile is a collection of such extensions that together describe some
particular modeling problem and facilitate modeling constructs in that domain.
Activity diagrams are used to model system behaviors, and the way in which
these behaviors are related in an overall flow of the system (that is, dynamic
element interactions).
Step 2: Identify Activities Break down the complex process into distinct activities
or actions involved.
Step 3: Start and End Nodes Draw a rounded rectangle to represent the start and
end of the process.
Step 4: Add Activities Use rectangles to represent activities. Connect them using
arrows to indicate the flow of the process.
Step 6: Connect Activities and Decisions Connect activities and decision points
with arrows. Based on the decision outcome, create branches using arrows
to represent different paths.
Symbols Used in Activity Diagrams 28
Start/End: Circle
A small filled circle that symbolizes the initial state or the start of
the activity (initial node).
As an example, the following state machine diagram shows the states that a door goes through
during its lifetime.
it is mainly used to analyze the object states influenced by events. This analysis is helpful to
understand the system behavior during its execution.
To identify the events responsible for state changes and Forward and reverse engineering.
1. States
A state is denoted by a round-cornered rectangle
with the name of the state written inside it.
2. Initial and Final States
The initial state is denoted by a filled black circle
and may be labeled with a name. The final state is
denoted by a circle with a dot inside and may also be
labeled with a name.
3. Transitions
Transitions from one state to the next are denoted
by lines with arrowheads. A transition may have a
trigger, a guard and an effect.
Self-Transitions 38
A state can have a transition that returns to itself, as in the following diagram. This is most useful
when an effect is associated with the transition.
Compound States
A state machine diagram may include sub-machine diagrams,
Entry Point
Sometimes you won’t want to enter a sub-machine at the normal initial state. For example, in the
following sub-machine it would be normal to begin in the "Initializing" state, but if for some reason
it wasn’t necessary to perform the initialization, it would be possible to begin in the "Ready" state by
transitioning to the named entry point.
Choice Pseudo-State
A choice pseudo-state is shown as a diamond with one transition arriving and two or more
transitions leaving.
Junction Pseudo-State
Junction pseudo-states are used to chain together multiple transitions. A single junction can have
one or more incoming, and one or more outgoing, transitions; a guard can be applied to each
transition. Junctions are semantic-free. A junction which splits an incoming transition into multiple
outgoing transitions realizes a static conditional branch, as opposed to a choice pseudo-state which
realizes a dynamic conditional branch.
39
The door can be in one of three states: "Opened", "Closed" or "Locked". It can respond to the
events Open, Close, Lock and Unlock. Notice that not all events are valid in all states; for example,
if a door is opened, you cannot lock it until you close it. Also notice that a state transition can have a
guard condition attached:
if the door is Opened, it can only respond to the Close event
if the condition doorWay->isEmpty is fulfilled.
40
Thanks