extended finite state machines (efsm)€¦ · 1. draw only one object's chart at a time. 2. a...

22
SOEN331W-W17-L16-L17: EFSM 1 Extended Finite State Machines (EFSM) Harel combined the Mealy and the Moore automaton and extended this combination by Conditional Transitions Hierarchical States Parallel States States with History

Upload: others

Post on 01-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

SOEN331W-W17-L16-L17: EFSM 1

Extended Finite State Machines (EFSM)

Harel combined the Mealy and the Moore automaton and extended this combination by ◆ Conditional Transitions ◆ Hierarchical States ◆ Parallel States ◆ States with History

Page 2: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

The basic rules

1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible object values that have similar

behavior - but possibly different attribute values. 4. A state is in a different box if objects in these states behave

differently. 5. From each state draw an arrow to another state if the object can

change from one to the other in one step. 6. Label the arrow with the event that causes it. 7. Show the initial state by drawing an arrow from a black blob to the

initial state. 8. Show the destruction of the object (if there is one) as an arrow

going from a state to a blob inside a circle.

SOEN331W-W17-L16-L17: EFSM 2

Page 3: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

State types■ Hierarchically nested states

■ A state (called superstate) is modeled as an EFSM and contain its own states (called substates, or nested states)

■ Substates inherit the transitions of their superstate

■ Orthogonal states ■ A state can include independent (or parallel)

regions.

SOEN331W-W17-L16-L17: EFSM 3

Page 4: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Exercise 1: Metro passageway

SOEN331W-W17-L16-L17: EFSM 4

Page 5: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Metro passageway: formal specs

SOEN331W-W17-L16-L17: EFSM 5

Page 6: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Metro passageway: state diagram

SOEN331W-W17-L16-L17: EFSM 6

Page 7: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Exercise 2: Bounded buffer■ Consider a bounded buffer of capacity greater than

one. ■ The buffer has three states: it can be empty, it can

be partially full, or it can be full. ■ One may place an item in the buffer provided it is

not full. ■ One may also retrieve an item from the buffer

provided it is not empty. ■ We will use the events put and get to correspond to

their respective operations.SOEN331W-W17-L16-L17: EFSM 7

Page 8: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Bounded buffer: Formal specification

SOEN331W-W17-L16-L17: EFSM 8

Page 9: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Bounded buffer: State Diagram

SOEN331W-W17-L16-L17: EFSM 9

Page 10: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Exercise 3: Safe■ The safe can be open or closed. ■ While being closed, the safe can be unlocked, or it can

be locked. ■ When the safe is unlocked and provided the door is

closed, a person may enter a valid code causing the safe to lock.

■ Upon locking, the safe produces a beep sound. ■ When the safe is locked, a person may enter a valid

code, causing the safe to unlock.

SOEN331W-W17-L16-L17: EFSM 10

Page 11: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Safe: formal specifications

SOEN331W-W17-L16-L17: EFSM 11

Page 12: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Safe: formal specifications

SOEN331W-W17-L16-L17: EFSM 12

Page 13: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Safe: state diagram

SOEN331W-W17-L16-L17: EFSM 13

Page 14: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Exercise 4: : Home garage■ Consider a system that controls the door to a home

garage which can hold one vehicle: ■ The system can be in states idle, opening or

closing. ■ Initially the system is at idle state. ■ If a vehicle arrives and provided the code sent from

the vehicle's remote control is valid, then the system performs a transition to the opening state and switches on an outside light.

SOEN331W-W17-L16-L17: EFSM 14

Page 15: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Home garage■ State opening is a compound state and its initial

state is ascending. ■ After 10 seconds the system performs a

transition to state open. ■ Having reached state open marks the completion of

the execution of all activities inside this compound state and the system would now perform a transition to state closing after 20 seconds.

SOEN331W-W17-L16-L17: EFSM 15

Page 16: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Home garage

■ Within state closing, the system starts at state descending and it would perform a transition to state closed after 10 seconds and switch on an inside light.

■ From here, the system would move to state idle after 30 seconds. However, if while at closing state the system detects a movement (perhaps a child has approached the descending gate), then the system halts the closing door, produces an alarming sound and performs a transition to state opening.

SOEN331W-W17-L16-L17: EFSM 16

Page 17: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Home garage : Formal specs

SOEN331W-W17-L16-L17: EFSM 17

Page 18: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Home garage : Formal specs

SOEN331W-W17-L16-L17: EFSM 18

Page 19: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Home garage : Formal specs

SOEN331W-W17-L16-L17: EFSM 19

Page 20: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Home garage : State diagram

SOEN331W-W17-L16-L17: EFSM 20

Page 21: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

State machine with concurrent (Orthogonal, AND) Composite State

■ An object is in concurrent states when it is considered to be in more than one state at the same time

SOEN331W-W17-L16-L17: EFSM 21

Page 22: Extended Finite State Machines (EFSM)€¦ · 1. Draw only one object's chart at a time. 2. A state is drawn as a box with rounded corners. 3. Each state models a set of possible

Exercise 5 (team work, submit at the end of the tutorial): modeling the behaviour of a Course Section

The course section life cycle starts from its planning. Once the decision for scheduling the registration for the course is received, the course is scheduled. The course section is opened for enrolment when the course registration begins. While the course section is opened, the requests for registering can be accepted. When a request for registration arrives while the class size is full and before the registration deadline has passed, it is added to the course waiting list. Once the registration deadline has passed the course section becomes closed. The course will not be actually taught until the class size reaches a predefined minimum. When the registration deadline has passed and the class size is below the minimum, the course section is cancelled. Requests for dropping the course or its waiting list can be received until the deadline for dropping a course is passed. The deadline for dropping a course is week 6 of the term. If the size of the course section becomes less than the minimum while the course is taught, the course section is cancelled and the remaining students are moved to another section. The course section can also be cancelled at any time before the term is started.

22SOEN331-W18: Tutorial 3