Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 0c310ad8982e1830e81818ac1550773ccbfcd1ca (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
RoomModel org.eclipse.etrice.integration.SendingDataByValueTest {

	import room.basic.types.java.* from "../../../runtime/org.eclipse.etrice.modellib/models/JavaTypes.room"

	LogicalSystem LogSys_SendingData {
		SubSystemRef application: SubSys_SendingData
	}

	SubSystemClass SubSys_SendingData {
		ActorRef top: SendingDataTop
	}

	ActorClass SendingDataTop {
		Structure {
			ActorRef mrPing: MrPing
			ActorRef mrPong: MrPong
			Binding mrPing.PingPongPort and mrPong.PingPongPort
		}
		Behavior { }
	}

	ActorClass MrPong {
		Interface {
			Port PingPongPort: PingPongProtocol
		}
		Structure {
			external Port PingPongPort
		}
		Behavior {
			Operation printData(d: PingPongData) {
				"System.out.printf(\"\\n\");"
				"System.out.printf(\"i8Val: %d \\n\",d.getI8Val());"
				"System.out.printf(\"i16Val: %d \\n\",d.getI16Val());"
				"System.out.printf(\"i32Val: %d \\n\",d.getI32Val());"
				"System.out.printf(\"charVal: %c \\n\",d.getCharVal());"
				"System.out.printf(\"f32Val: %f \\n\",d.getF32Val());"
				"System.out.printf(\"f64Val: %f \\n\",d.getF64Val());"
				"System.out.printf(\"stringVal: %s \\n\",d.getStringVal());"
				"System.out.printf(\"i32Array: %d %d %d %d %d\\n\",d.getArrayFromInt32()[0],d.getArrayFromInt32()[1],d.getArrayFromInt32()[2],d.getArrayFromInt32()[3],d.getArrayFromInt32()[4] );"
				"System.out.printf(\"\\n\");"
			}
			StateMachine {
				Transition tr0: reply -> reply {
					triggers {
						<ping: PingPongPort>
					}
					action {
						"p.setI8Val((byte)(p.getI8Val()+1));"
						""
						""
						"PingPongPort.pong(p);"
					}
				}
				Transition tr1: reply -> reply {
					triggers {
						<pingSimple: PingPongPort>
					}
					action {
						"PingPongPort.pongSimple(++p);"
					}
				}
				Transition init: initial -> reply { }
				State reply
			}
		}
	}

	ActorClass MrPing {
		Interface {
			conjugated Port PingPongPort: PingPongProtocol
		}
		Structure {
			usercode1{
				"import org.eclipse.etrice.integration.tests.helpers.*;"
				"import org.eclipse.etrice.runtime.java.messaging.RTServices;"
			}
			usercode2 {
				"private CRC16Generator crcGen = new CRC16Generator();"
			}
			external Port PingPongPort
			Attribute i32Array[10] : int32
			Attribute data : PingPongData
		}
		Behavior {
			Operation printData(d: PingPongData) {
				"System.out.printf(\"MrPing:\\n\");"
				"System.out.printf(\"i8Val: %d \\n\",d.getI8Val());"
				"System.out.printf(\"i16Val: %d \\n\",d.getI16Val());"
				"System.out.printf(\"i32Val: %d \\n\",d.getI32Val());"
				"System.out.printf(\"charVal: %c \\n\",d.getCharVal());"
				"System.out.printf(\"f32Val: %f \\n\",d.getF32Val());"
				"System.out.printf(\"f64Val: %f \\n\",d.getF64Val());"
				"System.out.printf(\"stringVal: %s \\n\",d.getStringVal());"
				"System.out.printf(\"i32Array: %d %d %d %d %d\\n\",d.getArrayFromInt32()[0],d.getArrayFromInt32()[1],d.getArrayFromInt32()[2],d.getArrayFromInt32()[3],d.getArrayFromInt32()[4] );"
				"System.out.printf(\"\\n\");"
			}
			StateMachine {
				Transition init: initial -> waitForPong {
					action {
						"int i;"
						"int[] intArray;"
						"this.data=new PingPongData();"
						""
						"// send default data"
						"PingPongData d = new PingPongData();"
						"PingPongPort.ping(d);"
						""
						"d.setI8Val((byte) 45);"
						"d.setI16Val((short) 34);"
						"d.setI32Val(2);"
						"d.setF32Val((float)3.14);"
						"d.setF64Val(7.12345);"
						"d.setStringVal(\"Hase !\");"
						""
						"d.getOwnType().setI8Val((byte)10);"
						"d.getOwnType().setI16Val((short)17);"
						"d.getOwnType().setI32Val(4711);"
						"d.getOwnType().setF32Val((float)3.0815);"
						"d.getOwnType().setF64Val(123.45678);"
						"d.getOwnType().setStringVal(\"Deep Hase !\");"
						"intArray = d.getOwnType().getArrayFromInt32();"
						"for (i=0;i<intArray.length;i++) {intArray[i] = 10+i;}"
						"d.getOwnType().setArrayFromInt32(intArray);"
						""
						"PingPongPort.ping(d);"
						""
						"d.setI8Val((byte) 55);"
						"d.setI16Val((short) 44);"
						"d.setI32Val(3);"
						"d.setF32Val((float)24.4563458);"
						"d.setF64Val(2347.2342312345);"
						"d.setStringVal(\"Mein Hase !\");"
						""
						"d.getOwnType().setI8Val((byte)15);"
						"d.getOwnType().setI16Val((short)23);"
						"d.getOwnType().setI32Val(4812);"
						"d.getOwnType().setF32Val((float)2453.30815);"
						"d.getOwnType().setF64Val(125332.42342);"
						"d.getOwnType().setStringVal(\"Mein Deep Hase !\");"
						"intArray = d.getOwnType().getArrayFromInt32();"
						"for (i=0;i<intArray.length;i++) {intArray[i] = 30+i;}"
						"d.getOwnType().setArrayFromInt32(intArray);"
						""
						"PingPongPort.ping(d);"
						"PingPongPort.ping(data);"
						""
						"data.setI8Val((byte) 67);"
						"data.setI16Val((short) 97);"
						"data.setI32Val(70);"
						"data.setF32Val((float)233.14);"
						"data.setF64Val(723434.12345);"
						"data.setStringVal(\"Falscher Hase !\");"
						""
						"crcGen.update(10);"
					}
				}
				Transition tr0: my tp0 -> my tp0 {
					triggers {
						<pong: PingPongPort>
					}
					action {
						"System.out.printf(\"Top Level : \\n\");"
						"printData(p);"
						"crcGen.update(20);"
					}
				}
				Transition tr1: my tp0 -> my tp0 {
					triggers {
						<pongSimple: PingPongPort>
					}
					action {
						"System.out.printf(\"Top Level Simple: \\n\");"
						"crcGen.update(35);"
					}
				}
				Transition tr10: waitForPong -> cp cp0 {
					triggers {
						<pong: PingPongPort>
					}
					action {
						"printData(p);"
						"crcGen.update(11);"
					}
				}
				Transition tr4: cp cp0 -> waitForPong {
					action {
						"crcGen.update(12);"
					}
				}
				Transition tr3: cp cp0 -> state0 {
					cond {
						"(p.i32Val==2) && (p.i8Val==46)"
					}
					action {
						"// send default values"
						"PingPongPort.ping(data);"
						""
						"data.getOwnType().setI8Val((byte)10);"
						"data.getOwnType().setI16Val((short)17);"
						"data.getOwnType().setI32Val(4711);"
						"data.getOwnType().setF32Val((float)3.0815);"
						"data.getOwnType().setF64Val(123.45678);"
						"data.getOwnType().setStringVal(\"Deep Hase !\");"
						"int[] intArray = data.getOwnType().getArrayFromInt32();"
						"for (int i=0;i<intArray.length;i++) {intArray[i] = 10+i;}"
						"data.getOwnType().setArrayFromInt32(intArray);"
						""
						"// use convenient function"
						"PingPongPort.ping((byte)45,(short)34,80,\'c\',(float)3.14,7.12345,\"Hase !\",intArray,data.getOwnType());"
						""
						"crcGen.update(13);"
					}
				}
				Transition tr5: state0 -> state1 {
					triggers {
						<pong: PingPongPort guard {
							"p.getI32Val()==3"
						}>
					}
					action {
						"printData(p);"
						"PingPongPort.pingSimple(12);"
						"PingPongPort.pingSimple(27);"
						"crcGen.update(14);"
					}
				}
				Transition tr6: state1 -> state2 {
					triggers {
						<pongSimple: PingPongPort>
					}
					action {
						"crcGen.update(15);"
					}
				}
				Transition tr7: state2 -> cp cp1 {
					triggers {
						<pongSimple: PingPongPort>
					}
					action {
						"crcGen.update(16);"
						"System.out.printf(\"CRC: %d \\n\", crcGen.getCrc());"
					}
				}
				Transition tr8: cp cp1 -> TestFalse {
					action {
						"RTServices.getInstance().getSubSystem().testFinished(1);"
					}
				}
				Transition tr9: cp cp1 -> TestOk {
					cond {
						"(p==28) && (crcGen.getCrc()==1187)"
					}
					action {
						"RTServices.getInstance().getSubSystem().testFinished(0);"
					}
				}
				ChoicePoint cp0
				ChoicePoint cp1
				TransitionPoint tp0
				State waitForPong
				State state0
				State state1
				State state2
				State TestFalse
				State TestOk
			}
		}
	}

	ProtocolClass PingPongProtocol {
		incoming {
			Message ping(p: PingPongData)
			Message pingSimple(p: int32)
		}
		outgoing {
			Message pong(p: PingPongData)
			Message pongSimple(p: int32)
		}
	}

	DataClass PingPongData {
		Attribute i8Val: int8 = "34"
		Attribute i16Val: int16 = "24"
		Attribute i32Val: int32 = "12"
		Attribute charVal: char = "'c'"
		Attribute f32Val: float32 = "4711.0815f"
		Attribute f64Val: float64 = "47114711.08150815"
		Attribute stringVal: string = "\"Du alter Depp !\""
		Attribute arrayFromInt32[5]: int32 = "{1,2,3,4,5}"
		Attribute ownType: PingPongDataDeep
	}

	DataClass PingPongDataDeep {
		Attribute i8Val: int8
		Attribute i16Val: int16
		Attribute i32Val: int32
		Attribute charVal: char
		Attribute f32Val: float32
		Attribute f64Val: float64
		Attribute stringVal: string
		Attribute arrayFromInt32[10]: int32
	}

}

Back to the top