extended finite state machines (efsm)€¦ · 1. draw only one object's chart at a time. 2. a...
TRANSCRIPT
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
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
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
Exercise 1: Metro passageway
SOEN331W-W17-L16-L17: EFSM 4
Metro passageway: formal specs
SOEN331W-W17-L16-L17: EFSM 5
Metro passageway: state diagram
SOEN331W-W17-L16-L17: EFSM 6
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
Bounded buffer: Formal specification
SOEN331W-W17-L16-L17: EFSM 8
Bounded buffer: State Diagram
SOEN331W-W17-L16-L17: EFSM 9
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
Safe: formal specifications
SOEN331W-W17-L16-L17: EFSM 11
Safe: formal specifications
SOEN331W-W17-L16-L17: EFSM 12
Safe: state diagram
SOEN331W-W17-L16-L17: EFSM 13
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
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
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
Home garage : Formal specs
SOEN331W-W17-L16-L17: EFSM 17
Home garage : Formal specs
SOEN331W-W17-L16-L17: EFSM 18
Home garage : Formal specs
SOEN331W-W17-L16-L17: EFSM 19
Home garage : State diagram
SOEN331W-W17-L16-L17: EFSM 20
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
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