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
|
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Define the top level</title>
<link href="book.css" rel="stylesheet" type="text/css">
<meta content="DocBook XSL Stylesheets V1.75.1" name="generator">
<link rel="home" href="index.html" title="eTrice User Guide">
<link rel="up" href="TutorialSendingData.html" title="Tutorial Sending Data">
<link rel="prev" href="DefinetheActorsStructureandBehavior.html" title="Define the Actors Structure and Behavior">
<link rel="next" href="Generateandrunthemodel.html" title="Generate and run the model">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<h1 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">Define the top level</h1>
<div class="section" title="Define the top level">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="Definethetoplevel"></a>Define the top level</h2>
</div>
</div>
</div>
<p>Open the Structure from SendingDataTop and add MrPing and MrPong as a reference. Connect the ports.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/025-SendingData13.png"></div>
<p>
</p>
<p>The model is finished now and the model file should look like this:</p>
<div class="literallayout">
<p></p>
</div>
<div class="literallayout">
<p>
<code class="code">RoomModel SendingData {<br>
<br>
LogicalSystem SendingData_LogSystem {<br>
SubSystemRef SendingDataAppl: SendingData_SubSystem<br>
}<br>
<br>
SubSystemClass SendingData_SubSystem {<br>
ActorRef SendigDataTopRef: SendingDataTop<br>
}<br>
<br>
ActorClass SendingDataTop {<br>
Structure {<br>
ActorRef ref0: MrPing<br>
ActorRef ref1: MrPong<br>
Binding ref0.PingPongPort and ref1.PingPongPort<br>
}<br>
Behavior { }<br>
}<br>
<br>
ActorClass MrPing {<br>
Interface {<br>
conjugated Port PingPongPort: PingPongProtocol<br>
}<br>
Structure {<br>
external Port PingPongPort<br>
}<br>
Behavior {<br>
<br>
Operation printData(d: DemoData) : void {<br>
"System.out.printf(\"d.int32Val: %d\\n\",d.int32Val);"<br>
"System.out.printf(\"d.float64Val: %f\\n\",d.float64Val);"<br>
"System.out.printf(\"d.int8Array: \");"<br>
"for(int i = 0; i<d.int8Array.length; i++) {"<br>
"System.out.printf(\"%d \",d.int8Array[i]);}"<br>
"System.out.printf(\"\\nd.stringVal: %s\\n\",d.stringVal);"<br>
}<br>
<br>
StateMachine {<br>
Transition wait2: waitForPong -> waitForPong {<br>
triggers {<br>
<pong: PingPongPort><br>
}<br>
action {<br>
"printData(data);"<br>
}<br>
}<br>
Transition wait1: waitForPongSimple -> waitForPongSimple {<br>
triggers {<br>
<pongSimple: PingPongPort guard {<br>
"data < 10"<br>
}><br>
}<br>
action {<br>
"// keep in mind that MrPong increments"<br>
"PingPongPort.pingSimple(data);"<br>
"System.out.printf(\"data: %d\\n\",data);"<br>
}<br>
}<br>
Transition next: waitForPongSimple -> waitForPong {<br>
triggers {<br>
<pongSimple: PingPongPort><br>
}<br>
action {<br>
"System.out.printf(\"data: %d\\n\",data);"<br>
""<br>
"DemoData d = new DemoData();"<br>
"// send the default values"<br>
"PingPongPort.ping(d);"<br>
"d.int32Val=815;"<br>
"for (int i = 0; i<d.int8Array.length;i++){"<br>
"\td.int8Array[i]=(byte)(i+100);"<br>
"\t}"<br>
"d.stringVal=\"some contents\";"<br>
"d.float64Val=3.141234;"<br>
"PingPongPort.ping(d);"<br>
}<br>
}<br>
Transition init0: initial -> waitForPongSimple {<br>
action {<br>
"PingPongPort.pingSimple(0);"<br>
}<br>
}<br>
State waitForPong<br>
State waitForPongSimple<br>
}<br>
}<br>
}<br>
<br>
ActorClass MrPong {<br>
Interface {<br>
Port PingPongPort: PingPongProtocol<br>
}<br>
Structure {<br>
external Port PingPongPort<br>
}<br>
Behavior {<br>
StateMachine {<br>
Transition init: initial -> looping { }<br>
Transition tr0: looping -> looping {<br>
triggers {<br>
<ping: PingPongPort><br>
}<br>
action {<br>
"PingPongPort.pong(data);"<br>
}<br>
}<br>
Transition tr1: looping -> looping {<br>
triggers {<br>
<pingSimple: PingPongPort><br>
}<br>
action {<br>
"PingPongPort.pongSimple(data+1);"<br>
}<br>
}<br>
State looping<br>
}<br>
}<br>
}<br>
<br>
ProtocolClass PingPongProtocol {<br>
incoming {<br>
Message ping(data: DemoData)<br>
Message pingSimple(data: int32)<br>
}<br>
outgoing {<br>
Message pong(data: DemoData)<br>
Message pongSimple(data: int32)<br>
}<br>
}<br>
<br>
DataClass DemoData {<br>
Attribute int32Val: int32 = "4711"<br>
Attribute int8Array [ 10 ]: int8 = "{1,2,3,4,5,6,7,8,9,10}"<br>
Attribute float64Val: float64 = "0.0"<br>
Attribute stringVal: string = "\"empty\""<br>
}<br>
}<br>
</code>
</p>
</div>
<div class="blockquote">
<blockquote class="blockquote">
<p></p>
</blockquote>
</div>
</div>
</body>
</html>
|