Back -
Formal Specification | Previous - Petrol Filling StationCase Study 4 - Therapy Machine
Models the Graphical User Interface, based upon the control console of a real medical device, though the same technique can be applied to any event driven system
The Z text is illustrated with a statechart. The system design is split into largely independent subsystems which can include both data and operations on that data, (as with C++ classes).
The Console state incorporates different displays and is concerned with the dialogue from the user who enters a setting via a text input and an accept button in a dialogue box on screen.
An event occurs through a mouse click or a keystroke to change the console state.
Selecting a Display
Changing a Setting Value
Finishing the Dialogue
The GUI is to be used in conjunction with the Machine
[DISPLAY,SETTING,VALUE,CHAR]
TEXT == seq CHAR
MODE ::= idle | dialog
BUTTON ::= accept | cancel
ÚÄConsoleÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
display : DISPLAY
mode : MODE
buffer : TEXT
setting : SETTING
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
[EVENT]
ÚÄEventÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Console
e? : EVENT
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
Many events are simply ignored (they do not change the Console state).
Ignore Event ™ Console
disp : EVENT DISPLAY
ÚÄSelectDisplayÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Event
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
mode = idle
e? î dom disp
display' = disp e?
mode' = mode
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ÚÄIgnoreDisplayÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Ignore
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
e? î dom disp
mode = dialog
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
We use schema disjunction to combine the two cases.
DisplayEvent SelectDisplay IgnoreDisplay
stg : EVENT SETTING
ÚÄSelectSettingÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Event
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
mode = idle
e? î dom stg
setting' = stg e?
mode' = dialog
buffer' = í
display' = display
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
If a dialog is already underway, this operation is disabled.
ÚÄIgnoreSettingÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Ignore
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
e? î dom stg
mode = dialog
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
SettingEvent SelectSetting IgnoreSetting
char : EVENT CHAR
edit : (TEXT
ÚÄGetCharÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Event
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
mode = dialog
e? î dom char
buffer' = edit (buffer,char e?)
mode' = mode
setting' = setting
display' = display
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ÚÄIgnoreCharÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Ignore
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
e? î dom char
mode = idle
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
CharEvent GetChar IgnoreChar
button : EVENT BUTTON
value : TEXT VALUE
vaild_ : SETTING VALUE
ÚÄAcceptÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Event
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
mode = dialog
e? î dom button
button e? = accept
valid(setting, value buffer)
mode' = idle
display' = display
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ÚÄRepromptÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Event
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
mode = dialog
e? î dom button
button e? = accept
valid(setting, value buffer)
buffer' = buffer
mode' = mode
display' = display
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ÚÄCancelÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Event
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
mode = dialog
e? î dom button
button e? = cancel
mode' = idle
display' = display
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ButtonEvent Accept Cancel Reprompt
ÚÄMachineÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
measured,prescribed : SETTING VALUE
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
The NewSetting operation describes what happens in the Machine when a new value v? is assigned to prescribed setting s?.
ÚÄNewSettingÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Machine
s? : SETTING
v? : VALUE
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
prescribed' = prescribed
ÚÄSysÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Console
Machine
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ÚÄChangeSettingÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Sys
Accept
NewSetting
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
s? = setting
v? = value buffer
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
SysDisplayEvent DisplayEvent ™ Machine
SysSettingEvent SettingEvent ™ Machine
SysCharEvent CharEvent ™ Machine
SysButtonEvent ChangeSetting (Reprompt ™ Machine) (Cancel ™ Machine)