https://taste.tuxfamily.org/wiki/index.php?title=Technical_topic:_Use_of_timers_in_user_code_with_TASTE&feed=atom&action=historyTechnical topic: Use of timers in user code with TASTE - Revision history2024-03-29T04:43:26ZRevision history for this page on the wikiMediaWiki 1.29.0https://taste.tuxfamily.org/wiki/index.php?title=Technical_topic:_Use_of_timers_in_user_code_with_TASTE&diff=995&oldid=prevMperrotin: /* Declare Timers in the TASTE interface view */2021-05-17T15:46:06Z<p><span dir="auto"><span class="autocomment">Declare Timers in the TASTE interface view</span></span></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 15:46, 17 May 2021</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l27" >Line 27:</td>
<td colspan="2" class="diff-lineno">Line 27:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Create a new TASTE system:</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Create a new TASTE system:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline"> $ mkdir demo</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>  $ taste</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline"> $ cd demo</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>  $ taste<del class="diffchange diffchange-inline">-create-interface-view</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>When the interface view editor opens, create two functions (right-click and select New Function). Name your functions, e.g. test_timers and my_gui.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>When the interface view editor opens, create two functions (right-click and select New Function). Name your functions, e.g. test_timers and my_gui.</div></td></tr>
</table>Mperrotinhttps://taste.tuxfamily.org/wiki/index.php?title=Technical_topic:_Use_of_timers_in_user_code_with_TASTE&diff=994&oldid=prevMperrotin: /* Introduction */2021-05-17T15:45:15Z<p><span dir="auto"><span class="autocomment">Introduction</span></span></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 15:45, 17 May 2021</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l21" >Line 21:</td>
<td colspan="2" class="diff-lineno">Line 21:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>You may look at the following demo to see how timers can also be used with C and Ada:</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>You may look at the following demo to see how timers can also be used with C and Ada:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>  ~/tool-src/<del class="diffchange diffchange-inline">testSuites</del>/<del class="diffchange diffchange-inline">Regression_AADLv2</del>/Demo_Timers/</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>  ~/tool-src/<ins class="diffchange diffchange-inline">kazoo</ins>/<ins class="diffchange diffchange-inline">test</ins>/Demo_Timers/</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>= Declare Timers in the TASTE interface view =</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>= Declare Timers in the TASTE interface view =</div></td></tr>
</table>Mperrotinhttps://taste.tuxfamily.org/wiki/index.php?title=Technical_topic:_Use_of_timers_in_user_code_with_TASTE&diff=179&oldid=prevTtsiodras: 1 revision imported2017-08-04T21:02:01Z<p>1 revision imported</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<tr style='vertical-align: top;' lang='en'>
<td colspan='1' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='1' style="background-color: white; color:black; text-align: center;">Revision as of 21:02, 4 August 2017</td>
</tr><tr><td colspan='2' style='text-align: center;' lang='en'><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>Ttsiodrashttps://taste.tuxfamily.org/wiki/index.php?title=Technical_topic:_Use_of_timers_in_user_code_with_TASTE&diff=178&oldid=prevMaxime-esa: /* Credits */2013-10-21T07:59:24Z<p><span dir="auto"><span class="autocomment">Credits</span></span></p>
<p><b>New page</b></p><div>= Introduction =<br />
<br />
This section explains how to use timers with TASTE. Timers are used when you want to implement requirements such as:<br />
<br />
Ring the bell<br />
Wait 10 seconds<br />
Ring Again<br />
Wait 10 Seconds<br />
Go back home<br />
<br />
Those kind of requirements are very frequent in embedded systems such as satellites, where complex scenarii occur at runtime to maintain the state of the system, or to discover it after a reboot.<br />
<br />
However, if timers seem "obvious" to end users, in critical real-time systems they are not easily implemented. TASTE runtime is based on the Ravenscar profile, which is a set of rules that dictates what constructs can be used for a real-time system to be analysable and ''feasible''.<br />
<br />
Among the Ravenscar rules, an important constraints is that when executing, a thread must ''run to completion'', i.e. must run until its next activation condition, without blocking in the middle of the user code. In other words, making a system call that suspends the thread is forbidden, as it would mess up the overall system scheduling: the entry point of a thread must be set at one place only (i.e. at the reception of a message or at the next cycle in case of a periodic thread).<br />
<br />
Keeping those restrictions in mind, TASTE is providing, through model transformations and code generation, a practical and transparent mechanism to define and use timers that can be triggered in the user code without violating the Ravenscar computational model.<br />
<br />
We will see how to use timers using the SDL language. This language has a built-in timer construct, which makes the use of timer natural and elegant.<br />
<br />
You may look at the following demo to see how timers can also be used with C and Ada:<br />
<br />
~/tool-src/testSuites/Regression_AADLv2/Demo_Timers/<br />
<br />
= Declare Timers in the TASTE interface view =<br />
<br />
Create a new TASTE system:<br />
<br />
$ mkdir demo<br />
$ cd demo<br />
$ taste-create-interface-view<br />
<br />
When the interface view editor opens, create two functions (right-click and select New Function). Name your functions, e.g. test_timers and my_gui.<br />
<br />
[[File:Timers-1.png|600px|border|center|thumb|Timers(1)]]<br />
<br />
Double click on each function to set the impplementation language. Use SDL for "test_timers" and GUI for "my_gui" <br />
<br />
Add a provided interface to the test_timers function (Rick-click on the function and select ''New PI''). Name your provided interface (e.g. ''hello'') and set it to ''Sporadic''. Add a parameter (choose any type from the list, e.g. T-Uint32).<br />
Add a corresponding Required interface of the other function, and click on it to draw a connection between the Required and the Provided interface.<br />
<br />
Now double-click again to edit the properties of the ''test_timers'' functions. Click on the ''Context Parameters'' tab, and add a timer there, as on the following picture:<br />
<br />
[[File:Timers-2.png|600px|border|center|thumb|Timers(2)]]<br />
<br />
You may declare multiple timers. As you can see the "Timer" type is proposed in the list.<br />
<br />
Now exit the property menu, and right-click on the function to edit the functional code (in that case open the SDL editor):<br />
<br />
[[File:Timers-3.png|600px|border|center|thumb|Timers(3)]]<br />
<br />
= Write the user code =<br />
<br />
Here is what you get. A timer has been declared in the model for you, together with explanations on how to use the timer.<br />
<br />
[[File:Timers-4.png|600px|border|center|thumb|Timers(4)]]<br />
<br />
This is how we can fill the SDL model to make a simple use of the timer, based on the reception of the "hello" message from the GUI. The scenario is the following:<br />
Wait for ''hello''<br />
On reception of ''hello'' set a 5 seconds timer<br />
If ''hello'' is received again before timer expiration, reset (disable) the timer<br />
Otherwise, after 5 seconds, display a message<br />
<br />
SDL is well suited for this kind of scenarii, as it is a state machine:<br />
<br />
[[File:Timers-5.png|600px|border|center|thumb|Timers(5)]]<br />
<br />
When you are done editing, save your model and exit the tool.<br />
<br />
= Create a deployment view and build your system =<br />
<br />
The last thing you have to do before being able to test your system is to select your target processor/OS on which you want to run your system.<br />
Back in the interface view, click on the Tools menu and open the Deployment View editor.<br />
<br />
[[File:Timers-6.png|600px|border|center|thumb|Timers(6)]]<br />
<br />
Mimic the picture above - make a simple deployment by dragging and dropping a Linux32 processor on the canvas, and right click to bind your two functions on it. You may rename the partition (e.g. call it ''demo''): this will be the name of the binary application that will be generated for this system.<br />
<br />
When you are done, save and quit the deployment view editor. You get back to the Interface view editor.<br />
<br />
= Build the system and try it =<br />
<br />
Click on the Tools menu and select Build system (in C or in Ada). A terminal will open showing the progress of the build ; after a while you will see the completion result:<br />
<br />
[[File:Timers-7.png|600px|border|center|thumb|Timers(7)]]<br />
<br />
We can now go to the pointed directory and try to run the generated binaries (one for the GUI and one for the main system, that comprises the test_timers function).<br />
<br />
Exit the interface view<br />
$ cd binary/binaries<br />
$ xterm -e ./GUI-mygui &<br />
$ ./demo<br />
<br />
The GUI will open, offering the possibility to send the ''hello'' message to the main binary. <br />
<br />
[[File:Timers-8.png|600px|border|center|thumb|Timers(8)]]<br />
<br />
Click on Send and look at the console where you ran the ''demo'' binary<br />
<br />
./demo<br />
Timer set!<br />
Timer expired! # It should appear after 5 seconds<br />
<br />
And you send the ''hello'' message twice:<br />
<br />
Timer set!<br />
Timer reset!<br />
<br />
= Icing on the cake =<br />
<br />
You can use the MSC recorder to observe the internal behaviour of the system.<br />
Instead of running<br />
<br />
$ xterm -e ./GUI-mygui &<br />
$ ./demo<br />
<br />
Run:<br />
$ xterm -e ./GUI-mygui &<br />
$ '''taste-run-and-trace''' ./demo<br />
<br />
Perform the scenario of your choice when the GUI run, and hit Ctrl-C when you are done. You will get a file called ''trace.msc''. Open it with the MSC Editor:<br />
<br />
$ msce.py -o trace.msc<br />
<br />
And you will see a trace of the system execution, showing when the timer has been set and reset (and showing all messages exchanged in the system):<br />
<br />
[[File:Timers-9.png|600px|border|center|thumb|Timers(9)]]<br />
<br />
= Additional information =<br />
<br />
Timer value has to be a multiple of 100 ms, that is the time quantum used by the timer manager. The timer manager is a function that is generated during the vertical transformation of your system and that has a periodic interface triggered every 100ms. It holds all the timers states of a node and is responsible for invoking the interface of the user code that corresponds to timer expiration. It has SET and RESET interfaces that are immediate interfaces the user code can invoke whenever the timer must be activated or disabled.<br />
<br />
= Credits =<br />
<br />
Timer management designed and implemented by Maxime Perrotin/ESA<br />
<br />
MSC tracing function by Thanassis Tsiodras (updated by MP for the timer symbols and interface to TASTE MSC Editor)<br />
<br />
MSC Editor written by Angel Esquinas Fernandez</div>Maxime-esa