Last sync 2016.04.01
[deliverable/titan.core.git] / help / info / altstep.html
1 <!--
2 Copyright (c) 2000-2016 Ericsson Telecom AB
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Eclipse Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/epl-v10.html
7
8 Contributors:
9 Baji, Laszlo
10 Balasko, Jeno
11 Farkas, Laszlo
12 Szabados, Kristof
13 Szabo, Janos Zoltan – initial implementation
14 -->
15 <html>
16 <head>
17 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
18 <meta http-equiv="Content-Language" content="en-us">
19 <title>altstep</title>
20 </head>
21 <body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258">
22 <table align="left" border="0" cellspacing="0" cellpadding="0" valign=top>
23 <tr>
24 <td width=105 height=40><a href="https://projects.eclipse.org/projects/tools.titan"><img src="../images/titan_transparent.gif" border=0 width=105 height=40 align="left" alt="Titan"></a></td>
25 </tr>
26 </table>
27 <table border="0" align="right" cellpadding="0" cellspacing="0">
28 <tr>
29 <td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td>
30 <td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td>
31 <td><a href="alt.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td>
32 <td><a href="and.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td>
33 </tr>
34 </table>
35 <p><br clear="all">
36 </p>
37 <hr>
38 <h1>altstep</h1>
39 <hr align="left" width="75%">
40 <p>The keyword is used to specify default behavior or to structure the alternatives of an <b><font face="Courier New" color="#003258" size="4">alt</font></b> statement. Altsteps are similar to
41 functions but the altstep body defines a set of alternatives (cf. <a href="alt.html"><b><font face="Courier New" color="#003258" size="4">alt</font></b></a>).&nbsp;
42 <ul>
43 <li>An altstep that is activated as default shall only have <b><font face="Courier New" color="#003258" size="4">in</font></b> parameters, port parameters and timer parameters.</li>
44 <li>An altstep that is only invoked as an alternative in an alt statement or as stand-alone statement may have <b><font face="Courier New" color="#003258" size="4">in</font></b>, <b><font
45 face="Courier New" color="#003258" size="4">out</font></b>and <b><font face="Courier New" color="#003258" size="4">inout</font></b> parameters.</li>
46 <li>Altsteps may define local definitions of constants, variables and timers but this is strongly deprecated.</li>
47 </ul>
48 <p>Related keywords:</p>
49 <ul>
50 <li><a href="alt.html"><b><font face="Courier New" color="#003258" size="4">alt</font></b></a></li>
51 <li><a href="default.html"><b><font face="Courier New" color="#003258" size="4">default</font></b></a></li>
52 </ul>
53 <hr align="left" width="50%">
54 <div align="center">
55 <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
56 <tr>
57 <td width="100%">
58 <h3 align="left"><font face="Courier New" color="#003258" size="5"><b>altstep&nbsp;</b></font><i> altstep_identifier </i> <font face="Courier New" color="#003258" size="5"><b>(</b></font> [<i>
59 altstep_parameter</i> ... ] <font face="Courier New" color="#003258" size="5"><b>)</b></font>[ <font face="Courier New" color="#003258" size="5"><b>runs on</b></font><i> component_reference </i>] <font
60 face="Courier New" color="#003258" size="5"><b>{<br>
61 &nbsp;&nbsp;&nbsp;&nbsp;</b></font> [ <i>local_definitions</i> ]&nbsp; <font face="Courier New" color="#003258" size="5"><b><br>
62 &nbsp;&nbsp;&nbsp; [</b></font> [<i>guard_expression</i>] <font face="Courier New" color="#003258" size="5"><b>]</b></font> [<i>condition</i>] <font face="Courier New" color="#003258" size="5"><b>{</b></font>
63 [<i>statement_block</i>] <font face="Courier New" color="#003258" size="5"><b>}<br>
64 &nbsp;&nbsp;&nbsp; </b></font> ...<font face="Courier New" color="#003258" size="5"><b><br>
65 };</b></font> &nbsp;</h3>
66 </td>
67 </tr>
68 </table>
69 </div>
70 <ul>
71 <li>
72 <p>The <font face="Courier New" color="#003258" size="4"><b>altstep</b></font> keyword introduces the altstep definition.</p>
73 </li>
74 <li>
75 <p><i>altstep_identifier</i> is the&nbsp;name used to refer to the altstep. Must begin with a letter, may contain letters, numbers and underscore characters. According to the&nbsp; <a
76 href="../docs/naming.pdf" target="_blank">Naming convention</a>, the prefix <b> as_</b> is recommended.</p>
77 </li>
78 <li>
79 <p><i>altstep_parameter</i> defines a formal parameter. The expression begins with an optional keyword indicating the parameter passing method (<a href="in.html"><font face="Courier New"
80 size="4"><b>in</b></font></a>, <a href="out.html"><font face="Courier New" size="4"><b>out</b></font></a> or <a href="inout.html"><font face="Courier New" size="4"><b>inout</b></font></a>), continues
81 with a reference to a built-in type (cf. <a href="const.html#par1">their list</a>) or a <a href="type.html"> referenced type</a> and ends by a parameter identifier. <b>...</b>
82 indicates that&nbsp; several parameters may be specified; they are separated by commas.</p>
83 </li>
84 <li>
85 <p>The optional keywords <font face="Courier New" color="#003258" size="4"><b>runs on</b></font> makes component constants, variables, timers and ports visible inside the altstep</p>
86 </li>
87 <li>
88 <p><i>component_reference</i> refers to the component. It is composed of two parts: the module identifier (may be omitted) and the component tpye identifier. The two parts are linked by a dot.</p>
89 </li>
90 <li>
91 <p>The optional <i>local_definitions</i> may include constants, variables and timers visible inside the altstep. It is not recommended to use them.</p>
92 </li>
93 <li>
94 <p>Each alternative begins with an optional <i>guard_expression</i> with the following options:</p>
95 <ul>
96 <li>empty guard (note that the brackets must be written) The <i>statement_block</i> will be executed if <i>condition</i> is met.&nbsp;</li>
97 <li>Boolean expression. The <i>statement_block</i> will be executed if the Boolean expression evaluates to true AND <i>condition</i> is met.</li>
98 <li>
99 <p><font face="Courier New" color="#003258" size="4"><b>else</b></font> keyword. The <i>statement_block</i> will always be executed.&nbsp; No <i>condition</i> may appear in the branch.</p>
100 </li>
101 </ul>
102 </li>
103 <li>
104 <p><i>condition</i> may be a communication or a timer event or the termination of a parallel test component. The following operations may be written here: <a href="receive.html"><b><font
105 face="Courier New" color="#003258" size="4">receive</font></b></a>, <a href="trigger.html"><b><font face="Courier New" color="#003258" size="4">trigger</font></b></a>, <a href="getcall.html"><b><font
106 face="Courier New" color="#003258" size="4">getcall</font></b></a>, <a href="getreply.html"><b><font face="Courier New" color="#003258" size="4">getreply</font></b></a>, <a href="catch.html"><b><font
107 face="Courier New" color="#003258" size="4">catch</font></b></a>, <a href="check.html"><b><font face="Courier New" color="#003258" size="4">check</font></b></a>, <a href="timeout.html"><b><font
108 face="Courier New" color="#003258" size="4">timeout</font></b></a> and <a href="done.html"><b><font face="Courier New" color="#003258" size="4">done</font></b></a>.</p>
109 </li>
110 <li>
111 <p>The optional <i>statement_block</i> contains one or more statements separated by semicolons. When empty, the curly brackets must be written.</p>
112 </li>
113 <li>
114 <p><b>...</b> indicates that&nbsp; several branches may occur in the <font face="Courier New" color="#003258" size="4"><b>altstep</b></font> body. There is no separator between them.</p>
115 </li>
116 </ul>
117 <hr align="left" width="50%">
118 <p>Example:
119 <p><font face="Courier New">altstep as_AltSet_A(in integer pl_MyPar1) runs on MyComponentType_ct {<br>
120 &nbsp;&nbsp;&nbsp;[]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;L1_PCO.receive { setverdict(pass) }&nbsp;<br>
121 &nbsp;&nbsp;&nbsp;[x&lt;=1] L2_PCO.receive { setverdict(inconc) }&nbsp;<br>
122 &nbsp;&nbsp;&nbsp;[else]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ setverdict(fail); stop }&nbsp;<br>
123 };</font>
124 <p>The altstep called as_AltSet_A is defined. It has a read/only parameter called pl_MyPar1. The definitions made in the component MyComponentType_ct are visible to the altstep. The first branch
125 is activated if a message has been received on port L1_PCO. The verdict is set to pass. The second branch is activated if a message has been received on port L2_PCO and the variable x is not grater
126 then one. In this case the verdict is set to inconclusive. The last branch is activated if none of the ports has received a messages. The verdict is set to fail and test execution is stopped.</p>
127 <hr align="left" width="25%">
128 <hr align="left" width="25%">
129 <p><a HREF="BNF.html#altstepdef">BNF definition</a> of <font face="Courier New"> altstep</font></p>
130 </body>
131 </html>
This page took 0.033247 seconds and 6 git commands to generate.