Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / Supervision / SuperV.py
index 7efe680c6836d9c11776007d662f9fed2b9c8a88..5a7aed0714c88d117577ec477a4ecca7243a4955 100644 (file)
@@ -2,8 +2,24 @@
 #
 #  SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
 #
-#  Copyright (C) 2003  CEA/DEN, EDF R&D
-#
+#  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+#  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+# 
+#  This library is free software; you can redistribute it and/or 
+#  modify it under the terms of the GNU Lesser General Public 
+#  License as published by the Free Software Foundation; either 
+#  version 2.1 of the License. 
+# 
+#  This library is distributed in the hope that it will be useful, 
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+#  Lesser General Public License for more details. 
+# 
+#  You should have received a copy of the GNU Lesser General Public 
+#  License along with this library; if not, write to the Free Software 
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+# 
+#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 #
 #  File   : SuperV.py
@@ -14,7 +30,11 @@ try :
     from salome import lcc
     from salome import naming_service
     from salome import CORBA
+    from salome import sg
+    from salome import SALOMEDS
     import SALOME_ModuleCatalog
+    import SUPERV
+    import SUPERV_idl
 except :
     import curses
     from LifeCycleCORBA import *
@@ -40,16 +60,54 @@ from types import *
 #    SuperVision.Swig = 1
 #    print 'SuperV_Swig created'
 #except :
-#    SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","Supervision")
+#    SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV")
 #    SuperVision.Swig = 0
 #    print 'Supervision Component loaded'
                     
-SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","Supervision")
-SuperVision.Swig = 0
+SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV")
+#SuperVision.Swig = 0
 
 modulecatalog = naming_service.Resolve("/Kernel/ModulCatalog")
 
 
+def createDataflowStudyObject( theStudy , aDataFlow , aBuilder ) :
+    aStudyObject = theStudy.FindObjectIOR( aDataFlow.G.getIOR() )
+    if aStudyObject == None :
+        aComponent = theStudy.FindComponent( "SUPERV" )
+        if aComponent == None :
+            print "createDataflowStudyObject Component SUPERV is None"
+            aComponent = aBuilder.NewComponent( "SUPERV" )
+            anAttr = aBuilder.FindOrCreateAttribute(aComponent, "AttributeName")
+            aName = anAttr._narrow( SALOMEDS.AttributeName )
+            aName.SetValue( modulecatalog.GetComponentInfo( "SUPERV" ).username )
+            anAttr = aBuilder.FindOrCreateAttribute( aComponent , "AttributePixMap" )
+            aPixmap = anAttr._narrow( SALOMEDS.AttributePixMap )
+            aPixmap.SetPixMap( "ICON_OBJBROWSER_Supervision" );
+            aBuilder.DefineComponentInstance( aComponent , SuperVision )
+            print "createDataflowStudyObject Component SUPERV is created"
+        aStudyObject = aBuilder.NewObject( aComponent )
+        anAttr =  aBuilder.FindOrCreateAttribute( aStudyObject , "AttributeName" )
+        aName = anAttr._narrow( SALOMEDS.AttributeName )
+        aName.SetValue( aDataFlow.Name() )
+        anAttr =  aBuilder.FindOrCreateAttribute( aStudyObject , "AttributeIOR" )
+        anIORAttr = anAttr._narrow( SALOMEDS.AttributeIOR )
+        anIORAttr.SetValue( aDataFlow.G.getIOR() )
+    return aStudyObject
+
+def addDataflowToStudy( theStudy , aDataFlow ) :
+    aBuilder = theStudy.NewBuilder()
+    aBuilder.NewCommand()
+    aStudyObject = createDataflowStudyObject( theStudy , aDataFlow , aBuilder )
+    if aStudyObject != None :
+        aBuilder.CommitCommand()
+        sg.updateObjBrowser( 1 )
+        print "addDataflowToStudy aStudyObject ",aDataFlow.Name()," added in study"
+        #theStudy.updateObjBrowser()
+    else :
+        print "addDataflowToStudy ERROR aStudyObject is None"
+        aBuilder.AbortCommand()
+    return aBuilder,aStudyObject
+
 
 def PortInputFloat(obj, x):
     return obj.Input( SuperVision.AnyValue( CORBA.Any(CORBA.TC_double, x)))
@@ -206,6 +264,11 @@ class CNode:
         if self.N.IsFactory() :
             print "ComponentName ",self.N.GetComponentName()
             print "InterfaceName ",self.N.GetInterfaceName()
+        if self.N.IsStreamGraph() :
+            Timeout,DataStreamTrace,DeltaTime = self.G.StreamParams()
+            print "Timeout",Timeout
+            print "DataStreamTrace",DataStreamTrace
+            print "DeltaTime",DeltaTime
         aService = self.N.Service()
         print "Service Name  ",aService.ServiceName
         lenin = len( aService.ServiceinParameter )
@@ -251,21 +314,54 @@ class CNode:
         if self.N.Verbose :
             print ErrMsg
         return anInput
-#    def BusPort( self , InOutParameterName , InOutParameterType ):
-#        sts,inp,outp = self.N.BusPort( InOutParameterName ,
-#                                       InOutParameterType )
-#        inp = Port( inp , self.N.Verbose )
-#        outp = Port( outp , self.N.Verbose )
-#        return sts,inp,outp
-#    def BusPorts( self , InputParameterName , InputParameterType ,
-#                  OutputParameterName , OutputParameterType ):
-#        sts,inp,outp = self.N.BusPorts( InputParameterName ,
-#                                        InputParameterType ,
-#                                        OutputParameterName ,
-#                                        OutputParameterType )
-#        inp = Port( inp , self.N.Verbose )
-#        outp = Port( outp , self.N.Verbose )
-#        return sts,inp,outp
+    def InStreamPort( self , aParameterName , aParameterType , aDependency ):
+        aPort = self.N.InStreamPort( aParameterName , aParameterType , aDependency )
+        if aPort != None :
+            myPort = StreamPort( aPort , self.N.Verbose )
+            return myPort
+        if self.N.Verbose :
+            print "Error while creating the Port : ",aParameterName
+        return None
+    def OutStreamPort( self , aParameterName , aParameterType , aDependency ):
+        aPort = self.N.OutStreamPort( aParameterName , aParameterType , aDependency )
+        if aPort != None :
+            myPort = StreamPort( aPort , self.N.Verbose )
+            return myPort
+        if self.N.Verbose :
+            print "Error while creating the Port : ",aParameterName
+        return None
+    def GetInPort( self , aParameterName ):
+        aPort = self.N.GetInPort( aParameterName )
+        if aPort != None :
+            myPort = Port( aPort , self.N.Verbose )
+            return myPort
+        if self.N.Verbose :
+            print "Error while creating the Port : ",aParameterName
+        return None
+    def GetOutPort( self , aParameterName ):
+        aPort = self.N.GetOutPort( aParameterName )
+        if aPort != None :
+            myPort = Port( aPort , self.N.Verbose )
+            return myPort
+        if self.N.Verbose :
+            print "Error while creating the Port : ",aParameterName
+        return None
+    def GetInStreamPort( self , aParameterName ):
+        aPort = self.N.GetInStreamPort( aParameterName )
+        if aPort != None :
+            myPort = StreamPort( aPort , self.N.Verbose )
+            return myPort
+        if self.N.Verbose :
+            print "Error while creating the Port : ",aParameterName
+        return None
+    def GetOutStreamPort( self , aParameterName ):
+        aPort = self.N.GetOutStreamPort( aParameterName )
+        if aPort != None :
+            myPort = StreamPort( aPort , self.N.Verbose )
+            return myPort
+        if self.N.Verbose :
+            print "Error while creating the Port : ",aParameterName
+        return None
     def Ports( self ):
         ports = self.N.Ports()
         i = 0
@@ -273,13 +369,34 @@ class CNode:
             ports[ i ] = Port( ports[i] , self.N.Verbose )
             i = i + 1
         return ports
+    def StreamPorts( self ):
+        ports = self.N.StreamPorts()
+        i = 0
+        while i < len( ports ) :
+            ports[ i ] = StreamPort( ports[i] , self.N.Verbose )
+            i = i + 1
+        return ports
+    def AllPorts( self ):
+        allports = self.N.Ports()
+        lenports = len( allports )
+        i = 0
+        while i < lenports :
+            allports[ i ] = Port( allports[i] , self.N.Verbose )
+            i = i + 1
+        ports = self.N.StreamPorts()
+        i = 0
+        while i < len( ports ) :
+            allports.append( StreamPort( ports[i] , self.N.Verbose ) )
+            i = i + 1
+        return allports
     def ListPorts( self , *args ):
         if len( args ) == 0 :
             aName = self.N.Name()
         else :
             aName = args[ 0 ]
-        ports = self.N.Ports()
+        ports = self.AllPorts()
         listofports = ""
+        ilst = 0
         if len( ports ) :
             portsname = ports[ 0 ].Name()
             bs = portsname.find('\\')
@@ -287,9 +404,9 @@ class CNode:
                 portsname1,portsname2 = portsname.split('\\')
                 portsname = portsname1 + portsname2
             if ports[ 0 ].IsInput():
-                listofports = aName + 'In' + portsname
+                listofports = 'I' + aName + portsname
             else :
-                listofports = aName + 'Out' + portsname
+                listofports = 'O' + aName + portsname
             i = 1
             while i < len( ports ) :
                 portsname = ports[ i ].Name()
@@ -298,24 +415,32 @@ class CNode:
                     portsname1,portsname2 = portsname.split('\\')
                     portsname = portsname1 + portsname2
                 if ports[ i ].IsInput():
-                    listofports = listofports + ',' + aName + 'In' + portsname
+                    listofports = listofports + ',' + 'I' + aName + portsname
                 else :
-                    listofports = listofports + ',' + aName + 'Out' + portsname
+                    listofports = listofports + ',' + 'O' + aName + portsname
                 i = i + 1
         print listofports
         if len( ports ) == 1 :
-            listofports = "[" + listofports + "] = " + aName + ".Ports()"
+            listofports = "[" + listofports + "] = " + aName + ".AllPorts()"
         else :
-            listofports = listofports + " = " + aName + ".Ports()"
+            listofports = listofports + " = " + aName + ".AllPorts()"
         return listofports
     def PrintPorts( self ):
-        ports = self.N.Ports()
+        ports = self.AllPorts()
         i = 0
         while i < len( ports ) :
             Direction = "Out"
             if ports[ i ].IsInput() :
                 Direction = "In"
-            print Direction,self.N.Name(),'(',ports[ i ].Name(),ports[ i ].Kind(),ports[ i ].Type(),') = ',ports[ i ].ToString()
+            if ( ports[ i ].IsDataStream() ) & ( self.N.IsStreamGraph() == 0 ) :
+                if ports[ i ].IsInput() :
+                    sts,aKindOfSchema,aKindOfInterpolation,aKindOfExtrapolation = ports[ i ].Params()
+                    print Direction,self.N.Name(),'(',ports[ i ].Name(),ports[ i ].Kind(),ports[ i ].Type(),') = ',ports[ i ].ToString(),ports[ i ].Dependency(),aKindOfSchema,aKindOfInterpolation,aKindOfExtrapolation
+                else :
+                    numberofvalues = ports[ i ].NumberOfValues()
+                    print Direction,self.N.Name(),'(',ports[ i ].Name(),ports[ i ].Kind(),ports[ i ].Type(),') = ',ports[ i ].ToString(),ports[ i ].Dependency(),'NumberOfValues',numberofvalues
+            else :
+                print Direction,self.N.Name(),'(',ports[ i ].Name(),ports[ i ].Kind(),ports[ i ].Type(),') = ',ports[ i ].ToString()
             i = i + 1
     def Links( self ) :
         links = self.N.Links()
@@ -324,14 +449,66 @@ class CNode:
             links[ i ] = Link( links[i] , self.N.Verbose )
             i = i + 1
         return links
+    def StreamLinks( self ) :
+        links = self.N.StreamLinks()
+        i = 0
+        while i < len( links ) :
+            links[ i ] = StreamLink( links[i] , self.N.Verbose )
+            i = i + 1
+        return links
+    def AllLinks( self ) :
+        alllinks = self.N.Links()
+        lenlinks = len( alllinks )
+        i = 0
+        while i < lenlinks :
+            alllinks[ i ] = Link( alllinks[i] , self.N.Verbose )
+            i = i + 1
+        links = self.N.StreamLinks()
+        i = 0
+        while i < len( links ) :
+            alllinks.append( StreamLink( links[i] , self.N.Verbose ) )
+            i = i + 1
+        return alllinks
+    def ListLinks( self , *args ):
+        links = self.AllLinks()
+        if len( links ) :
+            listoflinks = 'L' + links[ 0 ].OutPort().Node().Name()
+            listoflinks = listoflinks + links[ 0 ].OutPort().Name()
+            listoflinks = listoflinks + links[ 0 ].InPort().Node().Name()
+            listoflinks = listoflinks + links[ 0 ].InPort().Name()
+            i = 1
+            while i < len( links ) :
+                listoflinks = listoflinks + ',' + 'L' + links[ i ].OutPort().Node().Name()
+                listoflinks = listoflinks + links[ i ].OutPort().Name()
+                listoflinks = listoflinks + links[ i ].InPort().Node().Name()
+                listoflinks = listoflinks + links[ i ].InPort().Name()
+                i = i + 1
+        print listoflinks
+        if len( args ) == 0 :
+            aName = self.N.Name()
+        else :
+            aName = args[ 0 ]
+        if len( links ) == 1 :
+            listoflinks = "[" + listoflinks + "] = " + aName + ".AllLinks()"
+        else :
+            listoflinks = listoflinks + " = " + aName + ".AllLinks()"
+        return listoflinks
     def PrintLinks( self ):
-        links = self.Links()
+        links = self.AllLinks()
         i = 0
         while i < len( links ) :
             links[i].Print()
             i = i + 1
+    def IsStreamGraph( self ):
+        return self.N.IsStreamGraph()
     def IsGraph( self ):
         return self.N.IsGraph()
+    def IsMacro( self ):
+        return self.N.IsMacro()
+    def IsFlowMacro( self ):
+        return self.N.IsFlowMacro()
+    def IsStreamMacro( self ):
+        return self.N.IsStreamMacro()
     def IsComputing( self ):
         return self.N.IsComputing()
     def IsFactory( self ):
@@ -348,8 +525,12 @@ class CNode:
         return self.N.IsSwitch()
     def IsEndSwitch( self ):
         return self.N.IsEndSwitch()
+    def GraphLevel( self ) :
+        return self.N.GraphLevel()
     def SubGraph( self ):
         return self.N.SubGraph()
+    def SubStreamGraph( self ):
+        return self.N.SubStreamGraph()
     def Thread( self ):
         return self.N.Thread()
     def IsWaiting( self ):
@@ -366,8 +547,6 @@ class CNode:
         return self.N.Control()
     def ControlClear( self ):
         return self.N.ControlClear()
-    def AutoState( self ):
-        return self.N.AutoState()
     def ReadyW( self ):
         return self.N.ReadyW()
     def RunningW( self ):
@@ -376,14 +555,14 @@ class CNode:
         return self.N.DoneW()
     def SuspendedW( self ):
         return self.N.SuspendedW()
-    def ReRun( self ):
-        return self.N.ReRun()
-    def ReStart( self ):
-        return self.N.ReStart()
-    def ReRunAt( self , aNodeName ):
-        return self.N.ReRunAt( aNodeName )
-    def ReStartAt( self , aNodeName ):
-        return self.N.ReStartAt( aNodeName )
+    #def ReRun( self ):
+    #    return self.N.ReRun()
+    #def ReStart( self ):
+    #    return self.N.ReStart()
+    #def ReRunAt( self , aNodeName ):
+    #    return self.N.ReRunAt( aNodeName )
+    #def ReStartAt( self , aNodeName ):
+    #    return self.N.ReStartAt( aNodeName )
     def Ping( self ):
         return self.N.ping()
     def Kill( self ):
@@ -427,6 +606,8 @@ class FNode(CNode):
         return self.N.SetInterfaceName( anInterfaceName )
     def SetContainer( self , aComputer ):
         return self.N.SetContainer( aComputer )
+    def IsCimpl( self ):
+        return self.N.isCimpl
 
 ##########################################################
 class INode(CNode):
@@ -435,13 +616,22 @@ class INode(CNode):
         self.N = aNode
         self.N.Verbose = Verbose
     def Edit( self , FuncName , PyFunc ) :
-        file = '/tmp/' + FuncName + '.py' 
-        i = 0
+        import os
+        import random
+        suf = str(random.randrange(1,10000))
+        file = '/tmp/' + FuncName + '_' + suf + '.py' 
         try :
+            #d = dir ()
+            #print "dir()",d
             fd = os.open( file , os.O_CREAT | os.O_WRONLY | os.O_TRUNC )
+            #d = dir (fd)
+            #print "dir(fd)",d
+            i = 0
             while ( i < len( PyFunc ) ) :
+                print i,'/',len( PyFunc ),PyFunc[ i ]
                 os.write( fd , PyFunc[ i ] + '\n' )
                 i = i + 1
+            os.close( fd )
             edit = '${EDITOR} ' + file
             os.system( edit )
             fd = os.open( file , os.O_RDONLY )
@@ -450,6 +640,7 @@ class INode(CNode):
             while len( line ) :
                 res = res + line
                 line = os.read( fd , 132 )
+            os.close( fd )
             PyFunc = res.splitlines()
             i = 0
             while i < len( PyFunc ) :
@@ -464,10 +655,6 @@ class INode(CNode):
         return self.N.PyFunction()
     def PyFuncName( self ):
         return self.N.PyFuncName()
-    def EPyFunc( self ):
-        PyFunc = self.N.PyFunction()
-        PyFunc = self.Edit( self.N.PyFuncName() , PyFunc )
-        self.N.SetPyFunction( self.N.PyFuncName() , PyFunc )
     def InPort( self , aParameterName , aParameterType ):
         aPort = self.N.InPort( aParameterName ,
                              aParameterType )
@@ -486,6 +673,10 @@ class INode(CNode):
         if self.N.Verbose :
             print "Error while creating the Port : ",aParameterName
         return None
+    def EPyFunc( self ):
+        PyFunc = self.N.PyFunction()
+        PyFunc = self.Edit( self.N.PyFuncName() , PyFunc )
+        self.N.SetPyFunction( self.N.PyFuncName() , PyFunc )
 
 ##########################################################
 class GNode(INode):
@@ -580,7 +771,7 @@ class ESNode(GNode):
 #        self.Parametername = aServicesParameter.Parametername
 
 ##########################################################
-class Graph(INode):
+class Graph(GNode):
 ##########################################################
     def __init__( self , aName ):
         try:
@@ -589,8 +780,14 @@ class Graph(INode):
             try:
                 graph = aName.G.Copy()
             except:
-                graph = None
+                graph = aName
         if graph != None :
+            if graph.IsStreamGraph() :
+                aGraph = graph.ToStreamGraph()
+                if aGraph != None :
+                    graph = StreamGraph( aGraph )
+                else :
+                    print "Graph creation failed"
             self.G = graph
             self.G.Verbose = 1
             self.N = graph
@@ -615,16 +812,30 @@ class Graph(INode):
             print ErrMsg
         return aNode
     def Node( self , aComponent , anInterface , aService ):
-        if SuperVision.Swig :
-            aService = Service_Swig( aService )
+        #if SuperVision.Swig :
+            #aService = Service_Swig( aService )
         return self.FNode( aComponent , anInterface , aService )
+    def FNodeImpl( self , aComponent , anInterface , aService, isCimpl ):
+        NodeComponent = modulecatalog.GetComponent( aComponent )
+        aService = NodeComponent.GetService( anInterface , aService )
+        aNode = self.G.FNode( aComponent , anInterface , aService, isCimpl )
+        if aNode != None :
+            aNode.isCimpl = isCimpl
+            myNode = FNode( aNode , self.G.Verbose )
+            return myNode
+        ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
+        if self.G.Verbose :
+            print ErrMsg
+        return aNode
     def FNode( self , aComponent , anInterface , aService ):
+        # create node with C++ implementation type by default
         NodeComponent = modulecatalog.GetComponent( aComponent )
         aService = NodeComponent.GetService( anInterface , aService )
-        if SuperVision.Swig :
-            aService = Service_Swig( aService )
-        aNode = self.G.FNode( aComponent , anInterface , aService )
+        #if SuperVision.Swig :
+            #aService = Service_Swig( aService )
+        aNode = self.G.FNode( aComponent , anInterface , aService, SALOME_ModuleCatalog.SO )
         if aNode != None :
+            aNode.isCimpl = 1
             myNode = FNode( aNode , self.G.Verbose )
             return myNode
         ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
@@ -669,78 +880,36 @@ class Graph(INode):
         if self.G.Verbose :
             print ErrMsg
         return aNode
-#    def LoopNode( self , aComponent , anInterface , aService , aNodeName ):
-#        NodeComponent = modulecatalog.GetComponent( aComponent )
-#        aService = NodeComponent.GetService( anInterface , aService )
-#        aNode,anEndNode = self.G.LoopNode( aComponent , anInterface , aService , aNodeName )
-#        myNode = aNode
-#        myEndNode = anEndNode
-#        if aNode != None :
-#            myNode = Node( aNode , self.G.Verbose )
-#        if anEndNode != None :
-#            myEndNode = Node( anEndNode , self.G.Verbose )
-#        if ( aNode != None ) & ( anEndNode != None ) :
-#            return myNode,myEndNode
-#        ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
-#        if self.G.Verbose :
-#            print ErrMsg
-#        return aNode,anEndNode
-#    def SwitchNode( self , aComponent , anInterface , aService , aNodeName ):
-#        NodeComponent = modulecatalog.GetComponent( aComponent )
-#        aService = NodeComponent.GetService( anInterface , aService )
-#        aNode,anEndNode = self.G.SwitchNode( aComponent , anInterface , aService , aNodeName )
-#        myNode = aNode
-#        myEndNode = anEndNode
-#        if aNode != None :
-#            myNode = Node( aNode , self.G.Verbose )
-#        if anEndNode != None :
-#            myEndNode = Node( anEndNode , self.G.Verbose )
-#        if ( aNode != None ) & ( anEndNode != None ) :
-#            return myNode,myEndNode
-#        ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
-#        if self.G.Verbose :
-#            print ErrMsg
-#        return aNode,anEndNode
-#    def LNode( self , aNodeName ):
-#        aNode = self.G.LNode( aNodeName )
-#        if aNode != None :
-#            myNode = Node( aNode , self.G.Verbose )
-#            return myNode
-#        ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
-#        if self.G.Verbose :
-#            print ErrMsg
-#        return aNode
-#    def LService( self , aComponent , anInterface , aService ):
-#        NodeComponent = modulecatalog.GetComponent( aComponent )
-#        aService = NodeComponent.GetService( anInterface , aService )
-#        aNode = self.G.LService( aComponent , anInterface , aService )
-#        if aNode != None :
-#            myNode = Node( aNode , self.G.Verbose )
-#            return myNode
-#        ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
-#        if self.G.Verbose :
-#            print ErrMsg
-#        return aNode
-#    def CNode( self , aNodeName ):
-#        aNode = self.G.CNode( aNodeName )
-#        if aNode != None :
-#            myNode = Node( aNode , self.G.Verbose )
-#            return myNode
-#        ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
-#        if self.G.Verbose :
-#            print ErrMsg
-#        return aNode
-#    def CService( self , aComponent , anInterface , aService ):
-#        NodeComponent = modulecatalog.GetComponent( aComponent )
-#        aService = NodeComponent.GetService( anInterface , aService )
-#        aNode = self.G.CService( aComponent , anInterface , aService )
-#        if aNode != None :
-#            myNode = Node( aNode , self.G.Verbose )
-#            return myNode
-#        ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
-#        if self.G.Verbose :
-#            print ErrMsg
-#        return aNode
+    def MNode( self , aGraphXml ):
+        aMNode = self.G.MNode( aGraphXml )
+        if aMNode != None :
+            myMNode = MNode( aMNode , self.G.Verbose )
+            return myMNode
+        ErrMsg = "Failed to create a MNode"
+        if self.G.Verbose :
+            print ErrMsg
+        return aMNode
+    def GraphMNode( self , aGraph ):
+        aGraphMNode = self.G.GraphMNode( aGraph.G )
+        if aGraphMNode != None :
+            myMNode = MNode( aGraphMNode , self.G.Verbose )
+            return myMNode
+        ErrMsg = "Failed to create a MNode"
+        if self.G.Verbose :
+            print ErrMsg
+        return aGraphMNode
+    def FlowObjRef( self ) :
+        aGraph = self.G.FlowObjRef()
+        if aGraph != None :
+            myGraph = Graph( aGraph )
+            return myGraph
+        return aGraph
+    def StreamObjRef( self ) :
+        aGraph = self.G.StreamObjRef()
+        if aGraph != None :
+            myGraph = StreamGraph( aGraph )
+            return myGraph
+        return aGraph
     def PrintService( self , aComponent , anInterface , aService ):
         NodeComponent = modulecatalog.GetComponent( aComponent )
         aService = NodeComponent.GetService( anInterface , aService )
@@ -766,6 +935,8 @@ class Graph(INode):
         if self.G.Verbose :
             print ErrMsg
         return aLink
+    def Messages( self ):
+        return self.G.Messages()
     def Import( self , anXmlFileName ):
         return self.G.Import( anXmlFileName )
     def Export( self , anXmlFileName ):
@@ -786,8 +957,8 @@ class Graph(INode):
         return self.G.LevelMax()
     def ThreadsMax( self ):
         return self.G.ThreadsMax()
-    def GraphsNumber( self ):
-        return self.G.GraphsNumber()
+    def SubGraphsNumber( self ):
+        return self.G.SubGraphsNumber()
     def LevelNodes( self , aLevel ):
         nodes = self.G.LevelNodes( aLevel )
         return self.nodesTuple( nodes )
@@ -895,6 +1066,12 @@ class Graph(INode):
             pynodes.append( GNode( nodes.ESNodes[i] , self.G.Verbose ) )
             i = i + 1
             j = j + 1
+        n = len( nodes.Graphs )
+        i = 0
+        while i < n :
+            pynodes.append( MNode( nodes.Graphs[i] , self.G.Verbose ) )
+            i = i + 1
+            j = j + 1
         return pynodes
     def ListNodes( self , *args ):
         nodes = self.Nodes()
@@ -927,23 +1104,50 @@ class Graph(INode):
         nodes = self.Nodes()
         i = 0
         while i < len( nodes ) :
-            print nodes[i].Name(),nodes[i].Thread(),nodes[i].State(),nodes[i].Control(),nodes[i].AutoState()
+            print nodes[i].Name(),nodes[i].Thread(),nodes[i].State(),nodes[i].Control(),nodes[i]
             i = i + 1
     def GLinks( self ):
         links = self.G.GLinks()
         i = 0
-        while i < len( links ) :
+        linkslen = len( links )
+        #print 'GLinks ',linkslen,'Links'
+        while i < linkslen :
             links[ i ] = Link( links[i] , self.G.Verbose )
             i = i + 1
-        return links
+    def GStreamLinks( self ):
+        streamlinks = self.G.GStreamLinks()
+        i = 0 
+        #print 'GStreamLinks ',len( streamlinks ),'StreamLinks'
+        while i < len( streamlinks ) :
+            streamlinks[ i ] = StreamLink( streamlinks[i] , self.G.Verbose )
+            i = i + 1
+        return streamlinks
+    def GAllLinks( self ) :
+        alllinks = self.G.GLinks()
+        lenlinks = len( alllinks )
+        i = 0
+        while i < lenlinks :
+            alllinks[ i ] = Link( alllinks[i] , self.N.Verbose )
+            i = i + 1
+        links = self.G.StreamLinks()
+        j = 0
+        while j < len(links) :
+            alllinks.append( StreamLink( links[j] , self.N.Verbose ) )
+            i = i + 1
+            j = j + 1
+        return alllinks
     def ListLinks( self , *args ):
-        links = self.G.GLinks()
+        links = self.GAllLinks()
         if len( links ) :
-            listoflinks = links[ 0 ].InPort().Node().Name()
+            listoflinks = 'L' + links[ 0 ].OutPort().Node().Name()
+            listoflinks = listoflinks + links[ 0 ].OutPort().Name()
+            listoflinks = listoflinks + links[ 0 ].InPort().Node().Name()
             listoflinks = listoflinks + links[ 0 ].InPort().Name()
             i = 1
             while i < len( links ) :
-                listoflinks = listoflinks + ',' + links[ i ].InPort().Node().Name()
+                listoflinks = listoflinks + ',' + 'L' + links[ i ].OutPort().Node().Name()
+                listoflinks = listoflinks + links[ i ].OutPort().Name()
+                listoflinks = listoflinks + links[ i ].InPort().Node().Name()
                 listoflinks = listoflinks + links[ i ].InPort().Name()
                 i = i + 1
         print listoflinks
@@ -952,18 +1156,18 @@ class Graph(INode):
         else :
             aName = args[ 0 ]
         if len( links ) == 1 :
-            listoflinks = "[" + listoflinks + "] = " + aName + ".GLinks()"
+            listoflinks = "[" + listoflinks + "] = " + aName + ".GAllLinks()"
         else :
-            listoflinks = listoflinks + " = " + aName + ".GLinks()"
+            listoflinks = listoflinks + " = " + aName + ".GAllLinks()"
         return listoflinks
     def PrintLinks( self ):
-        links = self.G.GLinks()
+        links = self.GAllLinks()
         i = 0
         while i < len( links ) :
-            Link( links[ i ] , self.G.Verbose ).Print()
+            links[ i ].Print()
             i = i + 1
-    def Graphs( self ):
-        graphs = self.G.Graphs()
+    def SubGraphsNodes( self , ):
+        graphs = self.G.SubGraphsNodes()
         outgraphs = graphs
         i = 0
         while i < len( graphs ) :
@@ -980,6 +1184,14 @@ class Graph(INode):
         if self.G.Verbose :
             print ErrMsg
         return aCopy
+    def ToStreamGraph( self ):
+        aGraph = self.G.ToStreamGraph()
+        if aGraph != None :
+            return StreamGraph( aGraph )
+        return None
+    def SubGraphsNodes( self , aSubGraphsNumber ):
+        nodes = self.G.SubGraphsNodes( aSubGraphsNumber )
+        return self.nodesTuple( nodes )
     def Merge( self , aGraph ):
         return self.G.Merge( aGraph.G )
     def Destroy( self ):
@@ -994,6 +1206,81 @@ class GraphE(Graph):
         self.G.Verbose = 1
         self.N = graph
         self.N.Verbose = 1
+    def ToStreamGraph( self ):
+        aGraph = self.G.ToStreamGraph()
+        if aGraph != None :
+            return StreamGraphE( aGraph )
+        return None
+
+##########################################################
+class MNode(Graph):
+##########################################################
+    def __init__( self , aMNode , Verbose ):
+        self.G = aMNode
+        self.G.Verbose = Verbose
+        self.N = aMNode
+        self.N.Verbose = Verbose
+
+##########################################################
+class StreamGraph(Graph):
+##########################################################
+    def __init__( self , aName ):
+        try:
+            graph = SuperVision.StreamGraph( aName )
+        except:
+            try:
+                graph = aName.G.StreamCopy()
+            except:
+                graph = aName
+        if graph != None :
+            self.G = graph
+            self.G.Verbose = 1
+            self.N = graph
+            self.N.Verbose = 1
+        else :
+            print "StreamGraph creation failed"
+    def StreamCopy( self ):
+        aCopy = self.G.StreamCopy()
+        if aCopy != None:
+            myCopy = StreamGraph( aCopy )
+            return myCopy
+        ErrMsg = "Failed to get a Copy of " + self.G.Name()
+        if self.G.Verbose :
+            print ErrMsg
+        return aCopy
+    def StreamLink( self , anOutStreamPort , anInStreamPort ) :
+        aStreamLink = self.G.StreamLink( anOutStreamPort.P , anInStreamPort.P )
+        if aStreamLink!= None:
+            myStreamLink = StreamLink( aStreamLink , self.G.Verbose )
+            return myStreamLink
+        ErrMsg = "Failed to make a StreamLink in " + self.G.Name()
+        if self.G.Verbose :
+            print ErrMsg
+        return aStreamLink        
+    def SetStreamParams( self , Timeout , DataStreamTrace , DeltaTime ):
+        return self.G.SetStreamParams( Timeout , DataStreamTrace , DeltaTime )
+    def StreamParams( self ):
+        Timeout,DataStreamTrace,DeltaTime = self.G.StreamParams()
+        return Timeout,DataStreamTrace,DeltaTime
+    def ToFlowGraph( self ):
+        return self.G.ToFlowGraph()
+    def SubStreamGraphsNumber( self ):
+        return self.G.SubStreamGraphsNumber()
+    def SubStreamGraphsNodes( self , aSubStreamGraphsNumber ):
+        nodes = self.G.SubStreamGraphsNodes( aSubStreamGraphsNumber )
+        return self.nodesTuple( nodes )
+    def StreamMerge( self , aStreamGraph ):
+        return self.G.StreamMerge( aStreamGraph.G )
+
+##########################################################
+class StreamGraphE(StreamGraph):
+##########################################################
+    def __init__( self , aName ):
+        graph = SuperVision.StreamGraphE( aName )
+        self.G = graph
+        self.G.Verbose = 1
+        self.N = graph
+        self.N.Verbose = 1
 
 ##########################################################
 class Value:
@@ -1088,6 +1375,8 @@ class Port:
         return self.P.IsSwitch()
     def IsEndSwitch( self ):
         return self.P.IsEndSwitch()
+    def IsDataStream( self ):
+        return self.P.IsDataStream()
 #    def IsBus( self ):
 #        return self.P.IsBus()
     def Done( self ):
@@ -1109,6 +1398,28 @@ class Port:
     def Destroy( self ):
         self.P.destroy()
 
+##########################################################
+class StreamPort(Port):
+##########################################################
+    def __init__( self , aPort , Verbose ):
+        self.P = aPort
+        self.P.Verbose = Verbose
+    def StreamLink( self ) :
+        return self.P.StreamLink()
+    def Dependency( self ) :
+        return self.P.Dependency()
+    def SetDependency( self , aDependency ) :
+        return self.P.SetDependency( aDependency )
+    def Params( self ) :
+        sts,aKindOfSchema,aKindOfInterpolation,aKindOfExtrapolation = self.P.Params()
+        return sts,aKindOfSchema,aKindOfInterpolation,aKindOfExtrapolation
+    def SetParams( self , aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) :
+        return self.P.SetParams( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation )
+    def NumberOfValues( self ) :
+        return self.P.NumberOfValues()
+    def SetNumberOfValues( self , aNumberOfValues ) :
+        return self.P.SetNumberOfValues( aNumberOfValues )
+
 ##########################################################
 class Link:
 ##########################################################
@@ -1133,8 +1444,17 @@ class Link:
         return None
     def Print( self ):
         anOutPort = self.L.OutPort()
+        anOutPortName = anOutPort.Name()
+        anOutPortKind = anOutPort.Kind()
+        anOutPortValue = anOutPort.ToString()
+        anOutNode = anOutPort.Node()
+        anOutNodeName = anOutNode.Name()
         anInPort = self.L.InPort()
-        print anOutPort.Node().Name(),'(',anOutPort.Name(),' ',anOutPort.Kind(),') =',anOutPort.ToString(),' --> ',anInPort.Node().Name(),'(',anInPort.Name(),')',' ',anInPort.Kind()
+        anInPortName = anInPort.Name()
+        anInPortKind = anInPort.Kind()
+        anInNode = anInPort.Node()
+        anInNodeName = anInNode.Name()
+        print anOutNodeName,'(',anOutPortName,' ',anOutPortKind,') =',anOutPortValue,' --> ',anInNodeName,'(',anInPortName,')',' ',anInPortKind
     def CoordsSize( self ):
         return self.L.CoordsSize()
     def AddCoord( self , index , X , Y ):
@@ -1149,3 +1469,26 @@ class Link:
         self.L.destroy()
 
 
+
+##########################################################
+class StreamLink(Link):
+##########################################################
+    def __init__( self , aLink , Verbose ):
+        self.L = aLink
+        self.L.Verbose = Verbose
+    def OutStreamPort( self ):
+        aPort = self.L.OutStreamPort()
+        if aPort != None :
+            myPort = StreamPort( aPort , self.L.Verbose )
+            return myPort
+        if self.L.Verbose :
+            print "Error while getting the Port : "
+        return None
+    def InStreamPort( self ):
+        aPort = self.L.InStreamPort()
+        if aPort != None :
+            myPort = StreamPort( aPort , self.L.Verbose )
+            return myPort
+        if self.L.Verbose :
+            print "Error while getting the Port : "
+        return None