Salome HOME
6e82ad302550ae280a9abd9d72213b336b50b378
[modules/superv.git] / examples / GraphSwitch.py
1
2 # Generated python file of Graph GraphSwitch
3
4 from SuperV import *
5 # Graph creation 
6 GraphSwitch = Graph( 'GraphSwitch' )
7 GraphSwitch.SetName( 'GraphSwitch' )
8 GraphSwitch.SetAuthor( '' )
9 GraphSwitch.SetComment( '' )
10 GraphSwitch.Coords( 0 , 0 )
11
12 # Creation of Factory Nodes
13
14 # Creation of InLine Nodes
15 PyIsOdd = []
16 PyIsOdd.append( 'import time' )
17 PyIsOdd.append( 'def IsOdd(a) :   ' )
18 PyIsOdd.append( '    print a,"IsOdd"  ' )
19 PyIsOdd.append( '    time.sleep( 1 )' )
20 PyIsOdd.append( '    return a ' )
21 IsOdd = GraphSwitch.INode( 'IsOdd' , PyIsOdd )
22 IsOdd.InPort( 'a' , 'long' )
23 IsOdd.OutPort( 'a' , 'long' )
24 IsOdd.SetName( 'IsOdd' )
25 IsOdd.SetAuthor( '' )
26 IsOdd.SetComment( 'Python function' )
27 IsOdd.Coords( 296 , 249 )
28
29 # Creation of Switch Nodes
30 PySwitch = []
31 PySwitch.append( 'import time' )
32 PySwitch.append( 'def Switch(a) :  ' )
33 PySwitch.append( '    time.sleep( 1 )' )
34 PySwitch.append( '    return a & 1,a ' )
35 Switch,EndSwitch = GraphSwitch.SNode( 'Switch' , PySwitch )
36 EndSwitch.SetName( 'EndSwitch' )
37 EndSwitch.SetAuthor( '' )
38 EndSwitch.SetComment( '' )
39 EndSwitch.Coords( 569 , 94 )
40 PyEndSwitch = []
41 EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch )
42 EndSwitch.InPort( 'a' , 'long' )
43 EndSwitch.OutPort( 'a' , 'long' )
44 Switch.InPort( 'a' , 'long' )
45 Switch.OutPort( 'Odd' , 'long' )
46 Switch.OutPort( 'a' , 'long' )
47 Switch.SetName( 'Switch' )
48 Switch.SetAuthor( '' )
49 Switch.SetComment( '' )
50 Switch.Coords( 25 , 94 )
51
52 # Creation of intermediate Output variables and of Control Links
53 IsOdda = IsOdd.Port( 'a' )
54 EndSwitcha = GraphSwitch.Link( IsOdda , EndSwitch.Port( 'a' ) )
55 SwitchDefault = Switch.Port( 'Default' )
56 EndSwitchDefault = GraphSwitch.Link( SwitchDefault , EndSwitch.Port( 'Default' ) )
57 SwitchOdd = Switch.Port( 'Odd' )
58 IsOddInGate = GraphSwitch.Link( SwitchOdd , IsOdd.Port( 'InGate' ) )
59 IsOddInGate.AddCoord( 1 , 249 , 323 )
60 IsOddInGate.AddCoord( 2 , 249 , 157 )
61 IsOddInGate.AddCoord( 3 , 247 , 157 )
62 Switcha = Switch.Port( 'a' )
63 IsOdda = GraphSwitch.Link( Switcha , IsOdd.Port( 'a' ) )
64 IsOdda.AddCoord( 1 , 196 , 357 )
65 IsOdda.AddCoord( 2 , 196 , 186 )
66
67 # Creation of Input datas
68 Switcha = Switch.Input( 'a' , 2)
69
70 # Creation of Output variables
71 EndSwitcha = EndSwitch.Port( 'a' )
72
73 GraphSwitch.Run()
74
75 GraphSwitch.DoneW()
76
77 GraphSwitch.PrintPorts()
78