Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6cbf96cf0c5048bc195e394c98540b83d27f820c (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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
RoomModel replact {

	SubSystemClass Main {
		ActorRef appl1: AC1_Appl 
		ActorRef appl2: AC2_Appl 
		ActorRef appl3: AC3_Appl
		ActorRef appl4: AC4_Appl
		ActorRef appl5: ApplicationTop
	}

	// example 1: regular port of replicated actor connected to regular ports
	ActorClass AC1_Appl {
		Structure {
			conjugated Port intp1: PC
			conjugated Port intp2: PC
			conjugated Port intp3: PC
			ActorRef ac1repl [ 3 ]: AC1_1
			Binding ac1repl.ac1p and intp1
			Binding intp2 and ac1repl.ac1p
			Binding intp3 and ac1repl.ac1p
		}
		Behavior {
			StateMachine {
				Transition init: initial -> WaitAnswer {
					action {
						"intp1.ping(\"ping from \"+getInstancePath()+\"/intp1\");"
						"intp2.ping(\"ping from \"+getInstancePath()+\"/intp2\");"
						"intp3.ping(\"ping from \"+getInstancePath()+\"/intp3\");"
					}
				}
				Transition tr0: WaitAnswer -> WaitAnswer {
					triggers {
						<reply: intp1|reply: intp2|reply: intp3>
					}
					action {
						"System.out.println(\"received \"+msg);"
					}
				}
				State WaitAnswer
			}
		}
	}
		
	ActorClass AC1_1 {
		Interface {
			Port ac1p: PC
		}
		Structure {
			external Port ac1p
		}
		Behavior {
			StateMachine {
				Transition init: initial -> WaitForPing { }
				Transition tr0: WaitForPing -> WaitForPing {
					triggers {
						<ping: ac1p>
					}
					action {
						"ac1p.reply(\"answer from \"+getInstancePath()+\" to \"+msg);"
					}
				}
				State WaitForPing
			}
		}
	}
	
	// example 2: regular port of replicated actor connected to regular port of replicated actor
	ActorClass AC2_Appl {
		Structure {
			ActorRef ac1repl [ 3 ]: AC2_1
			ActorRef ac2repl [ 3 ]: AC2_2
			Binding ac2repl.ac2p and ac1repl.ac1p
		}
	}
		
	ActorClass AC2_1 {
		Interface {
			Port ac1p: PC
		}
		Structure {
			external Port ac1p
		}
		Behavior {
			StateMachine {
				Transition init: initial -> WaitForPing { }
				Transition tr0: WaitForPing -> WaitForPing {
					triggers {
						<ping: ac1p>
					}
					action {
						"ac1p.reply(\"answer from \"+getInstancePath()+\" to \"+msg);"
					}
				}
				State WaitForPing
			}
		}
	}
	ActorClass AC2_2 {
		Interface {
			conjugated Port ac2p: PC
		}
		Structure {
			external Port ac2p
		}
		Behavior {
			StateMachine {
				Transition init: initial -> WaitAnswer {
					action {
						"ac2p.ping(\"ping from \"+getInstancePath());"
					}
				}
				Transition tr0: WaitAnswer -> WaitAnswer {
					triggers {
						<reply: ac2p>
					}
					action {
						"System.out.println(\"received \"+msg);"
					}
				}
				State WaitAnswer
			}
		}
	}
	
	// example 3: regular port of replicated actor connected to replicated port
	ActorClass AC3_Appl {
		Structure {
			conjugated Port intrep [3]: PC
			ActorRef ac1repl [ 3 ]: AC3_1
			Binding ac1repl.ac1p and intrep
		}
		Behavior {
			StateMachine {
				Transition init: initial -> WaitAnswer {
					action {
						"intrep.ping(\"ping from \"+getInstancePath());"
					}
				}
				Transition tr0: WaitAnswer -> WaitAnswer {
					triggers {
						<reply: intrep>
					}
					action {
						"System.out.println(\"received \"+msg);"
					}
				}
				State WaitAnswer
			}
		}
	}
		
	ActorClass AC3_1 {
		Interface {
			Port ac1p: PC
		}
		Structure {
			external Port ac1p
		}
		Behavior {
			StateMachine {
				Transition init: initial -> WaitForPing { }
				Transition tr0: WaitForPing -> WaitForPing {
					triggers {
						<ping: ac1p>
					}
					action {
						"ac1p.reply(\"answer from \"+getInstancePath()+\" to \"+msg);"
					}
				}
				State WaitForPing
			}
		}
	}
	
	// example 4: regular port of replicated actor connected to replicated port of replicated actor
	ActorClass AC4_Appl {
		Structure {
			ActorRef ac1repl [ 2 ]: AC4_1
			ActorRef ac2repl [ 4 ]: AC4_2
			Binding ac2repl.ac2p and ac1repl.ac1p
		}
	}
		
	ActorClass AC4_1 {
		Interface {
			Port ac1p[2]: PC
		}
		Structure {
			external Port ac1p
		}
		Behavior {
			StateMachine {
				Transition init: initial -> WaitForPing { }
				Transition tr0: WaitForPing -> WaitForPing {
					triggers {
						<ping: ac1p>
					}
					action {
						"ac1p.reply(\"answer from \"+getInstancePath()+\" to \"+msg);"
					}
				}
				State WaitForPing
			}
		}
	}
	ActorClass AC4_2 {
		Interface {
			conjugated Port ac2p: PC
		}
		Structure {
			external Port ac2p
		}
		Behavior {
			StateMachine {
				Transition init: initial -> WaitAnswer {
					action {
						"ac2p.ping(\"ping from \"+getInstancePath());"
					}
				}
				Transition tr0: WaitAnswer -> WaitAnswer {
					triggers {
						<reply: ac2p>
					}
					action {
						"System.out.println(\"received \"+msg);"
					}
				}
				State WaitAnswer
			}
		}
	}

	// example 5: regular port of replicated actor connected to replicated port of sub actor
	ActorClass ApplicationTop {
		Structure {
			ActorRef testDriver: TestDriver
			ActorRef ref0 [ 8 ]: Channel
			Binding testDriver.testee and ref0.test
		}
		Behavior { }
	}

	ActorClass TestDriver  {
		Interface {
			conjugated Port testee [8]: PTestDriver
		}
		Structure {
			external Port testee
			Attribute counter : int32 = "0"
			Attribute startTime : int64 
		}
		Behavior {
			StateMachine {
				Transition init: initial -> TestRunning {
					action {
						"testee.start();"
						"System.out.println(\"Repl=\"+testee.getReplication());"
						"startTime = System.currentTimeMillis();"
					}
				}
				Transition tr0: TestRunning -> cp cp0 {
					triggers {
						<done: testee>
					}
					action {
						"counter++;"
					}
				}
				Transition tr1: cp cp0 -> TestRunning
				Transition tr2: cp cp0 -> TestDone {
					cond {
						"counter>=testee.getReplication()"
					}
					action {
						"long endTime = System.currentTimeMillis();"
						"//System.out.println(\"time in ms: \"+ (endTime-startTime));"
					}
				}
				ChoicePoint cp0
				State TestRunning
				State TestDone {
					entry {
						"System.out.println(\"Test Done\");"
					}
				}
			}
		}
	}

	ActorClass Channel {
		Interface {
			Port test: PTestDriver
		}
		Structure {
			ActorRef stack : ProtocolStack
			ActorRef tester : TestSender
			ActorRef mirror : Mirror
			Binding tester.stack and stack.sender
			Binding stack.receiver and mirror.stack
			Binding test and tester.test
		}
		Behavior { }
	}

	ActorClass TestSender {
		Interface {
			conjugated Port stack: CommunicationProtocol
			Port test: PTestDriver
		}
		Structure {
			external Port stack
			external Port test
			Attribute counter : int32 = "0"
		}
		Behavior {
			StateMachine {
				Transition init: initial -> idle { }
				Transition tr0: SendData -> cp cp0 {
					triggers {
						<receivedData: stack>
					}
					action {
						"counter++;"
					}
				}
				Transition tr1: cp cp0 -> SendData
				Transition tr2: cp cp0 -> TheEnd {
					cond {
						"counter>=1"
					}
					action {
						"test.done();"
					}
				}
				Transition tr3: idle -> SendData {
					triggers {
						<start: test>
					}
					action {
						"System.out.println(\"Channel Test Start\");"
					}
				}
				ChoicePoint cp0
				State SendData {
					entry {
						"stack.sendData(counter);"
					}
				}
				State TheEnd {
					entry {
						"System.out.println(\"Channel Test End\");"
					}
				}
				State idle
			}
		}
	}

	ActorClass Mirror {
		Interface {
			Port stack: CommunicationProtocol
		}
		Structure {
			external Port stack
		}
		Behavior {
			StateMachine {
				Transition init: initial -> mirror { }
				Transition tr0: mirror -> mirror {
					triggers {
						<sendData: stack>
					}
					action {
						"stack.receivedData();"
					}
				}
				State mirror
			}
		}
	}

	ActorClass ProtocolStack{
		Interface {
			Port sender: CommunicationProtocol
			conjugated Port receiver: CommunicationProtocol
		}
		Structure {
			external Port sender
			external Port receiver
		}
		Behavior {
			StateMachine {
				Transition init: initial -> idle { }
				Transition tr0: idle -> WaitingForReceive {
					triggers {
						<sendData: sender>
					}
					action {
						"receiver.sendData(data);"
					}
				}
				Transition tr1: WaitingForReceive -> idle {
					triggers {
						<receivedData: receiver>
					}
					action {
						"sender.receivedData();"
					}
				}
				State idle
				State WaitingForReceive
			}
		}
	}

	ProtocolClass PTestDriver {
		incoming {
			Message start()
		}
		outgoing {
			Message done()
		}
	}

	ProtocolClass CommunicationProtocol {
		incoming {
			Message sendData(data: int32)
		}
		outgoing {
			Message receivedData()
		}
	}
	
	ProtocolClass PC {
		incoming {
			Message ping(msg: string)
		}
		outgoing {
			Message reply(msg: string)
		}
	}

	PrimitiveType string: ptCharacter -> String (String) default "\"\""
	PrimitiveType int32: ptCharacter -> int (Integer) default "0"
	PrimitiveType int64: ptCharacter -> long (Long) default "0"
}

Back to the top