View
269
Download
1
Category
Tags:
Preview:
Citation preview
Control Flow Diagram
• extension to data flow diagram to represent control flow rather than data flow
• contains same processes as the data flow diagram but instead of showing data flow, it diagrams control flow
• diagram the events that cause the various process to be activated
Control Flow Diagram (2)
• together with the CSPEC (control specification) show– how software behaves when the event or
control signal is sensed– which processes are invoked as a consequence
of the occurrence of the event
Drawing a Control Flow Diagram
• draw the data flow diagram and remove all of the data flow arrows
• add control items and windows into CSPEC where needed
PSPEC for check temperature
If current temperature> safe temperature
then
set status to “true”;
else
set status to “false”;
end if;
Data Flow for Copier
read opinput
managecopying
produceuserdisplays
reloadpaper
performproblemdiagnosis
op commandsand data copy info
copystatus
displays
reloadreqs.
reloadstatus
problemtype
problemindicator
Control Flow for Copier
read opinput
managecopying
produceuserdisplays
reloadpaper
performproblemdiagnosis
start/stop paperfeedstatus
alarm
full
finished
Determining Events• list all sensors that are read by software• list all interrupt conditions• list all switches activated by operator• list all data conditions• look at noun-verb combinations reviewing
control items as possible CSPEC I/Os• identify states, how each state is reached, &
define transitions between states
Microwave Oven Events
• Half Power -- user pressed
• Full Power -- user pressed
• Timer -- user set
• Door open -- switch not closed
• Door Closed -- switch is closed
• Start -- user pressed
• Timeout -- timer has finished
Control Flow Diagram and CSPEC
• event that flows from the outside world into | (CSPEC) implies the CSPEC will activate one or more processes in the CFD
• A control item that emanates from a process and flows into | (CSPEC) implies control and activation of some other process or outside entity
Events
• events occur at discrete points in time and cause an instantaneous change in the state of a process
• can occur asynchronously (any point in time) or synchronously (at clocked intervals)
State Transition Diagrams
• graphical representation of the events and the stimuli that cause transition from one event to another
• above each transition list the input/output that cause/result from the stimuli and event.
State Transition Matrix
• uses a tabular rather than graphical form
• all possible states identify the rows
• all stimuli identify the columns
• at intersection next possible state is listed
• add column at end of matrix for outputs
State Transition Matrix for Copier
state\stimuli start full jammed done empty unjammed outputsread com. MC - DP RC RP - -make copies - - DP RC RP - copiesreload paper - RC - - RP - -diagnosis prob. - - DP - RP RC -
makingcopies
readingcommands
diagnosingproblem
reloadingpaper
not empty andstart
making copies
emptyreload paper
full
readingcommands
jammeddiagnosing
problem
not jammedreading
commands
idle
readingcommands
copies done
readingcommands
State Transition Diagram --Copy Machine
empty and start
reloading paper
STIMULUS STATE
LIFT PHONE
DIAL 9
DIAL 1-8
DIAL 0
HANG UP PHONE
SEVENTH DIGIT COLLECTED
IDLE
DIAL TONE STATE
__
__
__
__
__
DIAL TONE STATE
__
DISTINCTIVE DIAL TONE
COLLECTING 7 DIGITS
OPERATOR
IDLE
__
DISTINCTIVE DIAL TONE STATE
__
COLLECTING 7 DIGITS
COLLECTING 7 DIGITS
OPERATOR
IDLE
__
OPERATOR STATE
__
__
__
__
IDLE
__
COLLECTING 7 DIGITS STATE
__
COLLECTING 7 DIGITS
COLLECTING 7 DIGITS
COLLECTING 7 DIGITS
IDLE
IF CALLED PARTY BUSY, BUSY STATE; OTHERWISE, RINGING STATE
RINGING STATE
__
__
__
__
IDLE
__
BUSY STATE
__
__
__
__
IDLE
__
OUTPUTS
QUIET
DIAL TONE TOCALLING PARTY
DISTINCTIVEDIAL TONE TOCALLING PARTY
CONNECTCALLING PARTYTO OPERATOR
NO TONE TOCALLING PARTY
RINGING SIGNALTO CALLEDPARTY; RINGINGTONE TO CALLINGPARTY
BUSY TONE TOCALLING PARTY
IDLEDIALTONE
RINGING
DISTIN.DIALTONE
BUSY
BUSY
ON HOOK/QUIET
DIAL BUSY NUMBER/BUSY TONE
CALLED PARTYOFF HOOK/
CONNECTED
DIAL IDLE NUMBER/RING BACK TONE
DIAL IDLE NUMBER/RING BACK TONE
DIAL BUSY NUMBER/BUSY TONE
ON HOOK/QUIET
ON HOOK/QUIET
ON HOOK/QUIET
OFF HOOK/DIAL TONE
ON HOOK/QUIET
DIAL 9/DISTINCTIVE
DIAL TONE
State Transition Matrix for CD player
state\stimuli on button off button play door open track sel. door closed end play outputsidle if disk rp - if disk dp - if disk dp if do dc idle quietready ready idle ready door open ready - idle musicdoor open door open - door open - door open door closed - quietdisk playing - idle - door open disk play - rp musicready play - idle disk play door open disk play - - musicdoor closed - idle disk play door open disk play - - musictrack sel. - idle disk play - track sel. - - music
The state diagram depends on the range of facilities on the CD player.
IdleIdle
Door CloseDoor Close
ReadyReadyDisk Door
open
Disk Dooropen
Ready to play
Ready to play
IdleIdle
Diskplaying
Diskplaying
Trackselection
Trackselection
Off buttonOnbutton
Door closed
Off button
Open door
Door open
Door closed
End of playPlay button
Off button
Off button
Off button
Track selector
Track selector
Playbutton
State Transition Matrix for SIMPLE CD Player (2)
state\stimuli power play door stop track select outputoff if disc ready else on ------ ----- ---- ----- quieton off ndm door open ndm ndm quietready off play door open ready play musicdoor open off if disc play else ndm if disc ready else on door open if disc play else ndm quietplay off play door open ready play musicno disc m off ndm door open ndm ndm quiet
Off
On(no disc)
Door Open
Off
Play
Readydisc
power
door
power
power
play | track select
power
stop
door
play | track select
door
powerpower
door
door
CD PlayerState Transition Diagram
Display Messageno disc
play | track select| stop
door
play | stop |track select
power
play | track select
stop
play | track select
stop
Microwave Oven Events
• Half Power -- user pressed
• Full Power -- user pressed
• Timer -- user set
• Door open -- switch not closed
• Door Closed -- switch is closed
• Start -- user pressed
• Timeout -- timer has finished
State Transistion Matrix for Microwave Oven
state\stimuli half full timer door open door closed start timeout outputhalf half full set time op dis op en timed op ccfull half full set time op dis op en timed op ccset time set time set time set time op dis op en timed op set timeop disabled/light on half/op dis full/op dis set time/op dis op dis op en op dis op disop enabled/light off half full set time op dis op en timed op op entimed operation op dis op en timed op cccooking complete op dis op en op en op en
IdleIdle
Fullpower on
Fullpower on
Half power on
Half power on
Settime
Settime
Operationdisabled
Operationdisabled
Operationenabled
Operationenabled
Timedoperation
Timedoperation
Cookingcomplete
Cookingcomplete
IdleIdle
TimerTimer
Timer
Full Power Full
Power
Half Power
Half Power
Door open
Door open
Door closed
Door closed
Start
Timeout
Recommended