Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 070e710345bab4902afdd913627db6bcca2a27fa (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
RoomModel ReferenceCPP_ActorClasses {

	import ReferenceCPP_DataClasses.* from "ReferenceCPP_DataClasses.room"

	import ReferenceCPP_ProtocolClasses.* from "ReferenceCPP_ProtocolClasses.room"

	import room.basic.annotations.* from "../../org.eclipse.etrice.modellib.cpp/model/Annotations.room"

	import room.basic.types.* from "../../org.eclipse.etrice.modellib.cpp/model/Types.room"

	ActorClass ActorToplevel [ "instantiate all element to enforce code generation" ] {
		Structure {
			ActorRef allDataClasses: ActorAllDataClasses
			ActorRef actorWithImplementationSubclass: ActorWithImplementationSubclass
			Binding mirrorDataClasses.portMirror and allDataClasses.portSend
			ActorRef mirrorDataClasses: ActorAllDataClassesMirror
			Binding derived.port and mirror.port
			ActorRef mirror: GenericMirror
			ActorRef derived: InheritanceDerivedClassSimple
		}
	}

	ActorClass ActorAllDataClasses {
		Interface {
			conjugated Port portSend: PAllDatatypes
		}
		Structure {
			Attribute allDatatypes: DAllDatatypes
			Attribute char1: char
			Attribute char2: char
			Attribute charArray [ 100 ]: char
			external Port portSend
		}
		Behavior {
			StateMachine {
				State state0 {
					entry {
						"sprintf(charArray.getData(), \"Hallo eTrice\"); // no very secure -> only for testcase"
						"DAllDatatypes data(-1, -2, -3, -4, 1,2,3,4, 123.456, -123.456, false, 'A', charArray.getData(), std::string(\"ABC\"), string32(\"XYZ\"), (void*)0x0F0F, StaticArray<char, 4>(66), StaticArray<int32, 4>(55555));"
						"data.printAll(\"data 1 send\");"
						"portSend.sendAllDatatypes(data);"
					}
				}
				Transition init: initial -> state0
				State state1
				Transition tr0: state0 -> state1 {
					triggers {
						<mirrorAllDatatypes: portSend>
					}
					action {
						"// TODO: code proposals for data. do not work"
						"data.printAll(\"data 4 receive\");"
					}
				}
			}
		}
	}

	ActorClass ActorAllDataClassesMirror {
		Interface {
			Port portMirror: PAllDatatypes
		}
		Structure {
			Attribute allDatatypes: DAllDatatypes
			external Port portMirror
		}
		Behavior {
			StateMachine {
				State state0
				State state1
				Transition init: initial -> state0
				Transition tr0: state0 -> state1 {
					triggers {
						<sendAllDatatypes: portMirror>
					}
					action {
						"allDatatypes = data;"
						"allDatatypes.printAll(\"data 2 receive\");"
						"allDatatypes.attribute_char_array[3]++;"
						"allDatatypes.attribute_string32+=\"2\";"
						"allDatatypes.attribute_charPtr[0]=\'X\';"
						"allDatatypes.printAll(\"data 3 modify & send\");"
						""
						"portMirror.mirrorAllDatatypes(allDatatypes);"
					}
				}
			}
		}
	}

	ProtocolClass PStartStop {
		incoming {
			Message start()
			Message stop()
		}
		outgoing {
			Message started()
			Message stopped()
		}
	}

	datadriven ActorClass ActorWithImplementationSubclass {
		@ImplementationSubclass(fqnClassName = "ActorWithImplementationSubclass_Impl")
		Behavior {
			StateMachine {
				State State1 {
					entry {
						"//"
					}
					exit {
						"//"
					}
				}
				State State2 {
					entry {
						"//"
					}
					exit {
						"//"
					} do {
						"//"
					}
				}
				Transition init: initial -> State1 {
					action {
						"//"
					}
				}
				Transition tr0: State1 -> State2 {
					guard {
						"true"
					}
					action {
						"//"
					}
				}
			}
		}
	}

	abstract ActorClass InheritanceBaseClassSimple {
		Interface {
			conjugated Port port: PNumberedMessages
		}
		Structure {
			external Port port
		}
		Behavior {
			StateMachine {
				Transition init: initial -> tp0 of state0
				State state0 {
					subgraph {
						EntryPoint tp0
						ExitPoint tp1
					TransitionPoint tp2
					ExitPoint tp3
					}
				}
				Transition tr0: tp1 of state0 -> tp0 of state2
				State state1 {
					entry {
						"port.message2();"
					}
				}
				Transition tr1: state1 -> tp0 of state0 {
					triggers {
						<reply2: port>
					}
				}
				State state2 {
					subgraph {
						EntryPoint tp0
						ExitPoint tp1
					EntryPoint tr1
					}
				}
				Transition tr2: tp1 of state2 -> Done
				State Done
			TransitionPoint tp0
				Transition tr3: my tp0 -> state1 {
					triggers {
						<reply0: port>
					}
				}
			ChoicePoint cp0
				Transition tr4: state0 -> cp cp0 {
					triggers {
						<reply0: port>
					}
				}
				Transition tr5: cp cp0 -> tp0 of state2
				Transition tr6:  cp cp0 -> tr1 of state2 {
					cond {
						"true"
					}
				}
				Transition tr7: cp cp0 -> tp0 of state0 {
					cond {
						"true"
					}
				}
				Transition tr8: tp3 of state0 -> cp cp0
			}
		}
	}

	ActorClass InheritanceDerivedClassSimple extends InheritanceBaseClassSimple {
		Behavior {
			StateMachine {
				RefinedState state0 {
					subgraph {
						State state0 {
							entry {
								"port.message0();"
							}
						}
						Transition tr0: my tp0 -> state0
						Transition tr1: state0 -> my tp1 {
							triggers {
								<reply2:port>
							}
						}
						Transition tr2: state0 -> my tp3 {
							triggers {
								<reply3:port>
							}
						}
						
					}
				}
			}
		}
	}

	ActorClass GenericMirror {
		Interface {
			Port port: PNumberedMessages
		}
		Structure {
			external Port port
		}
		Behavior {
			StateMachine {
				State Idle
				Transition init: initial -> Idle
				Transition tr0: Idle -> Idle {
					triggers {
						<message0: port>
					}
					action {
						"port.reply0();"
					}
				}
				Transition tr1: Idle -> Idle {
					triggers {
						<message1: port>
					}
					action {
						"port.reply1();"
					}
				}
				Transition tr2: Idle -> Idle {
					triggers {
						<message2: port>
					}
					action {
						"port.reply2();"
					}
				}
				Transition tr3: Idle -> Idle {
					triggers {
						<message3: port>
					}
					action {
						"port.reply3();"
					}
				}
				Transition tr4: Idle -> Idle {
					triggers {
						<message4: port>
					}
					action {
						"port.reply4();"
					}
				}
				Transition tr5: Idle -> Idle {
					triggers {
						<message5: port>
					}
					action {
						"port.reply5();"
					}
				}
				Transition tr6: Idle -> Idle {
					triggers {
						<message6: port>
					}
					action {
						"port.reply6();"
					}
				}
			}
		}
	}

	ActorClass ReplicationTop {
		
	Structure {
			ActorRef replSub1 [3]: ReplicationSub1
			ActorRef replSub2 [3]: ReplicationSub2
		Binding replSub1.port and replSub2.port
		ActorRef replSub3_1 [1]: ReplicationSub3
		ActorRef replSub3_2: ReplicationSub3
			conjugated Port replPort [8]: PStartStop
		Binding replPort and replSub3_1.replPort
			Binding replPort and replSub3_2.replPort
		}
	Behavior {
			StateMachine {
				State state0 {
					entry {
						"replPort.start();"
					}
				}
				State DONE
				State state1
				Transition init0: initial -> state0
				Transition tr0: state0 -> state1 {
					triggers {
						<started: replPort>
					}
				}
				Transition tr1: state1 -> DONE {
					triggers {
						<started: replPort>
					}
				}
			}
		}
	}
	
	ActorClass ReplicationSub1 {
		
	Interface {
			conjugated Port port: PStartStop
		}
		Structure {
			external Port port
		}
	}

	ActorClass ReplicationSub2 {
		
	Interface {
			Port port: PStartStop
		}
		Structure {
			external Port port
		}
	}
	ActorClass ReplicationSub3 {
		
	Interface {
			Port replPort [1]: PStartStop
		}
		Structure {
			external Port replPort
		}
		Behavior {
			StateMachine { State state0
				State state1
				Transition init0: initial -> state0
				Transition tr0: state0 -> state1 {
					triggers {
						<start: replPort>
					}
					action {
						"replPort.started();"
					}
				}
			}
		}
	}
}

Back to the top