Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / doc / salome / gui / SUPERV / files / loop_nodes.htm
1 <!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">\r
2 \r
3 <html>\r
4 \r
5 <head>\r
6 <title>Loop nodes</title>\r
7 <meta http-equiv="content-type" content="text/html; charset=windows-1252">\r
8 <meta name="generator" content="RoboHelp by eHelp Corporation www.ehelp.com">\r
9 <link rel="stylesheet" href="../default_ns.css"><script type="text/javascript" language="JavaScript" title="WebHelpSplitCss">\r
10 <!--\r
11 if (navigator.appName !="Netscape")\r
12 {   document.write("<link rel='stylesheet' href='../default.css'>");}\r
13 //-->\r
14 </script>\r
15 <style type="text/css">\r
16 <!--\r
17 h1.whs1 { font-family:'Times New Roman' , serif; }\r
18 img_whs2 { border:none; width:30px; height:30px; float:none; border-style:none; }\r
19 p.whs3 { font-family:'Times New Roman' , serif; }\r
20 p.whs4 { font-family:'Times New Roman' , serif; font-style:italic; }\r
21 img_whs5 { border:none; width:775px; height:360px; float:none; border-style:none; }\r
22 ul.whs6 { list-style:disc; }\r
23 p.whs7 { font-family:'Times New Roman'  , serif; background-image:url('../texture_horiz_ltbluebubbles.jpg'); }\r
24 img_whs8 { border:none; float:none; width:36px; height:38px; border-style:none; }\r
25 img_whs9 { border:none; width:404px; height:297px; float:none; border-style:none; }\r
26 p.whs10 { font-family:'Courier New' , monospace; }\r
27 -->\r
28 </style><script type="text/javascript" language="JavaScript" title="BSSC Special Effects" src="../ehlpdhtm.js"></script><script type="text/javascript" language="JavaScript" title="WebHelpInlineScript">\r
29 <!--\r
30 function reDo() {\r
31   if (innerWidth != origWidth || innerHeight != origHeight)\r
32      location.reload();\r
33 }\r
34 if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {\r
35         origWidth = innerWidth;\r
36         origHeight = innerHeight;\r
37         onresize = reDo;\r
38 }\r
39 onerror = null; \r
40 //-->\r
41 </script>\r
42 <style type="text/css">\r
43 <!--\r
44 div.WebHelpPopupMenu { position:absolute; left:0px; top:0px; z-index:4; visibility:hidden; }\r
45 p.WebHelpNavBar { text-align:right; }\r
46 -->\r
47 </style><script type="text/javascript" language="javascript1.2" src="../whmsg.js"></script>\r
48 <script type="text/javascript" language="javascript" src="../whver.js"></script>\r
49 <script type="text/javascript" language="javascript1.2" src="../whproxy.js"></script>\r
50 <script type="text/javascript" language="javascript1.2" src="../whutils.js"></script>\r
51 <script type="text/javascript" language="javascript1.2" src="../whtopic.js"></script>\r
52 <script type="text/javascript" language="javascript1.2">\r
53 <!--\r
54 if (window.gbWhTopic)\r
55 {\r
56         if (window.setRelStartPage)\r
57         {\r
58         addTocInfo("SUPERVISOR module\nEditing graphs\nNodes in the graph\nLoop nodes");\r
59 addButton("show",BTN_IMG,"Show","","","","",0,0,"../whd_show0.gif","../whd_show2.gif","../whd_show1.gif");\r
60 addButton("hide",BTN_IMG,"Hide","","","","",0,0,"../whd_hide0.gif","../whd_hide2.gif","../whd_hide1.gif");\r
61 \r
62         }\r
63 \r
64 \r
65         if (window.setRelStartPage)\r
66         {\r
67         setRelStartPage("../index.htm");\r
68 \r
69                 autoSync(1);\r
70                 sendSyncInfo();\r
71                 sendAveInfoOut();\r
72         }\r
73 \r
74 }\r
75 else\r
76         if (window.gbIE4)\r
77                 document.location.reload();\r
78 //-->\r
79 </script>\r
80 </head>\r
81 <body><script type="text/javascript" language="javascript1.2">\r
82 <!--\r
83 if (window.writeIntopicBar)\r
84         writeIntopicBar(4);\r
85 //-->\r
86 </script>\r
87 <h1 class="whs1">Loop nodes</h1>\r
88 \r
89 <p><span style="font-weight: bold;"><B><img src="../i_blue.jpg" x-maintain-ratio="TRUE" width="30px" height="30px" border="0" class="img_whs2">Loop node</B></span> is a \r
90  kind of Control nodes. In fact two nodes represent Loop: <span style="font-weight: bold;"><B>start \r
91  loop</B></span> and <span style="font-weight: bold;"><B>end loop</B></span> nodes. \r
92  Nodes of such type are always InLine nodes. User have to supply this type \r
93  of node by service, which will check conditions of end of loop. </p>\r
94 \r
95 <p class="whs3"><span style="font-family: 'Times New Roman', serif;">With \r
96  that kind of nodes you may define all kinds of loops:</span></p>\r
97 \r
98 <p class="whs4">\93for( \r
99  initial condition(s) ; end condition(s) ; end loop code )\94 or </p>\r
100 \r
101 <p class="whs4">\93while( \r
102  end condition )\94</p>\r
103 \r
104 <p class="whs4">etc\85</p>\r
105 \r
106 <p class="whs3">&nbsp;</p>\r
107 \r
108 <p class="whs3"><img src="../loop1.jpg" x-maintain-ratio="TRUE" width="775px" height="360px" border="0" class="img_whs5"></p>\r
109 \r
110 <p class="whs3">&nbsp;</p>\r
111 \r
112 <ul type="disc" class="whs6">\r
113         \r
114         <li class=kadov-p><p class="whs3"><span \r
115  style="font-weight: bold;"><B>Titles of the nodes.</B></span> By default the \r
116  name of the service is used. You can change only the name of the Start \r
117  Loop node - the name of the End Loop node will be automatically created \r
118  as follows: EndOf + &quot;Name of the Start Loop node&quot; .</p></li>\r
119         \r
120         <li class=kadov-p><p class="whs3"><span \r
121  style="font-weight: bold;"><B>Status of execution</B></span> shows the state \r
122  of the loop. It can be: <span style="font-weight: bold;"><B>Not Started</B></span>, \r
123  <span style="font-weight: bold;"><B>Running</B></span>, <span style="font-weight: bold;"><B>Finished</B></span>.</p></li>\r
124         \r
125         <li class=kadov-p><p class="whs3"><span \r
126  style="font-weight: bold;"><B>InGate/OutGate</B></span> - control ports of the \r
127  loop execution. </p></li>\r
128         \r
129         <li class=kadov-p><p class="whs3"><span \r
130  style="font-weight: bold;"><B>Time of execution </B></span>is a time of node \r
131  execution in a launched dataflow.</p></li>\r
132         \r
133         <li class=kadov-p><p class="whs3"><span \r
134  style="font-weight: bold;"><B>Input/Output ports</B></span> \96 are BusPorts, which \r
135  are processed by Python function. Input ports of the Start Loop node &nbsp;will \r
136  get the initial values, which can be processed by underlying function \r
137  and will be transferred inside of the loop. Last calculation node of the \r
138  loop will put these values to the input port of the End Loop node. If \r
139  loop continues then this value will be copied to the Input port of the \r
140  Start Loop node, otherwise into output port of the End Loop node.</p></li>\r
141         \r
142         <li class=kadov-p><p class="whs3"><span \r
143  style="font-weight: bold;"><B>Control loop ports</B></span> \96 Control ports of \r
144  the loop nodes manage the functioning of the loop and they are not accessible \r
145  for the user. <span style="font-weight: bold;"><B>InitLoop</B></span> port launches \r
146  the loop. <span style="font-weight: bold;"><B>DoLoop</B></span> port of the Start \r
147  Loop node checks whether the end loop condition set in <span style="font-weight: bold;"><B>More \r
148  </B></span><span>function of the Loop node</span> has been achieved or not. \r
149  The value in this ports is of boolean type. It can be 0 or 1. </p></li>\r
150 </ul>\r
151 \r
152 <p class="whs3">&nbsp;</p>\r
153 \r
154 <p class="whs7"><img src="../note1.gif" x-maintain-ratio="TRUE" width="36px" height="38px" border="0" class="img_whs8">To create a Loop node you have to define three python functions \r
155  which will manage the loop with all input and output arguments (ports) \r
156  defined &nbsp;in \r
157  the node :</p>\r
158 \r
159 <p class="whs3">&nbsp;</p>\r
160 \r
161 <ul type="disc" class="whs6">\r
162         \r
163         <li class=kadov-p><p class="whs3">&nbsp;<span \r
164  style="font-weight: bold;"><B>INIT: </B></span>An \r
165  Initialization function which will be executed only when we enter in the \r
166  loop for the first time.</p></li>\r
167 </ul>\r
168 \r
169 <p class="whs3">&nbsp;</p>\r
170 \r
171 <ul type="disc" class="whs6">\r
172         \r
173         <li class=kadov-p><p class="whs3">&nbsp;<span \r
174  style="font-weight: bold;"><B>MORE: </B></span>A \r
175  \93More\94 function which is executed at each execution of the LoopNode even \r
176  for the first time. That function will have to return as first output \r
177  argument a boolean before output arguments (ports) defined by the user \r
178  in the node. If that function value is true the body of the loop will \r
179  automatically be executed. If it is false, Supervisor component will resume \r
180  execution after the end of the loop. That first output argument will not \r
181  be represented as an output port and will not be used in the graph.</p></li>\r
182 </ul>\r
183 \r
184 <p class="whs3">&nbsp;</p>\r
185 \r
186 <ul type="disc" class="whs6">\r
187         \r
188         <li class=kadov-p><p class="whs3"><span \r
189  style="font-weight: bold;"><B>NEXT: </B></span>A \93Next\94 function which is executed \r
190  each time that Supervisor component resume the execution from the end \r
191  of the loop to the beginning.</p></li>\r
192 </ul>\r
193 \r
194 <p class="whs3">&nbsp;</p>\r
195 \r
196 <p class="whs3">Setting of these functions \r
197  is possible from the standard <span style="font-weight: bold;"><B>Add Node</B></span> \r
198  dialog box (<a href="adding_nodes.htm">see also Adding nodes</a>):</p>\r
199 \r
200 <p class="whs3">&nbsp;</p>\r
201 \r
202 <p class="whs3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="../pics/loopfunctions.jpg" x-maintain-ratio="TRUE" width="404px" height="297px" border="0" class="img_whs9"></p>\r
203 \r
204 <p class="whs3">&nbsp;</p>\r
205 \r
206 <p class="whs3">Here you can see a simple \r
207  example of Python functions set in a Loop node:</p>\r
208 \r
209 <p class="whs3">&nbsp;</p>\r
210 \r
211 <p class="whs10">def <span style="font-weight: bold;"><B>Init</B></span>(Index,Min,Max,Incr) \r
212  : &nbsp;</p>\r
213 \r
214 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;if \r
215  Min &lt;= Max : &nbsp;</p>\r
216 \r
217 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Index \r
218  = Min &nbsp;</p>\r
219 \r
220 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;else \r
221  : &nbsp;</p>\r
222 \r
223 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Index \r
224  = Max &nbsp;</p>\r
225 \r
226 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;return \r
227  Index,Min,Max,Incr &nbsp;</p>\r
228 \r
229 <p class="whs10">&nbsp;</p>\r
230 \r
231 <p class="whs10">def <span style="font-weight: bold;"><B>More</B></span>(Index,Min,Max,Incr) \r
232  : &nbsp;</p>\r
233 \r
234 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;if \r
235  Index &lt; Max : &nbsp;</p>\r
236 \r
237 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoLoop \r
238  = 1 &nbsp;</p>\r
239 \r
240 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;else \r
241  : &nbsp;</p>\r
242 \r
243 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoLoop \r
244  = 0 &nbsp;</p>\r
245 \r
246 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;return \r
247  DoLoop,Index,Min,Max,Incr &nbsp;</p>\r
248 \r
249 <p class="whs10">&nbsp;</p>\r
250 \r
251 <p class="whs10">def <span style="font-weight: bold;"><B>Next</B></span>(Index,Min,Max,Incr) \r
252  : &nbsp;</p>\r
253 \r
254 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;Index \r
255  = Index + Incr &nbsp;</p>\r
256 \r
257 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;return \r
258  Index,Min,Max,Incr</p>\r
259 \r
260 <p class="whs3">&nbsp;</p>\r
261 \r
262 <p class="whs7"><img src="../note1.gif" x-maintain-ratio="TRUE" width="36px" height="38px" border="0" class="img_whs8">Loop nodes have the following particularities:</p>\r
263 \r
264 <p class="whs3">&nbsp;</p>\r
265 \r
266 <ul type="disc" class="whs6">\r
267         \r
268         <li class=kadov-p><p class="whs3">You \r
269  may create <span style="font-weight: bold;"><B>only input ports</B></span> in \r
270  the Loop node.</p></li>\r
271         \r
272         <li class=kadov-p><p class="whs3">The \r
273  input ports, which have been created in the Start Loop node are automatically \r
274  duplicated by Supervisor component as output ports of this node.</p></li>\r
275         \r
276         <li class=kadov-p><p class="whs3">Supervisor \r
277  component automatically &nbsp;adds \r
278  the same input and output ports in the &nbsp;End \r
279  Loop node as in the Start Loop node.</p></li>\r
280         \r
281         <li class=kadov-p><p class="whs3">If \r
282  an output port of the Start Loop node has no link and if the corresponding \r
283  input port of the End Loop node has no link, Supervisor component automatically \r
284  transmits its value to the corresponding End Loop node during execution. \r
285  You shouldn't define such links.</p></li>\r
286         \r
287         <li class=kadov-p><p class="whs3">When \r
288  Supervisor component executes the End Loop node, it automatically transmits \r
289  the actual values of &nbsp;the \r
290  output ports of the End Loop node to the input ports of the Start Loop \r
291  node.</p></li>\r
292         \r
293         <li class=kadov-p><p class="whs3">In \r
294  the body of a loop, an input port of a calculation node may not be linked \r
295  from an output port of a node which is not in the body of a loop. That \r
296  output port <span style="font-weight: bold;"><B>must be linked</B></span> to \r
297  an input port of the Start Loop node. So its value will be available through \r
298  the corresponding output port of the Start Loop node.</p></li>\r
299 </ul>\r
300 \r
301 <p class="whs3">&nbsp;</p>\r
302 \r
303 <p class="whs3">&nbsp;</p>\r
304 \r
305 <p class="whs3">&nbsp;</p>\r
306 \r
307 <p class="whs3">\r
308 <a href="javascript:void(0);" onClick="var e; if (parseInt(navigator.appVersion)>=4){e=event;}  if (parseInt(navigator.appVersion) >=2 && typeof(PickupDialog_Invoke) == 'function') PickupDialog_Invoke(e,'','About nodes','about_nodes.htm','Adding nodes','adding_nodes.htm');return false;" title="Related Topics"><img src="../ss_btn_related_topics.gif" border=0 height=17 width=82 alt="Related Topics"></a>\r
309 \r
310 \r
311  </p>\r
312 \r
313 <p class="whs3">&nbsp;</p>\r
314 \r
315 <p class="whs3">&nbsp;</p>\r
316 \r
317 <p class="whs3">&nbsp;</p>\r
318 \r
319 <p class="whs3">&nbsp;</p>\r
320 \r
321 <script type="text/javascript" language="JavaScript" title="WebHelpRelatedTopics"><!--\r
322 if (parseInt(navigator.appVersion) >= 3 && typeof (WritePopupMenuLayer) == "function")\r
323   WritePopupMenuLayer();\r
324 //--></script><script type="text/javascript" language="javascript1.2">\r
325 <!--\r
326 if (window.writeIntopicBar)\r
327         writeIntopicBar(0);\r
328 //-->\r
329 </script>\r
330 </body>\r
331 </html>\r