From 286329c1a1f3c1fbbbd5dd7bbfb6452bd6c5a038 Mon Sep 17 00:00:00 2001 From: smh Date: Mon, 6 Jun 2005 12:37:12 +0000 Subject: [PATCH] Instead on *in --- src/SALOME_SWIG/supervisionexample.py | 85 ++++++++++++++++++ src/SALOME_SWIG/supervisiongeomexample.py | 103 ++++++++++++++++++++++ 2 files changed, 188 insertions(+) create mode 100755 src/SALOME_SWIG/supervisionexample.py create mode 100755 src/SALOME_SWIG/supervisiongeomexample.py diff --git a/src/SALOME_SWIG/supervisionexample.py b/src/SALOME_SWIG/supervisionexample.py new file mode 100755 index 000000000..56bdd9bf5 --- /dev/null +++ b/src/SALOME_SWIG/supervisionexample.py @@ -0,0 +1,85 @@ +#============================================================================== +# File : supervisionexample.py +# Created : 23 nov 2001 +# Author : Jean Rahuel +# Project : SALOME +# Copyright : CEA +#============================================================================== + +from SuperV import * + + + +# load this object with Nodes, Links and Datas stored in GraphEssai.xml +# (GraphEssai.xml was created with python in SuperVisionTest and GraphEssai.py) +myGraph = Graph("@ROOT_BUILDDIR@/share/salome/resources/GraphEssai.xml") + +#myGraph = Graph("/home/data/jr_HEAD/build/share/salome/resources/GraphEssai.xml") +# This DataFlow is "valid" : no loop, correct links between Nodes etc... + +print myGraph.IsValid() + +# Get Nodes +myGraph.PrintNodes() +Add,Sub,Mul,Div = myGraph.Nodes() + +# Load Datas +Addx = Add.Input("x",3.) +Addy = Add.Input("y",4.5) +Subx = Sub.Input("x",1.5) + +# Get Output Port +Addz = Add.Port('z') +Subz = Sub.Port('z') +Mulz = Mul.Port('z') +Divz = Div.Port('z') + +# 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() + +# Wait for Completion (but it is already done after event loop ...) +print "Done : ",myGraph.DoneW() + +# Get result +print "Result : ",Divz.ToString() + +# Intermediate results : +print "Intermediate Result Add\z : ",Addz.ToString() +print "Intermediate Result Sub\z : ",Subz.ToString() +print "Intermediate Result Mul\z : ",Mulz.ToString() + +print " " +print "Type : print myGraph.IsDone()" +print " If execution is finished ==> 1 (true)" +print " " +print "Type : print Divz.ToString()" +print " You will get the result" +print " " +print "Type : myGraph.PrintPorts()" +print " to see input and output values of the graph" +print " " +print "Type : Add.PrintPorts()" +print "Type : Sub.PrintPorts()" +print "Type : Mul.PrintPorts()" +print "Type : Div.PrintPorts()" +print " to see input and output values of nodes" + +# Export will create newsupervisionexample.xml and the corresponding .py file +print myGraph.Export("@ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.xml") + +print " " +print "See file @ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.xml" +print "See file @ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.py" diff --git a/src/SALOME_SWIG/supervisiongeomexample.py b/src/SALOME_SWIG/supervisiongeomexample.py new file mode 100755 index 000000000..8c56bb1f2 --- /dev/null +++ b/src/SALOME_SWIG/supervisiongeomexample.py @@ -0,0 +1,103 @@ + +# Generated python file of Graph GraphGeom2Essai + +from SuperV import * + +import salome + +import geompy + + +geom = lcc.FindOrLoadComponent("FactoryServer", "Geometry") +geom.GetCurrentStudy(salome.myStudyId) + +myBuilder = salome.myStudy.NewBuilder() + +# Graph creation +GraphGeom2Essai = Graph( 'GraphGeom2Essai' ) +print GraphGeom2Essai.SetAuthor( '' ) +print GraphGeom2Essai.SetComment( '' ) +GraphGeom2Essai.Coords( 0 , 0 ) + +# Creation of Nodes +MakeSphere = GraphGeom2Essai.Node( 'Geometry' , 'Geometry' , 'MakeSphere' ) +print MakeSphere.SetAuthor( '' ) +print MakeSphere.SetContainer( 'FactoryServer' ) +print MakeSphere.SetComment( '' ) +MakeSphere.Coords( 26 , 13 ) +MakeCopy = GraphGeom2Essai.Node( 'Geometry' , 'Geometry' , 'MakeCopy' ) +print MakeCopy.SetAuthor( '' ) +print MakeCopy.SetContainer( 'FactoryServer' ) +print MakeCopy.SetComment( '' ) +MakeCopy.Coords( 219 , 12 ) +MakeTranslation = GraphGeom2Essai.Node( 'Geometry' , 'Geometry' , 'MakeTranslation' ) +print MakeTranslation.SetAuthor( '' ) +print MakeTranslation.SetContainer( 'FactoryServer' ) +print MakeTranslation.SetComment( '' ) +MakeTranslation.Coords( 219 , 159 ) +MakeFuse = GraphGeom2Essai.Node( 'Geometry' , 'Geometry' , 'MakeFuse' ) +print MakeFuse.SetAuthor( '' ) +print MakeFuse.SetContainer( 'FactoryServer' ) +print MakeFuse.SetComment( '' ) +MakeFuse.Coords( 465 , 106 ) + +# Creation of intermediate Output variables and of links +MakeSphereshape = MakeSphere.Port( 'shape' ) +MakeCopyshape1 = GraphGeom2Essai.Link( MakeSphereshape , MakeCopy.Port( 'shape1' ) ) +MakeTranslationshape1 = GraphGeom2Essai.Link( MakeSphereshape , MakeTranslation.Port( 'shape1' ) ) +MakeCopyshape = MakeCopy.Port( 'shape' ) +MakeFuseshape1 = GraphGeom2Essai.Link( MakeCopyshape , MakeFuse.Port( 'shape1' ) ) +MakeTranslationshape = MakeTranslation.Port( 'shape' ) +MakeFuseshape2 = GraphGeom2Essai.Link( MakeTranslationshape , MakeFuse.Port( 'shape2' ) ) + +# Creation of Input datas +MakeSpherex1 = MakeSphere.Input( 'x1' , 0) +MakeSpherey1 = MakeSphere.Input( 'y1' , 0) +MakeSpherez1 = MakeSphere.Input( 'z1' , 0) +MakeSphereradius = MakeSphere.Input( 'radius' , 50) +MakeTranslationx1 = MakeTranslation.Input( 'x1' , 80) +MakeTranslationy1 = MakeTranslation.Input( 'y1' , 0) +MakeTranslationz1 = MakeTranslation.Input( 'z1' , 0) + +# Missing Input datas : None + +# Creation of Output variables +MakeFuseshape = MakeFuse.Port( 'shape' ) + +# State of Ports of the Graph +GraphGeom2Essai.PrintPorts() + +# Start asynchronous run +print GraphGeom2Essai.Run() + +# Done ? +print GraphGeom2Essai.IsDone() + +# Events of execution : +aStatus,aNode,anEvent,aState = GraphGeom2Essai.Event() +while aStatus : + print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState + aStatus,aNode,anEvent,aState = GraphGeom2Essai.Event() +print GraphGeom2Essai.IsDone() + +# Waiting end of execution : +print GraphGeom2Essai.DoneW() + +print " " +print "Type print GraphGeom2Essai.IsDone()" +print "1 <==> It's done" +print " " +print "Type print GraphGeom2Essai.DoneW()" +print "Wait until end of execution : 1(success)" +print " " +print "Type GraphGeom2Essai.PrintPorts()" +print " to see input and output values of the graph" +print " " +print "Type MakeSphere.PrintPorts()" +print "Type MakeCopy.PrintPorts()" +print "Type MakeTranslation.PrintPorts()" +print "Type MakeFuse.PrintPorts()" +print " to see input and output values of nodes" +print " " +print "Type print GraphGeom2Essai.Export('File-Name')" +print "You will get a .py and a .xml file of this graph" -- 2.39.2