SimulationExecutionContext.cpp
Go to the documentation of this file.
1 #include <rtm/CorbaNaming.h>
2 #if (!defined(OPENRTM_VERSION042) && !defined(OPENRTM_VERSION110)) || defined(OPENRTM_VERSION_TRUNK)
3 #include <rtm/Manager.h>
4 #endif
6 
7 namespace RTC
8 {
9  ReturnCode_t SimulationExecutionContext::start() throw (CORBA::SystemException)
10  {
11 
13  if (ret == RTC_OK){
14  OpenRTM::ExtTrigExecutionContextService_var extTrigExecContext =
15  OpenRTM::ExtTrigExecutionContextService::_narrow(this->getObjRef());
16  m_cg->subscribe(extTrigExecContext, 1.0/get_rate());
17  }
18  return ret;
19  }
20 
21 
22  ReturnCode_t SimulationExecutionContext::stop() throw (CORBA::SystemException)
23  {
24 #if (defined(OPENRTM_VERSION042) || defined(OPENRTM_VERSION110)) && !defined(OPENRTM_VERSION_TRUNK)
25  if (!m_running) return RTC::PRECONDITION_NOT_MET;
26 
27  OpenRTM::ExtTrigExecutionContextService_var extTrigExecContext =
28  OpenRTM::ExtTrigExecutionContextService::_narrow(this->getObjRef());
29  m_cg->unsubscribe(extTrigExecContext);
30 
31  // stop thread
32  m_running = false;
33 
34  // invoke on_shutdown for each comps.
35  std::for_each(m_comps.begin(), m_comps.end(), invoke_on_shutdown());
36 
37  // change EC thread state
38  #ifdef OPENRTM_VERSION_042
39  m_state = false;
40  #else
41  //m_running = false;
42  m_svc = false;
43  #endif
44  return RTC::RTC_OK;
45 #else
47  if (ret == RTC_OK){
48  OpenRTM::ExtTrigExecutionContextService_var extTrigExecContext =
49  OpenRTM::ExtTrigExecutionContextService::_narrow(this->getObjRef());
50  m_cg->unsubscribe(extTrigExecContext);
51  }
52  return RTC::RTC_OK;
53 #endif
54  }
55 
56  OpenHRP::ClockGenerator_var SimulationExecutionContext::m_cg;
57 };
58 
60 {
61  RTC::Properties &props = manager->getConfig();
63  = RTC::CorbaNaming(manager->getORB(), props["corba.nameservers"].c_str());
64  try{
65  CORBA::Object_ptr obj = cn.resolve("ClockGenerator");
66  RTC::SimulationExecutionContext::m_cg = OpenHRP::ClockGenerator::_narrow(obj);
67 
68 #if defined(OPENRTM_VERSION042) || defined(OPENRTM_VERSION110)
69  manager->registerECFactory("SimulationEC",
70  RTC::ECCreate<RTC::SimulationExecutionContext>,
71  RTC::ECDelete<RTC::OpenHRPExecutionContext>);
72 #else
73  RTC::ExecutionContextFactory::
74  instance().addFactory("SimulationEC",
79 #endif
80 
81  }catch(RTC::CorbaNaming::NotFound& ex){
82  std::cerr << "SimultationExecutionContext: can not find ClockGenerator"
83  << std::endl;
84  }
85 }
86 
virtual ExecutionContextService_ptr getObjRef(void)
std::vector< Comp > m_comps
AbstractClass * Creator()
ReturnCode_t
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
CORBA::Object_ptr resolve(const CosNaming::Name &name)
CORBA::ORB_ptr getORB()
static OpenHRP::ClockGenerator_var m_cg
void SimulationECInit(RTC::Manager *manager)
RTC_OK
coil::Properties & getConfig()
CosNaming::NamingContext::NotFound NotFound
virtual ReturnCode_t start(void)
bool registerECFactory(const char *name, ECNewFunc new_func, ECDeleteFunc delete_func)
virtual ReturnCode_t stop(void)
void Destructor(AbstractClass *&obj)
virtual CORBA::Double get_rate(void)


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:05