Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / Supervision / batchmode_SuperV.py
index 397c9c3bc235f6e3654a6186363819ad4962c2bf..ffa73f634eba56d24fbd21eaeb6549909daf93ef 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   : batchmode_SuperV.py
@@ -15,12 +31,16 @@ try :
     from batchmode_salome import naming_service
     from batchmode_salome import CORBA
     from batchmode_salome import myStudy
+    import SALOME_ModuleCatalog
+    import SUPERV
+    import SUPERV_idl
 except :
     import curses
     from LifeCycleCORBA import *
     from SALOME_NamingServicePy import *
     import SUPERV
     import SUPERV_idl
+    import SALOME_ModuleCatalog
     from batchmode_salome import *
 #    try :
 #        from libSuperVision_Swig import SuperV_Swig
@@ -28,25 +48,31 @@ except :
 #    except :
 #        SuperV_Swig = None
     orb = CORBA.ORB_init([''], CORBA.ORB_ID)
-    lcc = LifeCycleCORBA(orb)
+    #lcc = LifeCycleCORBA(orb)
+    while lcc._catalog == None:
+           lcc = LifeCycleCORBA(orb)
     naming_service = SALOME_NamingServicePy_i(orb)
 
+import os
 import re
 from types import *
 import SALOMEDS
+import SALOMEDS_Attributes_idl
 #try :
 #    SuperVision = SuperV_Swig( len(sys.argv) , sys.argv )
 #    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")
+modulecatalog = None
+while modulecatalog == None:
+       modulecatalog = naming_service.Resolve("/Kernel/ModulCatalog")
 
 myBuilder = myStudy.NewBuilder()
 father = myStudy.FindComponent("SUPERV")
@@ -54,12 +80,10 @@ if father is None:
         father = myBuilder.NewComponent("SUPERV")
         A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName");
         FName = A1._narrow(SALOMEDS.AttributeName)
-
-#        FName.SetValue("Supervision")
-       Comp = modulecatalog.GetComponent( "SUPERV" )
-       FName.SetValue( Comp._get_componentusername() )
-
-       A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap");
+        #FName.SetValue("Supervision")
+       Comp = modulecatalog.GetComponent( "SUPERV" )
+       FName.SetValue(Comp._get_componentusername())
+       A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap");
        aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
        aPixmap.SetPixMap( "ICON_OBJBROWSER_Supervision" );
        myBuilder.DefineComponentInstance(father,SuperVision)
@@ -242,6 +266,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 )
@@ -302,6 +331,54 @@ class CNode:
 #        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
@@ -309,20 +386,44 @@ 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('\\')
             if bs != -1 :
                 portsname1,portsname2 = portsname.split('\\')
                 portsname = portsname1 + portsname2
-            listofports = aName + portsname
+            if ports[ 0 ].IsInput():
+                listofports = 'I' + aName + portsname
+            else :
+                listofports = 'O' + aName + portsname
             i = 1
             while i < len( ports ) :
                 portsname = ports[ i ].Name()
@@ -330,22 +431,33 @@ class CNode:
                 if bs != -1 :
                     portsname1,portsname2 = portsname.split('\\')
                     portsname = portsname1 + portsname2
-                listofports = listofports + ',' + aName + portsname
+                if ports[ i ].IsInput():
+                    listofports = listofports + ',' + 'I' + aName + portsname
+                else :
+                    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()
@@ -354,14 +466,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 ):
@@ -378,8 +542,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 ):
@@ -396,8 +564,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 ):
@@ -406,14 +572,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 ):
@@ -436,6 +602,8 @@ class CNode:
         return self.N.Y()
     def destroy( self ):
         self.N.destroy()
+    def CpuUsed( self ):
+        return self.N.CpuUsed()
 
 ##########################################################
 class FNode(CNode):
@@ -444,17 +612,19 @@ class FNode(CNode):
         self.N = aNode
         self.N.Verbose = Verbose
     def GetComponentName( self ):
-        return self.N.ComponentName()
+        return self.N.GetComponentName()
     def GetInterfaceName( self ):
         return self.N._get_interfaceName()
     def GetContainer( self ):
-        return self.N.Container()
+        return self.N.GetContainer()
     def SetComponentName( self , aComponentName ):
         return self.N.SetComponentName( aComponentName )
     def SetInterfaceName( self , anInterfaceName ):
         return self.N.SetInterfaceName( anInterfaceName )
     def SetContainer( self , aComputer ):
         return self.N.SetContainer( aComputer )
+    def IsCimpl( self ):
+        return self.N.isCimpl
 
 ##########################################################
 class INode(CNode):
@@ -463,25 +633,38 @@ class INode(CNode):
         self.N = aNode
         self.N.Verbose = Verbose
     def Edit( self , FuncName , PyFunc ) :
-        file = '/tmp/' + FuncName + '.py' 
-        i = 0
-        fd = os.open( file , os.O_CREAT | os.O_WRONLY | os.O_TRUNC )
-        while ( i < len( PyFunc ) ) :
-            os.write( fd , PyFunc[ i ] + '\n' )
-            i = i + 1
-        edit = '${EDITOR} ' + file
-        os.system( edit )
-        fd = os.open( file , os.O_RDONLY )
-        line = os.read( fd , 132 )
-        res = ''
-        while len( line ) :
-            res = res + line
+        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 )
             line = os.read( fd , 132 )
-        PyFunc = res.splitlines()
-        i = 0
-        while i < len( PyFunc ) :
-            print PyFunc[i]
-            i = i + 1
+            res = ''
+            while len( line ) :
+                res = res + line
+                line = os.read( fd , 132 )
+            os.close( fd )
+            PyFunc = res.splitlines()
+            i = 0
+            while i < len( PyFunc ) :
+                print PyFunc[i]
+                i = i + 1
+        except :
+            print "Open of",file,"failed."
         return PyFunc
     def SetPyFunction( self , FuncName , aPyFunction ):
         return self.N.SetPyFunction( FuncName , aPyFunction )
@@ -489,10 +672,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 )
@@ -511,6 +690,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):
@@ -605,7 +788,7 @@ class ESNode(GNode):
 #        self.Parametername = aServicesParameter.Parametername
 
 ##########################################################
-class Graph(INode):
+class Graph(GNode):
 ##########################################################
     def __init__( self , aName ):
         try:
@@ -614,8 +797,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
@@ -640,16 +829,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
@@ -766,6 +969,36 @@ class Graph(INode):
 #        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 )
@@ -791,6 +1024,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 ):
@@ -811,8 +1046,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 )
@@ -842,6 +1077,10 @@ class Graph(INode):
         sts,aNode,anEvent,aState = self.G.Event()
         self.S = sts
         return sts,aNode,anEvent,aState
+    def EventNoW( self ):
+        sts,aNode,anEvent,aState = self.G.EventNoW()
+        self.S = sts
+        return sts,aNode,anEvent,aState
     def EventW( self ):
         sts,aNode,anEvent,aState = self.G.EventW()
         self.S = sts
@@ -916,6 +1155,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()
@@ -942,29 +1187,56 @@ class Graph(INode):
         i = 0
         while i < n :
             print ' '
-            nodes[i].Print()
+            nodes[ i ].Print()
             i = i + 1
     def PrintThreads( self ):
         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
@@ -973,18 +1245,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 ) :
@@ -1001,6 +1273,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 ):
@@ -1010,7 +1290,97 @@ class Graph(INode):
 class GraphE(Graph):
 ##########################################################
     def __init__( self , aName ):
-        graph = SuperVision.GraphE( aName )
+        try:
+            graph = SuperVision.GraphE( aName )
+        except:
+            try:
+                graph = aName.G.Copy()
+            except:
+                graph = aName
+        if graph != None :
+            if graph.IsStreamGraph() :
+                aGraph = graph.ToStreamGraph()
+                if aGraph != None :
+                    graph = StreamGraphE( aGraph )
+                else :
+                    print "Graph creation failed"
+            self.G = graph
+            self.G.Verbose = 1
+            self.N = graph
+            self.N.Verbose = 1
+        else :
+            print "Graph creation failed"
+    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
@@ -1109,6 +1479,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 ):
@@ -1130,6 +1502,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:
 ##########################################################
@@ -1154,8 +1548,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 ):
@@ -1168,5 +1571,28 @@ class Link:
         return self.L.Coords( index )
     def destroy( self ):
         self.L.destroy()
+    def IsEqual( self, OtherLink ):
+        return self.L.IsEqual( OtherLink.L )
 
-
+##########################################################
+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