– 20 – 2015-02-03 – main –
Software Design, Modelling and Analysis in UML
Lecture 20: Live Sequence Charts
2015-02-03
- Prof. Dr. Andreas Podelski, Dr. Bernd Westphal
Albert-Ludwigs-Universit¨ at Freiburg, Germany
Lecture 20: Live Sequence Charts 2015-02-03 Prof. Dr. Andreas - - PowerPoint PPT Presentation
Software Design, Modelling and Analysis in UML Lecture 20: Live Sequence Charts 2015-02-03 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal 20 2015-02-03 main Albert-Ludwigs-Universit at Freiburg, Germany Contents & Goals
– 20 – 2015-02-03 – main –
Albert-Ludwigs-Universit¨ at Freiburg, Germany
– 20 – 2015-02-03 – Sprelim –
2/51
– 20 – 2015-02-03 – main –
3/51
– 20 – 2015-02-03 – main –
4/51
N S W E
CD, SM S = (T, C, V, atr ), SM M = (ΣD
S , AS , →SM )
ϕ ∈ OCL expr CD, SD S , SD B = (QSD, q0, AS , →SD, FSD) π = (σ0, ε0)
(cons0,Snd0)
− − − − − − − − →
u0
(σ1, ε1)· · · wπ = ((σi, consi, Sndi))i∈N G = (N, E, f)
OD
– 20 – 2015-02-03 – main –
5/51
– 20 – 2015-02-03 – Sbehav –
6/51
– 20 – 2015-02-03 – Sreflective –
7/51
system (S, − →, S0) constructed according to discard/dispatch/commence-rules.
→, S0).
(cons0,Snd0)
(cons1,Snd1)
– 20 – 2015-02-03 – main –
8/51
– 20 – 2015-02-03 – Slscsyn –
9/51
LSC: L AC: actcond AM: invariant I: strict
Environment : LightsCtrl Operational [1, 3] : CrossingCtrl t(10) t : BarrierCtrl [1, 5] secreq lights on barrier down lights ok b a r r i e r
¬MvUp done
CrossingCtrl
lights ok()
barrier ok done LightsCtrl
Operational : Bool lights on()
BarrierCtrl
MvUp : Bool
1 1 1 1
– 20 – 2015-02-03 – Slscsyn –
10/51
LSC: L AC: actcond AM: invariant I: strict
Environment : LightsCtrl Operational [1, 3] : CrossingCtrl t(10) t : BarrierCtrl [1, 5] secreq lights on barrier down lights ok b a r r i e r
¬MvUp done CrossingCtrl LightsCtrl BarrierCtrl
1 1 1 1
the rest of this scenario doesn’t apply; maybe there’s another LSC for that case.
it shall reply with ‘lights ok’ within 1–3 time units,
(dispatch time not included) it shall not be in state ‘MvUp’,
– 20 – 2015-02-03 – Slscsyn –
11/51
LSC: L AC: actcond AM: invariant I: strict
Environment : LightsCtrl Operational [1, 3] : CrossingCtrl t(10) t : BarrierCtrl [1, 5] secreq lights on barrier down lights ok b a r r i e r
¬MvUp done CrossingCtrl LightsCtrl BarrierCtrl
1 1 1 1
Environment : C
– 20 – 2015-02-03 – Slscsyn –
12/51
LSC: L AC: actcond AM: invariant I: strict
Environment : LightsCtrl Operational [1, 3] : CrossingCtrl t(10) t : BarrierCtrl [1, 5] secreq lights on barrier down lights ok b a r r i e r
¬MvUp done CrossingCtrl LightsCtrl BarrierCtrl
1 1 1 1
a b
– 20 – 2015-02-03 – Slscsyn –
13/51
LSC: L AC: actcond AM: invariant I: strict
Environment : LightsCtrl Operational [1, 3] : CrossingCtrl t(10) t : BarrierCtrl [1, 5] secreq lights on barrier down lights ok b a r r i e r
¬MvUp done CrossingCtrl LightsCtrl BarrierCtrl
1 1 1 1
expr1 expr2 expr3
– 20 – 2015-02-03 – Slscsyn –
14/51
a b a
a expr 1 b c
a b
– 20 – 2015-02-03 – Slscsyn –
15/51
LSC: L AC: actcond AM: invariant I: strict
Environment : LightsCtrl Operational [1, 3] : CrossingCtrl t(10) t : BarrierCtrl [1, 5] secreq lights on barrier down lights ok b a r r i e r
¬MvUp done CrossingCtrl LightsCtrl BarrierCtrl
1 1 1 1
the rest of this scenario doesn’t apply; maybe there’s another LSC for that case.
it shall reply with ‘lights ok’ within 1–3 time units,
(dispatch time not included) it shall not be in state ‘MvUp’,
– 20 – 2015-02-03 – Slscsyn –
16/51
chart location message condition/ local inv. hot:
a b b p
cold:
a b b p
always vs. at least once must vs. may progress mustn’t vs. may get lost necessary vs. legal exit
– 20 – 2015-02-03 – Slscsyn –
17/51
LSC: L AC: actcond AM: invariant I: strict
Environment : LightsCtrl Operational [1, 3] : CrossingCtrl t(10) t : BarrierCtrl [1, 5] secreq lights on barrier down lights ok b a r r i e r
¬MvUp done CrossingCtrl LightsCtrl BarrierCtrl
1 1 1 1
the rest of this scenario doesn’t apply; maybe there’s another LSC for that case.
it shall reply with ‘lights ok’ within 1–3 time units,
(dispatch time not included) it shall not be in state ‘MvUp’,
– 20 – 2015-02-03 – Slscsyn –
18/51
One major defect of MSCs and SDs: they don’t say when the scenario has to/may be observed. LSCs: Activation condition (AC ∈ ExprS ), activation mode (AM ∈ {init, inv}), and pre-chart.
: C : D a b
LSC: L AC: expr AM: invariant I: strict
: C : D a b
– 20 – 2015-02-03 – Slscsyn –
18/51
One major defect of MSCs and SDs: they don’t say when the scenario has to/may be observed. LSCs: Activation condition (AC ∈ ExprS ), activation mode (AM ∈ {init, inv}), and pre-chart.
: C : D a b
LSC: L AC: expr AM: invariant I: strict
: C : D a b
(AM = initial)
(AM = invariant) and if the pre-chart is observed from k to k + n, then the main-chart has to follow from k + n + 1.
– 20 – 2015-02-03 – Slscsyn –
19/51
LSC: L AC: actcond AM: invariant I: strict
Environment : LightsCtrl Operational [1, 3] : CrossingCtrl t(10) t : BarrierCtrl [1, 5] secreq lights on barrier down lights ok b a r r i e r
¬MvUp done CrossingCtrl LightsCtrl BarrierCtrl
1 1 1 1
the rest of this scenario doesn’t apply; maybe there’s another LSC for that case.
it shall reply with ‘lights ok’ within 1–3 time units,
(dispatch time not included) it shall not be in state ‘MvUp’,
– 20 – 2015-02-03 – main –
20/51
– 20 – 2015-02-03 – main –
21/51
x : y : z :
E F G
– 20 – 2015-02-03 – main –
22/51
x : y : z :
E F G
– 20 – 2015-02-03 – main –
23/51
x : y : z :
E F G
l1,0 l1,1 l1,2 l2,0 l2,1 l2,2 l2,3 l3,0 l3,1
– 20 – 2015-02-03 – main –
24/51
x : y : z :
E F G
l1,0 l1,1 l1,2 l2,0 l2,1 l2,2 l2,3 l3,0 l3,1
– 20 – 2015-02-03 – main –
25/51
x : y : z :
E F G
l1,0 l1,1 l1,2 l2,0 l2,1 l2,2 l2,3 l3,0 l3,1
– 20 – 2015-02-03 – main –
26/51
x : y : z :
E F G
l1,0 l1,1 l1,2 l2,0 l2,1 l2,2 l2,3 l3,0 l3,1
E!
x,y
E?
x,y
F !
y,x
F ?
y,z ∧ ¬G?! y,x
G?!
y,x ∧ ¬F ? y,z
G?!
y,x
F ?
y,z
F ?
y,z ∧ G?! y,x
– 20 – 2015-02-03 – main –
27/51
x : y : z :
E F G
l1,0 l1,1 l1,2 l2,0 l2,1 l2,2 l2,3 l3,0 l3,1
E!
x,y
E?
x,y
F !
y,x
F ?
y,z ∧ ¬G?! y,x
G?!
y,x ∧ ¬F ? y,z
G?!
y,x
F ?
y,z
F ?
y,z ∧ G?! y,x
¬E!
x,y
¬E?
x,y
¬F !
y,x
¬(F ?
y,z ∨ G?! y,x)
¬G?!
y,x
¬F ?
y,z
true
– 20 – 2015-02-03 – main –
28/51
x : y : z :
E F G
l1,0 l1,1 l1,2 l2,0 l2,1 l2,2 l2,3 l3,0 l3,1
q1 q2 q3 q4 q5 q6 q7
E!
x,y
E?
x,y
F !
y,x
F ?
y,z ∧ ¬G?! y,x
G?!
y,x ∧ ¬F ? y,z
G?!
y,x
F ?
y,z
F ?
y,z ∧ G?! y,x
¬E!
x,y
¬E?
x,y
¬F !
y,x
¬(F ?
y,z ∨ G?! y,x)
¬G?!
y,x
¬F ?
y,z
true
– 20 – 2015-02-03 – main –
29/51
– 20 – 2015-02-03 – main –
30/51
N S W E
CD, SM S = (T, C, V, atr ), SM M = (ΣD
S , AS , →SM )
ϕ ∈ OCL expr CD, SD S , SD B = (QSD, q0, AS , →SD, FSD) π = (σ0, ε0)
(cons0,Snd0)
− − − − − − − − →
u0
(σ1, ε1)· · · wπ = ((σi, consi, Sndi))i∈N G = (N, E, f)
OD
– 20 – 2015-02-03 – main –
31/51
– 20 – 2015-02-03 – Smodellang –
32/51
S × 2D(C )×Evs(E ,D)×D(C ) × 2D(C )×Evs(E ,D)×D(C )ω
– 20 – 2015-02-03 – Smodellang –
33/51
A
S × ˜
(cons0,Snd0)
u0
– 20 – 2015-02-03 – Smodellang –
34/51
L(M) := {(σi, consi, Snd i)i∈N0 ∈ (ΣD
S × ˜
A)ω | ∃ (εi, ui)i∈N0 : (σ0, ε0)
(cons0,Snd0)
− − − − − − − − →
u0
(σ1, ε1) · · · ∈ M}
– 20 – 2015-02-03 – Smodellang –
35/51
x,y | E? x,y | ¬ψ | ψ1 ∨ ψ2,
– 20 – 2015-02-03 – Smodellang –
36/51
S × ˜
x,y if and only if ∃
x,y if and only if ∃
– 20 – 2015-02-03 – Smodellang –
37/51
– 20 – 2015-02-03 – Smodellang –
38/51 (σ, cons, Snd) | =β expr iff Iexpr(σ, β) = 1; (σ, cons, Snd) | =β E!
x,y iff (β(x), (E,
d), β(y)) ∈ Snd
E!
x,y
E?
x,y
F !
y,x
F ?
y,z ∧ ¬G?! y,x
G?!
y,x ∧ ¬F ? y,z
G?!
y,x
F ?
y,z
F ?
y,z ∧ G?! y,x
¬E!
x,y
¬E?
x,y
¬F !
y,x
¬(F ?
y,z ∨ G?! y,x)
¬G?!
y,x
¬F ?
y,z
true
– 20 – 2015-02-03 – main –
39/51
– 20 – 2015-02-03 – main –
40/51
x : y : z :
E F G
– 20 – 2015-02-03 – main –
41/51
x : y : z :
E F G
– 20 – 2015-02-03 – main –
42/51
x : y : z :
E F G
– 20 – 2015-02-03 – main –
43/51
– 20 – 2015-02-03 – main –
44/51
E!
x,y
E?
x,y
F !
y,x
F ?
y,z ∧ ¬G?! y,x
G?!
y,x ∧ ¬F ? y,z
G?!
y,x
F ?
y,z
F ?
y,z ∧ G?! y,x
¬E!
x,y
¬E?
x,y
¬F !
y,x
¬(F ?
y,z ∨ G?! y,x)
¬G?!
y,x
¬F ?
y,z
true
– 20 – 2015-02-03 – main –
45/51
– 20 – 2015-02-03 – Sinteract –
46/51
– 20 – 2015-02-03 – Sinteract –
47/51
Figure 14.26 - Sequence Diagram with time and timing concepts sd UserAccepted
:User :ACSystem Code d=duration CardOut {0..13} OK Unlock {d..3*d} t=now {t..t+3}
DurationConstraint TimeObservation TimeConstraint DurationObservation
[OMG, 2007b, 513]
Figure 14.27 - Communication diagram sd M :r s[k]:B s[u]:B 1a:m1 2:m2 1b:m3 1b.1:m3 1b.1.1:m3, 1b.1.1.1:m2
Lifeline Message with Sequence number Messages
[OMG, 2007b, 515]
Figure 14.30 - Compact Lifeline with States sd UserAcc_User
Idle WaitCard WaitAccess Idle {d..3*d} :User
State or condition Lifeline DurationConstraint
[OMG, 2007b, 522]
Figure 14.31 - Timing Diagram with more than one Lifeline and with Messages sd UserAccepted
Idle WaitCard WaitAccess {t..t+3} {d..3*d} :User 1 2 t HasCard NoCard :ACSystem Code CardOut {0..13} OK Unlock d t=now
State or condition Lifelines Duration Observation Duration Constraints Time Observation Time Constraint Message
[OMG, 2007b, 522]
Figure 14.28 - Interaction Overview Diagram representing a High Level Interaction diagram
sd OverviewDiagram lifelines :User, :ACSystem ref EstablishAccess("Illegal PIN") sd :User :ACSystem CardOut sd :User :ACSystem Msg("Please Enter") ref OpenDoor
[pin ok]
{0..25} {1..14}InteractionUse (inline) Interaction decision interaction constraint Duration Constraint
[OMG, 2007b, 518]
– 20 – 2015-02-03 – Sinteract –
47/51
Figure 14.26 - Sequence Diagram with time and timing concepts sd UserAccepted
:User :ACSystem Code d=duration CardOut {0..13} OK Unlock {d..3*d} t=now {t..t+3}
DurationConstraint TimeObservation TimeConstraint DurationObservation
[OMG, 2007b, 513]
Figure 14.27 - Communication diagram sd M :r s[k]:B s[u]:B 1a:m1 2:m2 1b:m3 1b.1:m3 1b.1.1:m3, 1b.1.1.1:m2
Lifeline Message with Sequence number Messages
[OMG, 2007b, 515]
Figure 14.30 - Compact Lifeline with States sd UserAcc_User
Idle WaitCard WaitAccess Idle {d..3*d} :User
State or condition Lifeline DurationConstraint
[OMG, 2007b, 522]
Figure 14.31 - Timing Diagram with more than one Lifeline and with Messages sd UserAccepted
Idle WaitCard WaitAccess {t..t+3} {d..3*d} :User 1 2 t HasCard NoCard :ACSystem Code CardOut {0..13} OK Unlock d t=now
State or condition Lifelines Duration Observation Duration Constraints Time Observation Time Constraint Message
[OMG, 2007b, 522]
Figure 14.28 - Interaction Overview Diagram representing a High Level Interaction diagram
sd OverviewDiagram lifelines :User, :ACSystem ref EstablishAccess("Illegal PIN") sd :User :ACSystem CardOut sd :User :ACSystem Msg("Please Enter") ref OpenDoor
[pin ok]
{0..25} {1..14}InteractionUse (inline) Interaction decision interaction constraint Duration Constraint
[OMG, 2007b, 518]
Figure 9.11 - The internal structure of the Observer collaboration shown inside the collaboration icon (a connection is shown between the Subject and the Observer role). Observer Observer : SlidingBarIcon Subject : CallQueue
[OMG, 2007b, 170]
Figure 9.12 - In the Observer collaboration two roles, a Subject and an Observer, collaborate to produce the desired
the Observer role. Observer SlidingBarIcon Observer CallQueue Subject queue: List of Call source: Object waitAlarm: Alarm reading: Real color: Color range: Interval Observer.reading = length (Subject.queue) capacity: Integer Observer.range = (0 .. Subject.capacity)
[OMG, 2007b, 170]
– 20 – 2015-02-03 – Sinteract –
48/51
example scenario or invariant?
what triggers the requirement?
must all messages be observed?
forbidden scenarios
LSC: L AC: actcond AM: invariant I: strict
Environment : LightsCtrl Operational [1, 3] : CrossingCtrl t(10) t : BarrierCtrl [1, 5] secreq lights on barrier down lights ok barrier ok ¬MvUp done
– 20 – 2015-02-03 – Sinteract –
49/51
– 20 – 2015-02-03 – main –
50/51
– 20 – 2015-02-03 – main –
51/51
[Damm and Harel, 2001] Damm, W. and Harel, D. (2001). LSCs: Breathing life into Message Sequence Charts. Formal Methods in System Design, 19(1):45–80. [Harel, 1997] Harel, D. (1997). Some thoughts on statecharts, 13 years later. In Grumberg, O., editor, CAV, volume 1254 of LNCS, pages 226–231. Springer-Verlag. [Harel and Maoz, 2007] Harel, D. and Maoz, S. (2007). Assert and negate revisited: Modal semantics for UML sequence diagrams. Software and System Modeling (SoSyM). To appear. (Early version in SCESM’06, 2006, pp. 13-20). [Harel and Marelly, 2003] Harel, D. and Marelly, R. (2003). Come, Let’s Play: Scenario-Based Programming Using LSCs and the Play-Engine. Springer-Verlag. [Klose, 2003] Klose, J. (2003). LSCs: A Graphical Formalism for the Specification of Communication Behavior. PhD thesis, Carl von Ossietzky Universit¨ at Oldenburg. [OMG, 2007a] OMG (2007a). Unified modeling language: Infrastructure, version 2.1.2. Technical Report formal/07-11-04. [OMG, 2007b] OMG (2007b). Unified modeling language: Superstructure, version 2.1.2. Technical Report formal/07-11-02. [St¨
urjens, J., Rumpe, B., France, R., and Fernandez, E. B., editors, CSDUML 2003, number TUM-I0323. Technische Universit¨ at M¨ unchen.