Commit | Line | Data |
---|---|---|
970ed795 EL |
1 | <!-- |
2 | Copyright (c) 2000-2014 Ericsson Telecom AB | |
3 | ||
4 | All rights reserved. This program and the accompanying materials | |
5 | are made available under the terms of the Eclipse Public License v1.0 | |
6 | which accompanies this distribution, and is available at | |
7 | http://www.eclipse.org/legal/epl-v10.html | |
8 | --> | |
9 | <html> | |
10 | <head> | |
11 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
12 | <meta http-equiv="Content-Language" content="en-us"> | |
13 | <title>altstep</title> | |
14 | </head> | |
15 | <body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258"> | |
16 | <table align="left" border="0" cellspacing="0" cellpadding="0" valign=top> | |
17 | <tr> | |
18 | <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> | |
19 | </tr> | |
20 | </table> | |
21 | <table border="0" align="right" cellpadding="0" cellspacing="0"> | |
22 | <tr> | |
23 | <td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td> | |
24 | <td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td> | |
25 | <td><a href="alt.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td> | |
26 | <td><a href="and.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td> | |
27 | </tr> | |
28 | </table> | |
29 | <p><br clear="all"> | |
30 | </p> | |
31 | <hr> | |
32 | <h1>altstep</h1> | |
33 | <hr align="left" width="75%"> | |
34 | <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 | |
35 | 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>). | |
36 | <ul> | |
37 | <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> | |
38 | <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 | |
39 | 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> | |
40 | <li>Altsteps may define local definitions of constants, variables and timers but this is strongly deprecated.</li> | |
41 | </ul> | |
42 | <p>Related keywords:</p> | |
43 | <ul> | |
44 | <li><a href="alt.html"><b><font face="Courier New" color="#003258" size="4">alt</font></b></a></li> | |
45 | <li><a href="default.html"><b><font face="Courier New" color="#003258" size="4">default</font></b></a></li> | |
46 | </ul> | |
47 | <hr align="left" width="50%"> | |
48 | <div align="center"> | |
49 | <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4"> | |
50 | <tr> | |
51 | <td width="100%"> | |
52 | <h3 align="left"><font face="Courier New" color="#003258" size="5"><b>altstep </b></font><i> altstep_identifier </i> <font face="Courier New" color="#003258" size="5"><b>(</b></font> [<i> | |
53 | 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 | |
54 | face="Courier New" color="#003258" size="5"><b>{<br> | |
55 | </b></font> [ <i>local_definitions</i> ] <font face="Courier New" color="#003258" size="5"><b><br> | |
56 | [</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> | |
57 | [<i>statement_block</i>] <font face="Courier New" color="#003258" size="5"><b>}<br> | |
58 | </b></font> ...<font face="Courier New" color="#003258" size="5"><b><br> | |
59 | };</b></font> </h3> | |
60 | </td> | |
61 | </tr> | |
62 | </table> | |
63 | </div> | |
64 | <ul> | |
65 | <li> | |
66 | <p>The <font face="Courier New" color="#003258" size="4"><b>altstep</b></font> keyword introduces the altstep definition.</p> | |
67 | </li> | |
68 | <li> | |
69 | <p><i>altstep_identifier</i> is the name used to refer to the altstep. Must begin with a letter, may contain letters, numbers and underscore characters. According to the <a | |
70 | href="../docs/naming.pdf" target="_blank">Naming convention</a>, the prefix <b> as_</b> is recommended.</p> | |
71 | </li> | |
72 | <li> | |
73 | <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" | |
74 | 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 | |
75 | 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> | |
76 | indicates that several parameters may be specified; they are separated by commas.</p> | |
77 | </li> | |
78 | <li> | |
79 | <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> | |
80 | </li> | |
81 | <li> | |
82 | <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> | |
83 | </li> | |
84 | <li> | |
85 | <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> | |
86 | </li> | |
87 | <li> | |
88 | <p>Each alternative begins with an optional <i>guard_expression</i> with the following options:</p> | |
89 | <ul> | |
90 | <li>empty guard (note that the brackets must be written) The <i>statement_block</i> will be executed if <i>condition</i> is met. </li> | |
91 | <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> | |
92 | <li> | |
93 | <p><font face="Courier New" color="#003258" size="4"><b>else</b></font> keyword. The <i>statement_block</i> will always be executed. No <i>condition</i> may appear in the branch.</p> | |
94 | </li> | |
95 | </ul> | |
96 | </li> | |
97 | <li> | |
98 | <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 | |
99 | 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 | |
100 | 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 | |
101 | 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 | |
102 | 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> | |
103 | </li> | |
104 | <li> | |
105 | <p>The optional <i>statement_block</i> contains one or more statements separated by semicolons. When empty, the curly brackets must be written.</p> | |
106 | </li> | |
107 | <li> | |
108 | <p><b>...</b> indicates that 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> | |
109 | </li> | |
110 | </ul> | |
111 | <hr align="left" width="50%"> | |
112 | <p>Example: | |
113 | <p><font face="Courier New">altstep as_AltSet_A(in integer pl_MyPar1) runs on MyComponentType_ct {<br> | |
114 | [] L1_PCO.receive { setverdict(pass) } <br> | |
115 | [x<=1] L2_PCO.receive { setverdict(inconc) } <br> | |
116 | [else] { setverdict(fail); stop } <br> | |
117 | };</font> | |
118 | <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 | |
119 | 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 | |
120 | 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> | |
121 | <hr align="left" width="25%"> | |
122 | <hr align="left" width="25%"> | |
123 | <p><a HREF="BNF.html#altstepdef">BNF definition</a> of <font face="Courier New"> altstep</font></p> | |
124 | </body> | |
125 | </html> |