corba/RTObject.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
19 #include <assert.h>
20 #include "rtm/RTObject.h"
21 
22 namespace RTC
23 {
24 
25  RTObject_impl::RTObject_impl(RTC::Interface::RTObjectInterface* rtobj)
26  : m_rtobj(rtobj)
27  {
28  }
29 
31  {
32  }
33 
34  //============================================================
35  // RTC::LightweightRTObject
36  //============================================================
38  throw (CORBA::SystemException)
39  {
40  return m_rtobj->initialize();
41  }
42 
44  throw (CORBA::SystemException)
45  {
46  return m_rtobj->finalize();
47  }
48 
50  throw (CORBA::SystemException)
51  {
52  return m_rtobj->exit();
53  }
54 
55  CORBA::Boolean
56  RTObject_impl::is_alive(ExecutionContext_ptr exec_context)
57  throw (CORBA::SystemException)
58  {
59  DObjectRegistry doreg;
60  doreg = Manager::instance().DObjectRegistry();
61 
62  if (doreg.isLocal(exec_context))
63  {
64  ExecutionContextInterface& ec(doreg.getLocalObject(exec_context));
65  }
66  else
67  {
68  ExecutionContextInterface& ec(exec_context);
69  }
70 
71  return m_rtobj->is_alive(ec);
72  }
73 
81  ExecutionContext_ptr
83  throw (CORBA::SystemException)
84  {
85  ExecutionContextInterface& ecif(m_rtobj->get_context(ec_id));
86 
87  return Local2Corba(ecif);
88  }
89 
98  throw (CORBA::SystemException)
99  {
100  ExecutionContextInterfaceList& eclist(m_rtobj->get_owned_contexts());
101 
102  ExecutionContextList_var retval;
103  retval = new ExecutionContextList();
104  CORBA_SeqUtil::for_each(eclist, ec_copy(retval));
105 
106  return retval._retn();
107  }
108 
117  throw (CORBA::SystemException)
118  {
119  ExecutionContextInterfaceList& eclist(m_rtobj->get_participating_contexts());
120  ExecutionContextList_var retval;
121  retval = new ExecutionContextList();
122  CORBA_SeqUtil::for_each(eclist, ec_copy(retval));
123 
124  return retval._retn();
125  }
126 
127 
136  RTObject_impl::get_context_handle(ExecutionContext_ptr cxt)
137  throw (CORBA::SystemException)
138  {
139  ExecutionContextInterface ecif(Corba2Local(cxt));
140  return m_rtobj->get_context_handle(ecif);
141  }
142 
143 
151  UniqueId RTObject_impl::attach_context(ExecutionContext_ptr exec_context)
152  throw (CORBA::SystemException)
153  {
154  return m_rtobj->attach_context(ExecutionContext_ptr exec_context);
155  }
156 
165  throw (CORBA::SystemException)
166  {
167  return m_rtobj->detach_context(UniqueId ec_id);
168  }
169 
170  //============================================================
171  // RTC::RTObject
172  //============================================================
173 
181  ComponentProfile* RTObject_impl::get_component_profile()
182  throw (CORBA::SystemException)
183  {
184  return m_rtobj->RTObject;
185  }
186 
195  throw (CORBA::SystemException)
196  {
197  return m_rtobj->get_ports();
198  }
199 
200  //============================================================
201  // RTC::ComponentAction
202  //============================================================
211  throw (CORBA::SystemException)
212  {
213  return m_rtobj->on_initialize();
214  }
215 
224  throw (CORBA::SystemException)
225  {
226  return m_rtobj->on_finalize();
227  }
228 
237  throw (CORBA::SystemException)
238  {
239  return m_rtobj->on_startup(UniqueId ec_id);
240  }
241 
250  throw (CORBA::SystemException)
251  {
252  return m_rtobj->on_shutdown(UniqueId ec_id);
253  }
254 
263  throw (CORBA::SystemException)
264  {
265  return m_rtobj->on_activated(UniqueId ec_id);
266  }
267 
276  throw (CORBA::SystemException)
277  {
278  return m_rtobj->on_deactivated(UniqueId ec_id);
279  }
280 
289  throw (CORBA::SystemException)
290  {
291  return m_rtobj->on_aborting(UniqueId ec_id);
292  }
293 
302  throw (CORBA::SystemException)
303  {
304  return m_rtobj->on_error(UniqueId ec_id);
305  }
306 
315  throw (CORBA::SystemException)
316  {
317  return m_rtobj->on_reset(UniqueId ec_id);
318  }
319 
329  throw (CORBA::SystemException)
330  {
331  return m_rtobj->on_execute(UniqueId ec_id);
332  }
333 
343  throw (CORBA::SystemException)
344  {
345  return m_rtobj->on_state_update(UniqueId ec_id);
346  }
347 
356  throw (CORBA::SystemException)
357  {
358  return m_rtobj->on_rate_changed(UniqueId ec_id);
359  }
360 
361  //============================================================
362  // SDO interfaces
363  //============================================================
371  SDOPackage::OrganizationList* RTObject_impl::get_owned_organizations()
372  throw (CORBA::SystemException, SDOPackage::NotAvailable)
373  {
374 
375  }
376 
377  // SDOPackage::SDO
386  throw (CORBA::SystemException,
387  SDOPackage::NotAvailable, SDOPackage::InternalError)
388  {
389 
390  }
391 
400  throw (CORBA::SystemException,
401  SDOPackage::NotAvailable, SDOPackage::InternalError)
402  {
403 
404  }
405 
413  SDOPackage::DeviceProfile* RTObject_impl::get_device_profile()
414  throw (CORBA::SystemException,
415  SDOPackage::NotAvailable, SDOPackage::InternalError)
416  {
417  try
418  {
419  SDOPackage::DeviceProfile_var dprofile;
420  dprofile = new SDOPackage::DeviceProfile();
421  dprofile->device_type = CORBA::string_dup(m_profile.category);
422  dprofile->manufacturer = CORBA::string_dup(m_profile.vendor);
423  dprofile->model = CORBA::string_dup(m_profile.type_name);
424  dprofile->version = CORBA::string_dup(m_profile.version);
425  dprofile->properties = m_profile.properties;
426  return dprofile._retn();
427  }
428  catch (...)
429  {
430  throw SDOPackage::InternalError("get_device_profile()");
431  }
432  return new SDOPackage::DeviceProfile();
433  }
434 
442  SDOPackage::ServiceProfileList* RTObject_impl::get_service_profiles()
443  throw (CORBA::SystemException,
444  SDOPackage::NotAvailable, SDOPackage::InternalError)
445  {
446  try
447  {
448  SDOPackage::ServiceProfileList_var sprofiles;
449  sprofiles = new SDOPackage::ServiceProfileList(m_sdoSvcProfiles);
450  return sprofiles._retn();
451  }
452  catch (...)
453  {
454  throw SDOPackage::InternalError("get_service_profiles()");
455  }
456  return new SDOPackage::ServiceProfileList();
457  }
458 
466  SDOPackage::ServiceProfile*
467  RTObject_impl::get_service_profile(const char* id)
468  throw (CORBA::SystemException,
469  SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
470  SDOPackage::InternalError)
471  {
472  if (!id)
473  throw SDOPackage::InvalidParameter("get_service_profile(): Empty name.");
474 
475  try
476  {
477  CORBA::Long index;
478  index = CORBA_SeqUtil::find(m_sdoSvcProfiles, svc_name(id));
479 
480  SDOPackage::ServiceProfile_var sprofile;
481  sprofile = new SDOPackage::ServiceProfile(m_sdoSvcProfiles[index]);
482  return sprofile._retn();
483  }
484  catch (...)
485  {
486  throw SDOPackage::InternalError("get_service_profile()");
487  }
488  return new SDOPackage::ServiceProfile();
489  }
490 
498  SDOPackage::SDOService_ptr RTObject_impl::get_sdo_service(const char* id)
499  throw (CORBA::SystemException,
500  SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
501  SDOPackage::InternalError)
502  {
503  if (!id)
504  throw SDOPackage::InvalidParameter("get_service(): Empty name.");
505 
506  try
507  {
508  CORBA::Long index;
509  index = CORBA_SeqUtil::find(m_sdoSvcProfiles, svc_name(id));
510 
511  SDOPackage::SDOService_var service;
512  service = m_sdoSvcProfiles[index].service;
513  return service._retn();
514  }
515  catch (...)
516  {
517  throw SDOPackage::InternalError("get_service()");
518  }
519  return SDOPackage::SDOService::_nil();
520  }
521 
529  SDOPackage::Configuration_ptr RTObject_impl::get_configuration()
530  throw (CORBA::SystemException,
531  SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
532  SDOPackage::InternalError)
533  {
534  if (m_pSdoConfig == NULL)
535  throw SDOPackage::InterfaceNotImplemented();
536  try
537  {
538  SDOPackage::Configuration_var config;
539  config = m_pSdoConfig;
540  return config._retn();
541  }
542  catch (...)
543  {
544  SDOPackage::InternalError("get_configuration()");
545  }
546  return SDOPackage::Configuration::_nil();
547  }
548 
556  SDOPackage::Monitoring_ptr RTObject_impl::get_monitoring()
557  throw (CORBA::SystemException,
558  SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
559  SDOPackage::InternalError)
560  {
561  throw SDOPackage::InterfaceNotImplemented();
562  return SDOPackage::Monitoring::_nil();
563  }
564 
572  SDOPackage::OrganizationList* RTObject_impl::get_organizations()
573  throw (CORBA::SystemException,
574  SDOPackage::NotAvailable, SDOPackage::InternalError)
575  {
576  try
577  {
578  SDOPackage::OrganizationList_var org;
579  org = new SDOPackage::OrganizationList(m_sdoOrganizations);
580  return org._retn();
581  }
582  catch (...)
583  {
584  throw SDOPackage::InternalError("get_organizations()");
585  }
586  return new SDOPackage::OrganizationList(0);
587  }
588 
597  throw (CORBA::SystemException,
598  SDOPackage::NotAvailable, SDOPackage::InternalError)
599  {
600  try
601  {
602  NVList_var status;
603  status = new NVList(m_sdoStatus);
604  return status._retn();
605  }
606  catch (...)
607  {
608  SDOPackage::InternalError("get_status_list()");
609  }
610  return new SDOPackage::NVList(0);
611  }
612 
620  CORBA::Any* RTObject_impl::get_status(const char* name)
621  throw (CORBA::SystemException,
622  SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
623  SDOPackage::InternalError)
624  {
625  CORBA::Long index;
626  index = CORBA_SeqUtil::find(m_sdoStatus, nv_name(name));
627  if (index < 0)
628  throw SDOPackage::InvalidParameter("get_status(): Not found");
629  try
630  {
631  CORBA::Any_var status;
632  status = new CORBA::Any(m_sdoStatus[index].value);
633  return status._retn();
634  }
635  catch (...)
636  {
637  throw SDOPackage::InternalError("get_status()");
638  }
639  return new CORBA::Any();
640  }
641 
642  //============================================================
643  // Local methods
644  //============================================================
652  void RTObject_impl::setInstanceName(const char* instance_name)
653  {
654  m_properties["instance_name"] = instance_name;
655  m_profile.instance_name = m_properties["instance_name"].c_str();
656  }
657 
665  std::vector<std::string> RTObject_impl::getNamingNames()
666  {
667  return split(m_properties["naming.names"], ",");
668  }
669 
677  void RTObject_impl::setObjRef(const RTObject_ptr rtobj)
678  {
679  m_objref = rtobj;
680  }
681 
689  RTObject_ptr RTObject_impl::getObjRef() const
690  {
691  return RTC::RTObject::_duplicate(m_objref);
692  }
693 
702  {
703  m_properties << prop;
704  m_profile.instance_name = m_properties["instance_name"].c_str();
705  m_profile.type_name = m_properties["type_name"].c_str();
706  m_profile.description = m_properties["description"].c_str();
707  m_profile.version = m_properties["version"].c_str();
708  m_profile.vendor = m_properties["vendor"].c_str();
709  m_profile.category = m_properties["category"].c_str();
710  }
711 
720  {
721  return m_properties;
722  }
723 
731  void RTObject_impl::updateParameters(const char* config_set)
732  {
733  m_configsets.update(config_set);
734  return;
735  }
736 
745  {
747  port.setOwner(this->getObjRef());
748  return;
749  }
750 
759  {
760  m_portAdmin.deletePort(port);
761  return;
762  }
763 
771  void RTObject_impl::deletePortByName(const char* port_name)
772  {
773  m_portAdmin.deletePortByName(port_name);
774  return;
775  }
776 
785  {
787  }
788 
797  {
798  try
799  {
800  finalizePorts();
801  m_pPOA->deactivate_object(*m_pPOA->servant_to_id(m_pSdoConfigImpl));
802  m_pPOA->deactivate_object(*m_pPOA->servant_to_id(this));
803  }
804  catch (...)
805  {
806  ;
807  }
808 
809  if (m_pManager != NULL)
810  {
812  }
813  }
814 };
ComponentProfile m_profile
ComponentProfile.
Definition: RTObject.h:4588
PortAdmin m_portAdmin
List of Port Object reference.
Definition: RTObject.h:4606
virtual ReturnCode_t on_shutdown(UniqueId exec_handle)
[ComponentAction CORBA interface] Shutdown RTC
Definition: RTObject.cpp:861
virtual SDOPackage::ServiceProfileList * get_service_profiles()
[SDO interface] Get SDO ServiceProfile
Definition: RTObject.cpp:1203
virtual ComponentProfile * get_component_profile()
[RTObject CORBA interface] Get RTC&#39;s profile
Definition: RTObject.cpp:698
EXECUTION_HANDLE_TYPE_NATIVE ExecutionContextHandle_t
Definition: IRTC.h:63
virtual ExecutionContextHandle_t get_context_handle(ExecutionContext_ptr cxt)
[CORBA interface] Return a handle of a ExecutionContext
Definition: RTObject.cpp:557
virtual char * get_sdo_id()
[SDO interface] Get the SDO ID
Definition: RTObject.cpp:1124
RT-Component.
virtual SDOPackage::Monitoring_ptr get_monitoring()
[SDO interface] Get Monitoring object
Definition: RTObject.cpp:1336
void finalizePorts()
Deactivate all Ports and unregister them.
Definition: PortAdmin.cpp:368
virtual ReturnCode_t initialize()
[CORBA interface] Initialize the RTC that realizes this interface.
Definition: RTObject.cpp:310
SDOPackage::Configuration_impl * m_pSdoConfigImpl
The pointer to the SDO Configuration Object.
Definition: RTObject.h:4549
virtual ReturnCode_t on_activated(UniqueId exec_handle)
[ComponentAction CORBA interface] Activate RTC
Definition: RTObject.cpp:886
virtual ReturnCode_t on_startup(UniqueId exec_handle)
[ComponentAction CORBA interface] Startup RTC
Definition: RTObject.cpp:836
ReturnCode_t detach_context(UniqueId exec_handle)
[CORBA interface] Detach ExecutionContext.
Definition: RTObject.cpp:660
void updateParameters(const char *config_set)
Update configuration parameters (by ID)
Definition: RTObject.cpp:1538
virtual SDOPackage::OrganizationList * get_owned_organizations()
[SDO interface] Get Organization list
Definition: RTObject.cpp:1098
SDOPackage::OrganizationList m_sdoOrganizations
SDO organization.
Definition: RTObject.h:4567
ReturnCode_t
Definition: doil.h:53
std::vector< std::pair< std::string, std::string > > NVList
Definition: IRTC.h:67
std::vector< std::string > getNamingNames()
[local interface] Get Naming Server information
Definition: RTObject.cpp:1457
SDOPackage::Configuration_var m_pSdoConfig
The pointer to the SDO Configuration Interface.
Definition: RTObject.h:4558
virtual ~RTObject_impl(void)
Virtual destructor.
Definition: RTObject.cpp:111
vstring split(const std::string &input, const std::string &delimiter, bool ignore_empty)
Split string by delimiter.
Definition: stringutil.cpp:341
void registerPort(PortBase &port)
[local interface] Register Port
Definition: RTObject.cpp:1552
virtual ExecutionContextList * get_participating_contexts()
[CORBA interface] Get participating ExecutionContextList.
Definition: RTObject.cpp:536
virtual PortServiceList * get_ports()
[RTObject CORBA interface] Get Ports
Definition: RTObject.cpp:748
Manager * m_pManager
Manager object.
Definition: RTObject.h:4493
coil::Properties & getProperties()
[local interface] Get RTC property
Definition: RTObject.cpp:1525
virtual SDOPackage::Configuration_ptr get_configuration()
[SDO interface] Get Configuration object
Definition: RTObject.cpp:1302
static Manager & instance()
Get instance of the manager.
Definition: Manager.cpp:140
UniqueId attach_context(ExecutionContext_ptr exec_context)
[CORBA interface] Attach ExecutionContext
Definition: RTObject.cpp:583
virtual ReturnCode_t on_reset(UniqueId exec_handle)
[ComponentAction CORBA interface] Resetting RTC
Definition: RTObject.cpp:990
SDOPackage::NVList m_sdoStatus
SDO Status.
Definition: RTObject.h:4576
PortableServer::POA_var m_pPOA
The pointer to the POA.
Definition: RTObject.h:4511
virtual ReturnCode_t on_finalize()
[ComponentAction CORBA interface] Finalize RTC
Definition: RTObject.cpp:811
SDO Package.
virtual ReturnCode_t finalize()
[CORBA interface] Finalize the RTC for destruction
Definition: RTObject.cpp:357
std::vector< ExecutionContext * > ExecutionContextList
Definition: IRTC.h:69
void setObjRef(const RTObject_ptr rtobj)
[local interface] Set the object reference
Definition: RTObject.cpp:1470
void update(void)
Update the values of configuration parameters (Active configuration set)
Definition: ConfigAdmin.cpp:64
ExecutionContextHandle_t UniqueId
string service
Definition: README_gen.py:139
virtual ReturnCode_t on_deactivated(UniqueId exec_handle)
[ComponentAction CORBA interface] Deactivate RTC
Definition: RTObject.cpp:913
RTObject_impl(Manager *manager)
Constructor.
Definition: RTObject.cpp:60
void registerPort(PortBase &port)
Regsiter the Port.
Definition: PortAdmin.cpp:239
CORBA::Long find(const CorbaSequence &seq, Functor f)
Return the index of CORBA sequence element that functor matches.
list index
Definition: rtimages.py:10
virtual ExecutionContext_ptr get_context(UniqueId exec_handle)
[CORBA interface] Get ExecutionContext.
Definition: RTObject.cpp:461
ConfigAdmin m_configsets
Configuration Administrator Object.
Definition: RTObject.h:4696
virtual ReturnCode_t exit()
[CORBA interface]top the RTC&#39;s execution context(s) and finalize it along with its contents...
Definition: RTObject.cpp:394
virtual SDOPackage::NVList * get_status_list()
[SDO interface] Get SDO Status list
Definition: RTObject.cpp:1379
void deletePort(PortBase &port)
[local interface] Unregister Port
Definition: RTObject.cpp:1764
virtual SDOPackage::DeviceProfile * get_device_profile()
[SDO interface] Get SDO DeviceProfile list
Definition: RTObject.cpp:1174
prop
Organization::get_organization_property ();.
virtual ExecutionContextList * get_owned_contexts()
[CORBA interface] Get ExecutionContextList.
Definition: RTObject.cpp:499
void shutdown()
Shutdown RTC.
Definition: RTObject.cpp:2444
std::vector< IPortService * > PortServiceList
Definition: IPortService.h:39
virtual ReturnCode_t on_error(UniqueId exec_handle)
[ComponentAction CORBA interface] Error Processing of RTC
Definition: RTObject.cpp:964
void deletePortByName(const char *port_name)
Unregister the Port&#39;s registration by its name.
Definition: PortAdmin.cpp:320
virtual ReturnCode_t on_initialize()
[RTObject CORBA interface] Get ExecutionContextAdmin
Definition: RTObject.cpp:775
void deletePortByName(const char *port_name)
[local interface] Delete Port by specifying its name
Definition: RTObject.cpp:1793
virtual SDOPackage::SDOService_ptr get_sdo_service(const char *id)
[SDO interface] Get specified SDO Service&#39;s reference
Definition: RTObject.cpp:1268
void setInstanceName(const char *instance_name)
[local interface] Set instance name
Definition: RTObject.cpp:1437
void cleanupComponent(RTObject_impl *comp)
Unregister RT-Components.
Definition: Manager.cpp:1524
virtual ReturnCode_t on_aborting(UniqueId exec_handle)
[ComponentAction CORBA interface] Transition to Error State
Definition: RTObject.cpp:939
virtual SDOPackage::OrganizationList * get_organizations()
[SDO interface] Get Organization list
Definition: RTObject.cpp:1353
void deletePort(PortBase &port)
Unregister the Port registration.
Definition: PortAdmin.cpp:297
void finalizePorts()
Unregister All Ports.
Definition: RTObject.cpp:2097
virtual ReturnCode_t on_state_update(UniqueId exec_handle)
[DataFlowComponentAction CORBA interface] Secondary Periodic Operation of RTC
Definition: RTObject.cpp:1044
virtual CORBA::Boolean is_alive(ExecutionContext_ptr exec_context)
[CORBA interface] Confirm whether RTC is the alive state
Definition: RTObject.cpp:433
coil::Properties m_properties
Alive Status Flag.
Definition: RTObject.h:4687
virtual ReturnCode_t on_execute(UniqueId exec_handle)
[DataFlowComponentAction CORBA interface] Primary Periodic Operation of RTC
Definition: RTObject.cpp:1016
RTObject_var m_objref
Object reference.
Definition: RTObject.h:4597
virtual char * get_sdo_type()
[SDO interface] Get SDO type
Definition: RTObject.cpp:1148
void setProperties(const coil::Properties &prop)
[local interface] Set RTC property
Definition: RTObject.cpp:1497
virtual CORBA::Any * get_status(const char *name)
[SDO interface] Get SDO Status
Definition: RTObject.cpp:1404
Functor for_each(CorbaSequence &seq, Functor f)
Apply the functor to all CORBA sequence elements.
Definition: CORBA_SeqUtil.h:98
RTObject_ptr getObjRef() const
[local interface] Get the object reference
Definition: RTObject.cpp:1483
virtual SDOPackage::ServiceProfile * get_service_profile(const char *id)
[SDO interface] Get specified ServiceProfile
Definition: RTObject.cpp:1231
virtual ReturnCode_t on_rate_changed(UniqueId exec_handle)
[DataFlowComponentAction CORBA interface] Notify rate changed
Definition: RTObject.cpp:1070


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:26:00