Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.doc/help/ImplementtheBehavior.html')
-rw-r--r--plugins/org.eclipse.etrice.doc/help/ImplementtheBehavior.html246
1 files changed, 0 insertions, 246 deletions
diff --git a/plugins/org.eclipse.etrice.doc/help/ImplementtheBehavior.html b/plugins/org.eclipse.etrice.doc/help/ImplementtheBehavior.html
deleted file mode 100644
index 8847c69b5..000000000
--- a/plugins/org.eclipse.etrice.doc/help/ImplementtheBehavior.html
+++ /dev/null
@@ -1,246 +0,0 @@
-<html>
-<head>
-<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<title>Implement the Behavior</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="TutorialBlinkyJava.html" title="Tutorial Blinky (Java)">
-<link rel="prev" href="Finishthemodelstructure.html" title="Finish the model structure">
-<link rel="next" href="Summary2.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">Implement the Behavior</h1>
-<div class="section" title="Implement the Behavior">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both">
-<a name="ImplementtheBehavior"></a>Implement the Behavior</h2>
-</div>
-</div>
-</div>
-<p>The application should switch on and off the LED for 5 seconds in a 1 second interval, then stop blinking for 5 seconds and start again. To implement this behavior we will implement two FSMs. One for the 1 second interval and one for the 5 second interval. The 1 second blinking should be implemented in
- <span class="emphasis"><em>Blinky</em></span>. The 5 second interval should be implemented in
- <span class="emphasis"><em>BlinkyController</em></span>. First implement the Controller.
- </p>
-<p>Right click to
- <span class="emphasis"><em>BlinkyController</em></span> and select
- <span class="emphasis"><em>Edit Behavior</em></span>.
- Drag and Drop the
- <span class="emphasis"><em>Initial Point</em></span> and two
- <span class="emphasis"><em>States</em></span> into the top state. Name the states
- <span class="emphasis"><em>on</em></span> and
- <span class="emphasis"><em>off</em></span>.
- Use the
- <span class="emphasis"><em>Transition</em></span> tool to draw transitions from
- <span class="emphasis"><em>init</em></span> to
- <span class="emphasis"><em>on</em></span> from
- <span class="emphasis"><em>on</em></span> to
- <span class="emphasis"><em>off</em></span> and from
- <span class="emphasis"><em>off</em></span> to
- <span class="emphasis"><em>on</em></span>.
- </p>
-<p>Open the transition dialog by double click the arrow to specify the trigger event and the action code of each transition. Note that the initial transition does not have a trigger event.</p>
-<p>The transition dialog should look like this:</p>
-<p>
-
-</p>
-<div class="mediaobject">
-<img src="images/020-Blinky09.png"></div>
-<p>
-
-</p>
-<p>The defined ports will be generated as a member attribute of the actor class from type of the attached protocol. So, to send e message you must state
- <span class="emphasis"><em>port.message(param);</em></span>. In this example
- <span class="emphasis"><em>ControlPort.start()</em></span> sends the
- <span class="emphasis"><em>start</em></span> message via the
- <span class="emphasis"><em>ControlPort</em></span> to the outside world. Assuming that
- <span class="emphasis"><em>Blinky</em></span> is connected to this port, the message will start the one second blinking FSM. It is the same thing with the
- <span class="emphasis"><em>timer</em></span>. The SAP is also a port and follows the same rules. So it is clear that
- <span class="emphasis"><em>timer.Start(5000);</em></span> will send the
- <span class="emphasis"><em>Start</em></span> message to the timing service. The timing service will send a
- <span class="emphasis"><em>timeoutTick</em></span> message back after 5000ms.
- </p>
-<p>Within each transition the timer will be restarted and the appropriate message will be sent via the
- <span class="emphasis"><em>ControlPort</em></span>.
- </p>
-<p>The resulting state machine should look like this:
- (Note that the arrows peak changes if the transition contains action code.)</p>
-<p>
-
-</p>
-<div class="mediaobject">
-<img src="images/020-Blinky10.png"></div>
-<p>
-
-</p>
-<p>Save the diagram and inspect the
- <span class="emphasis"><em>Blinky.room</em></span> file. The
- <span class="emphasis"><em>BlinkyController</em></span> should look like this:
- </p>
-<p>
-
-</p>
-<div class="mediaobject">
-<img src="images/020-Blinky11.png"></div>
-<p>
-
-</p>
-<p>Now we will implement
- <span class="emphasis"><em>Blinky</em></span>. Due to the fact that
- <span class="emphasis"><em>Blinky</em></span> interacts with the GUI class a view things must to be done in the model file.
- </p>
-<p>Double click
- <span class="emphasis"><em>Blinky</em></span> in the outline view to navigate to
- <span class="emphasis"><em>Blinky</em></span> within the model file.
- Add the following code:
- (type it or simply copy it from the tutorial project)
- </p>
-<p>
-
-</p>
-<div class="mediaobject">
-<img src="images/020-Blinky12.png"></div>
-<p>
-
-</p>
-<p>
-
-<span class="emphasis"><em>usercode1</em></span> will be generated at the beginning of the file, outside the class definition.
- <span class="emphasis"><em>usercode2</em></span> will be generated within the class definition. The code imports the GUI class and instantiates the window class. Attributes for the carLights and pedLights will be declared to easily access the lights in the state machine.
- The Operation
- <span class="emphasis"><em>destroyUser()</em></span> is a predefined operation that will be called during shutdown of the application. Within this operation, cleanup of manual coded classes can be done.
- </p>
-<p>Now design the FSM of
- <span class="emphasis"><em>Blinky</em></span>. Remember, as the name suggested
- <span class="emphasis"><em>blinking</em></span> is a state in which the LED must be switched on and off. We will realize that by an hierarchical FSM in which the
- <span class="emphasis"><em>blinking</em></span> state has two sub states.
- </p>
-<p>Open the behavior diagram of
- <span class="emphasis"><em>Blinky</em></span> by right clicking the
- <span class="emphasis"><em>Blinky</em></span> actor in the outline view. Create two states named
- <span class="emphasis"><em>blinking</em></span> and
- <span class="emphasis"><em>off</em></span>. Right click to
- <span class="emphasis"><em>blinking</em></span> and create a subgraph.
- </p>
-<p>
-
-</p>
-<div class="mediaobject">
-<img src="images/020-Blinky13.png"></div>
-<p>
-
-</p>
-<p>Create the following state machine. The trigger events between
- <span class="emphasis"><em>on</em></span> and
- <span class="emphasis"><em>off</em></span> are the
- <span class="emphasis"><em>timeoutTick</em></span> from the
- <span class="emphasis"><em>timer</em></span> port.
- </p>
-<p>
-
-</p>
-<div class="mediaobject">
-<img src="images/020-Blinky14.png"></div>
-<p>
-
-</p>
-<p>Create entry code for both states by right clicking the state and select
- <span class="emphasis"><em>Edit State...</em></span>
-
-</p>
-<p>Entry code of
- <span class="emphasis"><em>on</em></span> is:
- </p>
-<div class="literallayout">
-<p>
-<code class="code">timer.Start(1000);<br>
-carLights.setState(TrafficLight3.YELLOW);&nbsp;<br>
-
-</code>
-</p>
-</div>
-<div class="blockquote">
-<blockquote class="blockquote">
-<p></p>
-</blockquote>
-</div>
-<p>Entry code of
- <span class="emphasis"><em>off</em></span> is:
- </p>
-<div class="literallayout">
-<p>
-<code class="code">timer.Start(1000);<br>
-carLights.setState(TrafficLight3.OFF);<br>
-
-</code>
-</p>
-</div>
-<div class="blockquote">
-<blockquote class="blockquote">
-<p></p>
-</blockquote>
-</div>
-<p>Navigate to the Top level state by double clicking the
- <span class="emphasis"><em>/blinking</em></span> state. Create the following state machine:
- </p>
-<p>
-
-</p>
-<div class="mediaobject">
-<img src="images/020-Blinky15.png"></div>
-<p>
-
-</p>
-<p>The trigger event from
- <span class="emphasis"><em>off</em></span> to
- <span class="emphasis"><em>blinking</em></span> is the
- <span class="emphasis"><em>start</em></span> event from the
- <span class="emphasis"><em>ControlPort</em></span>.The trigger event from
- <span class="emphasis"><em>blinking</em></span> to
- <span class="emphasis"><em>off</em></span> is the
- <span class="emphasis"><em>stop</em></span> event from the
- <span class="emphasis"><em>ControlPort</em></span>.
- Note: The transition from
- <span class="emphasis"><em>blinking</em></span> to
- <span class="emphasis"><em>off</em></span> is a so called group transition. This is a outgoing transition from a super state (state with sub states) without specifying the concrete leave state (state without sub states). An incoming transition to a super state is called history transition.
- </p>
-<p>Action code of the init transition is:</p>
-<div class="literallayout">
-<p>
-<code class="code">carLights&nbsp;=&nbsp;light.getCarLights();<br>
-pedLights&nbsp;=&nbsp;light.getPedLights();<br>
-carLights.setState(TrafficLight3.OFF);<br>
-pedLights.setState(TrafficLight2.OFF);<br>
-
-</code>
-</p>
-</div>
-<div class="blockquote">
-<blockquote class="blockquote">
-<p></p>
-</blockquote>
-</div>
-<p>Action code from
- <span class="emphasis"><em>blinking</em></span> to
- <span class="emphasis"><em>off</em></span> is:
- </p>
-<div class="literallayout">
-<p>
-<code class="code">timer.Kill();<br>
-carLights.setState(TrafficLight3.OFF);&nbsp;<br>
-
-</code>
-</p>
-</div>
-<div class="blockquote">
-<blockquote class="blockquote">
-<p></p>
-</blockquote>
-</div>
-<p>The model is complete now. You can run and debug the model as described in getting started. Have fun.</p>
-<p>The complete model can be found in /org.eclipse.etrice.tutorials/model/Blinky.</p>
-</div>
-</body>
-</html>

Back to the top