from salome import sg
import SALOMEDS
import os
+import sys
import SALOME_ModuleCatalog
# ---- create Hypothesis
if sys.platform == "win32":
- stdMeshersEngine = "StdMeshersEngine.dll"
+ stdMeshersEngine = "StdMeshersEngine"
else:
stdMeshersEngine = "libStdMeshersEngine.so"
smesh.Compute(mesh, box)
sg.updateObjBrowser(1);
-print
-print "============= Test Supervisor ============================="
-print
-
-comp = catalog.GetComponent("SUPERV")
-if comp is None:
- raise RuntimeError,"Component SUPERV not found in Module Catalog."
-
-from SuperV import *
-import SALOMEDS
-myStudy = salome.myStudy
-myBuilder = myStudy.NewBuilder()
-
-SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV")
-father = myStudy.FindComponent("SUPERV")
-if father is None:
- father = myBuilder.NewComponent("SUPERV")
- A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName");
- FName = A1._narrow(SALOMEDS.AttributeName)
- FName.SetValue( salome.sg.getComponentUserName("SUPERV") )
- A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap");
- aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
- aPixmap.SetPixMap( "ICON_OBJBROWSER_Supervision" );
- myBuilder.DefineComponentInstance(father,SuperVision)
-
-def addStudy(ior):
- dataflow = SuperVision.getStreamGraph(ior)
- name=dataflow.Name()
- itr = myStudy.NewChildIterator(father)
- while itr.More():
- item=itr.Value()
- res,A=item.FindAttribute("AttributeName")
- if res:
- aName = A._narrow(SALOMEDS.AttributeName)
- if aName.Value() == name :
- print myBuilder.FindOrCreateAttribute(item, "AttributeIOR")
- A = myBuilder.FindOrCreateAttribute(item, "AttributeIOR")
- print "A = ", A
- if A is not None :
- #res,A = myBuilder.FindOrCreateAttribute(item, "AttributeIOR")
- anIOR = A._narrow(SALOMEDS.AttributeIOR);
- print "anIOR.SetValue(dataflow.getIOR())"
- anIOR.SetValue(dataflow.getIOR())
- return
- itr.Next()
- obj = myBuilder.NewObject(father)
- A=myBuilder.FindOrCreateAttribute(obj, "AttributeName")
- aName=A._narrow(SALOMEDS.AttributeName)
- aName.SetValue(name)
- A=myBuilder.FindOrCreateAttribute(obj, "AttributeIOR")
- anIOR = A._narrow(SALOMEDS.AttributeIOR)
- anIOR.SetValue(dataflow.getIOR())
-
-import os
-dir= os.getenv("DATA_DIR")
-if dir == None:
- raise RuntimeError, "DATA_DIR is not defined"
-xmlfile = dir + "/Superv/Graphs/GraphGeomEssaiGates.xml"
-print "Load dataflow from the file : "
-print xmlfile
-print
-
-myGraph = StreamGraph ( xmlfile )
-
-# This DataFlow is "valid" : no loop, correct links between Nodes etc...
-print "myGraph.IsValid() = ", myGraph.IsValid()
-
-# Get Nodes
-myGraph.PrintNodes()
-
-# This DataFlow is "executable" : all pending Ports are defined with Datas
-print myGraph.IsExecutable()
-
-# Starts only execution of that DataFlow and gets control immediatly
-print myGraph.Run()
-
-# That DataFlow is running ==> 0 (false)
-print myGraph.IsDone()
-
-# Events of execution :
-aStatus,aNode,anEvent,aState = myGraph.Event()
-while aStatus :
- print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState
- aStatus,aNode,anEvent,aState = myGraph.Event()
-print "myGraph.IsDone() = ",myGraph.IsDone()
-
-# Wait for Completion (but it is already done after event loop ...)
-print "Done : ",myGraph.DoneW()
-
-print " "
-#print "Type : print myGraph.IsDone()"
-#print " If execution is finished ==> 1 (true)"
-res=myGraph.IsDone()
-if res != 1:
- raise RuntimeError, "myGraph.Run() is not done"
-
-print " "
-print "Type : myGraph.PrintPorts()"
-print " to see input and output values of the graph"
-myGraph.PrintPorts()
-
-# Export will create newsupervisionexample.xml and the corresponding .py file
-tmpdir=os.getenv("TmpDir")
-if tmpdir is None:
- tmpdir="/tmp"
-file = tmpdir + "/newsupervisionexample"
-print "--------------\n"+file+"\n--------------\n"
-myGraph.Export(file)
-
-ior = salome.orb.object_to_string(myGraph.G)
-addStudy(ior)
-
-GraphName = myGraph.Name()
-print "Befor save ",
-#nodes = myGraph.Nodes()
-nodes = myGraph.G.Nodes().FNodes
-length_bs = len(nodes)
-print "ListOfNodes length = ", length_bs
-names=[]
-for node in nodes:
- names.append(node.Name())
-print names
-
-# Graph creation
-GraphInLines = StreamGraph( 'GraphInLines' )
-GraphInLines.SetName( 'GraphInLines' )
-GraphInLines.SetAuthor( '' )
-GraphInLines.SetComment( '' )
-GraphInLines.Coords( 0 , 0 )
-
-# Creation of InLine Nodes
-PyAdd = []
-PyAdd.append( 'def Add(a,b) : ' )
-PyAdd.append( ' return a+b ' )
-PyAdd.append( '' )
-Add = GraphInLines.INode( 'Add' , PyAdd )
-Add.InPort( 'a' , 'long' )
-Add.InPort( 'b' , 'long' )
-Add.OutPort( 'f' , 'long' )
-Add.SetName( 'Add' )
-Add.SetAuthor( '' )
-Add.SetComment( 'Python function' )
-Add.Coords( 351 , 77 )
-PySub = []
-PySub.append( 'def Sub(a,b) : ' )
-PySub.append( ' return a-b ' )
-PySub.append( '' )
-Sub = GraphInLines.INode( 'Sub' , PySub )
-Sub.InPort( 'a' , 'long' )
-Sub.InPort( 'b' , 'long' )
-Sub.OutPort( 'f' , 'long' )
-Sub.SetName( 'Sub' )
-Sub.SetAuthor( '' )
-Sub.SetComment( 'Python function' )
-Sub.Coords( 86 , 333 )
-PyMul = []
-PyMul.append( 'def Mul(a,b) : ' )
-PyMul.append( ' return a*b ' )
-Mul = GraphInLines.INode( 'Mul' , PyMul )
-Mul.InPort( 'a' , 'long' )
-Mul.InPort( 'b' , 'long' )
-Mul.OutPort( 'Result' , 'long' )
-Mul.SetName( 'Mul' )
-Mul.SetAuthor( '' )
-Mul.SetComment( 'Python function' )
-Mul.Coords( 616 , 247 )
-
-# Creation of intermediate Output variables and of Control Links
-Addf = Add.Port( 'f' )
-Mula = GraphInLines.Link( Addf , Mul.Port( 'a' ) )
-Mula.AddCoord( 1 , 570 , 356 )
-Mula.AddCoord( 2 , 570 , 186 )
-Subf = Sub.Port( 'f' )
-Mulb = GraphInLines.Link( Subf , Mul.Port( 'b' ) )
-Mulb.AddCoord( 1 , 282 , 376 )
-Mulb.AddCoord( 2 , 282 , 442 )
-Addb = GraphInLines.Link( Subf , Add.Port( 'b' ) )
-Addb.AddCoord( 1 , 283 , 209 )
-Addb.AddCoord( 2 , 283 , 374 )
-Addb.AddCoord( 3 , 283 , 442 )
-
-# Creation of Input datas
-Adda = Add.Input( 'a' , 1)
-Suba = Sub.Input( 'a' , 3)
-Subb = Sub.Input( 'b' , 4)
-
-# Creation of Output variables
-MulResult = Mul.Port( 'Result' )
-
-GraphInLines.Run()
-
-GraphInLines.DoneW()
-
-GraphInLines.PrintPorts()
-
-sg.updateObjBrowser(1);
+if sys.platform != "win32":
+ print
+ print "============= Test Supervisor ============================="
+ print
+
+ comp = catalog.GetComponent("SUPERV")
+ if comp is None:
+ raise RuntimeError,"Component SUPERV not found in Module Catalog."
+
+ from SuperV import *
+ import SALOMEDS
+ myStudy = salome.myStudy
+ myBuilder = myStudy.NewBuilder()
+
+ SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV")
+ father = myStudy.FindComponent("SUPERV")
+ if father is None:
+ father = myBuilder.NewComponent("SUPERV")
+ A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName");
+ FName = A1._narrow(SALOMEDS.AttributeName)
+ FName.SetValue( salome.sg.getComponentUserName("SUPERV") )
+ A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap");
+ aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
+ aPixmap.SetPixMap( "ICON_OBJBROWSER_Supervision" );
+ myBuilder.DefineComponentInstance(father,SuperVision)
+
+ def addStudy(ior):
+ dataflow = SuperVision.getStreamGraph(ior)
+ name=dataflow.Name()
+ itr = myStudy.NewChildIterator(father)
+ while itr.More():
+ item=itr.Value()
+ res,A=item.FindAttribute("AttributeName")
+ if res:
+ aName = A._narrow(SALOMEDS.AttributeName)
+ if aName.Value() == name :
+ print myBuilder.FindOrCreateAttribute(item, "AttributeIOR")
+ A = myBuilder.FindOrCreateAttribute(item, "AttributeIOR")
+ print "A = ", A
+ if A is not None :
+ #res,A = myBuilder.FindOrCreateAttribute(item, "AttributeIOR")
+ anIOR = A._narrow(SALOMEDS.AttributeIOR);
+ print "anIOR.SetValue(dataflow.getIOR())"
+ anIOR.SetValue(dataflow.getIOR())
+ return
+ itr.Next()
+ obj = myBuilder.NewObject(father)
+ A=myBuilder.FindOrCreateAttribute(obj, "AttributeName")
+ aName=A._narrow(SALOMEDS.AttributeName)
+ aName.SetValue(name)
+ A=myBuilder.FindOrCreateAttribute(obj, "AttributeIOR")
+ anIOR = A._narrow(SALOMEDS.AttributeIOR)
+ anIOR.SetValue(dataflow.getIOR())
+
+ import os
+ dir= os.getenv("DATA_DIR")
+ if dir == None:
+ raise RuntimeError, "DATA_DIR is not defined"
+ xmlfile = dir + "/Superv/Graphs/GraphGeomEssaiGates.xml"
+ print "Load dataflow from the file : "
+ print xmlfile
+ print
+
+ myGraph = StreamGraph ( xmlfile )
+
+ # This DataFlow is "valid" : no loop, correct links between Nodes etc...
+ print "myGraph.IsValid() = ", myGraph.IsValid()
+
+ # Get Nodes
+ myGraph.PrintNodes()
+
+ # This DataFlow is "executable" : all pending Ports are defined with Datas
+ print myGraph.IsExecutable()
+
+ # Starts only execution of that DataFlow and gets control immediatly
+ print myGraph.Run()
+
+ # That DataFlow is running ==> 0 (false)
+ print myGraph.IsDone()
+
+ # Events of execution :
+ aStatus,aNode,anEvent,aState = myGraph.Event()
+ while aStatus :
+ print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState
+ aStatus,aNode,anEvent,aState = myGraph.Event()
+ print "myGraph.IsDone() = ",myGraph.IsDone()
+
+ # Wait for Completion (but it is already done after event loop ...)
+ print "Done : ",myGraph.DoneW()
+
+ print " "
+ #print "Type : print myGraph.IsDone()"
+ #print " If execution is finished ==> 1 (true)"
+ res=myGraph.IsDone()
+ if res != 1:
+ raise RuntimeError, "myGraph.Run() is not done"
+
+ print " "
+ print "Type : myGraph.PrintPorts()"
+ print " to see input and output values of the graph"
+ myGraph.PrintPorts()
+
+ # Export will create newsupervisionexample.xml and the corresponding .py file
+ tmpdir=os.getenv("TmpDir")
+ if tmpdir is None:
+ tmpdir="/tmp"
+ file = tmpdir + "/newsupervisionexample"
+ print "--------------\n"+file+"\n--------------\n"
+ myGraph.Export(file)
+
+ ior = salome.orb.object_to_string(myGraph.G)
+ addStudy(ior)
+
+ GraphName = myGraph.Name()
+ print "Befor save ",
+ #nodes = myGraph.Nodes()
+ nodes = myGraph.G.Nodes().FNodes
+ length_bs = len(nodes)
+ print "ListOfNodes length = ", length_bs
+ names=[]
+ for node in nodes:
+ names.append(node.Name())
+ print names
+
+ # Graph creation
+ GraphInLines = StreamGraph( 'GraphInLines' )
+ GraphInLines.SetName( 'GraphInLines' )
+ GraphInLines.SetAuthor( '' )
+ GraphInLines.SetComment( '' )
+ GraphInLines.Coords( 0 , 0 )
+
+ # Creation of InLine Nodes
+ PyAdd = []
+ PyAdd.append( 'def Add(a,b) : ' )
+ PyAdd.append( ' return a+b ' )
+ PyAdd.append( '' )
+ Add = GraphInLines.INode( 'Add' , PyAdd )
+ Add.InPort( 'a' , 'long' )
+ Add.InPort( 'b' , 'long' )
+ Add.OutPort( 'f' , 'long' )
+ Add.SetName( 'Add' )
+ Add.SetAuthor( '' )
+ Add.SetComment( 'Python function' )
+ Add.Coords( 351 , 77 )
+ PySub = []
+ PySub.append( 'def Sub(a,b) : ' )
+ PySub.append( ' return a-b ' )
+ PySub.append( '' )
+ Sub = GraphInLines.INode( 'Sub' , PySub )
+ Sub.InPort( 'a' , 'long' )
+ Sub.InPort( 'b' , 'long' )
+ Sub.OutPort( 'f' , 'long' )
+ Sub.SetName( 'Sub' )
+ Sub.SetAuthor( '' )
+ Sub.SetComment( 'Python function' )
+ Sub.Coords( 86 , 333 )
+ PyMul = []
+ PyMul.append( 'def Mul(a,b) : ' )
+ PyMul.append( ' return a*b ' )
+ Mul = GraphInLines.INode( 'Mul' , PyMul )
+ Mul.InPort( 'a' , 'long' )
+ Mul.InPort( 'b' , 'long' )
+ Mul.OutPort( 'Result' , 'long' )
+ Mul.SetName( 'Mul' )
+ Mul.SetAuthor( '' )
+ Mul.SetComment( 'Python function' )
+ Mul.Coords( 616 , 247 )
+
+ # Creation of intermediate Output variables and of Control Links
+ Addf = Add.Port( 'f' )
+ Mula = GraphInLines.Link( Addf , Mul.Port( 'a' ) )
+ Mula.AddCoord( 1 , 570 , 356 )
+ Mula.AddCoord( 2 , 570 , 186 )
+ Subf = Sub.Port( 'f' )
+ Mulb = GraphInLines.Link( Subf , Mul.Port( 'b' ) )
+ Mulb.AddCoord( 1 , 282 , 376 )
+ Mulb.AddCoord( 2 , 282 , 442 )
+ Addb = GraphInLines.Link( Subf , Add.Port( 'b' ) )
+ Addb.AddCoord( 1 , 283 , 209 )
+ Addb.AddCoord( 2 , 283 , 374 )
+ Addb.AddCoord( 3 , 283 , 442 )
+
+ # Creation of Input datas
+ Adda = Add.Input( 'a' , 1)
+ Suba = Sub.Input( 'a' , 3)
+ Subb = Sub.Input( 'b' , 4)
+
+ # Creation of Output variables
+ MulResult = Mul.Port( 'Result' )
+
+ GraphInLines.Run()
+
+ GraphInLines.DoneW()
+
+ GraphInLines.PrintPorts()
+
+ sg.updateObjBrowser(1);
+
+ pass
print
print "============= Test VISU and MED ============================="