Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: fe9d3199e2e175e0587649347c0837491e3071d1 (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
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Summary</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="TutorialSendingDataJava.html" title="Tutorial Sending Data (Java)">
<link rel="prev" href="Generateandrunthemodel.html" title="Generate and run the model">
<link rel="next" href="TutorialPedestrianLightsJava.html" title="Tutorial Pedestrian Lights (Java)">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<h1 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">Summary</h1>
<div class="section" title="Summary">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="Summary3"></a>Summary</h2>
</div>
</div>
</div>
<p>Within the first loop an integer value will be incremented by 
				<span class="emphasis"><em>MrPong</em></span> and sent back to 
				<span class="emphasis"><em>MrPing</em></span>. As long as the guard is true 
				<span class="emphasis"><em>MrPing</em></span> sends back the value.
			</p>
<p>Within the 
				<span class="emphasis"><em>next</em></span> transition, 
				<span class="emphasis"><em>MrPing</em></span> creates a data class and sends the default values. Then 
				<span class="emphasis"><em>MrPing</em></span> changes the values and sends the class again. At this point you should note that during the send operation, a copy of the data class will be created and sent. Otherwise it would not be possible to send the same object two times, even more it would not be possible to send a stack object at all. This type of data passing is called 
				<span class="emphasis"><em>sending data by value</em></span>.
				However, for performance reasons some applications requires 
				<span class="emphasis"><em>sending data by reference</em></span>. In this case the user is responsible for the life cycle of the object. In Java the VM takes care of the life cycle of an object. This is not the case for C/C++. Consider that a object which is created within a transition of a state machine will be destroyed when the transition is finished. The receiving FSM would receive an invalid reference. Therefore care must be taken when sending references.      
			</p>
<p>For sending data by reference you simply have to add the keyword 
				<span class="emphasis"><em>ref</em></span> to the protocol definition.
			</p>
<div class="literallayout">
<p>
<code class="code">Message&nbsp;ping(data:&nbsp;DemoData&nbsp;ref)<br>

</code>
</p>
</div>
<p>Make the test and inspect the console output.</p>
</div>
</body>
</html>

Back to the top