aboutsummaryrefslogtreecommitdiffstats
blob: 923e7ea6d7c63f22aa51bd47840a34705826d9de (plain)
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
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Setup the model</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="TutorialPedestrianLightsJava.html" title="Tutorial Pedestrian Lights (Java)">
<link rel="prev" href="TutorialPedestrianLightsJava.html" title="Tutorial Pedestrian Lights (Java)">
<link rel="next" href="Whydoesitworkandwhyisitsafe.html" title="Why does it work and why is it safe?">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<h1 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">Setup the model</h1>
<div class="section" title="Setup the model">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="Setupthemodel"></a>Setup the model</h2>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>Use the 
						<span class="emphasis"><em>New Model Wizzard</em></span> to create a new eTrice project and name it 
						<span class="emphasis"><em>PedLightsController</em></span>.
					</p>
</li>
<li class="listitem">
<p>Copy the package 
						<span class="emphasis"><em>org.eclipse.etrice.tutorials.PedLightGUI</em></span> to your 
						<span class="emphasis"><em>src</em></span> directory (see blinky tutorial).
					</p>
</li>
<li class="listitem">
<p>In PedestrianLightWndNoTcp.jav uncomment line 15 (import), 36, 122 (usage) and 132-134 (registration). The error markers will disappear after the code is generated from the model.</p>
</li>
<li class="listitem">
<p>Copy the model from /org.eclipse.etrice.tutorials/model/PedLightsController to your model file, or run the model directly in the tutorial directory. </p>
</li>
<li class="listitem">
<p>Adapt the import statement to your path.</p>
</li>
</ul>
</div>
<div class="literallayout">
<p>
<code class="code">import&nbsp;room.basic.service.timing.*&nbsp;from&nbsp;"../../org.eclipse.etrice.modellib/models/TimingService.room"&nbsp;<br>

</code>
</p>
</div>
<div class="blockquote">
<blockquote class="blockquote">
<p></p>
</blockquote>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>Generate the code from the model.</p>
</li>
<li class="listitem">
<p>Add the org.eclipse.etrice.modellib to the Java Class Path of your project.</p>
</li>
<li class="listitem">
<p>All error markers should be disappeared and the model should be operable. </p>
</li>
<li class="listitem">
<p>Arrange the Structure and the Statemachines to understand the model</p>
</li>
</ul>
</div>
<p>
				
</p>
<div class="mediaobject">
<img src="images/030-PedLights01.png"></div>
<p>
				The 
				<span class="emphasis"><em>GuiAdapter</em></span> represents the interface to the external code. It registers its 
				<span class="emphasis"><em>ControlPort</em></span> by the external code.
			</p>
<p>
				
</p>
<div class="mediaobject">
<img src="images/030-PedLights02.png"></div>
<p>
				Visit the initial transition to understand the registration. The actor handles the incoming messages as usual and controls the traffic lights as known from blinky. 
			</p>
<p>
				
</p>
<div class="mediaobject">
<img src="images/030-PedLights03.png"></div>
<p>
				The 
				<span class="emphasis"><em>Controller</em></span> receives the 
				<span class="emphasis"><em>start</em></span> message and controls the timing of the lights. Note that the 
				<span class="emphasis"><em>start</em></span> message will be sent from the external code whenever the 
				<span class="emphasis"><em>REQUEST</em></span> button is pressed.
			</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p> Visit the model and take a closer look to the following elements:</p>
</li>
</ul>
</div>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>PedControlProtocol =&gt; notice that the start message is defined as usual</p>
</li>
<li class="listitem">
<p>Initial transition of the 
						<span class="emphasis"><em>GuiAdapter</em></span> =&gt; see the registration
					</p>
</li>
<li class="listitem">
<p>The 
						<span class="emphasis"><em>Controller</em></span> =&gt; notice that the 
						<span class="emphasis"><em>Controller</em></span> receives the external message (not the 
						<span class="emphasis"><em>GuiAdapter</em></span>). The 
						<span class="emphasis"><em>GuiAdapter</em></span> just provides its port and handles the incoming messages.
					</p>
</li>
<li class="listitem">
<p>Visit the hand written code =&gt; see the import statement of the protocol class and the usage of the port.</p>
</li>
</ol>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>Generate and test the model</p>
</li>
<li class="listitem">
<p>Take a look at the generated MSC =&gt; notice that the start message will shown as if the 
						<span class="emphasis"><em>GuiAdapter</em></span> had sent it.
					</p>
</li>
</ul>
</div>
<p>
				
</p>
<div class="mediaobject">
<img src="images/030-PedLights04.png"></div>
<p>
			
</p>
</div>
</body>
</html>