1 <!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
\r
5 <meta http-equiv="Content-Type"
\r
6 content="text/html; charset=iso-8859-1">
\r
8 <meta name="GENERATOR"
\r
9 content="Mozilla/4.73 [en] (WinNT; I) [Netscape]">
\r
10 <title>Main Page</title>
\r
12 <link href="doxygen.css" rel="stylesheet" type="text/css">
\r
20 <td><a href="http://www.opencascade.com"><img
\r
21 src="sources/logocorp.gif" border="0" height="46" width="122">
\r
24 <div align="right"><a href="http://www.opencascade.org/SALOME/"><img
\r
25 src="sources/application.gif" border="0" height="46" width="108">
\r
34 <h1><a name="page2">Examples</a> </h1>
\r
36 <h3><big><i><b>Interfaces:</b></i></big></h3>
\r
38 <a href="#Graph"><big>SUPERV::Graph</big></a><br>
\r
39 <a href="#CNode"><big>SUPERV::CNode</big></a><br>
\r
40 <a href="#FNode"><big>SUPERV::FNode</big></a><big><br>
\r
41 <a href="#INode">SUPERV::INode</a></big><br>
\r
42 <a href="#LNode"><big>SUPERV::LNode</big></a><br>
\r
43 <a href="#Port"><big>SUPERV::Port</big></a><br>
\r
44 <a href="#Link"><big>SUPERV::Link</big></a><br>
\r
49 <div align="center"><big><big><b><u><br>
\r
50 </u></b></big></big></div>
\r
51 <div align="center"><big><u><b><big><a name="Graph"></a>SUPERV::Graph<br>
\r
52 </big></b></u></big><br>
\r
53 <div align="left"><big><b><a href="#CNode">CNode</a> CNode( in SALOME_ModuleCatalog::Service
\r
54 <i>aService</i> ) </b></big><br>
\r
56 <u><i><big>Create a Computing Node in a Graph</big></i></u><br>
\r
58 <a name="CreateCNode"></a>GraphEssai = Graph( 'GraphEssai' )<br>
\r
60 AddAndCompare_ServiceinParameter = []<br>
\r
61 AddAndCompare_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter(
\r
62 'Adder' , 'Adder' ) )<br>
\r
63 AddAndCompare_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter(
\r
64 'double' , 'x' ) )<br>
\r
65 AddAndCompare_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter(
\r
66 'double' , 'y' ) )<br>
\r
67 AddAndCompare_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter(
\r
68 'Adder' , 'anOtherAdder' ) )<br>
\r
70 AddAndCompare_ServiceoutParameter = []<br>
\r
71 AddAndCompare_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter(
\r
72 'double' , 'FuncValue' ) )<br>
\r
73 AddAndCompare_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter(
\r
74 'double' , 'z' ) )<br>
\r
75 AddAndCompare_Service = SALOME_ModuleCatalog.Service( 'AddAndCompare' , AddAndCompare_ServiceinParameter
\r
76 , AddAndCompare_ServiceoutParameter , 0 )<br>
\r
78 AddAndCompare = GraphEssai.CNode( AddAndCompare_Service )<br>
\r
83 <div align="left"><big><b><a href="#FNode">FNode</a> FNode( in string <i>aComponentName</i>,
\r
84 in string <i>anInterfaceName</i>, in SALOME_ModuleCatalog::Service
\r
85 <i>aService</i> ) </b></big><br>
\r
87 <u><i><big>Create a Factory Node in a Graph</big></i></u><br>
\r
89 <a name="CreateFNode"></a>GraphEssai = Graph( 'GraphEssai' )<br>
\r
90 Add = GraphEssai.FNode( 'AddComponent' , 'AddComponent' , 'Add' )<br>
\r
94 <b><big>INode INode( in string <i>FuncName</i>, in ListOfStrings <i>aPythonFunction</i>
\r
97 <u><i><big>Create an InLine Node in a Graph</big></i></u><br>
\r
99 <a name="CreateINode"></a>GraphEssai = Graph( 'GraphEssai' )<br>
\r
101 PyAdd.append( 'from time import * ' )<br>
\r
102 PyAdd.append( 'def Add(a,b) :
\r
104 PyAdd.append( ' print "Add will wait 5 seconds"
\r
106 PyAdd.append( ' d = dir()
\r
108 PyAdd.append( ' print "Add",d
\r
110 PyAdd.append( ' d = dir(sleep)
\r
112 PyAdd.append( ' print "Add",d
\r
114 PyAdd.append( ' sleep(5)
\r
116 PyAdd.append( ' print "Add waited"
\r
118 PyAdd.append( ' n = 0 ' )<br>
\r
119 PyAdd.append( ' while n < 10000 :
\r
121 PyAdd.append( ' i = 0
\r
123 PyAdd.append( ' s = 0
\r
125 PyAdd.append( ' while i <= b
\r
126 : ' )<br>
\r
127 PyAdd.append( '
\r
128 s = s + i ' )<br>
\r
129 PyAdd.append( '
\r
130 i = i + 1 ' )<br>
\r
131 PyAdd.append( ' n = n + 1
\r
133 PyAdd.append( ' return s
\r
135 PyAdd.append( '' )<br>
\r
136 Add = GraphEssai.INode( 'Add' , PyAdd )<br>
\r
140 <b><big>GNode GNode( in string <i>FuncName</i> , in ListOfStrings <i>aPythonFunction</i>,
\r
141 in string <i>anINode</i> )</big></b><br>
\r
143 <u><i><big>Create a GOTO node and link to the corresponding InLine node</big></i></u><br>
\r
145 GraphEssai = Graph( 'GraphEssai' )<br>
\r
146 Pylabel_test = []<br>
\r
147 Pylabel_test.append( 'def label_test( ValEven , ValOne , NB , KB ):' )<br>
\r
148 Pylabel_test.append( ' print "label_begin",ValEven,ValOne,NB,KB'
\r
150 Pylabel_test.append( ' return ValEven,ValOne,NB,KB' )<br>
\r
151 label_test = GraphEssai.INode( 'label_test' , Pylabel_test )<br>
\r
153 Pycontrol.append( 'def control_m3p1( N , K ):' )<br>
\r
154 Pycontrol.append( ' return 0,1,N,K' )<br>
\r
155 control = GraphEssai.GNode( 'control_m3p1' , Pycontrol , 'label_test' )<br>
\r
159 <big><b>LNode LNode( in string <i>InitName</i> , in ListOfStrings <i>InitFunction</i>
\r
160 , in string <i>MoreName</i> , in ListOfStrings <i>MoreFunction</i> , in string
\r
161 <i>NextName</i> , in ListOfStrings <i>NextFunction</i> , out INode <i>anEndOfLoop</i>
\r
164 <u><i><big>Create a "for" or "while" node and the corresponding end of loop
\r
165 node</big></i></u><br>
\r
167 <a name="CreateLNode"></a>GraphEssai = Graph( 'GraphEssai' )<br>
\r
170 PyforN.append( 'def InitN( NN , K , SyrComponent , min , max ) :' )<br>
\r
171 PyforN.append( ' N = max' )<br>
\r
172 PyforN.append( ' if min > 0 :' )<br>
\r
173 PyforN.append( ' if max >= min
\r
175 PyforN.append( '
\r
177 PyforN.append( ' return N,K,SyrComponent,min,max' )<br>
\r
179 PyMoreforN = []<br>
\r
180 PyMoreforN.append( 'def MoreN( NN , KK , SyrComponent , min , max ) :' )<br>
\r
181 PyMoreforN.append( ' N = 0' )<br>
\r
182 PyMoreforN.append( ' OutLoop = 0' )<br>
\r
183 PyMoreforN.append( ' if max > NN :' )<br>
\r
184 PyMoreforN.append( ' N = NN' )<br>
\r
185 PyMoreforN.append( ' OutLoop =
\r
187 PyMoreforN.append( ' return OutLoop,N,0,SyrComponent,min,max'
\r
190 PyNextforN = []<br>
\r
191 PyNextforN.append( 'def NextN( NN , KK , SyrComponent , min , max ) :' )<br>
\r
192 PyNextforN.append( ' N = NN + 1' )<br>
\r
193 PyNextforN.append( ' K = KK' )<br>
\r
194 PyNextforN.append( ' return N,K,SyrComponent,min,max' )<br>
\r
196 forN,endforN = GraphEssai.LNode( 'InitN' , PyforN , 'MoreN' , PyMoreforN
\r
197 , 'NextN' , PyNextforN )<br>
\r
200 <b><big>SNode SNode( in string <i>FuncName,</i> in ListOfStrings <i>aPythonFunction,</i>
\r
201 out INode <i>anEndOfSwitch</i> )</big></b><br>
\r
203 <u><i><big>Create a "if / elseif / else" or "switch" node and the corresponding
\r
204 end node</big></i></u><br>
\r
206 GraphEssai = Graph( 'GraphEssai' )<br>
\r
208 PyifNotEven = []<br>
\r
209 PyifNotEven.append( 'import SyrComponent_idl' )<br>
\r
210 PyifNotEven.append( 'def ifNotEven( SyrComponent , N , K ) :' )<br>
\r
211 PyifNotEven.append( ' Even = SyrComponent.C_ISEVEN( N )'
\r
213 PyifNotEven.append( ' Odd = 1 - Even' )<br>
\r
214 PyifNotEven.append( ' return Odd,Even,SyrComponent,N,K'
\r
217 ifNotEven,endifNotEven = GraphEssai.SNode( 'ifNotEven' , PyifNotEven )<br>
\r
220 <big><b>Link Link( in Port <i>OutputPort</i> , in Port <i>InputPort</i>
\r
223 <u><i><big>Creates a link connecting two ports of the nodes in a Graph</big></i></u><br>
\r
225 GraphEssai = Graph( 'GraphEssai' )<br>
\r
226 Add = GraphEssai.FNode( 'AddComponent' , 'AddComponent' , 'Add' )<br>
\r
227 Mul = GraphEssai.FNode( 'MulComponent' , 'MulComponent' , 'Mul' )<br>
\r
228 Link = GraphEssai.Link( Add.Port( 'FuncValue' ), Mul.Port( 'x' ) )<br>
\r
231 <b><big>boolean Run()</big></b><br>
\r
233 <u><i><big>Starts asynchronous execution of the graph</big></i></u><br>
\r
236 GraphEssai.Run()<br>
\r
239 <b><big>boolean Event( out CNode <i>aNode</i> , out GraphEvent <i>anEvent</i>
\r
240 , out GraphState <i>aState</i> )</big></b><br>
\r
242 <u><i><big>Runs Graph and prints information about Graph performance</big></i></u><br>
\r
245 <a name="RunandWait"></a>GraphEssai.Run()<br>
\r
246 aStatus,aNode,anEvent,aState = GraphEssai.Event()<br>
\r
247 while aStatus :<br>
\r
248 print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState<br>
\r
249 aStatus,aNode,anEvent,aState = GraphEssai.Event()<br>
\r
254 <div align="center"><big><b><big><a name="CNode"></a>SUPERV::CNode</big></b></big><br>
\r
257 <big><b>string Name() <br>
\r
258 string Author()<br>
\r
259 string Comment()<br>
\r
260 boolean SetName(in string <i>aNewName</i> ) <br>
\r
261 boolean SetAuthor(in string <i>anAuthor</i> ) <br>
\r
262 boolean SetComment(in string <i>aComment</i> ) <br>
\r
264 </b><u><i>Get / Set methods for Name, Author and Comment strings of the node.</i></u><br>
\r
266 </b><a href="#CreateCNode"><small>#Create CNode</small></a><b><br>
\r
267 </b></big>AddAndCompare.SetName( 'AddAndCompare' )<br>
\r
268 AddAndCompare.SetAuthor( 'NoBody' )<br>
\r
269 AddAndCompare.SetComment( 'Python function' )<br>
\r
270 print "Name:", AddAndCompare.Name(), " Author:", AddAndCompare.Author(),
\r
271 " Comment:", AddAndCompare.Comment()<br>
\r
275 <big><b>Port Port( in string <i>aParameterName</i> )</b></big><br>
\r
277 <big><u><i>Returns Port instance from created node</i></u></big><br>
\r
279 <a href="#CreateFNode">#Create FNode</a><br>
\r
280 Addz = Add.Port('z')<br>
\r
283 <big><b>Port Input( in string <i>InputParameterName</i> , in Value
\r
284 <i>aValue</i> ) </b></big><br>
\r
286 <i><u><big>Sets value into Port by its name and returs correspondent port
\r
287 instance</big></u></i><br>
\r
289 <a href="#CreateFNode">#Create FNode</a><br>
\r
290 Addx = Add.Input("x",3.)<br>
\r
294 <b><big>void Coords( in long <i>X</i> , in long <i>Y</i> )<br>
\r
295 </big><big>long X()</big></b><br>
\r
296 <b><big>long Y()</big></b><br>
\r
298 <big><u><i>Methods to sets position of the node and getting current coordinates</i></u></big><br>
\r
301 href="file:///vsv/salome/build/doc/html/html/examples_SUPERV.html#CreateFNode">#Create
\r
303 Add.Coords( 1 , 152 )<br>
\r
304 print "X=", Add.X(), " Y=", Add.Y()<br>
\r
307 <b><big>long CpuUsed()</big></b><br>
\r
309 <u><i><big>Returns the Cpu used by a node in seconds</big></i></u><br>
\r
311 <a href="#RunandWait">#Run Graph and wait for its finish</a><br>
\r
312 print "CPU used: ", Add.CpuUsed(), " sec"<br>
\r
318 <div align="center"><big><b><big><a name="FNode"></a>SUPERV::FNode</big><br>
\r
321 <b><big>string GetContainer() <br>
\r
322 boolean SetContainer(in string <i>aContainer</i> ) <br>
\r
324 <big><u><i>Get / Set method for container name</i></u></big><br>
\r
327 href="file:///vsv/salome/build/doc/html/html/examples_SUPERV.html#CreateFNode">#Create
\r
329 Add.SetContainer( 'localhost/FactoryServer' )<br>
\r
330 print "Container: ", Add.GetContainer()<br>
\r
334 <div align="center"><big><b><big><a name="INode"></a>SUPERV::INode</big></b></big><br>
\r
338 <big><b>void SetPyFunction( in string <i>FuncName</i> , in ListOfStrings
\r
339 <i>aPyInitFunction</i> )</b></big><br>
\r
341 <u><i><big>Replaces Python function of inline node by new one</big></i></u><br>
\r
343 <a href="#CreateINode">#Create INode</a><br>
\r
345 PyIsOdd.append( 'def IsOdd(a) : ' )<br>
\r
346 PyIsOdd.append( ' print a,"IsOdd" ' )<br>
\r
347 PyIsOdd.append( ' return a ' )<br>
\r
348 Add.SetPyFunction("IsOdd", PyIsOdd)<br>
\r
351 <b><big>string PyFuncName()</big></b><br>
\r
353 <div align="left"><u><i><big>Returns Name of the Python function</big></i></u><br>
\r
356 href="file:///vsv/salome/build/doc/html/html/examples_SUPERV.html#CreateINode">#Create
\r
358 print "Name:", Add.PyFuncName()<br>
\r
362 <b><big>ListOfStrings PyFunction()<br>
\r
364 </big></b><u><i><big>Returns Python function as a list of strings</big></i></u><br>
\r
367 href="file:///vsv/salome/build/doc/html/html/examples_SUPERV.html#CreateINode">#Create
\r
369 PyFunc = Add.PyFunction()<br>
\r
372 <b><big>SUPERV::Port InPort( in string <i>aParameterName</i> , in string
\r
373 <i>aParameterType</i> ) <br>
\r
374 SUPERV::Port OutPort( in string <i>aParameterName</i> , in string <i>aParameterType</i>
\r
377 <u><i><big>Creation of In and Out ports of Inline Node</big></i></u><br>
\r
379 <a name="CreatePorts"></a><a
\r
380 href="file:///vsv/salome/build/doc/html/html/examples_SUPERV.html#CreateINode">#Create
\r
382 Add.InPort('a', 'long')<br>
\r
383 <div align="left">Add.InPort('b', 'long')<br>
\r
385 <div align="left">Add.OutPort('s', 'long')<br>
\r
391 <div align="center"><big><b><big><a name="LNode"></a>SUPERV::LNode</big></b></big><br>
\r
395 <b><big>void SetPyInit( in string <i>InitName</i> , in ListOfStrings
\r
396 <i>aPyInitFunction</i> )</big></b><br>
\r
397 <b><big>void SetPyMore( in string <i>MoreName</i> , in ListOfStrings
\r
398 <i>aPyMoreFunction</i> )<br>
\r
399 void SetPyNext( in string <i>NextName</i> , in ListOfStrings <i>aPyNextFunction</i>
\r
402 <i><u><big>Sets (replaces) Python fonction of according clause (Init, More,
\r
403 Next) in Loop Node</big></u></i><br>
\r
405 <a href="#CreateLNode">#Create Loop Node</a><br>
\r
407 Pyfori.append( 'def Initfori( ii , K ) :' )<br>
\r
408 Pyfori.append( ' return 1,0,K' )<br>
\r
409 PyMorefori = []<br>
\r
410 PyMorefori.append( 'def Morefori( ii , K ) :' )<br>
\r
411 PyMorefori.append( ' OutLoop = 0' )<br>
\r
412 PyMorefori.append( ' if 2 > ii :' )<br>
\r
413 PyMorefori.append( ' OutLoop =
\r
415 PyMorefori.append( ' return OutLoop,ii,K' )<br>
\r
416 PyNextfori = []<br>
\r
417 PyNextfori.append( 'def Nextfori( ii , K ) :' )<br>
\r
418 PyNextfori.append( ' ii = ii + 1' )<br>
\r
419 PyNextfori.append( ' return ii,K' )<br>
\r
420 forN.SetPyInit('Initfori', Pyfori)<br>
\r
421 <div align="left">forN.SetPyMore('Morefori', PyMorefori)<br>
\r
423 <div align="left">forN.SetPyNext('Nextfori', PyNextfori)<br>
\r
427 <b><big>string PyInitName() <br>
\r
429 <b><big>string PyMoreName()<br>
\r
430 string PyNextName()<br>
\r
433 </big></b><u><i><big>Returns Python function name of according clause</big></i></u><br>
\r
436 href="file:///vsv/salome/build/doc/html/html/examples_SUPERV.html#CreateLNode">#Create
\r
438 print "Init Name:", forN.PyInitName()<br>
\r
439 print "More Name:", forN.PyMoreName()<br>
\r
440 print "Next Name:", forN.PyNextName()<br>
\r
443 <b><big>ListOfStrings PyInit()<br>
\r
444 ListOfStrings PyMore()<br>
\r
445 ListOfStrings PyNext()<br>
\r
447 <u><i><big>Returns Python function as a list of strings</big></i><i><big>
\r
448 from according clause</big></i></u><br>
\r
451 href="file:///vsv/salome/build/doc/html/html/examples_SUPERV.html#CreateLNode">#Create
\r
453 InitFunc = forN.PyInit()<br>
\r
454 <div align="left">MoreFunc = forN.PyMoret()<br>
\r
456 <div align="left">NextFunc = forN.PyNext()<br>
\r
462 <div align="center"><big><b><big><a name="Port"></a>SUPERV::Port</big></b></big><br>
\r
465 <b><big>boolean Input( in Value <i>aValue</i> )</big></b><br>
\r
467 <u><i><big>Sets value to the input port instance</big></i></u><br>
\r
469 <a href="#CreatePorts">#CreatePorts</a><br>
\r
470 aPort = Add.Port('a')<br>
\r
471 aPort.Input(10)<br>
\r
474 <b><big>CNode Node()</big></b><br>
\r
476 <u><i><big>Returns Node - owner of the port</big></i></u><br>
\r
478 Add = aPort.Node()<br>
\r
481 <b><big>string Name()</big></b><br>
\r
483 <u><i><big>Returns Name of the Port</big></i></u><br>
\r
485 print "Port Name:", aPort.Name()<br>
\r