Time Exceptions in Sequence Diagrams Oddleif Halvorsen, Ragnhild Kobro Runde, Øystein Haugen

advertisement
Time Exceptions
Time Exceptions in Sequence Diagrams
Oddleif Halvorsen, Ragnhild Kobro Runde,
Øystein Haugen
02-Oct-2006
MARTES 2006 at MoDELS 2006
1
Summary
Time Exceptions
ƒ Introducing time exceptions improve the completeness of
sequence diagram descriptions without obscuring the
readability of the specification.
ƒ A concrete syntax is suggested and motivated
ƒ Formal semantics are given showing compositionality
– associativity of time exceptions
– that adding a time exception is a refinement
– that refinement is monotonic wrt. time exceptions
ƒ meaning that the main part and the exceptional parts can be refined
separately
02-Oct-2006
MARTES 2006 at MoDELS 2006
2
Time constraints in proper UML 2
Time Exceptions
02-Oct-2006
MARTES 2006 at MoDELS 2006
3
Why exceptions?
Focus on the
entering of
the PIN
sd Withdrawal
:User
:ATM
:Bank
Cardid(cid)
Time Exceptions
ref
EnterPin
Code(cid, pin)
msg(”Select amount”)
Amount(selectedAmount)
OK
Withdraw(selectedAmount)
Money(selectedAmount)
card
02-Oct-2006
MARTES 2006 at MoDELS 2006
4
The PIN was not entered properly
The PIN is not
fully received by
the ATM
sd EnterPin
:User
:ATM
loop(4)
Digit
{0..5}
Exception
UserLeftCard
sd UserLeftCard
:User
... but we want to
specify what should
happen then
02-Oct-2006
Time Exceptions
msg(”Enter PIN”)
:ATM
msg(”Service canceled.”)
terminate
MARTES 2006 at MoDELS 2006
5
Returning from recovery
sd Withdrawal catch
:User
:ATM
:Bank
sd ATMPinValidationTimeout
Cardid(cid)
ref
:ATM
EnterPin
:Bank
Code(cid, pin)
msg(”Select amount”)
Code(cid, pin)
{0..3}
OK(maxAmount)
Amount(selectedAmount)
Withdraw(selectedAmount)
{0..3}
OK(maxAmount)
Time Exceptions
Exception
ATMCancel
Money(selectedAmount)
Card
return
Exception
ATMPinValidationTimeout
The ATM does not
receive the OK in time
returning to the
exception caller ...
sd ATMCancel
:User
:ATM
Msg(”Bank timeout”)
card
terminate
02-Oct-2006
MARTES 2006 at MoDELS 2006
... unless it fails again
and no OK comes
6
The ATM has not received the OK
in time, and cannot proceed until
this has been handled
Exception semantics
sd Withdrawal catch
:User
:ATM
:Bank
sd ATMPinValidationTimeout
Cardid(cid)
ref
:ATM
EnterPin
:Bank
Code(cid, pin)
msg(”Select amount”)
Amount(selectedAmount)
Code(cid, pin)
{0..3}
OK(maxAmount)
Withdraw(selectedAmount)
{0..3}
OK(maxAmount)
Time Exceptions
Exception
ATMCancel
Money(selectedAmount)
Card
return
Exception
ATMPinValidationTimeout
sd ATMCancel
...But
butthe
theBank
Bankand
andthe
the
User
User does
does not
not know
know
about
about the
the exception.
exception.
:User
:ATM
Msg(”Bank timeout”)
card
terminate
02-Oct-2006
MARTES 2006 at MoDELS 2006
7
TimedSTAIRS
ƒ Defines denotational trace semantics for timed sequence
diagrams.
ƒ An event is a triple (kind, message, timestamp tag) where
Time Exceptions
– kind is either sending, reception or consumption
– message is a triple (signal, transmitter, receiver)
– timestamp tag is a placeholder for real timestamp values
ƒ The semantics of a sequence diagram d is a pair (p,n)
– p is a set of positive, i.e. valid traces
– n is a set of negative, i.e. invalid traces
– traces that are neither positive nor negative are inconclusive
ƒ If a time constraint is broken, the described traces are
negative.
02-Oct-2006
MARTES 2006 at MoDELS 2006
8
Refinement in TimedSTAIRS
Positive
Supplementing
Inconclusive
Narrowing
Time Exceptions
Negative
ƒ A sequence diagram d’ with semantics (p',n') is a
refinement of a sequence diagram d with semantics (p,n)
iff
– n ⊆ n'
– p ⊆ p’ ∪ n'
02-Oct-2006
MARTES 2006 at MoDELS 2006
9
STAIRS semantics for Time Exceptions
q: the event that may never arrive
C: the time constraint on q
ƒ Textual syntax:
e: the exception handling when C is violated
Time Exceptions
ƒ The semantics of such a diagram is the combination of
– The semantics without the exception, i.e. the semantics of
– The semantics of d1 and d2 in parallel with the exception e,
such that
ƒ the exception handling does not start too early (this is negative).
ƒ for the lifeline of q, the exception handling comes strictly after d1 and
strictly before d2.
ƒ Also: formal semantics for return, terminate and catch
02-Oct-2006
MARTES 2006 at MoDELS 2006
10
Results: Associativity
We have associativity with respect to exceptions, i.e.
=
Time Exceptions
02-Oct-2006
MARTES 2006 at MoDELS 2006
11
Results: Refinement
ƒ Adding a time constraint with an exception is a valid
refinement:
02-Oct-2006
MARTES 2006 at MoDELS 2006
12
Time Exceptions
ƒ Refinement is monotonic with respect to exceptions,
meaning that the main diagram and the exception can be
refined separately:
Summary
– associativity of time exceptions
– that adding a time exception is a refinement
– that refinement is monotonic wrt. time exceptions
ƒ meaning that the main part and the exceptional parts can be refined
separately
02-Oct-2006
MARTES 2006 at MoDELS 2006
13
Time Exceptions
ƒ Introducing time exceptions improve the completeness of
sequence diagram descriptions without obscuring the
readability of the specification.
ƒ A concrete syntax is suggested and motivated
ƒ Formal semantics are given showing compositionality
Download