Salome HOME
*** empty log message ***
[modules/superv.git] / src / Supervision / SuperV.py
index a1028ee8d8a982397f2b765463c304efefefacc3..e791cebfff551bf0f3c5d8a28c7719d4d9312fcb 100644 (file)
@@ -1,4 +1,13 @@
 #! /usr/bin/env python
+#
+#  SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
+#
+#  Copyright (C) 2003  CEA/DEN, EDF R&D
+#
+#
+#
+#  File   : SuperV.py
+#  Module : SUPERV
 
 try :
     from salome import orb
@@ -6,12 +15,14 @@ try :
     from salome import naming_service
     from salome import CORBA
     from salome import sg
+    import SALOME_ModuleCatalog
 except :
     import curses
     from LifeCycleCORBA import *
     from SALOME_NamingServicePy import *
     import SUPERV
     import SUPERV_idl
+    import SALOME_ModuleCatalog
 #    try :
 #        from libSuperVision_Swig import SuperV_Swig
 #        print 'SuperV_Swig imported'
@@ -35,7 +46,7 @@ from types import *
 #    print 'Supervision Component loaded'
                     
 SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV")
-SuperVision.Swig = 0
+#SuperVision.Swig = 0
 
 modulecatalog = naming_service.Resolve("/Kernel/ModulCatalog")
 
@@ -241,6 +252,42 @@ class CNode:
         if self.N.Verbose :
             print ErrMsg
         return anInput
+    def InPort( self , aParameterName , aParameterType ):
+        aPort = self.N.InPort( aParameterName ,
+                             aParameterType )
+        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 OutPort( self , aParameterName , aParameterType ):
+        aPort = self.N.OutPort( aParameterName ,
+                                aParameterType )
+        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 InDataStreamPort( self , aParameterName , aParameterType ):
+        aPort = self.N.InDataStreamPort( aParameterName ,
+                                         aParameterType )
+        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 OutDataStreamPort( self , aParameterName , aParameterType ):
+        aPort = self.N.OutDataStreamPort( aParameterName ,
+                                          aParameterType )
+        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 BusPort( self , InOutParameterName , InOutParameterType ):
 #        sts,inp,outp = self.N.BusPort( InOutParameterName ,
 #                                       InOutParameterType )
@@ -396,6 +443,8 @@ class CNode:
         return self.N.Y()
     def destroy( self ):
         self.N.destroy()
+    def CpuUsed( self ):
+        return self.N.CpuUsed()
 
 ##########################################################
 class FNode(CNode):
@@ -423,13 +472,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 )
@@ -438,6 +496,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 ) :
@@ -456,24 +515,6 @@ class INode(CNode):
         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 )
-        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 OutPort( self , aParameterName , aParameterType ):
-        aPort = self.N.OutPort( aParameterName ,
-                                aParameterType )
-        if aPort != None :
-            myPort = Port( aPort , self.N.Verbose )
-            return myPort
-        if self.N.Verbose :
-            print "Error while creating the Port : ",aParameterName
-        return None
 
 ##########################################################
 class GNode(INode):
@@ -603,14 +644,14 @@ 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 FNode( self , aComponent , anInterface , aService ):
         NodeComponent = modulecatalog.GetComponent( aComponent )
         aService = NodeComponent.GetService( anInterface , aService )
-        if SuperVision.Swig :
-            aService = Service_Swig( aService )
+        #if SuperVision.Swig :
+            #aService = Service_Swig( aService )
         aNode = self.G.FNode( aComponent , anInterface , aService )
         if aNode != None :
             myNode = FNode( aNode , self.G.Verbose )
@@ -1076,6 +1117,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 ):