2 # Generated python file of Graph GraphSwitch1
6 GraphSwitch1 = Graph( 'GraphSwitch1' )
7 GraphSwitch1.SetName( 'GraphSwitch1' )
8 GraphSwitch1.SetAuthor( '' )
9 GraphSwitch1.SetComment( '' )
10 GraphSwitch1.Coords( 0 , 0 )
12 # Creation of Factory Nodes
14 # Creation of InLine Nodes
16 PyIsOdd.append( 'from time import * ' )
17 PyIsOdd.append( 'def IsOdd(a) : ' )
18 PyIsOdd.append( ' print a,"IsOdd (GraphSwitch1)" ' )
19 PyIsOdd.append( ' sleep( 1 ) ' )
20 PyIsOdd.append( ' return a ' )
21 IsOdd = GraphSwitch1.INode( 'IsOdd' , PyIsOdd )
22 IsOdd.SetName( 'IsOdd' )
24 IsOdd.SetComment( 'Python function' )
25 IsOdd.Coords( 388 , 50 )
26 IsOdd.InPort( 'a' , 'long' )
27 IsOdd.OutPort( 'a' , 'long' )
29 # Creation of Loop Nodes
31 PyInitLoop.append( 'def InitLoop(Index,Min,Max) : ' )
32 PyInitLoop.append( ' return Index,Min,Max ' )
34 PyMoreInitLoop.append( 'def MoreLoop(Index,Min,Max) : ' )
35 PyMoreInitLoop.append( ' if Index <= Max : ' )
36 PyMoreInitLoop.append( ' DoLoop = 1 ' )
37 PyMoreInitLoop.append( ' else : ' )
38 PyMoreInitLoop.append( ' DoLoop = 0 ' )
39 PyMoreInitLoop.append( ' return DoLoop,Index,Min,Max ' )
41 PyNextInitLoop.append( 'def NextLoop(Index,Min,Max) : ' )
42 PyNextInitLoop.append( ' Index = Index + 1 ' )
43 PyNextInitLoop.append( ' return Index,Min,Max ' )
44 InitLoop,EndOfInitLoop = GraphSwitch1.LNode( 'InitLoop' , PyInitLoop , 'MoreLoop' , PyMoreInitLoop , 'NextLoop' , PyNextInitLoop )
45 EndOfInitLoop.SetName( 'EndOfInitLoop' )
46 EndOfInitLoop.SetAuthor( '' )
47 EndOfInitLoop.SetComment( '' )
48 EndOfInitLoop.Coords( 766 , 127 )
49 InitLoop.SetName( 'InitLoop' )
50 InitLoop.SetAuthor( '' )
51 InitLoop.SetComment( '' )
52 InitLoop.Coords( 10 , 129 )
53 InitLoop.InPort( 'Index' , 'long' )
54 InitLoop.InPort( 'Min' , 'long' )
55 InitLoop.InPort( 'Max' , 'long' )
56 InitLoop.OutPort( 'Index' , 'long' )
57 InitLoop.OutPort( 'Min' , 'long' )
58 InitLoop.OutPort( 'Max' , 'long' )
60 # Creation of Switch Nodes
62 PySwitch.append( 'from time import * ' )
63 PySwitch.append( 'def Switch(a) : ' )
64 PySwitch.append( ' if ( a & 1 ) == 0 : ' )
65 PySwitch.append( ' sleep(1) ' )
66 PySwitch.append( ' return a & 1,1-(a&1),a ' )
67 Switch,EndOfSwitch = GraphSwitch1.SNode( 'Switch' , PySwitch )
68 EndOfSwitch.SetName( 'EndOfSwitch' )
69 EndOfSwitch.SetAuthor( '' )
70 EndOfSwitch.SetComment( '' )
71 EndOfSwitch.Coords( 587 , 126 )
73 EndOfSwitch.SetPyFunction( 'EndSwitch' , PyEndOfSwitch )
74 EndOfSwitch.InPort( 'a' , 'long' )
75 EndOfSwitch.OutPort( 'a' , 'long' )
76 Switch.SetName( 'Switch' )
77 Switch.SetAuthor( '' )
78 Switch.SetComment( '' )
79 Switch.Coords( 186 , 130 )
80 Switch.InPort( 'a' , 'long' )
81 Switch.OutPort( 'Odd' , 'long' )
82 Switch.OutPort( 'Even' , 'int' )
83 Switch.OutPort( 'a' , 'int' )
86 IsOdda = IsOdd.Port( 'a' )
87 EndOfSwitcha = GraphSwitch1.Link( IsOdda , EndOfSwitch.Port( 'a' ) )
88 EndOfSwitcha.AddCoord( 1 , 571 , 161 )
89 EndOfSwitcha.AddCoord( 2 , 571 , 131 )
91 InitLoopIndex = InitLoop.Port( 'Index' )
92 Switcha = GraphSwitch1.Link( InitLoopIndex , Switch.Port( 'a' ) )
94 InitLoopMin = InitLoop.Port( 'Min' )
95 EndOfInitLoopMin = GraphSwitch1.Link( InitLoopMin , EndOfInitLoop.Port( 'Min' ) )
97 InitLoopMax = InitLoop.Port( 'Max' )
98 EndOfInitLoopMax = GraphSwitch1.Link( InitLoopMax , EndOfInitLoop.Port( 'Max' ) )
100 SwitchOdd = Switch.Port( 'Odd' )
101 IsOddInGate = GraphSwitch1.Link( SwitchOdd , IsOdd.Port( 'InGate' ) )
103 SwitchEven = Switch.Port( 'Even' )
104 EndOfSwitchDefault = GraphSwitch1.Link( SwitchEven , EndOfSwitch.Port( 'Default' ) )
106 Switcha = Switch.Port( 'a' )
107 IsOdda = GraphSwitch1.Link( Switcha , IsOdd.Port( 'a' ) )
108 IsOdda.AddCoord( 1 , 372 , 129 )
109 IsOdda.AddCoord( 2 , 371 , 223 )
111 EndOfSwitcha = GraphSwitch1.Link( Switcha , EndOfSwitch.Port( 'a' ) )
112 EndOfSwitcha.AddCoord( 1 , 571 , 161 )
113 EndOfSwitcha.AddCoord( 2 , 570 , 221 )
115 EndOfSwitcha = EndOfSwitch.Port( 'a' )
116 EndOfInitLoopIndex = GraphSwitch1.Link( EndOfSwitcha , EndOfInitLoop.Port( 'Index' ) )
118 # Creation of Input datas
119 InitLoopIndex = InitLoop.Input( 'Index' , 0)
120 InitLoopMin = InitLoop.Input( 'Min' , 0)
121 InitLoopMax = InitLoop.Input( 'Max' , 100)
123 # Creation of Output variables
124 EndOfInitLoopIndex = EndOfInitLoop.Port( 'Index' )
125 EndOfInitLoopMin = EndOfInitLoop.Port( 'Min' )
126 EndOfInitLoopMax = EndOfInitLoop.Port( 'Max' )
130 print GraphSwitch1.State()
131 GraphSwitch1.PrintPorts()