# Creation of InLine Nodes
PyIsOdd = []
-PyIsOdd.append( 'import time' )
-PyIsOdd.append( 'def IsOdd(a) : ' )
-PyIsOdd.append( ' print a,"IsOdd" ' )
-PyIsOdd.append( ' time.sleep( 1 )' )
-PyIsOdd.append( ' return a ' )
+PyIsOdd.append( 'from time import * ' )
+PyIsOdd.append( 'def IsOdd(a) : ' )
+PyIsOdd.append( ' print a,"IsOdd (GraphSwitch)" ' )
+PyIsOdd.append( ' sleep( 1 ) ' )
+PyIsOdd.append( ' return a ' )
IsOdd = GraphSwitch.INode( 'IsOdd' , PyIsOdd )
-IsOdd.InPort( 'a' , 'long' )
-IsOdd.OutPort( 'a' , 'long' )
IsOdd.SetName( 'IsOdd' )
IsOdd.SetAuthor( '' )
IsOdd.SetComment( 'Python function' )
-IsOdd.Coords( 296 , 249 )
+IsOdd.Coords( 388 , 50 )
+IsOdd.InPort( 'a' , 'long' )
+IsOdd.OutPort( 'a' , 'long' )
+
+# Creation of Loop Nodes
+PyInitLoopSwitch = []
+PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) : ' )
+PyInitLoopSwitch.append( ' return Index,Min,Max ' )
+PyMoreInitLoopSwitch = []
+PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) : ' )
+PyMoreInitLoopSwitch.append( ' if Index <= Max : ' )
+PyMoreInitLoopSwitch.append( ' DoLoop = 1 ' )
+PyMoreInitLoopSwitch.append( ' else : ' )
+PyMoreInitLoopSwitch.append( ' DoLoop = 0 ' )
+PyMoreInitLoopSwitch.append( ' return DoLoop,Index,Min,Max ' )
+PyNextInitLoopSwitch = []
+PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) : ' )
+PyNextInitLoopSwitch.append( ' Index = Index + 1 ' )
+PyNextInitLoopSwitch.append( ' return Index,Min,Max ' )
+InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitch.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch )
+EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' )
+EndOfInitLoopSwitch.SetAuthor( '' )
+EndOfInitLoopSwitch.SetComment( '' )
+EndOfInitLoopSwitch.Coords( 766 , 127 )
+InitLoopSwitch.SetName( 'InitLoopSwitch' )
+InitLoopSwitch.SetAuthor( '' )
+InitLoopSwitch.SetComment( '' )
+InitLoopSwitch.Coords( 10 , 129 )
+InitLoopSwitch.InPort( 'Index' , 'long' )
+InitLoopSwitch.InPort( 'Min' , 'long' )
+InitLoopSwitch.InPort( 'Max' , 'long' )
+InitLoopSwitch.OutPort( 'Index' , 'long' )
+InitLoopSwitch.OutPort( 'Min' , 'long' )
+InitLoopSwitch.OutPort( 'Max' , 'long' )
# Creation of Switch Nodes
PySwitch = []
-PySwitch.append( 'import time' )
-PySwitch.append( 'def Switch(a) : ' )
-PySwitch.append( ' time.sleep( 1 )' )
-PySwitch.append( ' return a & 1,a ' )
-Switch,EndSwitch = GraphSwitch.SNode( 'Switch' , PySwitch )
-EndSwitch.SetName( 'EndSwitch' )
-EndSwitch.SetAuthor( '' )
-EndSwitch.SetComment( '' )
-EndSwitch.Coords( 569 , 94 )
-PyEndSwitch = []
-EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch )
-EndSwitch.InPort( 'a' , 'long' )
-EndSwitch.OutPort( 'a' , 'long' )
-Switch.InPort( 'a' , 'long' )
-Switch.OutPort( 'Odd' , 'long' )
-Switch.OutPort( 'a' , 'long' )
+PySwitch.append( 'from time import * ' )
+PySwitch.append( 'def Switch(a) : ' )
+PySwitch.append( ' if ( a & 1 ) == 0 : ' )
+PySwitch.append( ' sleep(1) ' )
+PySwitch.append( ' return a & 1,1-(a&1),a ' )
+Switch,EndOfSwitch = GraphSwitch.SNode( 'Switch' , PySwitch )
+EndOfSwitch.SetName( 'EndOfSwitch' )
+EndOfSwitch.SetAuthor( '' )
+EndOfSwitch.SetComment( '' )
+EndOfSwitch.Coords( 587 , 126 )
+PyEndOfSwitch = []
+EndOfSwitch.SetPyFunction( 'EndSwitch' , PyEndOfSwitch )
+EndOfSwitch.InPort( 'a' , 'long' )
+EndOfSwitch.OutPort( 'a' , 'long' )
Switch.SetName( 'Switch' )
Switch.SetAuthor( '' )
Switch.SetComment( '' )
-Switch.Coords( 25 , 94 )
+Switch.Coords( 186 , 130 )
+Switch.InPort( 'a' , 'long' )
+Switch.OutPort( 'Odd' , 'long' )
+Switch.OutPort( 'Even' , 'int' )
+Switch.OutPort( 'a' , 'int' )
-# Creation of intermediate Output variables and of Control Links
+# Creation of Links
IsOdda = IsOdd.Port( 'a' )
-EndSwitcha = GraphSwitch.Link( IsOdda , EndSwitch.Port( 'a' ) )
-SwitchDefault = Switch.Port( 'Default' )
-EndSwitchDefault = GraphSwitch.Link( SwitchDefault , EndSwitch.Port( 'Default' ) )
+EndOfSwitcha = GraphSwitch.Link( IsOdda , EndOfSwitch.Port( 'a' ) )
+EndOfSwitcha.AddCoord( 1 , 571 , 161 )
+EndOfSwitcha.AddCoord( 2 , 571 , 131 )
+
+InitLoopSwitchIndex = InitLoopSwitch.Port( 'Index' )
+Switcha = GraphSwitch.Link( InitLoopSwitchIndex , Switch.Port( 'a' ) )
+
+InitLoopSwitchMin = InitLoopSwitch.Port( 'Min' )
+EndOfInitLoopSwitchMin = GraphSwitch.Link( InitLoopSwitchMin , EndOfInitLoopSwitch.Port( 'Min' ) )
+
+InitLoopSwitchMax = InitLoopSwitch.Port( 'Max' )
+EndOfInitLoopSwitchMax = GraphSwitch.Link( InitLoopSwitchMax , EndOfInitLoopSwitch.Port( 'Max' ) )
+
SwitchOdd = Switch.Port( 'Odd' )
IsOddInGate = GraphSwitch.Link( SwitchOdd , IsOdd.Port( 'InGate' ) )
-IsOddInGate.AddCoord( 1 , 249 , 323 )
-IsOddInGate.AddCoord( 2 , 249 , 157 )
-IsOddInGate.AddCoord( 3 , 247 , 157 )
+
Switcha = Switch.Port( 'a' )
IsOdda = GraphSwitch.Link( Switcha , IsOdd.Port( 'a' ) )
-IsOdda.AddCoord( 1 , 196 , 357 )
-IsOdda.AddCoord( 2 , 196 , 186 )
+IsOdda.AddCoord( 1 , 372 , 129 )
+IsOdda.AddCoord( 2 , 371 , 223 )
+
+SwitchDefault = Switch.Port( 'Default' )
+EndOfSwitchDefault = GraphSwitch.Link( SwitchDefault , EndOfSwitch.Port( 'Default' ) )
+EndOfSwitchDefault.AddCoord( 1 , 572 , 194 )
+EndOfSwitchDefault.AddCoord( 2 , 571 , 257 )
+
+EndOfSwitcha = EndOfSwitch.Port( 'a' )
+EndOfInitLoopSwitchIndex = GraphSwitch.Link( EndOfSwitcha , EndOfInitLoopSwitch.Port( 'Index' ) )
# Creation of Input datas
-Switcha = Switch.Input( 'a' , 2)
+InitLoopSwitchIndex = InitLoopSwitch.Input( 'Index' , 0)
+InitLoopSwitchMin = InitLoopSwitch.Input( 'Min' , 0)
+InitLoopSwitchMax = InitLoopSwitch.Input( 'Max' , 100)
# Creation of Output variables
-EndSwitcha = EndSwitch.Port( 'a' )
+EndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.Port( 'Index' )
+EndOfInitLoopSwitchMin = EndOfInitLoopSwitch.Port( 'Min' )
+EndOfInitLoopSwitchMax = EndOfInitLoopSwitch.Port( 'Max' )
+SwitchEven = Switch.Port( 'Even' )
GraphSwitch.Run()
-
GraphSwitch.DoneW()
-
+GraphSwitch.State()
GraphSwitch.PrintPorts()
-