Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a83050fcd16f2ff69fa0452eeeed1821a79294c5 (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
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Create a new model from scratch</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="TutorialHelloWorld.html" title="Tutorial HelloWorld">
<link rel="prev" href="TutorialHelloWorld.html" title="Tutorial HelloWorld">
<link rel="next" href="Summary.html" title="Summary">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<h1 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">Create a new model from scratch</h1>
<div class="section" title="Create a new model from scratch">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="Createanewmodelfromscratch"></a>Create a new model from scratch</h2>
</div>
</div>
</div>
<p>The goal of eTrice is to describe distributed systems on a logical level. In the current version not all elements will be supported. But as prerequisite for further versions the following elements are mandatory for an eTrice model:</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>the 
						<span class="italic">LogicalSystem</span> 
					
</p>
</li>
<li class="listitem">
<p>at least one 
						<span class="italic">SubSystemClass</span>
					
</p>
</li>
<li class="listitem">
<p>at least one 
						<span class="italic">ActorClass</span>
					
</p>
</li>
</ul>
</div>
<p>The 
				<span class="italic">LogicalSystem</span> represents the complete distributed system and contains at least one 
				<span class="italic">SubSystemRef</span>. The 
				<span class="italic">SubSystemClass</span> represents an address space and contains at least one 
				<span class="italic">ActorRef</span>. The 
				<span class="italic">ActorClass</span> is the building block of which an application will be build of. It is a good idea to define a top level actor that can be used as reference within the subsystem.
			</p>
<p>The resulting model code looks like this:</p>
<div class="literallayout">
<p>
<code class="code">RoomModel&nbsp;HelloWorld&nbsp;{<br>

<br>
	LogicalSystem&nbsp;System_Blinky&nbsp;{<br>
		SubSystemRef&nbsp;subsystem&nbsp;:&nbsp;SubSystem_HelloWorld<br>
	}<br>

<br>
	SubSystemClass&nbsp;SubSystem_HelloWorld&nbsp;{<br>
		ActorRef&nbsp;application&nbsp;:&nbsp;HelloWorldTop<br>
	}<br>

<br>
	ActorClass&nbsp;HelloWorldTop&nbsp;{<br>
	}<br>
}&nbsp;<br>

</code>
</p>
</div>
<div class="literallayout">
<p>
<code class="code"></code>
</p>
</div>
<div class="section" title="Create a new model file">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="Createanewmodelfile"></a>Create a new model file </h3>
</div>
</div>
</div>
<p>Create a new file in your org.eclipse.etrice.doc.tutorials.scratch.model directory and name it 
					<span class="italic">HelloWorld.room</span> and select finish.
				</p>
<p>
					
</p>
<div class="mediaobject">
<img src="images/OpenFile2.PNG"></div>
<p>
				
</p>
<p>The file ending must be 
					<span class="italic">.room</span> for selecting the correct editor. Open the file and copy the above code into the editor window. You should see something like this:
				</p>
<p>
					
</p>
<div class="mediaobject">
<img src="images/HelloWorld1.PNG"></div>
<p>
				
</p>
</div>
<div class="section" title="Create a state machine">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="Createastatemachine"></a>Create a state machine</h3>
</div>
</div>
</div>
<p>We will implement the Hello World code on the initial transition of the 
					<span class="italic">HelloWorldTop</span> actor. Therefore open the state machine editor by right clicking the 
					<span class="italic">HelloWorldTop</span> actor in the outline view and select 
					<span class="italic">Edit Behavior</span>.
				</p>
<p>
					
</p>
<div class="mediaobject">
<img src="images/HelloWorld2.PNG"></div>
<p>
				
</p>
<p>The state machine editor will be opened. Create the state machine as follow. Put the action code to the initial transition.</p>
<p>
					
</p>
<div class="mediaobject">
<img src="images/HelloWorld3.PNG"></div>
<p>
				
</p>
<p>Save the diagram and inspect the model file. Note that the textual representation was created after saving the diagram.</p>
<p>
					
</p>
<div class="mediaobject">
<img src="images/HelloWorld4.PNG"></div>
<p>
				
</p>
</div>
<div class="section" title="Build and run the model">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="Buildandrunthemodel"></a>Build and run the model</h3>
</div>
</div>
</div>
<p>Now the model is finshed and source code can be generated. 
					From org.eclipse.etrice.doc.tutorials.scratch.workflow select genAllModells.mwe2 and run it as MWE2Workflow. Currently all models in the directory will be generated.</p>
<p>
					
</p>
<div class="mediaobject">
<img src="images/HelloWorld6.PNG"></div>
<p>
				
</p>
<p>The code will be generated to the src-gen directory. The main class will be contained in __SubSystem_HelloWorldRunner.java__. Select this file and run it as Java application.</p>
<p>
					
</p>
<div class="mediaobject">
<img src="images/HelloWorld7.PNG"></div>
<p>
				
</p>
<p>The Hello World application starts and the string will be printed on the console window. To stop the application the user must type 
					<span class="italic">quit</span> in the console window.
				</p>
<p>
					
</p>
<div class="mediaobject">
<img src="images/HelloWorld8.PNG"></div>
<p>
				
</p>
</div>
<div class="section" title="Open the Message Sequence Chart">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="OpentheMessageSequenceChart"></a>Open the Message Sequence Chart</h3>
</div>
</div>
</div>
<p>During runtime the application produces a MSC and wrote it to a file. Open /org.eclipse.etrice.doc.tutorials/tmp/log/SubSystem_HelloWorld_Async.seq. You should see something like this:</p>
<p>
					
</p>
<div class="mediaobject">
<img src="images/HelloWorld9.PNG"></div>
<p>
				
</p>
</div>
</div>
</body>
</html>

Back to the top