3 # SALOME Container : implementation of container and engine for Kernel
5 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
26 # File : SALOME_ComponentPy.py
27 # Author : Paul RASCLE, EDF
34 from omniORB import CORBA, PortableServer
35 import Engines, Engines__POA
37 from Utils_Identity import *
38 from SALOME_NamingServicePy import *
39 from libNOTIFICATION import *
41 from SALOME_utilities import *
43 #=============================================================================
45 #define an implementation of the component interface
47 class SALOME_ComponentPy_i (Engines__POA.Component):
51 #-------------------------------------------------------------------------
53 def __init__ (self, orb, poa, contID, containerName,
54 instanceName, interfaceName, notif):
55 # Notif for notification services
57 MESSAGE( "SALOME_ComponentPy_i::__init__" + " " + str (containerName) + " " + str(instanceName) + " " + str(interfaceName) )
60 self._instanceName = instanceName
61 self._interfaceName = interfaceName
62 self._containerName = containerName
64 self._myConnexionToRegistry = 0
70 naming_service = SALOME_NamingServicePy_i(self._orb)
71 Component_path = "/Containers/" + os.getenv( "HOSTNAME" ) + "/" + self._containerName + "/" + self._interfaceName
72 MESSAGE( 'SALOME_ComponentPy_i Register' + str( Component_path ) )
73 naming_service.Register(self._this(), Component_path)
75 # Add componentinstance to registry
76 obj = naming_service.Resolve('/Registry')
78 MESSAGE( "Registry Reference is invalid" )
80 regist = obj._narrow(Registry.Components)
82 MESSAGE( "Registry Reference is invalid" )
84 ior = orb.object_to_string(contID)
87 lesInfos = Identity(self._instanceName)
88 infos = Registry.Infos(lesInfos._name,
94 int(lesInfos._tc_start),
100 res = regist.add(infos)
102 self._notifSupplier = NOTIFICATION_Supplier_Swig(instanceName, notif)
104 #-------------------------------------------------------------------------
106 def _get_instanceName(self):
107 MESSAGE( "SALOME_ComponentPy_i::_get_instanceName" )
108 return self._instanceName
110 #-------------------------------------------------------------------------
113 MESSAGE( "SALOME_ComponentPy_i::ping" )
115 #-------------------------------------------------------------------------
118 MESSAGE( "SALOME_ComponentPy_i::destroy" )
119 poa.deactivate_object(self)
122 #-------------------------------------------------------------------------
124 def GetContainerRef(self):
125 MESSAGE( "SALOME_ComponentPy_i::GetContainerRef" )
127 #-------------------------------------------------------------------------
129 def beginService(self , serviceName ):
130 MESSAGE( "Send BeginService notification for " + str(serviceName) + "for graph/node" + str(self._graphName) + str(self._nodeName) )
131 MESSAGE( "Component instance : " + str ( self._instanceName ) )
133 self._StartUsed = self.CpuUsed_impl()
135 #-------------------------------------------------------------------------
137 def endService(self , serviceName ):
138 MESSAGE( "Send EndService notification for " + str(serviceName) + "for graph/node" + str(self._graphName) + str(self._nodeName) )
139 MESSAGE( "Component instance : " + str(self._instanceName) )
141 #-------------------------------------------------------------------------
143 def sendMessage(self , event_type , message ):
144 self._notifSupplier.Send(self.graphName(), self.nodeName(), event_type, message)
146 #-------------------------------------------------------------------------
148 def Names(self , GraphName , NodeName ):
149 MESSAGE( "SALOME_ComponentPy_i::Names" + str(GraphName) + str(NodeName) )
150 self._graphName = GraphName
151 self._nodeName = NodeName
153 #-------------------------------------------------------------------------
156 return self._graphName
158 #-------------------------------------------------------------------------
161 return self._nodeName
163 #-------------------------------------------------------------------------
166 MESSAGE( "SALOME_ComponentPy_i::Kill not yet implemented" )
168 #-------------------------------------------------------------------------
171 MESSAGE( "SALOME_ComponentPy_i::Stop not yet implemented" )
173 #-------------------------------------------------------------------------
176 MESSAGE( "SALOME_ComponentPy_i::Suspend not yet implemented" )
178 #-------------------------------------------------------------------------
181 MESSAGE( "SALOME_ComponentPy_i::Resume not yet implemented" )
183 #-------------------------------------------------------------------------
185 def CpuUsed_impl(self):
187 cpuL = int(cpu) - self._StartUsed
188 print "SALOME_ComponentPy_i::CpuUsed_impl ",cpuL,type(cpuL)
191 #-------------------------------------------------------------------------