Commit | Line | Data |
---|---|---|
970ed795 | 1 | <!-- |
3abe9331 | 2 | Copyright (c) 2000-2015 Ericsson Telecom AB |
970ed795 EL |
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>receive</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="read.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td> | |
26 | <td><a href="record.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>receive</h1> | |
33 | <hr align="left" width="75%"> | |
34 | <p>The asynchronous operation belongs to the family of message-based communication operations. It is used to receive a value from an incoming message port queue. | |
35 | <ul> | |
36 | <li>The operation can be used on connected ports only.</li> | |
37 | <li>The operation has blocking semantics (except when used within an alt statement!) i.e., the TTCN3 program execution is halted until the message matching the criteria described in the value | |
38 | part arrives.</li> | |
39 | <li>The operation examines the 1st message on the port queue but extracts this only if the message matches the receiving template</li> | |
40 | <li>In case of multiple connections the operation may be restricted to a certain sender.</li> | |
41 | <li>The received value and the address of the sender may be stored.</li> | |
42 | </ul> | |
43 | <p>Related keywords:</p> | |
44 | <ul> | |
45 | <li><a href="address.html"><b><font face="Courier New" color="#003258" size="4">address</font></b></a></li> | |
46 | <li><a href="any.html"><b><font face="Courier New" color="#003258" size="4">any</font></b></a></li> | |
47 | <li><a href="create.html"><b><font face="Courier New" color="#003258" size="4">create</font></b></a></li> | |
48 | <li><a href="from.html"><b><font face="Courier New" color="#003258" size="4">from</font></b></a></li> | |
49 | <li><a href="modifies.html"><b><font face="Courier New" color="#003258" size="4">modifies</font></b></a></li> | |
50 | <li><a href="sender.html"><b><font face="Courier New" color="#003258" size="4">sender</font></b></a></li> | |
51 | <li><a href="system.html"><b><font face="Courier New" color="#003258" size="4">system</font></b></a></li> | |
52 | <li><a href="value.html"><b><font face="Courier New" color="#003258" size="4">value</font></b></a></li> | |
53 | </ul> | |
54 | <hr align="left" width="50%"> | |
55 | <div align="center"> | |
56 | <center> | |
57 | <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4"> | |
58 | <tr> | |
59 | <td width="100%"> | |
60 | <h3 align="center"><i>port_reference</i><font face="Courier New" color="#003258" size="5"><b>.receive </b></font>[ <font face="Courier New" color="#003258" size="5"><b> (</b></font><i> | |
61 | value_part </i><font face="Courier New" color="#003258" size="5"><b>)</b></font> ] [ <font face="Courier New" color="#003258" size="5"><b>from </b></font><i>address_reference</i> ] [ <font | |
62 | face="Courier New" color="#003258" size="5"><b>-> </b></font><i>assignment_part</i> ]<font face="Courier New" color="#003258" size="5"><b>;</b></font> </h3> | |
63 | </td> | |
64 | </tr> | |
65 | </table> | |
66 | </center> | |
67 | </div> | |
68 | <ul> | |
69 | <li> | |
70 | <p><i> port_reference</i> points out the incoming message port.</p> | |
71 | </li> | |
72 | <ul> | |
73 | <li> | |
74 | <p>the keywords <b><font face="Courier New" color="#003258" size="4">any port</font> </b> may be used to indicate that messages from any ports will be accepted (see the <a href="#Example 7:">example | |
75 | 7</a>).</p> | |
76 | </li> | |
77 | </ul> | |
78 | <li> | |
79 | <p>The <b><font face="Courier New" color="#003258" size="4">receive</font> </b> keyword introduces the message reception.</p> | |
80 | </li> | |
81 | <li> | |
82 | <p><i>value_part</i> is one of the following: (rem.: when omitted, <a href="#Example 4"> any message will be received</a>)</p> | |
83 | <ul> | |
84 | <li>a literal value, a constant, a variable, an expression. (see the <a href="#Example 1">example1</a>)</li> | |
85 | <li>a value template (see the <a href="#Example 2">example 2</a>)</li> | |
86 | <li>a modified template (see the <a href="#Example 3">example 3</a>)<br> | |
87 | </li> | |
88 | </ul> | |
89 | </li> | |
90 | <li> | |
91 | <p>The optional <b><font face="Courier New" color="#003258" size="4">from</font> </b> keyword is used when a port is connected to several entities and restriction to one communication partner is | |
92 | required.</p> | |
93 | </li> | |
94 | </ul> | |
95 | <ul> | |
96 | <li> | |
97 | <p><i>address_reference</i> is one of the following:</p> | |
98 | <ul> | |
99 | <li>a component reference (cf. <a href="create.html"><b><font face="Courier New" color="#003258" size="4">create</font></b></a>) or the keyword <a href="system.html" | |
100 | target="_blank"><b><font face="Courier New" color="#003258" size="4">system</font></b></a>, in case of one-to-many connections.</li> | |
101 | <li> | |
102 | <p>an address reference (cf. <a href="address.html"><b><font face="Courier New" color="#003258" size="4">address</font></b></a>) , when there are several entities within the | |
103 | system under test .</p> | |
104 | </li> | |
105 | </ul> | |
106 | </li> | |
107 | <li> | |
108 | <p><i>assignment_part</i> is one or both of the following:</p> | |
109 | <ul> | |
110 | <li>the <a href="sender.html"><b><font face="Courier New" color="#003258" size="4">sender</font></b></a> keyword followed by a variable of <a href="address.html" | |
111 | target="_blank"><b><font face="Courier New" color="#003258" size="4">address</font></b></a> or <a href="component.html"><b><font face="Courier New" color="#003258" | |
112 | size="4">component</font></b></a> type to store the address of the sender (see the <a href="#Example 5">example 5</a>).</li> | |
113 | <li>the <a href="value.html"><b><font face="Courier New" color="#003258" size="4">value</font></b></a> keyword followed by a variable of the same type as the received message | |
114 | to store the received value (see the <a href="#Example 6:">example 6</a>).</li> | |
115 | </ul> | |
116 | </li> | |
117 | </ul> | |
118 | <hr align="left" width="50%"> | |
119 | <p><a name="Example 1">Example 1</a>: literal value | |
120 | <p><font face="Courier New">portibus_PCO.receive (charstring:"abl") from system;</font> | |
121 | <p>The character string abl is received over the port portibus_PCO from the test system interface. The port is connected to several components.</p> | |
122 | <hr align="left" width="50%"> | |
123 | <p><a name="Example 2">Example 2</a>: template</p> | |
124 | <p><font face="Courier New">portibus_PCO.receive (tr_MeiTemplate);</font></p> | |
125 | <p>The template (tr_MeiTemplate) determines what kind of messages will be received.</p> | |
126 | <hr align="left" width="50%"> | |
127 | <p><a name="Example 3">Example 3</a>: modified template</p> | |
128 | <p><font face="Courier New">portibus_PCO.receive (modifies tr_MeiTemplate := {field1 := false});</font></p> | |
129 | <p>The modified template (tr_MeiTemplate) determines what kind of messages will be received.</p> | |
130 | <hr align="left" width="50%"> | |
131 | <p><a name="Example 4">Example 4</a>: any message reception</p> | |
132 | <p><font face="Courier New">portibus_PCO.receive;</font></p> | |
133 | <p>Any message on port portibus_PCO will be accepted.</p> | |
134 | <hr align="left" width="50%"> | |
135 | <p><a name="Example 5">Example 5</a>: storing the sender address</p> | |
136 | <p><font face="Courier New">portibus_PCO.receive (tr_MeiTemplate) -> sender v_address;</font></p> | |
137 | <p>The address of the sender is stored in the variable v_address.</p> | |
138 | <hr align="left" width="50%"> | |
139 | <p><a name="Example 6:">Example 6:</a> storing the received value</p> | |
140 | <p><font face="Courier New">portibus_PCO.receive (tr_MeiTemplate) -> value v_ReceivedMessage;</font></p> | |
141 | <p>The received message is saved in the variable v_ReceivedMessage.</p> | |
142 | <hr align="left" width="50%"> | |
143 | <p><a name="Example 7:">Example 7:</a> receive on any port</p> | |
144 | <p><font face="Courier New">any port.receive (tr_MeiTemplate) -> value v_ReceivedMessage;</font></p> | |
145 | <p>The message matching the template tr_MeiTemplate and received on any port is saved to the variable v_ReceivedMessage.</p> | |
146 | <hr align="left" width="25%"> | |
147 | <hr align="left" width="25%"> | |
148 | <p><a HREF="BNF.html#receivestatement">BNF definition</a> of <font face="Courier New"> receive</font></p> | |
149 | </body> | |
150 | </html> |