X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FContainer%2FSALOME_ComponentPy.py;h=e02ed1b3086dab6fca1b397dc3c6ffa982a084a3;hb=f2d7bee74f47cd695b4c4b9b0921424837140d0c;hp=642c76e5a4f65e08067e2fb9b7f5a1b5053393e6;hpb=1bd1d38e86c39b13e265f8ff534fc1463c25fef3;p=modules%2Fkernel.git diff --git a/src/Container/SALOME_ComponentPy.py b/src/Container/SALOME_ComponentPy.py index 642c76e5a..e02ed1b30 100755 --- a/src/Container/SALOME_ComponentPy.py +++ b/src/Container/SALOME_ComponentPy.py @@ -1,39 +1,43 @@ #! /usr/bin/env python +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE # -# SALOME Container : implementation of container and engine for Kernel +# Copyright (C) 2003-2007 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, or (at your option) any later version. # -# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# 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 # + +# SALOME Container : implementation of container and engine for Kernel # File : SALOME_ComponentPy.py # Author : Paul RASCLE, EDF # Module : SALOME # $Header$ +## @package SALOME_ComponentPy +# \brief python implementation of component interface for Kernel +# + import os import sys import time import string import signal -from omniORB import CORBA, PortableServer +from omniORB import CORBA, PortableServer, any import Engines, Engines__POA import Registry from Utils_Identity import * @@ -48,14 +52,14 @@ from thread import * _Sleeping = 0 -#define an implementation of the component interface - -class SALOME_ComponentPy_i (Engines__POA.Component): +## define an implementation of the component interface Engines::Component +# +# +class SALOME_ComponentPy_i (Engines__POA.EngineComponent): _orb = None _poa = None _fieldsDict = [] - _studyId = -1 - + #------------------------------------------------------------------------- def __init__ (self, orb, poa, contID, containerName, @@ -72,6 +76,7 @@ class SALOME_ComponentPy_i (Engines__POA.Component): self._myConnexionToRegistry = 0 self._graphName = '' self._nodeName = '' + self._serviceName = '' self._ThreadId = 0 self._StartUsed = 0 self._ThreadCpuUsed = 0 @@ -82,7 +87,9 @@ class SALOME_ComponentPy_i (Engines__POA.Component): myMachine=getShortHostName() Component_path = self._containerName + "/" + self._instanceName MESSAGE( 'SALOME_ComponentPy_i Register' + str( Component_path ) ) - naming_service.Register(self._this(), Component_path) + id_o = poa.activate_object(self) + compo_o = poa.id_to_reference(id_o) + naming_service.Register(compo_o, Component_path) # Add componentinstance to registry obj = naming_service.Resolve('/Registry') @@ -118,17 +125,23 @@ class SALOME_ComponentPy_i (Engines__POA.Component): def _get_instanceName(self): MESSAGE( "SALOME_ComponentPy_i::_get_instanceName" ) return self._instanceName - + + #------------------------------------------------------------------------- + + def _get_interfaceName(self): + MESSAGE( "SALOME_ComponentPy_i::_get_interfaceName" ) + return self._interfaceName + #------------------------------------------------------------------------- def ping(self): MESSAGE( "SALOME_ComponentPy_i::ping() pid " + str(os.getpid()) ) - + #------------------------------------------------------------------------- def setProperties(self, dico): self._fieldsDict = dico - + #------------------------------------------------------------------------- def getProperties(self): @@ -138,16 +151,16 @@ class SALOME_ComponentPy_i (Engines__POA.Component): def destroy(self): MESSAGE( "SALOME_ComponentPy_i::destroy" ) - self._poa.deactivate_object(self) - CORBA.release(self._poa) - + id = self._poa.servant_to_id(self) + self._poa.deactivate_object(id) + return + #------------------------------------------------------------------------- def GetContainerRef(self): MESSAGE( "SALOME_ComponentPy_i::GetContainerRef" ) - corbaObj_ptr = self._poa.id_to_reference(self._contId) - return corbaObj_ptr._narrow(Engines.Container) - + return self._contId._narrow(Engines.Container) + #------------------------------------------------------------------------- def beginService(self , serviceName ): @@ -159,14 +172,22 @@ class SALOME_ComponentPy_i (Engines__POA.Component): self._StartUsed = self.CpuUsed_impl() self._ThreadCpuUsed = 0 self._Executed = 1 + print "beginService for ",serviceName," Component instance : ",self._instanceName MESSAGE( "SALOME_ComponentPy_i::beginService _StartUsed " + str( self._ThreadId ) + " " + str( self._StartUsed ) ) - + for e in self._fieldsDict: + key=e.key + value=any.from_any(e.value) + if isinstance(value,str): + os.environ[key]=value + #------------------------------------------------------------------------- def endService(self , serviceName ): MESSAGE( "Send EndService notification for " + str( self._ThreadId ) + " " + str(serviceName) + " for graph/node " + str(self._graphName) + " " + str(self._nodeName) + " CpuUsed " + str( self.CpuUsed_impl() ) ) MESSAGE( "Component instance : " + str(self._instanceName) ) + print "endService for",serviceName,"Component instance :",self._instanceName,"Cpu Used:",self.CpuUsed_impl()," (s) " + #------------------------------------------------------------------------- @@ -179,7 +200,7 @@ class SALOME_ComponentPy_i (Engines__POA.Component): MESSAGE( "SALOME_ComponentPy_i::Names" + str(GraphName) + str(NodeName) ) self._graphName = GraphName self._nodeName = NodeName - + #------------------------------------------------------------------------- def graphName(self): @@ -204,8 +225,8 @@ class SALOME_ComponentPy_i (Engines__POA.Component): # return 0 #else: # MESSAGE() - return 1 - + return 1 + #------------------------------------------------------------------------- def Kill_impl(self): @@ -261,7 +282,7 @@ class SALOME_ComponentPy_i (Engines__POA.Component): if ( self._ThreadId | self._Executed ) : if self._ThreadId == get_ident() : cpu = time.clock() - self._ThreadCpuUsed = int(cpu) - self._StartUsed + self._ThreadCpuUsed = cpu - self._StartUsed MESSAGE( "SALOME_ComponentPy_i::CpuUsed_impl " + self._serviceName + " " + str( int(cpu) ) + " - " + str( self._StartUsed ) + " = " + str( self._ThreadCpuUsed ) ) return self._ThreadCpuUsed MESSAGE( "SALOME_ComponentPy_i::CpuUsed_impl " + self._serviceName + " " + str( self._ThreadCpuUsed ) ) @@ -270,17 +291,28 @@ class SALOME_ComponentPy_i (Engines__POA.Component): return 0 #------------------------------------------------------------------------- - - def DumpPython(self, theStudy, isPublished, isValidScript): - aBuffer = "def RebuildData(theStudy): pass" - 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() - - #------------------------------------------------------------------------- - - def getStudyId(self): - return self._studyId + + def DumpPython(self, isPublished, isMultiFile): + aBuffer = "\0" + if isMultiFile : + aBuffer = "def RebuildData(): pass\n\0" + return (aBuffer, 1) + + #------------------------------------------------------------------------- + + def hasObjectInfo(self): + return 0 + + #------------------------------------------------------------------------- + + def getObjectInfo(self, entry): + return "" + + #------------------------------------------------------------------------- + + def getVersion(self): + return "" # empty string means "unknown" version + + #------------------------------------------------------------------------- + + pass # end of SALOME_ComponentPy_i