aboutsummaryrefslogtreecommitdiffstats
blob: 06bad08bb4fac0ee07331b6e82e1d8472f1888d1 (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
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Tutorial Pedestrian Lights (Java)</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="index.html" title="eTrice User Guide">
<link rel="prev" href="Summary3.html" title="Summary">
<link rel="next" href="Setupthemodel.html" title="Setup 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">Tutorial Pedestrian Lights (Java)</h1>
<div class="chapter" title="Tutorial Pedestrian Lights (Java)">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="TutorialPedestrianLightsJava"></a>Tutorial Pedestrian Lights (Java)</h2>
</div>
</div>
</div>
<div class="toc">
<dl>
<dt>
<span class="section"><a href="TutorialPedestrianLightsJava.html#Scope4">Scope</a></span>
</dt>
<dt>
<span class="section"><a href="Setupthemodel.html">Setup the model</a></span>
</dt>
<dt>
<span class="section"><a href="Whydoesitworkandwhyisitsafe.html">Why does it work and why is it safe?</a></span>
</dt>
</dl>
</div>
<div class="section" title="Scope">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="Scope4"></a>Scope</h2>
</div>
</div>
</div>
<p>The scope of this tutorial is to demonstrate how to receive model messages from outside the model. Calling methods which are not part of the model is simple and you have already done this within the blinky tutorial (this is the other way round: model =&gt; external code). Receiving events from outside the model is a very common problem and a very frequently asked question. Therefore this tutorial shows how an external event (outside the model) can be received by the model.</p>
<p>This tutorial is not like hello world or blinky. Being familiar with the basic tool features is mandatory for this tutorial. The goal is to understand the mechanism not to learn the tool features.</p>
<p>The idea behind the exercise is, to control a Pedestrian crossing light. We will use the same GUI as for the blinky tutorial but now we will use the 
				<span class="emphasis"><em>REQUEST</em></span> button to start a FSM, which controls the traffic lights.
			</p>
<p>
				
</p>
<div class="mediaobject">
<img src="images/020-Blinky08.png"></div>
<p>
			
</p>
<p>The 
				<span class="emphasis"><em>REQUEST</em></span> must lead to a model message which starts the activity of the lights.
			</p>
<p>There are several possibilities to receive external events (e.g. TCP/UDP Socket, using OS messaging mechanism), but the easiest way is, to make a port usable from outside the model. To do that a few steps are necessary:</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>specify the messages (within a protocol) which should be sent into the model</p>
</li>
<li class="listitem">
<p>model an actor with a port (which uses the specified protocol) and connect the port to the receiver </p>
</li>
<li class="listitem">
<p>the external code should know the port (import of the port class)</p>
</li>
<li class="listitem">
<p>the external code should provide a registration method, so that the actor is able to allow access to this port</p>
</li>
<li class="listitem">
<p>the port can be used from the external code</p>
</li>
</ol>
</div>
</div>
</div>
</body>
</html>