]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Fix for bug PAL9773 : SALOME_ComponentPy.py not synchronized with latest LifeCycleCOR...
authormkr <mkr@opencascade.com>
Thu, 25 Aug 2005 04:37:08 +0000 (04:37 +0000)
committermkr <mkr@opencascade.com>
Thu, 25 Aug 2005 04:37:08 +0000 (04:37 +0000)
src/Container/Component_i.cxx
src/Container/SALOME_ComponentPy.py

index 2d3ef4c522be41dcad242eff337a72beee78beac..e40508347f5cec004067ff8f13d374e7bfabc316 100644 (file)
@@ -405,6 +405,7 @@ bool Engines_Component_i::Suspend_impl()
 #else
        RetVal = Killer( *_ThreadId ,SIGINT ) ;
 #endif
+       //if ( RetVal ) _Sleeping = true;
 
       }
     }
index 708bcb2c41b77f689ec9ce1336106225a92284b8..6ae1812b469c824594e9ae767ab554ba7a150863 100755 (executable)
@@ -32,6 +32,7 @@ import os
 import sys
 import time
 import string
+import signal
 from omniORB import CORBA, PortableServer
 import Engines, Engines__POA
 import Registry
@@ -45,6 +46,8 @@ from thread import *
 
 #=============================================================================
 
+_Sleeping = 0
+
 #define an implementation of the component interface
 
 class SALOME_ComponentPy_i (Engines__POA.Component):
@@ -73,6 +76,7 @@ class SALOME_ComponentPy_i (Engines__POA.Component):
         self._StartUsed = 0
         self._ThreadCpuUsed = 0
         self._Executed = 0
+        self._contId = contID
 
         naming_service = SALOME_NamingServicePy_i(self._orb)
         myMachine=getShortHostName()
@@ -118,7 +122,7 @@ class SALOME_ComponentPy_i (Engines__POA.Component):
     #-------------------------------------------------------------------------
 
     def ping(self):
-        MESSAGE(  "SALOME_ComponentPy_i::ping" )
+        MESSAGE(  "SALOME_ComponentPy_i::ping() pid " + str(os.getpid()) )
         
     #-------------------------------------------------------------------------
 
@@ -134,14 +138,16 @@ class SALOME_ComponentPy_i (Engines__POA.Component):
 
     def destroy(self):
         MESSAGE(  "SALOME_ComponentPy_i::destroy" )
-        poa.deactivate_object(self)
-        CORBA.release(_poa)
+        self._poa.deactivate_object(self)
+        CORBA.release(self._poa)
         
     #-------------------------------------------------------------------------
 
     def GetContainerRef(self):
         MESSAGE(  "SALOME_ComponentPy_i::GetContainerRef" )
-        
+        corbaObj_ptr = self._poa.id_to_reference(self._contId)
+        return corbaObj_ptr._narrow(Engines.Container)
+                
     #-------------------------------------------------------------------------
 
     def beginService(self , serviceName ):
@@ -186,23 +192,68 @@ class SALOME_ComponentPy_i (Engines__POA.Component):
 
     #-------------------------------------------------------------------------
 
-    def Kill(self):
-        MESSAGE(  "SALOME_ComponentPy_i::Kill not yet implemented" )
+    def Killer(self, ThreadId, signum):
+        #if ThreadId > 0:
+            #if signum == 0:
+                #if pthread_cancel(ThreadId): <- from C++
+                #   return 0
+                #else:
+                #   MESSAGE()
+            #else:
+                #if pthread_kill(ThreadId): <- from C++
+                #   return 0
+                #else:
+                #   MESSAGE()
+        return 1                 
+    
+    #-------------------------------------------------------------------------
+
+    def Kill_impl(self):
+        MESSAGE(  "SALOME_ComponentPy_i::Kill_impl" )
+        RetVal = 0
+        if self._ThreadId > 0 & self._ThreadId != get_ident():
+            RetVal = Killer(self._ThreadId,0)
+            self._ThreadId = 0
+        return RetVal
 
     #-------------------------------------------------------------------------
 
-    def Stop(self):
-        MESSAGE(  "SALOME_ComponentPy_i::Stop not yet implemented" )
+    def Stop_impl(self):
+        MESSAGE(  "SALOME_ComponentPy_i::Stop_impl" )
+        RetVal = 0
+        if self._ThreadId > 0 & self._ThreadId != get_ident():
+            RetVal = Killer(self._ThreadId,0)
+            self._ThreadId = 0
+        return RetVal
 
     #-------------------------------------------------------------------------
 
-    def Suspend(self):
-        MESSAGE(  "SALOME_ComponentPy_i::Suspend not yet implemented" )
+    def Suspend_impl(self):
+        MESSAGE(  "SALOME_ComponentPy_i::Suspend_impl" )
+        global _Sleeping
+        RetVal = 0
+        if self._ThreadId > 0 & self._ThreadId != get_ident():
+            if _Sleeping > 0:
+                return 0
+            else:
+                RetVal = Killer(self._ThreadId, signal.SIGINT)
+                if RetVal > 0:
+                    _Sleeping = 1
+        return RetVal
 
     #-------------------------------------------------------------------------
 
-    def Resume(self):
-        MESSAGE(  "SALOME_ComponentPy_i::Resume not yet implemented" )
+    def Resume_impl(self):
+        MESSAGE(  "SALOME_ComponentPy_i::Resume_impl" )
+        global _Sleeping
+        RetVal = 0
+        if self._ThreadId > 0 & self._ThreadId != get_ident():
+            if _Sleeping > 0:
+                _Sleeping = 0
+                RetVal = 1
+            else:
+                RetVal = 0
+        return RetVal
 
     #-------------------------------------------------------------------------
 
@@ -220,9 +271,14 @@ class SALOME_ComponentPy_i (Engines__POA.Component):
 
     #-------------------------------------------------------------------------
    
-    def DumpPython(self, theStudy, isPublished):
+    def DumpPython(self, theStudy, isPublished, isValidScript):
         aBuffer = "def RebuildData(theStudy): pass"
-       return (aBuffer, 1) 
+        aBufferSize = len(aBuffer) + 1
+        anOctetBuf = aBuffer._narrow(CORBA.Octet)
+        aTMPFile = Engines.TMPFile(aBufferSize, aBufferSize, anOctetBuf._this(), 1)
+        isValidScript = 1
+       #return (aBuffer, 1)
+        return aTMPFile._this()
 
     #-------------------------------------------------------------------------