Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 753b3bc09929b17b63ca134545284808e4090f18 (plain) (blame)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
RoomModel CashTerminal {

	ActorClass Controller {
		Interface {
			conjugated Port terminal:TerminalProtocol
			conjugated Port auth:AuthProtocol
		}
		Structure { 
			external Port terminal
			external Port auth
		}
		Behavior {
			StateMachine{
				Transition init: initial -> state0_sm {
					action {
						"auth.hello();"
					}
				}
				Transition tr0: state0_sm -> offline {
					triggers {
						<serviceNA: auth>
					}
					action {
						"terminal.showOffline();"
					}
				}
				Transition tr1: state0_sm -> idle_sm {
					triggers {
						<hello: auth>
					}
				}
				Transition tr2: idle_sm -> handleCard {
					triggers {
						<cardEntered: terminal>
					}
				}
				Transition tr3: tp0 of handleCard -> tp0 of handlePIN
				Transition tr4: tp1 of handlePIN -> idle_sm
				Transition tr5: handlePIN -> idle_sm {
					triggers {
						<correctPIN: auth>
					}
					action {
						"terminal.dispenseMoney();"
					}
				}
				Transition tr6: tp1 of handleCard -> idle_sm
				State state0_sm
				State idle_sm {
					entry {
						"terminal.showWelcome();"
					}
				}
				State offline
				State handleCard {
					subgraph {
						Transition init: initial -> state0_sm {
							action {
								"auth.checkCard();"
							}
						}
						Transition tr0: state0_sm -> wait_sm {
							triggers {
								<validCard: auth>
							}
							action {
								"terminal.showPIN();"
							}
						}
						Transition tr1: wait_sm -> my tp0 {
							triggers {
								<pinEntered: terminal>
							}
						}
						Transition tr2: state0_sm -> my tp1 {
							triggers {
								<invalidCard: auth>
							}
						}
						ExitPoint tp0
						ExitPoint tp1
						State state0_sm
						State wait_sm
					}
				}
				State handlePIN {
					subgraph {
						Transition tr0: my tp0 -> wait_sm
						Transition tr1: wait_sm -> cp cp0 {
							triggers {
								<wrongPIN: auth>
							}
						}
						Transition tr2: cp cp0 -> my tp1 {
							action {
								"terminal.confiscateCard();"
							}
						}
						Transition tr3: cp cp0 -> wait_sm {
							cond {
								"if(count_tries < 2)"
							}
						}
						ChoicePoint cp0
						EntryPoint tp0
						ExitPoint tp1
						State wait_sm {
							entry {
								"auth.checkPIN();"
							}
						}
					}
				}
			}
			
			}
	}
	
	ActorClass AuthServer {
		Interface {
			Port client:AuthProtocol
		}
		Structure { 
			external Port client
		}
		Behavior {
			StateMachine {
				Transition tr0: cp cp0 -> error {
					action {
						"client.serviceNA();"
					}
				}
				Transition tr2: cp cp0 -> standby {
					cond {
						"if(okay)"
					}
					action {
						"client.hello();"
					}
				}
				Transition tr4: standby -> standby {
					triggers {
						<checkCard: client>
					}
					action {
						"if(valid)"
						"\tclient.validCard();"
						"else"
						"\tinvalidCard();"
					}
				}
				Transition tr5_vm: standby -> standby {
					triggers {
						<checkPIN: client>
					}
					action {
						"if(correct)"
						"\tclient.correctPIN();"
						"else"
						"\tclient.wrongPIN();"
					}
				}
				Transition init: initial -> state0 { }
				Transition tr6: state0 -> cp cp0 {
					triggers {
						<hello: client>
					}
				}
				ChoicePoint cp0
				State standby
				State error
				State state0
			}
		}
	}
	
	ProtocolClass TerminalProtocol {
		incoming {
			Message showWelcome()
			Message showPIN()
			Message confiscateCard()
			Message dispenseMoney()
			Message showOffline()
			
		}
		outgoing {
			Message pinEntered()
			Message cardEntered()
		}
		semantics { 
			in:showOffline
			in:showWelcome->out:cardEntered->(in:showPIN->out:pinEntered->(in:dispenseMoney->in:showWelcome,in:confiscateCard->in:showWelcome),in:showWelcome)
		}
	}
	
	ProtocolClass AuthProtocol {
		incoming {
			Message hello()
			Message checkCard()
			Message checkPIN()
		}
		
		outgoing {
			Message validCard()
			Message invalidCard()
			Message correctPIN()
			Message wrongPIN()
			Message serviceNA()
			Message hello()
		}
		semantics {
			in:hello->(out:hello->in:checkCard->(out:validCard->in:checkPIN->(out:correctPIN, out:wrongPIN->in:checkPIN->(out:correctPIN, out:wrongPIN)), out:invalidCard), out:serviceNA)
		}
	}

}

Back to the top