-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtelephone.vdmsl
82 lines (65 loc) · 4.5 KB
/
telephone.vdmsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
module EXCH
definitions
types
Subscriber = token;
Initiator = <AI> | <WI> | <SI>;
Recipient = <WR> | <SR>;
Status = <fr> | <un> | Initiator | Recipient;
state Exchange of
status: map Subscriber to Status
calls: inmap Subscriber to Subscriber
inv mk_Exchange(status, calls) ==
forall i in set dom calls &
(status(i) = <WI> and status(calls(i)) = <WR>)
or
(status(i) = <SI> and status(calls(i)) = <SR>)
init s == s = mk_Exchange({|->},{|->})
end
operations
Lift(s: Subscriber)
ext wr status
pre s in set dom (status :> {<fr>})
-- pre s in set dom status and status(s) = <fr>
post status = status~ ++ {s |-> <AI>};
Connect(i: Subscriber, r: Subscriber)
ext wr status
wr calls
pre i in set dom (status :> {<AI>}) and
r in set dom (status :> {<fr>})
post status = status~ ++ {i |-> <WI>, r |-> <WR>} and
calls = calls~ ++ {i |-> r};
MakeUn(i: Subscriber)
ext wr status
pre i in set dom (status :> {<AI>})
post status = status~ ++ {i |-> <un>};
Answer(r: Subscriber)
ext rd calls
wr status
pre r in set dom (status :> {<WR>})
post status = status~ ++ {r |-> <SR>, (inverse calls)(r) |-> <SI>};
ClearAttempt(i: Subscriber)
ext wr status
pre i in set dom (status :> {<AI>})
post status = status~ ++ {i |-> <fr>};
ClearWait(i: Subscriber)
ext wr status
wr calls
pre i in set dom (status :> {<WI>})
post status = status~ ++ {i |-> <fr>, calls(i) |-> <fr>} and
calls = {i} <-: calls~;
ClearSpeak(i: Subscriber)
ext wr status
wr calls
pre i in set dom (status :> {<SI>})
post status = status~ ++ {i |-> <fr>, calls(i) |-> <un>} and
calls = {i} <-: calls~;
Suspend(r: Subscriber)
ext rd calls
wr status
pre r in set dom (status :> {<SR>})
post status = status~ ++ {r |-> <WR>, (inverse calls)(r) |-> <WI>};
ClearUn(s: Subscriber)
ext wr status
pre s in set dom (status :> {<un>})
post status = status~ ++ {s |-> <fr>}
end EXCH