]> SALOME platform Git repositories - modules/superv.git/blobdiff - examples/GraphLoopSwitch.py
Salome HOME
Merging with JR_ASV_2_1_0_deb_with_KERNEL_Head branch, which contains many bug fixes...
[modules/superv.git] / examples / GraphLoopSwitch.py
index c14aad196004137cca25666b8e4e4a005de94a75..f9998e60673b722f1c0072d9c693544a7ee5c85d 100755 (executable)
 
-# Generated python file of Graph GraphLoopSwitch
+# Generated python file of Graph GraphLoopSwitch_1
 
 from SuperV import *
-# Graph creation 
-GraphLoopSwitch = Graph( 'GraphLoopSwitch' )
-GraphLoopSwitch.SetName( 'GraphLoopSwitch' )
-GraphLoopSwitch.SetAuthor( '' )
-GraphLoopSwitch.SetComment( '' )
-GraphLoopSwitch.Coords( 0 , 0 )
 
-# Creation of Factory Nodes
-
-# Creation of InLine Nodes
-PyIsOdd = []
-PyIsOdd.append( 'from time import *    ' )
-PyIsOdd.append( 'def IsOdd(a,Even) :        ' )
-PyIsOdd.append( '    print a,"IsOdd (GraphLoopSwitch1)"       ' )
-PyIsOdd.append( '    sleep( 1 )    ' )
-PyIsOdd.append( '    return a      ' )
-IsOdd = GraphLoopSwitch.INode( 'IsOdd' , PyIsOdd )
-IsOdd.SetName( 'IsOdd' )
-IsOdd.SetAuthor( '' )
-IsOdd.SetComment( 'Python function' )
-IsOdd.Coords( 397 , 1 )
-IsOdd.InPort( 'a' , 'long' )
-IsOdd.InPort( 'Even' , 'boolean' )
-IsOdd.OutPort( 'a' , 'long' )
-
-# Creation of Loop Nodes
-PyInitLoop = []
-PyInitLoop.append( ' ' )
-PyMoreInitLoop = []
-PyMoreInitLoop.append( ' ' )
-PyNextInitLoop = []
-PyNextInitLoop.append( ' ' )
-InitLoop,EndOfInitLoop = GraphLoopSwitch.LNode( '' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop )
-EndOfInitLoop.SetName( 'EndOfInitLoop' )
-EndOfInitLoop.SetAuthor( '' )
-EndOfInitLoop.SetComment( '' )
-EndOfInitLoop.Coords( 767 , 102 )
-PyEndOfInitLoop = []
-PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' )
-PyEndOfInitLoop.append( '      Index = Index + 1     ' )
-PyEndOfInitLoop.append( '      if Index <= Max :   ' )
-PyEndOfInitLoop.append( '              DoLoop = 1     ' )
-PyEndOfInitLoop.append( '      else :     ' )
-PyEndOfInitLoop.append( '              DoLoop = 0     ' )
-PyEndOfInitLoop.append( '      return DoLoop,Index,Min,Max     ' )
-EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop )
-InitLoop.SetName( 'InitLoop' )
-InitLoop.SetAuthor( '' )
-InitLoop.SetComment( '' )
-InitLoop.Coords( 10 , 108 )
-InitLoop.InPort( 'Index' , 'long' )
-InitLoop.InPort( 'Min' , 'long' )
-InitLoop.InPort( 'Max' , 'long' )
-InitLoop.OutPort( 'Index' , 'long' )
-InitLoop.OutPort( 'Min' , 'long' )
-InitLoop.OutPort( 'Max' , 'long' )
-
-# Creation of Switch Nodes
-PySwitch = []
-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,EndSwitch = GraphLoopSwitch.SNode( 'Switch' , PySwitch )
-EndSwitch.SetName( 'EndSwitch' )
-EndSwitch.SetAuthor( '' )
-EndSwitch.SetComment( '' )
-EndSwitch.Coords( 587 , 103 )
-PyEndSwitch = []
-PyEndSwitch.append( 'def EndSwitch(a) :    ' )
-PyEndSwitch.append( '    if ( a & 1 ) == 0 :  ' )
-PyEndSwitch.append( '        sleep(1)  ' )
-PyEndSwitch.append( '    return a    ' )
-EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch )
-EndSwitch.InPort( 'a' , 'long' )
-EndSwitch.OutPort( 'a' , 'long' )
-Switch.SetName( 'Switch' )
-Switch.SetAuthor( '' )
-Switch.SetComment( '' )
-Switch.Coords( 194 , 109 )
-Switch.InPort( 'a' , 'long' )
-Switch.OutPort( 'Odd' , 'long' )
-Switch.OutPort( 'Even' , 'int' )
-Switch.OutPort( 'a' , 'int' )
-
-# Creation of Links
-IsOdda = IsOdd.Port( 'a' )
-EndSwitcha = GraphLoopSwitch.Link( IsOdda , EndSwitch.Port( 'a' ) )
-EndSwitcha.AddCoord( 1 , 576 , 136 )
-EndSwitcha.AddCoord( 2 , 575 , 81 )
-
-InitLoopIndex = InitLoop.Port( 'Index' )
-Switcha = GraphLoopSwitch.Link( InitLoopIndex , Switch.Port( 'a' ) )
-
-InitLoopMin = InitLoop.Port( 'Min' )
-EndOfInitLoopMin = GraphLoopSwitch.Link( InitLoopMin , EndOfInitLoop.Port( 'Min' ) )
-
-InitLoopMax = InitLoop.Port( 'Max' )
-EndOfInitLoopMax = GraphLoopSwitch.Link( InitLoopMax , EndOfInitLoop.Port( 'Max' ) )
-
-SwitchOdd = Switch.Port( 'Odd' )
-IsOddInGate = GraphLoopSwitch.Link( SwitchOdd , IsOdd.Port( 'InGate' ) )
-
-SwitchEven = Switch.Port( 'Even' )
-EndSwitchDefault = GraphLoopSwitch.Link( SwitchEven , EndSwitch.Port( 'Default' ) )
-
-IsOddEven = GraphLoopSwitch.Link( SwitchEven , IsOdd.Port( 'Even' ) )
-IsOddEven.AddCoord( 1 , 375 , 111 )
-IsOddEven.AddCoord( 2 , 375 , 172 )
-
-Switcha = Switch.Port( 'a' )
-IsOdda = GraphLoopSwitch.Link( Switcha , IsOdd.Port( 'a' ) )
-IsOdda.AddCoord( 1 , 362 , 82 )
-IsOdda.AddCoord( 2 , 360 , 201 )
-
-EndSwitcha = EndSwitch.Port( 'a' )
-EndOfInitLoopIndex = GraphLoopSwitch.Link( EndSwitcha , EndOfInitLoop.Port( 'Index' ) )
-
-# Creation of Input datas
-InitLoopIndex = InitLoop.Input( 'Index' , 0)
-InitLoopMin = InitLoop.Input( 'Min' , 0)
-InitLoopMax = InitLoop.Input( 'Max' , 100)
-
-# Creation of Output variables
-EndOfInitLoopIndex = EndOfInitLoop.Port( 'Index' )
-EndOfInitLoopMin = EndOfInitLoop.Port( 'Min' )
-EndOfInitLoopMax = EndOfInitLoop.Port( 'Max' )
-
-GraphLoopSwitch.Run()
-GraphLoopSwitch.DoneW()
-GraphLoopSwitch.State()
-GraphLoopSwitch.PrintPorts()
+# Graph creation of GraphLoopSwitch_1
+def DefGraphLoopSwitch_1() :
+    GraphLoopSwitch_1 = Graph( 'GraphLoopSwitch_1' )
+    GraphLoopSwitch_1.SetName( 'GraphLoopSwitch_1' )
+    GraphLoopSwitch_1.SetAuthor( '' )
+    GraphLoopSwitch_1.SetComment( '' )
+    GraphLoopSwitch_1.Coords( 0 , 0 )
+    
+    # Creation of Factory Nodes
+    
+    # Creation of InLine Nodes
+    PyIsOdd = []
+    PyIsOdd.append( 'from time import *    ' )
+    PyIsOdd.append( 'def IsOdd(a,Even) :        ' )
+    PyIsOdd.append( '    print a,"IsOdd (GraphLoopSwitch1)"       ' )
+    PyIsOdd.append( '    sleep( 1 )    ' )
+    PyIsOdd.append( '    return a      ' )
+    IsOdd = GraphLoopSwitch_1.INode( 'IsOdd' , PyIsOdd )
+    IsOdd.SetName( 'IsOdd' )
+    IsOdd.SetAuthor( '' )
+    IsOdd.SetComment( 'Python function' )
+    IsOdd.Coords( 397 , 1 )
+    IIsOdda = IsOdd.InPort( 'a' , 'long' )
+    IIsOddEven = IsOdd.InPort( 'Even' , 'boolean' )
+    IIsOddGate = IsOdd.GetInPort( 'Gate' )
+    OIsOdda = IsOdd.OutPort( 'a' , 'long' )
+    OIsOddGate = IsOdd.GetOutPort( 'Gate' )
+    
+    # Creation of Loop Nodes
+    PyInitLoop = []
+    PyInitLoop.append( 'def InitLoop(Index,Min,Max) : ' )
+    PyInitLoop.append( '       Index = Min ' )
+    PyInitLoop.append( '       return Index,Min,Max ' )
+    PyInitLoop.append( ' ' )
+    PyMoreInitLoop = []
+    PyMoreInitLoop.append( ' ' )
+    PyNextInitLoop = []
+    PyNextInitLoop.append( ' ' )
+    InitLoop,EndOfInitLoop = GraphLoopSwitch_1.LNode( 'InitLoop' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop )
+    EndOfInitLoop.SetName( 'EndOfInitLoop' )
+    EndOfInitLoop.SetAuthor( '' )
+    EndOfInitLoop.SetComment( 'Compute Node' )
+    EndOfInitLoop.Coords( 767 , 102 )
+    PyEndOfInitLoop = []
+    PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' )
+    PyEndOfInitLoop.append( '  Index = Index + 1     ' )
+    PyEndOfInitLoop.append( '  if Index <= Max :   ' )
+    PyEndOfInitLoop.append( '          DoLoop = 1     ' )
+    PyEndOfInitLoop.append( '  else :     ' )
+    PyEndOfInitLoop.append( '          DoLoop = 0     ' )
+    PyEndOfInitLoop.append( '  return DoLoop,Index,Min,Max     ' )
+    EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop )
+    IInitLoopDoLoop = InitLoop.GetInPort( 'DoLoop' )
+    IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' )
+    IInitLoopMin = InitLoop.InPort( 'Min' , 'long' )
+    IInitLoopMax = InitLoop.InPort( 'Max' , 'long' )
+    IInitLoopGate = InitLoop.GetInPort( 'Gate' )
+    OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' )
+    OInitLoopIndex = InitLoop.GetOutPort( 'Index' )
+    OInitLoopMin = InitLoop.GetOutPort( 'Min' )
+    OInitLoopMax = InitLoop.GetOutPort( 'Max' )
+    IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' )
+    IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' )
+    IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' )
+    IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' )
+    IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' )
+    OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' )
+    OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
+    OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
+    OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
+    InitLoop.SetName( 'InitLoop' )
+    InitLoop.SetAuthor( '' )
+    InitLoop.SetComment( 'Compute Node' )
+    InitLoop.Coords( 10 , 108 )
+    
+    # Creation of Switch Nodes
+    PySwitch = []
+    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,EndSwitch = GraphLoopSwitch_1.SNode( 'Switch' , PySwitch )
+    EndSwitch.SetName( 'EndSwitch' )
+    EndSwitch.SetAuthor( '' )
+    EndSwitch.SetComment( 'Compute Node' )
+    EndSwitch.Coords( 587 , 103 )
+    PyEndSwitch = []
+    PyEndSwitch.append( 'def EndSwitch(a) :    ' )
+    PyEndSwitch.append( '    if ( a & 1 ) == 0 :  ' )
+    PyEndSwitch.append( '        sleep(1)  ' )
+    PyEndSwitch.append( '    return a    ' )
+    EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch )
+    IEndSwitcha = EndSwitch.InPort( 'a' , 'long' )
+    IEndSwitchDefault = EndSwitch.GetInPort( 'Default' )
+    OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' )
+    OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' )
+    Switch.SetName( 'Switch' )
+    Switch.SetAuthor( '' )
+    Switch.SetComment( 'Compute Node' )
+    Switch.Coords( 194 , 109 )
+    ISwitcha = Switch.InPort( 'a' , 'long' )
+    ISwitchGate = Switch.GetInPort( 'Gate' )
+    OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
+    OSwitchEven = Switch.OutPort( 'Even' , 'int' )
+    OSwitcha = Switch.OutPort( 'a' , 'int' )
+    OSwitchDefault = Switch.GetOutPort( 'Default' )
+    
+    # Creation of Links
+    LIsOddaEndSwitcha = GraphLoopSwitch_1.Link( OIsOdda , IEndSwitcha )
+    LIsOddaEndSwitcha.AddCoord( 1 , 576 , 136 )
+    LIsOddaEndSwitcha.AddCoord( 2 , 575 , 81 )
+    
+    LInitLoopIndexSwitcha = GraphLoopSwitch_1.Link( OInitLoopIndex , ISwitcha )
+    
+    LInitLoopMinEndOfInitLoopMin = GraphLoopSwitch_1.Link( OInitLoopMin , IEndOfInitLoopMin )
+    
+    LInitLoopMaxEndOfInitLoopMax = GraphLoopSwitch_1.Link( OInitLoopMax , IEndOfInitLoopMax )
+    
+    LSwitchOddIsOddGate = GraphLoopSwitch_1.Link( OSwitchOdd , IIsOddGate )
+    
+    LSwitchEvenEndSwitchDefault = GraphLoopSwitch_1.Link( OSwitchEven , IEndSwitchDefault )
+    
+    LSwitchEvenIsOddEven = GraphLoopSwitch_1.Link( OSwitchEven , IIsOddEven )
+    LSwitchEvenIsOddEven.AddCoord( 1 , 375 , 111 )
+    LSwitchEvenIsOddEven.AddCoord( 2 , 375 , 172 )
+    
+    LSwitchaIsOdda = GraphLoopSwitch_1.Link( OSwitcha , IIsOdda )
+    LSwitchaIsOdda.AddCoord( 1 , 362 , 82 )
+    LSwitchaIsOdda.AddCoord( 2 , 360 , 201 )
+    
+    LEndSwitchaEndOfInitLoopIndex = GraphLoopSwitch_1.Link( OEndSwitcha , IEndOfInitLoopIndex )
+    
+    # Input datas
+    IInitLoopIndex.Input( 0 )
+    IInitLoopMin.Input( 5 )
+    IInitLoopMax.Input( 100 )
+    
+    # Output Ports of the graph
+    #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
+    #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
+    #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
+    return GraphLoopSwitch_1
+
+
+GraphLoopSwitch_1 = DefGraphLoopSwitch_1()