Go to the documentation of this file.00001
00019 #include <assert.h>
00020 #include "rtm/RTObject.h"
00021
00022 namespace RTC
00023 {
00024
00025 RTObject_impl::RTObject_impl(RTC::Interface::RTObjectInterface* rtobj)
00026 : m_rtobj(rtobj)
00027 {
00028 }
00029
00030 RTObject_impl::~RTObject_impl()
00031 {
00032 }
00033
00034
00035
00036
00037 ReturnCode_t RTObject_impl::initialize()
00038 throw (CORBA::SystemException)
00039 {
00040 return m_rtobj->initialize();
00041 }
00042
00043 ReturnCode_t RTObject_impl::finalize()
00044 throw (CORBA::SystemException)
00045 {
00046 return m_rtobj->finalize();
00047 }
00048
00049 ReturnCode_t RTObject_impl::exit()
00050 throw (CORBA::SystemException)
00051 {
00052 return m_rtobj->exit();
00053 }
00054
00055 CORBA::Boolean
00056 RTObject_impl::is_alive(ExecutionContext_ptr exec_context)
00057 throw (CORBA::SystemException)
00058 {
00059 DObjectRegistry doreg;
00060 doreg = Manager::instance().DObjectRegistry();
00061
00062 if (doreg.isLocal(exec_context))
00063 {
00064 ExecutionContextInterface& ec(doreg.getLocalObject(exec_context));
00065 }
00066 else
00067 {
00068 ExecutionContextInterface& ec(exec_context);
00069 }
00070
00071 return m_rtobj->is_alive(ec);
00072 }
00073
00081 ExecutionContext_ptr
00082 RTObject_impl::get_context(ExecutionContextHandle_t ec_id)
00083 throw (CORBA::SystemException)
00084 {
00085 ExecutionContextInterface& ecif(m_rtobj->get_context(ec_id));
00086
00087 return Local2Corba(ecif);
00088 }
00089
00097 ExecutionContextList* RTObject_impl::get_owned_contexts()
00098 throw (CORBA::SystemException)
00099 {
00100 ExecutionContextInterfaceList& eclist(m_rtobj->get_owned_contexts());
00101
00102 ExecutionContextList_var retval;
00103 retval = new ExecutionContextList();
00104 CORBA_SeqUtil::for_each(eclist, ec_copy(retval));
00105
00106 return retval._retn();
00107 }
00108
00116 ExecutionContextList* RTObject_impl::get_participating_contexts()
00117 throw (CORBA::SystemException)
00118 {
00119 ExecutionContextInterfaceList& eclist(m_rtobj->get_participating_contexts());
00120 ExecutionContextList_var retval;
00121 retval = new ExecutionContextList();
00122 CORBA_SeqUtil::for_each(eclist, ec_copy(retval));
00123
00124 return retval._retn();
00125 }
00126
00127
00135 ExecutionContextHandle_t
00136 RTObject_impl::get_context_handle(ExecutionContext_ptr cxt)
00137 throw (CORBA::SystemException)
00138 {
00139 ExecutionContextInterface ecif(Corba2Local(cxt));
00140 return m_rtobj->get_context_handle(ecif);
00141 }
00142
00143
00151 UniqueId RTObject_impl::attach_context(ExecutionContext_ptr exec_context)
00152 throw (CORBA::SystemException)
00153 {
00154 return m_rtobj->attach_context(ExecutionContext_ptr exec_context);
00155 }
00156
00164 ReturnCode_t RTObject_impl::detach_context(UniqueId ec_id)
00165 throw (CORBA::SystemException)
00166 {
00167 return m_rtobj->detach_context(UniqueId ec_id);
00168 }
00169
00170
00171
00172
00173
00181 ComponentProfile* RTObject_impl::get_component_profile()
00182 throw (CORBA::SystemException)
00183 {
00184 return m_rtobj->RTObject;
00185 }
00186
00194 PortServiceList* RTObject_impl::get_ports()
00195 throw (CORBA::SystemException)
00196 {
00197 return m_rtobj->get_ports();
00198 }
00199
00200
00201
00202
00210 ReturnCode_t RTObject_impl::on_initialize()
00211 throw (CORBA::SystemException)
00212 {
00213 return m_rtobj->on_initialize();
00214 }
00215
00223 ReturnCode_t RTObject_impl::on_finalize()
00224 throw (CORBA::SystemException)
00225 {
00226 return m_rtobj->on_finalize();
00227 }
00228
00236 ReturnCode_t RTObject_impl::on_startup(UniqueId ec_id)
00237 throw (CORBA::SystemException)
00238 {
00239 return m_rtobj->on_startup(UniqueId ec_id);
00240 }
00241
00249 ReturnCode_t RTObject_impl::on_shutdown(UniqueId ec_id)
00250 throw (CORBA::SystemException)
00251 {
00252 return m_rtobj->on_shutdown(UniqueId ec_id);
00253 }
00254
00262 ReturnCode_t RTObject_impl::on_activated(UniqueId ec_id)
00263 throw (CORBA::SystemException)
00264 {
00265 return m_rtobj->on_activated(UniqueId ec_id);
00266 }
00267
00275 ReturnCode_t RTObject_impl::on_deactivated(UniqueId ec_id)
00276 throw (CORBA::SystemException)
00277 {
00278 return m_rtobj->on_deactivated(UniqueId ec_id);
00279 }
00280
00288 ReturnCode_t RTObject_impl::on_aborting(UniqueId ec_id)
00289 throw (CORBA::SystemException)
00290 {
00291 return m_rtobj->on_aborting(UniqueId ec_id);
00292 }
00293
00301 ReturnCode_t RTObject_impl::on_error(UniqueId ec_id)
00302 throw (CORBA::SystemException)
00303 {
00304 return m_rtobj->on_error(UniqueId ec_id);
00305 }
00306
00314 ReturnCode_t RTObject_impl::on_reset(UniqueId ec_id)
00315 throw (CORBA::SystemException)
00316 {
00317 return m_rtobj->on_reset(UniqueId ec_id);
00318 }
00319
00328 ReturnCode_t RTObject_impl::on_execute(UniqueId ec_id)
00329 throw (CORBA::SystemException)
00330 {
00331 return m_rtobj->on_execute(UniqueId ec_id);
00332 }
00333
00342 ReturnCode_t RTObject_impl::on_state_update(UniqueId ec_id)
00343 throw (CORBA::SystemException)
00344 {
00345 return m_rtobj->on_state_update(UniqueId ec_id);
00346 }
00347
00355 ReturnCode_t RTObject_impl::on_rate_changed(UniqueId ec_id)
00356 throw (CORBA::SystemException)
00357 {
00358 return m_rtobj->on_rate_changed(UniqueId ec_id);
00359 }
00360
00361
00362
00363
00371 SDOPackage::OrganizationList* RTObject_impl::get_owned_organizations()
00372 throw (CORBA::SystemException, SDOPackage::NotAvailable)
00373 {
00374
00375 }
00376
00377
00385 char* RTObject_impl::get_sdo_id()
00386 throw (CORBA::SystemException,
00387 SDOPackage::NotAvailable, SDOPackage::InternalError)
00388 {
00389
00390 }
00391
00399 char* RTObject_impl::get_sdo_type()
00400 throw (CORBA::SystemException,
00401 SDOPackage::NotAvailable, SDOPackage::InternalError)
00402 {
00403
00404 }
00405
00413 SDOPackage::DeviceProfile* RTObject_impl::get_device_profile()
00414 throw (CORBA::SystemException,
00415 SDOPackage::NotAvailable, SDOPackage::InternalError)
00416 {
00417 try
00418 {
00419 SDOPackage::DeviceProfile_var dprofile;
00420 dprofile = new SDOPackage::DeviceProfile();
00421 dprofile->device_type = CORBA::string_dup(m_profile.category);
00422 dprofile->manufacturer = CORBA::string_dup(m_profile.vendor);
00423 dprofile->model = CORBA::string_dup(m_profile.type_name);
00424 dprofile->version = CORBA::string_dup(m_profile.version);
00425 dprofile->properties = m_profile.properties;
00426 return dprofile._retn();
00427 }
00428 catch (...)
00429 {
00430 throw SDOPackage::InternalError("get_device_profile()");
00431 }
00432 return new SDOPackage::DeviceProfile();
00433 }
00434
00442 SDOPackage::ServiceProfileList* RTObject_impl::get_service_profiles()
00443 throw (CORBA::SystemException,
00444 SDOPackage::NotAvailable, SDOPackage::InternalError)
00445 {
00446 try
00447 {
00448 SDOPackage::ServiceProfileList_var sprofiles;
00449 sprofiles = new SDOPackage::ServiceProfileList(m_sdoSvcProfiles);
00450 return sprofiles._retn();
00451 }
00452 catch (...)
00453 {
00454 throw SDOPackage::InternalError("get_service_profiles()");
00455 }
00456 return new SDOPackage::ServiceProfileList();
00457 }
00458
00466 SDOPackage::ServiceProfile*
00467 RTObject_impl::get_service_profile(const char* id)
00468 throw (CORBA::SystemException,
00469 SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00470 SDOPackage::InternalError)
00471 {
00472 if (!id)
00473 throw SDOPackage::InvalidParameter("get_service_profile(): Empty name.");
00474
00475 try
00476 {
00477 CORBA::Long index;
00478 index = CORBA_SeqUtil::find(m_sdoSvcProfiles, svc_name(id));
00479
00480 SDOPackage::ServiceProfile_var sprofile;
00481 sprofile = new SDOPackage::ServiceProfile(m_sdoSvcProfiles[index]);
00482 return sprofile._retn();
00483 }
00484 catch (...)
00485 {
00486 throw SDOPackage::InternalError("get_service_profile()");
00487 }
00488 return new SDOPackage::ServiceProfile();
00489 }
00490
00498 SDOPackage::SDOService_ptr RTObject_impl::get_sdo_service(const char* id)
00499 throw (CORBA::SystemException,
00500 SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00501 SDOPackage::InternalError)
00502 {
00503 if (!id)
00504 throw SDOPackage::InvalidParameter("get_service(): Empty name.");
00505
00506 try
00507 {
00508 CORBA::Long index;
00509 index = CORBA_SeqUtil::find(m_sdoSvcProfiles, svc_name(id));
00510
00511 SDOPackage::SDOService_var service;
00512 service = m_sdoSvcProfiles[index].service;
00513 return service._retn();
00514 }
00515 catch (...)
00516 {
00517 throw SDOPackage::InternalError("get_service()");
00518 }
00519 return SDOPackage::SDOService::_nil();
00520 }
00521
00529 SDOPackage::Configuration_ptr RTObject_impl::get_configuration()
00530 throw (CORBA::SystemException,
00531 SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
00532 SDOPackage::InternalError)
00533 {
00534 if (m_pSdoConfig == NULL)
00535 throw SDOPackage::InterfaceNotImplemented();
00536 try
00537 {
00538 SDOPackage::Configuration_var config;
00539 config = m_pSdoConfig;
00540 return config._retn();
00541 }
00542 catch (...)
00543 {
00544 SDOPackage::InternalError("get_configuration()");
00545 }
00546 return SDOPackage::Configuration::_nil();
00547 }
00548
00556 SDOPackage::Monitoring_ptr RTObject_impl::get_monitoring()
00557 throw (CORBA::SystemException,
00558 SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
00559 SDOPackage::InternalError)
00560 {
00561 throw SDOPackage::InterfaceNotImplemented();
00562 return SDOPackage::Monitoring::_nil();
00563 }
00564
00572 SDOPackage::OrganizationList* RTObject_impl::get_organizations()
00573 throw (CORBA::SystemException,
00574 SDOPackage::NotAvailable, SDOPackage::InternalError)
00575 {
00576 try
00577 {
00578 SDOPackage::OrganizationList_var org;
00579 org = new SDOPackage::OrganizationList(m_sdoOrganizations);
00580 return org._retn();
00581 }
00582 catch (...)
00583 {
00584 throw SDOPackage::InternalError("get_organizations()");
00585 }
00586 return new SDOPackage::OrganizationList(0);
00587 }
00588
00596 SDOPackage::NVList* RTObject_impl::get_status_list()
00597 throw (CORBA::SystemException,
00598 SDOPackage::NotAvailable, SDOPackage::InternalError)
00599 {
00600 try
00601 {
00602 NVList_var status;
00603 status = new NVList(m_sdoStatus);
00604 return status._retn();
00605 }
00606 catch (...)
00607 {
00608 SDOPackage::InternalError("get_status_list()");
00609 }
00610 return new SDOPackage::NVList(0);
00611 }
00612
00620 CORBA::Any* RTObject_impl::get_status(const char* name)
00621 throw (CORBA::SystemException,
00622 SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00623 SDOPackage::InternalError)
00624 {
00625 CORBA::Long index;
00626 index = CORBA_SeqUtil::find(m_sdoStatus, nv_name(name));
00627 if (index < 0)
00628 throw SDOPackage::InvalidParameter("get_status(): Not found");
00629 try
00630 {
00631 CORBA::Any_var status;
00632 status = new CORBA::Any(m_sdoStatus[index].value);
00633 return status._retn();
00634 }
00635 catch (...)
00636 {
00637 throw SDOPackage::InternalError("get_status()");
00638 }
00639 return new CORBA::Any();
00640 }
00641
00642
00643
00644
00652 void RTObject_impl::setInstanceName(const char* instance_name)
00653 {
00654 m_properties["instance_name"] = instance_name;
00655 m_profile.instance_name = m_properties["instance_name"].c_str();
00656 }
00657
00665 std::vector<std::string> RTObject_impl::getNamingNames()
00666 {
00667 return split(m_properties["naming.names"], ",");
00668 }
00669
00677 void RTObject_impl::setObjRef(const RTObject_ptr rtobj)
00678 {
00679 m_objref = rtobj;
00680 }
00681
00689 RTObject_ptr RTObject_impl::getObjRef() const
00690 {
00691 return RTC::RTObject::_duplicate(m_objref);
00692 }
00693
00701 void RTObject_impl::setProperties(const Properties& prop)
00702 {
00703 m_properties << prop;
00704 m_profile.instance_name = m_properties["instance_name"].c_str();
00705 m_profile.type_name = m_properties["type_name"].c_str();
00706 m_profile.description = m_properties["description"].c_str();
00707 m_profile.version = m_properties["version"].c_str();
00708 m_profile.vendor = m_properties["vendor"].c_str();
00709 m_profile.category = m_properties["category"].c_str();
00710 }
00711
00719 Properties& RTObject_impl::getProperties()
00720 {
00721 return m_properties;
00722 }
00723
00731 void RTObject_impl::updateParameters(const char* config_set)
00732 {
00733 m_configsets.update(config_set);
00734 return;
00735 }
00736
00744 void RTObject_impl::registerPort(PortBase& port)
00745 {
00746 m_portAdmin.registerPort(port);
00747 port.setOwner(this->getObjRef());
00748 return;
00749 }
00750
00758 void RTObject_impl::deletePort(PortBase& port)
00759 {
00760 m_portAdmin.deletePort(port);
00761 return;
00762 }
00763
00771 void RTObject_impl::deletePortByName(const char* port_name)
00772 {
00773 m_portAdmin.deletePortByName(port_name);
00774 return;
00775 }
00776
00784 void RTObject_impl::finalizePorts()
00785 {
00786 m_portAdmin.finalizePorts();
00787 }
00788
00796 void RTObject_impl::shutdown()
00797 {
00798 try
00799 {
00800 finalizePorts();
00801 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(m_pSdoConfigImpl));
00802 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(this));
00803 }
00804 catch (...)
00805 {
00806 ;
00807 }
00808
00809 if (m_pManager != NULL)
00810 {
00811 m_pManager->cleanupComponent(this);
00812 }
00813 }
00814 };