Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/superv.git] / examples / GraphStreamInLines.py
diff --git a/examples/GraphStreamInLines.py b/examples/GraphStreamInLines.py
new file mode 100644 (file)
index 0000000..b46483a
--- /dev/null
@@ -0,0 +1,256 @@
+
+# Generated python file of Graph GraphStreamInLines
+
+from SuperV import *
+# Graph creation 
+GraphStreamInLines = StreamGraph( 'GraphStreamInLines' )
+GraphStreamInLines.SetStreamParams( 300 , SUPERV.WithoutTrace , 0 )
+GraphStreamInLines.SetName( 'GraphStreamInLines' )
+GraphStreamInLines.SetAuthor( '' )
+GraphStreamInLines.SetComment( '' )
+GraphStreamInLines.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 (GraphStreamInLines1)"       ' )
+PyIsOdd.append( '    sleep( 1 )    ' )
+PyIsOdd.append( '    return a      ' )
+IsOdd = GraphStreamInLines.INode( 'IsOdd' , PyIsOdd )
+IsOdd.SetName( 'IsOdd' )
+IsOdd.SetAuthor( '' )
+IsOdd.SetComment( 'Python function' )
+IsOdd.Coords( 394 , 59 )
+IIsOdda = IsOdd.InPort( 'a' , 'long' )
+IIsOddEven = IsOdd.InPort( 'Even' , 'boolean' )
+IIsOddGate = IsOdd.GetInPort( 'Gate' )
+OIsOdda = IsOdd.OutPort( 'a' , 'long' )
+OIsOddGate = IsOdd.GetOutPort( 'Gate' )
+IIsOddistream = IsOdd.InStreamPort( 'istream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
+IIsOddistream.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
+OIsOddostream = IsOdd.OutStreamPort( 'ostream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_ITERATIVE )
+OIsOddostream.SetNumberOfValues( 0 )
+
+# Creation of Loop Nodes
+PyInitLoop = []
+PyMoreInitLoop = []
+PyMoreInitLoop.append( '' )
+PyNextInitLoop = []
+PyNextInitLoop.append( '' )
+InitLoop,EndOfInitLoop = GraphStreamInLines.LNode( '' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop )
+EndOfInitLoop.SetName( 'EndOfInitLoop' )
+EndOfInitLoop.SetAuthor( '' )
+EndOfInitLoop.SetComment( '' )
+EndOfInitLoop.Coords( 776 , 105 )
+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 )
+IInitLoopInitLoop = InitLoop.GetInPort( 'InitLoop' )
+IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' )
+IInitLoopMin = InitLoop.InPort( 'Min' , 'long' )
+IInitLoopMax = InitLoop.InPort( 'Max' , 'long' )
+IInitLoopistream = InitLoop.InStreamPort( 'istream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
+IInitLoopistream.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
+IInitLoopGate = InitLoop.GetInPort( 'Gate' )
+OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' )
+OInitLoopIndex = InitLoop.GetOutPort( 'Index' )
+OInitLoopMin = InitLoop.GetOutPort( 'Min' )
+OInitLoopMax = InitLoop.GetOutPort( 'Max' )
+OInitLoopostream = InitLoop.OutStreamPort( 'ostream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_ITERATIVE )
+OInitLoopostream.SetNumberOfValues( 0 )
+IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' )
+IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' )
+IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' )
+IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' )
+IEndOfInitLoopistream = EndOfInitLoop.InStreamPort( 'istream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_ITERATIVE )
+IEndOfInitLoopistream.SetParams( SUPERV.SCHENULL , SUPERV.INTERNULL , SUPERV.EXTRANULL )
+IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' )
+OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' )
+OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
+OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
+OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
+OEndOfInitLoopostream = EndOfInitLoop.OutStreamPort( 'ostream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
+OEndOfInitLoopostream.SetNumberOfValues( 0 )
+InitLoop.SetName( 'InitLoop' )
+InitLoop.SetAuthor( '' )
+InitLoop.SetComment( '' )
+InitLoop.Coords( 11 , 119 )
+IInitLoopistream = InitLoop.InStreamPort( 'istream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
+IInitLoopistream.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
+OInitLoopostream = InitLoop.OutStreamPort( 'ostream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_ITERATIVE )
+OInitLoopostream.SetNumberOfValues( 0 )
+
+# 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 = GraphStreamInLines.SNode( 'Switch' , PySwitch )
+EndSwitch.SetName( 'EndSwitch' )
+EndSwitch.SetAuthor( '' )
+EndSwitch.SetComment( '' )
+EndSwitch.Coords( 587 , 104 )
+PyEndSwitch = []
+PyEndSwitch.append( 'def EndOfSwitch(a) :    ' )
+PyEndSwitch.append( '    if ( a & 1 ) == 0 :  ' )
+PyEndSwitch.append( '        sleep(1)  ' )
+PyEndSwitch.append( '    return a    ' )
+EndSwitch.SetPyFunction( 'EndOfSwitch' , PyEndSwitch )
+IEndSwitcha = EndSwitch.InPort( 'a' , 'long' )
+IEndSwitchistream = EndSwitch.InStreamPort( 'istream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
+IEndSwitchistream.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
+IEndSwitchDefault = EndSwitch.GetInPort( 'Default' )
+OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' )
+OEndSwitchostream = EndSwitch.OutStreamPort( 'ostream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
+OEndSwitchostream.SetNumberOfValues( 0 )
+OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' )
+Switch.SetName( 'Switch' )
+Switch.SetAuthor( '' )
+Switch.SetComment( '' )
+Switch.Coords( 197 , 119 )
+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' )
+ISwitchistream = Switch.InStreamPort( 'istream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_TEMPORAL )
+ISwitchistream.SetParams( SUPERV.TI , SUPERV.L1 , SUPERV.EXTRANULL )
+OSwitchostream = Switch.OutStreamPort( 'ostream' , SALOME_ModuleCatalog.DATASTREAM_INTEGER , SALOME_ModuleCatalog.DATASTREAM_ITERATIVE )
+OSwitchostream.SetNumberOfValues( 0 )
+
+# Creation of Links
+LIsOddaEndSwitcha = GraphStreamInLines.Link( OIsOdda , IEndSwitcha )
+
+LIsOddostreamInitLoopistream = GraphStreamInLines.StreamLink( OIsOddostream , IInitLoopistream )
+LIsOddostreamInitLoopistream.AddCoord( 1 , 3 , 240 )
+LIsOddostreamInitLoopistream.AddCoord( 2 , 3 , 395 )
+LIsOddostreamInitLoopistream.AddCoord( 3 , 571 , 394 )
+LIsOddostreamInitLoopistream.AddCoord( 4 , 571 , 187 )
+
+LInitLoopIndexSwitcha = GraphStreamInLines.Link( OInitLoopIndex , ISwitcha )
+
+LInitLoopMinEndOfInitLoopMin = GraphStreamInLines.Link( OInitLoopMin , IEndOfInitLoopMin )
+
+LInitLoopMaxEndOfInitLoopMax = GraphStreamInLines.Link( OInitLoopMax , IEndOfInitLoopMax )
+
+LInitLoopostreamEndSwitchistream = GraphStreamInLines.StreamLink( OInitLoopostream , IEndSwitchistream )
+LInitLoopostreamEndSwitchistream.AddCoord( 1 , 584 , 167 )
+LInitLoopostreamEndSwitchistream.AddCoord( 2 , 584 , 369 )
+LInitLoopostreamEndSwitchistream.AddCoord( 3 , 184 , 368 )
+LInitLoopostreamEndSwitchistream.AddCoord( 4 , 185 , 240 )
+
+LSwitchOddIsOddGate = GraphStreamInLines.Link( OSwitchOdd , IIsOddGate )
+LSwitchOddIsOddGate.AddCoord( 1 , 373 , 222 )
+LSwitchOddIsOddGate.AddCoord( 2 , 373 , 147 )
+
+LSwitchEvenEndSwitchDefault = GraphStreamInLines.Link( OSwitchEven , IEndSwitchDefault )
+
+LSwitchEvenIsOddEven = GraphStreamInLines.Link( OSwitchEven , IIsOddEven )
+LSwitchEvenIsOddEven.AddCoord( 1 , 363 , 154 )
+LSwitchEvenIsOddEven.AddCoord( 2 , 362 , 177 )
+
+LSwitchaIsOdda = GraphStreamInLines.Link( OSwitcha , IIsOdda )
+LSwitchaIsOdda.AddCoord( 1 , 385 , 123 )
+LSwitchaIsOdda.AddCoord( 2 , 386 , 206 )
+
+LSwitchostreamIsOddistream = GraphStreamInLines.StreamLink( OSwitchostream , IIsOddistream )
+LSwitchostreamIsOddistream.AddCoord( 1 , 360 , 185 )
+LSwitchostreamIsOddistream.AddCoord( 2 , 361 , 240 )
+
+LSwitchostreamEndOfInitLoopistream = GraphStreamInLines.StreamLink( OSwitchostream , IEndOfInitLoopistream )
+LSwitchostreamEndOfInitLoopistream.AddCoord( 1 , 775 , 226 )
+LSwitchostreamEndOfInitLoopistream.AddCoord( 2 , 775 , 261 )
+LSwitchostreamEndOfInitLoopistream.AddCoord( 3 , 361 , 261 )
+LSwitchostreamEndOfInitLoopistream.AddCoord( 4 , 361 , 240 )
+
+LEndSwitchaEndOfInitLoopIndex = GraphStreamInLines.Link( OEndSwitcha , IEndOfInitLoopIndex )
+
+LEndSwitchostreamSwitchistream = GraphStreamInLines.StreamLink( OEndSwitchostream , ISwitchistream )
+LEndSwitchostreamSwitchistream.AddCoord( 1 , 186 , 240 )
+LEndSwitchostreamSwitchistream.AddCoord( 2 , 186 , 331 )
+LEndSwitchostreamSwitchistream.AddCoord( 3 , 766 , 330 )
+LEndSwitchostreamSwitchistream.AddCoord( 4 , 766 , 167 )
+
+# Input datas
+IInitLoopIndex.Input( 0 )
+IInitLoopMin.Input( 0 )
+IInitLoopMax.Input( 100 )
+
+# Output Ports of the graph
+#OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
+#OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
+#OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
+
+
+
+GraphStreamInLines.Run()
+GraphStreamInLines.DoneW()
+print GraphStreamInLines.State()
+
+GraphStreamInLines.PrintPorts()
+
+
+subgraphs = GraphStreamInLines.SubGraphsNumber()
+i = 1
+while i <= subgraphs :
+    nodes = GraphStreamInLines.SubGraphsNodes( i )
+    j = 0
+    while j < len(nodes) :
+        print 'SubGraph',i,nodes[j].Name()
+        j = j + 1
+    i = i + 1
+
+
+substreamgraphs = GraphStreamInLines.SubStreamGraphsNumber()
+i = 1
+while i <= substreamgraphs :
+    nodes = GraphStreamInLines.SubStreamGraphsNodes( i )
+    j = 0
+    while j < len(nodes) :
+        print 'SubStreamGraph',i,nodes[j].Name()
+        j = j + 1
+    i = i + 1
+
+GraphStreamInLines.Export('/tmp/GraphStreamInLines.xml')
+
+from SuperV import *
+GraphStreamInLines = StreamGraph('/tmp/GraphStreamInLines.xml')
+
+
+GraphStreamInLines.Run()
+GraphStreamInLines.DoneW()
+print GraphStreamInLines.State()
+
+subgraphs = GraphStreamInLines.SubGraphsNumber()
+i = 1
+while i <= subgraphs :
+    nodes = GraphStreamInLines.SubGraphsNodes( i )
+    j = 0
+    while j < len(nodes) :
+        print 'SubGraph',i,nodes[j].Name()
+        j = j + 1
+    i = i + 1
+
+
+substreamgraphs = GraphStreamInLines.SubStreamGraphsNumber()
+i = 1
+while i <= substreamgraphs :
+    nodes = GraphStreamInLines.SubStreamGraphsNodes( i )
+    j = 0
+    while j < len(nodes) :
+        print 'SubStreamGraph',i,nodes[j].Name()
+        j = j + 1
+    i = i + 1
+