Salome HOME
SMH: 3.0.0 preparation = merged version (POLYWORK + RTVDEBUG01) + adopation for new GUI
[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-style:none; border:none; width:30px; height:30px; float: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-style:none; border:none; width:775px; height:360px; float: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-style:none; border:none; float:none; width:36px; height:38px; }\r
25 img_whs9 { border-style:none; border:none; width:404px; height:297px; float: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 -->\r
46 </style><script type="text/javascript" language="javascript1.2" src="../whmsg.js"></script>\r
47 <script type="text/javascript" language="javascript" src="../whver.js"></script>\r
48 <script type="text/javascript" language="javascript1.2" src="../whproxy.js"></script>\r
49 <script type="text/javascript" language="javascript1.2" src="../whutils.js"></script>\r
50 <script type="text/javascript" language="javascript1.2" src="../whtopic.js"></script>\r
51 </head>\r
52 <body><script type="text/javascript" language="javascript1.2">\r
53 <!--\r
54 if (window.gbWhTopic)\r
55 {\r
56         if (window.addTocInfo)\r
57         {\r
58         addTocInfo("SUPERVISION module\nEditing graphs\nNodes in the graph\nLoop nodes");\r
59 addButton("show",BTN_TEXT,"Show","","","","",0,0,"","","");\r
60 \r
61         }\r
62         if (window.writeBtnStyle)\r
63                 writeBtnStyle();\r
64 \r
65         if (window.writeIntopicBar)\r
66                 writeIntopicBar(1);\r
67 \r
68         if (window.setRelStartPage)\r
69         {\r
70         setRelStartPage("../supervision.htm");\r
71 \r
72                 autoSync(1);\r
73                 sendSyncInfo();\r
74                 sendAveInfoOut();\r
75         }\r
76 }\r
77 else\r
78         if (window.gbIE4)\r
79                 document.location.reload();\r
80 //-->\r
81 </script>\r
82 <h1 class="whs1">Loop nodes</h1>\r
83 \r
84 <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
85  kind of Control nodes. In fact two nodes represent Loop: <span style="font-weight: bold;"><B>start \r
86  loop</B></span> and <span style="font-weight: bold;"><B>end loop</B></span> nodes. \r
87  Nodes of such type are always InLine nodes. User have to supply this type \r
88  of node by service, which will check conditions of end of loop. </p>\r
89 \r
90 <p class="whs3"><span style="font-family: 'Times New Roman', serif;">With \r
91  that kind of nodes you may define all kinds of loops:</span></p>\r
92 \r
93 <p class="whs4">\93for( \r
94  initial condition(s) ; end condition(s) ; end loop code )\94 or </p>\r
95 \r
96 <p class="whs4">\93while( \r
97  end condition )\94</p>\r
98 \r
99 <p class="whs4">etc\85</p>\r
100 \r
101 <p class="whs3">&nbsp;</p>\r
102 \r
103 <p class="whs3"><img src="../loop1.jpg" x-maintain-ratio="TRUE" width="775px" height="360px" border="0" class="img_whs5"></p>\r
104 \r
105 <p class="whs3">&nbsp;</p>\r
106 \r
107 <ul type="disc" class="whs6">\r
108         \r
109         <li class=kadov-p><p class="whs3"><span \r
110  style="font-weight: bold;"><B>Titles of the nodes.</B></span> By default the \r
111  name of the service is used. You can change only the name of the Start \r
112  Loop node - the name of the End Loop node will be automatically created \r
113  as follows: EndOf + &quot;Name of the Start Loop node&quot; .</p></li>\r
114         \r
115         <li class=kadov-p><p class="whs3"><span \r
116  style="font-weight: bold;"><B>Status of execution</B></span> shows the state \r
117  of the loop. It can be: <span style="font-weight: bold;"><B>Not Started</B></span>, \r
118  <span style="font-weight: bold;"><B>Running</B></span>, <span style="font-weight: bold;"><B>Finished</B></span>.</p></li>\r
119         \r
120         <li class=kadov-p><p class="whs3"><span \r
121  style="font-weight: bold;"><B>InGate/OutGate</B></span> - control ports of the \r
122  loop execution. </p></li>\r
123         \r
124         <li class=kadov-p><p class="whs3"><span \r
125  style="font-weight: bold;"><B>Time of execution </B></span>is a time of node \r
126  execution in a launched dataflow.</p></li>\r
127         \r
128         <li class=kadov-p><p class="whs3"><span \r
129  style="font-weight: bold;"><B>Input/Output ports</B></span> \96 are BusPorts, which \r
130  are processed by Python function. Input ports of the Start Loop node &nbsp;will \r
131  get the initial values, which can be processed by underlying function \r
132  and will be transferred inside of the loop. Last calculation node of the \r
133  loop will put these values to the input port of the End Loop node. If \r
134  loop continues then this value will be copied to the Input port of the \r
135  Start Loop node, otherwise into output port of the End Loop node.</p></li>\r
136         \r
137         <li class=kadov-p><p class="whs3"><span \r
138  style="font-weight: bold;"><B>Control loop ports</B></span> \96 Control ports of \r
139  the loop nodes manage the functioning of the loop and they are not accessible \r
140  for the user. <span style="font-weight: bold;"><B>InitLoop</B></span> port launches \r
141  the loop. <span style="font-weight: bold;"><B>DoLoop</B></span> port of the Start \r
142  Loop node checks whether the end loop condition set in <span style="font-weight: bold;"><B>More \r
143  </B></span><span>function of the Loop node</span> has been achieved or not. \r
144  The value in this ports is of boolean type. It can be 0 or 1. </p></li>\r
145 </ul>\r
146 \r
147 <p class="whs3">&nbsp;</p>\r
148 \r
149 <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
150  which will manage the loop with all input and output arguments (ports) \r
151  defined &nbsp;in \r
152  the node :</p>\r
153 \r
154 <p class="whs3">&nbsp;</p>\r
155 \r
156 <ul type="disc" class="whs6">\r
157         \r
158         <li class=kadov-p><p class="whs3">&nbsp;<span \r
159  style="font-weight: bold;"><B>INIT: </B></span>An \r
160  Initialization function which will be executed only when we enter in the \r
161  loop for the first time.</p></li>\r
162 </ul>\r
163 \r
164 <p class="whs3">&nbsp;</p>\r
165 \r
166 <ul type="disc" class="whs6">\r
167         \r
168         <li class=kadov-p><p class="whs3">&nbsp;<span \r
169  style="font-weight: bold;"><B>MORE: </B></span>A \r
170  \93More\94 function which is executed at each execution of the LoopNode even \r
171  for the first time. That function will have to return as first output \r
172  argument a boolean before output arguments (ports) defined by the user \r
173  in the node. If that function value is true the body of the loop will \r
174  automatically be executed. If it is false SUPERVISOR component will resume \r
175  execution after the end of the loop. That first output argument will not \r
176  be represented as an output port and will not be used in the graph.</p></li>\r
177 </ul>\r
178 \r
179 <p class="whs3">&nbsp;</p>\r
180 \r
181 <ul type="disc" class="whs6">\r
182         \r
183         <li class=kadov-p><p class="whs3"><span \r
184  style="font-weight: bold;"><B>NEXT: </B></span>A \93Next\94 function which is executed \r
185  each time that SUPERVISOR component resume the execution from the end \r
186  of the loop to the beginning.</p></li>\r
187 </ul>\r
188 \r
189 <p class="whs3">&nbsp;</p>\r
190 \r
191 <p class="whs3">Setting of these functions \r
192  is possible from the standard <span style="font-weight: bold;"><B>Add Node</B></span> \r
193  dialog box (<a href="adding_nodes.htm">see also Adding nodes</a>):</p>\r
194 \r
195 <p class="whs3">&nbsp;</p>\r
196 \r
197 <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
198 \r
199 <p class="whs3">&nbsp;</p>\r
200 \r
201 <p class="whs3">Here you can see a simple \r
202  example of Python functions set in a Loop node:</p>\r
203 \r
204 <p class="whs3">&nbsp;</p>\r
205 \r
206 <p class="whs10">def <span style="font-weight: bold;"><B>Init</B></span>(Index,Min,Max,Incr) \r
207  : &nbsp;</p>\r
208 \r
209 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;if \r
210  Min &lt;= Max : &nbsp;</p>\r
211 \r
212 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Index \r
213  = Min &nbsp;</p>\r
214 \r
215 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;else \r
216  : &nbsp;</p>\r
217 \r
218 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Index \r
219  = Max &nbsp;</p>\r
220 \r
221 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;return \r
222  Index,Min,Max,Incr &nbsp;</p>\r
223 \r
224 <p class="whs10">&nbsp;</p>\r
225 \r
226 <p class="whs10">def <span style="font-weight: bold;"><B>More</B></span>(Index,Min,Max,Incr) \r
227  : &nbsp;</p>\r
228 \r
229 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;if \r
230  Index &lt; Max : &nbsp;</p>\r
231 \r
232 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoLoop \r
233  = 1 &nbsp;</p>\r
234 \r
235 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;else \r
236  : &nbsp;</p>\r
237 \r
238 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoLoop \r
239  = 0 &nbsp;</p>\r
240 \r
241 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;return \r
242  DoLoop,Index,Min,Max,Incr &nbsp;</p>\r
243 \r
244 <p class="whs10">&nbsp;</p>\r
245 \r
246 <p class="whs10">def <span style="font-weight: bold;"><B>Next</B></span>(Index,Min,Max,Incr) \r
247  : &nbsp;</p>\r
248 \r
249 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;Index \r
250  = Index + Incr &nbsp;</p>\r
251 \r
252 <p class="whs10">&nbsp;&nbsp;&nbsp;&nbsp;return \r
253  Index,Min,Max,Incr</p>\r
254 \r
255 <p class="whs3">&nbsp;</p>\r
256 \r
257 <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
258 \r
259 <p class="whs3">&nbsp;</p>\r
260 \r
261 <ul type="disc" class="whs6">\r
262         \r
263         <li class=kadov-p><p class="whs3">You \r
264  may create <span style="font-weight: bold;"><B>only input ports</B></span> in \r
265  the Loop node.</p></li>\r
266         \r
267         <li class=kadov-p><p class="whs3">The \r
268  input ports, which have been created in the Start Loop node are automatically \r
269  duplicated by SUPERVISOR component as output ports of this node.</p></li>\r
270         \r
271         <li class=kadov-p><p class="whs3">SUPERVISOR \r
272  component automatically &nbsp;adds \r
273  the same input and output ports in the &nbsp;End \r
274  Loop node as in the Start Loop node.</p></li>\r
275         \r
276         <li class=kadov-p><p class="whs3">If \r
277  an output port of the Start Loop node has no link and if the corresponding \r
278  input port of the End Loop node has no link, SUPERVISOR component automatically \r
279  transmits its value to the corresponding End Loop node during execution. \r
280  You shouldn't define such links.</p></li>\r
281         \r
282         <li class=kadov-p><p class="whs3">When \r
283  SUPERVISOR component executes the End Loop node, it automatically transmits \r
284  the actual values of &nbsp;the \r
285  output ports of the End Loop node to the input ports of the Start Loop \r
286  node.</p></li>\r
287         \r
288         <li class=kadov-p><p class="whs3">In \r
289  the body of a loop, an input port of a calculation node may not be linked \r
290  from an output port of a node which is not in the body of a loop. That \r
291  output port <span style="font-weight: bold;"><B>must be linked</B></span> to \r
292  an input port of the Start Loop node. So its value will be available through \r
293  the corresponding output port of the Start Loop node.</p></li>\r
294 </ul>\r
295 \r
296 <p class="whs3">&nbsp;</p>\r
297 \r
298 <p class="whs3">&nbsp;</p>\r
299 \r
300 <p class="whs3">&nbsp;</p>\r
301 \r
302 <p class="whs3">\r
303 <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
304 \r
305 \r
306  </p>\r
307 \r
308 <p class="whs3">&nbsp;</p>\r
309 \r
310 <p class="whs3">&nbsp;</p>\r
311 \r
312 <p class="whs3">&nbsp;</p>\r
313 \r
314 <p class="whs3">&nbsp;</p>\r
315 \r
316 <script type="text/javascript" language="JavaScript" title="WebHelpRelatedTopics"><!--\r
317 if (parseInt(navigator.appVersion) >= 3 && typeof (WritePopupMenuLayer) == "function")\r
318   WritePopupMenuLayer();\r
319 //--></script><script type="text/javascript" language="javascript1.2">\r
320 <!--\r
321 if (window.writeIntopicBar)\r
322         writeIntopicBar(0);\r
323 //-->\r
324 </script>\r
325 </body>\r
326 </html>\r