_graphName("") ,
_nodeName(""),
_studyId(-1),
+ _id(0),
+ _contId(0),
_CanceledThread(false)
{
MESSAGE("Component constructor with instanceName "<< _instanceName);
_graphName("") ,
_nodeName(""),
_studyId(-1),
+ _id(0),
+ _contId(0),
_CanceledThread(false)
{
MESSAGE("Component constructor with instanceName "<< _instanceName);
_orb = CORBA::ORB::_duplicate(orb);
_poa = PortableServer::POA::_duplicate(poa);
_container=Engines::Container::_duplicate(container);
- try
- {
- _contId=_poa->reference_to_id(container);
- }
- catch(PortableServer::POA::WrongAdapter)
- {
- //not created by this poa
- _contId = 0;
- }
const CORBA::String_var ior = _orb->object_to_string(_container);
if(regist)
_myConnexionToRegistry = new RegistryConnexion(0, 0, ior,"theSession", _instanceName.c_str());
MESSAGE("Component destructor");
Engines_Container_i::decInstanceCnt(_interfaceName);
if(_myConnexionToRegistry)delete _myConnexionToRegistry;
+ _myConnexionToRegistry = 0 ;
if(_notifSupplier)delete _notifSupplier;
+ _notifSupplier = 0;
+ if(_id) delete _id;
+ _id=0;
}
//=============================================================================
{
MESSAGE("Engines_Component_i::destroy()");
//SCRUTE(_refcount_value());
-
- if(_myConnexionToRegistry)delete _myConnexionToRegistry;
- _myConnexionToRegistry = 0 ;
- if(_notifSupplier)delete _notifSupplier;
- _notifSupplier = 0;
_poa->deactivate_object(*_id);
- if(_id)
- delete(_id) ;
//SCRUTE(_refcount_value());
_remove_ref();
//SCRUTE(_refcount_value());
Engines_Container_i *Engines_Component_i::GetContainerPtr()
{
- return dynamic_cast<Engines_Container_i*>(_poa->id_to_servant(*_contId)) ;
+ PortableServer::ObjectId_var contId=_poa->reference_to_id(_container);
+ return dynamic_cast<Engines_Container_i*>(_poa->id_to_servant(contId)) ;
}
//=============================================================================
void Engines_Component_i::beginService(const char *serviceName)
{
-#ifndef WIN32
- MESSAGE(pthread_self() << "Send BeginService notification for " <<serviceName
- << endl << "Component instance : " << _instanceName << endl << endl);
-#else
- MESSAGE(pthread_self().p << "Send BeginService notification for " <<serviceName
- << endl << "Component instance : " << _instanceName << endl << endl);
-#endif
std::cerr << "beginService for " << serviceName << " Component instance : " << _instanceName << std::endl;
+
#ifndef WIN32
_ThreadId = pthread_self() ;
#else
perror("pthread_setcancelstate ") ;
exit(0) ;
}
-// MESSAGE(pthread_self() << " Return from BeginService for " << serviceName
-// << " ThreadId " << _ThreadId << " StartUsed " << _StartUsed
-// << " _graphName " << _graphName << " _nodeName " << _nodeName );
- // --- for supervisor : all strings given with setProperties
- // are set in environment
- bool overwrite = true;
+ // --- all strings given with setProperties are set in environment
map<std::string,CORBA::Any>::iterator it;
for (it = _fieldsDict.begin(); it != _fieldsDict.end(); it++)
{
{
const char* value;
(*it).second >>= value;
- // ---todo: replace __GNUC__ test by an autoconf macro AC_CHECK_FUNC.
-#if defined __GNUC__
-// int ret = setenv(cle.c_str(), value, overwrite);
- setenv(cle.c_str(), value, overwrite);
-#else
- //CCRT porting : setenv not defined in stdlib.h
std::string s(cle);
s+='=';
s+=value;
- // char* cast because 1st arg of linux putenv function
- // is not a const char* !
-// int ret=putenv((char *)s.c_str());
putenv((char *)s.c_str());
- //End of CCRT porting
-#endif
MESSAGE("--- setenv: "<<cle<<" = "<< value);
}
}
float cpus=_ThreadCpuUsed/1000.;
std::cerr << "endService for " << serviceName << " Component instance : " << _instanceName ;
std::cerr << " Cpu Used: " << cpus << " (s) " << std::endl;
-#ifndef WIN32
- MESSAGE(pthread_self() << " Send EndService notification for " << serviceName
+ MESSAGE("Send EndService notification for " << serviceName
<< endl << " Component instance : " << _instanceName << " StartUsed "
<< _StartUsed << " _ThreadCpuUsed "<< _ThreadCpuUsed << endl <<endl);
-#else
- MESSAGE(pthread_self().p << " Send EndService notification for " << serviceName
- << endl << " Component instance : " << _instanceName << " StartUsed "
- << _StartUsed << " _ThreadCpuUsed "<< _ThreadCpuUsed << endl <<endl);
-#endif
_ThreadId = 0 ;
}
}
else
{
-#ifndef WIN32
- MESSAGE(pthread_self() << "Killer : ThreadId " << ThreadId
- << " pthread_canceled") ;
-#else
- MESSAGE(pthread_self().p << "Killer : ThreadId " << ThreadId.p
- << " pthread_canceled") ;
-#endif
+ MESSAGE("Killer : ThreadId " << ThreadId << " pthread_canceled") ;
}
}
else
}
else
{
-#ifndef WIN32
- MESSAGE(pthread_self() << "Killer : ThreadId " << ThreadId
- << " pthread_killed(" << signum << ")") ;
-#else
- MESSAGE(pthread_self().p << "Killer : ThreadId " << ThreadId.p
- << " pthread_killed(" << signum << ")") ;
-#endif
+ MESSAGE("Killer : ThreadId " << ThreadId << " pthread_killed(" << signum << ")") ;
}
}
}
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 *
def destroy(self):
MESSAGE( "SALOME_ComponentPy_i::destroy" )
- #id = self._poa.servant_to_id(self)
- #self._poa.deactivate_object(id)
+ 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)
#-------------------------------------------------------------------------
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) "
+
#-------------------------------------------------------------------------
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 ) )