[openrtm-commit:03066] r3161 - branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 1月 17日 (水) 10:40:05 JST
Author: miyamoto
Date: 2018-01-17 10:40:05 +0900 (Wed, 17 Jan 2018)
New Revision: 3161
Modified:
branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DefaultConfiguration.h
branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerServant.cpp
branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerServant.h
Log:
[compat,->RELENG_1_2] refs #3274
Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DefaultConfiguration.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DefaultConfiguration.h 2018-01-17 01:09:28 UTC (rev 3160)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DefaultConfiguration.h 2018-01-17 01:40:05 UTC (rev 3161)
@@ -72,6 +72,8 @@
"corba.nameservers", "localhost",
"corba.master_manager", "localhost:2810",
"corba.nameservice.replace_endpoint", "NO",
+ "corba.update_master_manager.enable", "YES",
+ "corba.update_master_manager.interval", "10.0",
"exec_cxt.periodic.type", "PeriodicExecutionContext",
"exec_cxt.periodic.rate", "1000",
"exec_cxt.sync_transition", "YES",
@@ -86,6 +88,7 @@
"manager.name", "manager",
"manager.components.naming_policy", "process_unique",
"manager.command", "rtcd",
+ "manager.nameservers", "default",
"manager.supported_languages", "C++, Python, Java",
"manager.modules.C++.manager_cmd", "rtcd",
"manager.modules.C++.profile_cmd", "rtcprof",
Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerServant.cpp
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerServant.cpp 2018-01-17 01:09:28 UTC (rev 3160)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerServant.cpp 2018-01-17 01:40:05 UTC (rev 3161)
@@ -121,7 +121,8 @@
/*!
* @if jp
- * @brief ¥â¥¸¥å¡¼¥Eò¥ú½¼¥É¤¹¤E * @else
+ * @brief W
[ð[h·é
+ * @else
* @brief Loading a module
* @endig
*/
@@ -137,7 +138,8 @@
/*!
* @if jp
- * @brief ¥â¥¸¥å¡¼¥Eò¥¢¥ó¥ú½¼¥É¤¹¤E * @else
+ * @brief W
[ðA[h·é
+ * @else
* @brief Unloading a module
* @endig
*/
@@ -152,7 +154,8 @@
/*!
* @if jp
- * @brief ¥ú½¼¥É²Äǽ¤Ê¥â¥¸¥å¡¼¥EÎ¥×¥úÁÕ¥¡¥¤¥Eò¼èÆÀ¤¹¤E * @else
+ * @brief [hÂ\ÈW
[Ìvt@Cðæ¾·é
+ * @else
* @brief Getting loadable module profiles
* @endig
*/
@@ -205,7 +208,8 @@
/*!
* @if jp
- * @brief ¥ú½¼¥ÉºÑ¤ß¤Î¥â¥¸¥å¡¼¥EÎ¥×¥úÁÕ¥¡¥¤¥Eò¼èÆÀ¤¹¤E * @else
+ * @brief [hÏÝÌW
[Ìvt@Cðæ¾·é
+ * @else
* @brief Getting loaded module profiles
* @endig
*/
@@ -221,7 +225,7 @@
for (int i(0), len(prof.size()); i < len; ++i)
{
RTC_VERBOSE_STR((prof[i]));
- NVUtil::copyFromProperties(cprof[(CORBA::Long)i].properties, prof[i]);
+ NVUtil::copyFromProperties(cprof.inout()[(CORBA::Long)i].properties, prof[i]);
}
if (0)
@@ -258,7 +262,8 @@
/*!
* @if jp
- * @brief ¥³¥ó¥Ý¡¼¥Í¥ó¥È¥Õ¥¡¥¯¥È¥ê¤Î¥×¥úÁÕ¥¡¥¤¥Eò¼èÆÀ¤¹¤E * @else
+ * @brief R|[lgt@NgÌvt@Cðæ¾·é
+ * @else
* @brief Getting component factory profiles
* @endig
*/
@@ -274,7 +279,7 @@
for (int i(0), len(prof.size()); i < len; ++i)
{
RTC_VERBOSE_STR((prof[i]));
- NVUtil::copyFromProperties(cprof[(CORBA::Long)i].properties, prof[i]);
+ NVUtil::copyFromProperties(cprof.inout()[(CORBA::Long)i].properties, prof[i]);
}
if (0)
@@ -309,9 +314,82 @@
return cprof._retn();
}
+
+ std::string ManagerServant::getParameterByModulename(const std::string param_name, std::string &module_name)
+ {
+ int pos0 = module_name.find("&" + param_name + "=");
+ int pos1 = module_name.find("?" + param_name + "=");
+
+ if (pos0 == -1 && pos1 == -1)
+ {
+ return "";
+ }
+
+ int pos = 0;
+ if (pos0 == -1)
+ {
+ pos = pos1;
+ }
+ else{
+ pos = pos0;
+ }
+
+
+
+ std::string paramstr;
+ int endpos = module_name.find('&', pos + 1);
+
+
+ if (endpos == -1)
+ {
+ endpos = module_name.find('?', pos + 1);
+
+
+ if (endpos == -1)
+ {
+ paramstr = module_name.substr((pos + 1));
+
+ }
+ else
+ {
+ paramstr = module_name.substr((pos + 1), endpos);
+ }
+ }
+ else
+ {
+ paramstr = module_name.substr((pos + 1), endpos);
+ }
+ RTC_VERBOSE(("%s arg: %s", param_name.c_str(), paramstr.c_str()));
+
+
+
+
+ int eqpos = paramstr.find("=");
+
+
+
+ paramstr = paramstr.substr(eqpos + 1);
+
+
+ RTC_DEBUG(("%s is %s", param_name.c_str(), paramstr.c_str()));
+
+
+ if (endpos == -1)
+ {
+ module_name = module_name.substr(0, pos);
+ }
+ else
+ {
+ module_name = module_name.substr(0, pos) + module_name.substr(endpos);
+ }
+
+
+ return paramstr;
+ }
/*!
* @if jp
- * @brief ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤òÀ¸À®¤¹¤E * @else
+ * @brief R|[lg𶬷é
+ * @else
* @brief Creating an RT-Component
* @endig
*/
@@ -324,49 +402,93 @@
{
return RTC::RTObject::_nil();
}
+ coil::vstring tmp = coil::split(create_arg, "&");
+ if (tmp.back().empty())
+ {
+ create_arg = create_arg.substr(0, create_arg.size() - 1);
+ }
+ tmp = coil::split(create_arg, "?");
+ if (tmp.back().empty())
+ {
+ create_arg = create_arg.substr(0,create_arg.size() - 1);
+ }
+
+
+
RTC::RTObject_var rtobj;
+
// create component by address
rtobj = createComponentByAddress(create_arg);
if (!CORBA::is_nil(rtobj)) { return rtobj._retn(); }
-
+
// create component by manager's name
rtobj = createComponentByManagerName(create_arg);
if (!CORBA::is_nil(rtobj)) { return rtobj._retn(); }
+
+ getParameterByModulename("manager_address", create_arg);
+ std::string manager_name = getParameterByModulename("manager_name", create_arg);
+
+
+ CompParam comp_param(create_arg);
+
+
// === Master ===
// The aster manager never hosts RT-Components and it request to
// create to slave components.
if (m_isMaster)
{
- Guard guard(m_slaveMutex);
- for (size_t i(0); i < m_slaves.length(); ++i)
- {
- try
- {
- RTC::RTObject_var rtobj;
- rtobj = m_slaves[i]->create_component(create_arg.c_str());
- RTC_DEBUG(("Component created %s", create_arg.c_str()));
- if (!CORBA::is_nil(rtobj)) { return rtobj._retn(); }
- }
- catch (CORBA::SystemException& e)
- {
- RTC_DEBUG(("Exception was caught while creating component."));
- }
- }
+ {
+ Guard guard(m_slaveMutex);
+ for (size_t i(0); i < m_slaves.length(); ++i)
+ {
+ try
+ {
+ RTM::NVList* prof = m_slaves[i]->get_configuration();
+ coil::Properties prop;
+ RTC::RTObject_var rtobj;
+ NVUtil::copyToProperties(prop, (*prof));
+ std::string slave_lang = prop["manager.language"];
+
+ if (slave_lang == comp_param.language())
+ {
+ rtobj = m_slaves[i]->create_component(create_arg.c_str());
+ RTC_DEBUG(("Component created %s", create_arg.c_str()));
+ if (!CORBA::is_nil(rtobj)) { return rtobj._retn(); }
+ }
+
+
+ }
+ catch (CORBA::SystemException& e)
+ {
+ RTC_DEBUG(("Exception was caught while creating component."));
+ }
+ }
+ }
+
+ if (manager_name.empty())
+ {
+ create_arg = create_arg + "&manager_name=manager_%p";
+
+ rtobj = createComponentByManagerName(create_arg);
+ if (!CORBA::is_nil(rtobj)) { return rtobj._retn(); };
+ }
return RTC::RTObject::_nil();
}
+ else
+ {
+ // === Slave ===
+ // create component on the manager
+ RTC_DEBUG(("Creating component on this manager"));
+ RTC_DEBUG(("arg: %s", create_arg.c_str()));
+ RTC::RTObject_impl* rtc = m_mgr.createComponent(create_arg.c_str());
+ if (rtc != NULL)
+ {
+ return RTC::RTObject::_duplicate(rtc->getObjRef());
+ }
+ }
- // === Slave ===
- // create component on the manager
- RTC_DEBUG(("Creating component on this manager"));
- RTC_DEBUG(("arg: %s", create_arg.c_str()));
- RTC::RTObject_impl* rtc = m_mgr.createComponent(create_arg.c_str());
- if (rtc != NULL)
- {
- return RTC::RTObject::_duplicate(rtc->getObjRef());
- }
-
// no RTObject created.
return RTC::RTObject::_nil();
}
@@ -373,7 +495,8 @@
/*!
* @if jp
- * @brief ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤òºEE¹¤E * @else
+ * @brief R|[lgðí·é
+ * @else
* @brief Deleting an RT-Component
* @endig
*/
@@ -401,7 +524,8 @@
/*!
* @if jp
- * @brief µ¯Æ°Ãæ¤Î¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Î¥E¹¥È¤ò¼èÆÀ¤¹¤E * @else
+ * @brief N®ÌR|[lgÌXgðæ¾·é
+ * @else
* @brief Getting RT-Component list running on this manager
* @endig
*/
@@ -416,7 +540,7 @@
crtcs->length((CORBA::Long)rtcs.size());
for (int i(0), len(rtcs.size()); i < len; ++i)
{
- crtcs[(CORBA::Long)i] = RTC::RTObject::_duplicate(rtcs[i]->getObjRef());
+ crtcs.inout()[(CORBA::Long)i] = RTC::RTObject::_duplicate(rtcs[i]->getObjRef());
}
// get slaves' component references
@@ -450,7 +574,8 @@
/*!
* @if jp
- * @brief µ¯Æ°Ãæ¤Î¥³¥ó¥Ý¡¼¥Í¥ó¥È¥×¥úÁÕ¥¡¥¤¥EÎ¥E¹¥È¤ò¼èÆÀ¤¹¤E * @else
+ * @brief N®ÌR|[lgvt@CÌXgðæ¾·é
+ * @else
* @brief Getting RT-Component's profile list running on this manager
* @endig
*/
@@ -465,7 +590,7 @@
for (int i(0), len(rtcs.size()); i < len; ++i)
{
::RTC::ComponentProfile_var prof = rtcs[i]->get_component_profile();
- cprofs[(CORBA::Long)i] = prof;
+ cprofs.inout()[(CORBA::Long)i] = prof;
}
// copy slaves' component profiles
@@ -497,10 +622,11 @@
return cprofs._retn();
}
- // manager ´ðËÜ
+ // manager î{
/*!
* @if jp
- * @brief ¥Þ¥Í¡¼¥¸¥ã¤Î¥×¥úÁÕ¥¡¥¤¥Eò¼èÆÀ¤¹¤E * @else
+ * @brief }l[WÌvt@Cðæ¾·é
+ * @else
* @brief Getting this manager's profile.
* @endig
*/
@@ -515,7 +641,8 @@
/*!
* @if jp
- * @brief ¥Þ¥Í¡¼¥¸¥ã¤Î¥³¥ó¥Õ¥£¥®¥å¥E¼¥·¥ç¥ó¤ò¼èÆÀ¤¹¤E * @else
+ * @brief }l[WÌRtBM
[Vðæ¾·é
+ * @else
* @brief Getting this manager's configuration.
* @endig
*/
@@ -536,7 +663,8 @@
/*!
* @if jp
- * @brief ¥Þ¥Í¡¼¥¸¥ã¤Î¥³¥ó¥Õ¥£¥®¥å¥E¼¥·¥ç¥ó¤òÀßÄꤹ¤E * @else
+ * @brief }l[WÌRtBM
[VðÝè·é
+ * @else
* @brief Setting manager's configuration
* @endig
*/
@@ -549,7 +677,7 @@
}
/*!
* @if jp
- * @brief ¥Þ¥Í¡¼¥¸¥ã¤¬¥Þ¥¹¥¿¡¼¤«¤É¤¦¤«
+ * @brief }l[Wª}X^[©Ç¤©
* @else
* @brief Whether this manager is master or not
* @endig
@@ -562,7 +690,7 @@
/*!
* @if jp
- * @brief ¥Þ¥¹¥¿¡¼¥Þ¥Í¡¼¥¸¥ã¤Î¼èÆÀ
+ * @brief }X^[}l[WÌæ¾
* @else
* @brief Getting master managers
* @endig
@@ -576,7 +704,7 @@
/*!
* @if jp
- * @brief ¥Þ¥¹¥¿¡¼¥Þ¥Í¡¼¥¸¥ã¤ÎÄɲÃ
+ * @brief }X^[}l[WÌÇÁ
* @else
* @brief Getting a master manager
* @endig
@@ -601,7 +729,8 @@
/*!
* @if jp
- * @brief ¥Þ¥¹¥¿¡¼¥Þ¥Í¡¼¥¸¥ã¤ÎºEE * @else
+ * @brief }X^[}l[WÌí
+ * @else
* @brief Removing a master manager
* @endig
*/
@@ -627,7 +756,7 @@
/*!
* @if jp
- * @brief ¥¹¥E¼¥Ö¥Þ¥Í¡¼¥¸¥ã¤Î¼èÆÀ
+ * @brief X[u}l[WÌæ¾
* @else
* @brief Getting slave managers
* @endig
@@ -642,7 +771,7 @@
/*!
* @if jp
- * @brief ¥¹¥E¼¥Ö¥Þ¥Í¡¼¥¸¥ã¤ÎÄɲÃ
+ * @brief X[u}l[WÌÇÁ
* @else
* @brief Getting a slave manager
* @endig
@@ -649,7 +778,9 @@
*/
RTC::ReturnCode_t ManagerServant::add_slave_manager(RTM::Manager_ptr mgr)
{
+
Guard guard(m_slaveMutex);
+
RTC_TRACE(("add_slave_manager(), %d slaves", m_slaves.length()));
CORBA::Long index;
@@ -668,7 +799,8 @@
/*!
* @if jp
- * @brief ¥¹¥E¼¥Ö¥Þ¥Í¡¼¥¸¥ã¤ÎºEE * @else
+ * @brief X[u}l[WÌí
+ * @else
* @brief Removing a slave manager
* @endig
*/
@@ -692,7 +824,8 @@
/*!
* @if jp
- * @brief ¥×¥úÁ»¥¹¤Î¥³¥Ô¡¼¤òÀ¸À®¤¹¤E * @else
+ * @brief vZXÌRs[𶬷é
+ * @else
* @brief The copy of the process is generated.
* @endif
*/
@@ -705,7 +838,8 @@
/*!
* @if jp
- * @brief shutdown¤¹¤E * @else
+ * @brief shutdown·é
+ * @else
* @brief This method shutdowns RTC.
* @endif
*/
@@ -717,7 +851,7 @@
/*!
* @if jp
- * @brief ºÆµ¯Æ°¤¹¤E£
+ * @brief ÄN®·éB
* @else
* @brief This method restarts RTC.
* @endif
@@ -730,7 +864,7 @@
/*!
* @if jp
- * @brief »ØÄE¾¤ÎRTC¥ª¥Ö¥¸¥§¥¯¥È¥EÕ¥¡¥E󥹤ò¼èÆÀ
+ * @brief wè¼ÌRTCIuWFNgt@Xðæ¾
* @else
* @brief Obtain specific RTObject reference by name
* @endig
@@ -785,7 +919,7 @@
/*!
* @if jp
- * @brief RTC¤Î¥EÕ¥¡¥E󥹤ò¼èÆÀ¤¹¤E£
+ * @brief RTCÌt@Xðæ¾·éB
* @else
* @brief Get the reference of RTC.
* @endif
@@ -799,7 +933,7 @@
// Local functions
/*!
* @if jp
- * @brief Manager¤Î¥EÕ¥¡¥E󥹤ò¼èÆÀ¤¹¤E£
+ * @brief ManagerÌt@Xðæ¾·éB
* @else
* @brief Get the reference of Manager.
* @endif
@@ -811,7 +945,7 @@
/*!
* @if jp
- * @brief INSManager¤ÎÀ¸À®
+ * @brief INSManager̶¬
* @else
* @brief Generate INSManager.
* @endif
@@ -866,7 +1000,7 @@
/*!
* @if jp
- * @brief Manager¤Î¥EÕ¥¡¥E󥹤ò¸¡º÷¤¹¤E£
+ * @brief ManagerÌt@Xðõ·éB
* @else
* @brief Find the reference of Manager.
* @endif
@@ -924,7 +1058,7 @@
/*!
* @if jp
- * @brief »ØÄE¾¤Î¥Þ¥Í¡¼¥¸¥ã¤ò¼èÆÀ
+ * @brief wè¼Ì}l[Wðæ¾
* @else
* @brief Obtain Manager's reference by name
* @endif
@@ -949,7 +1083,7 @@
/*!
* @if jp
- * @brief ¥Þ¥Í¡¼¥¸¥ã¤Î¥E¹¥È¤«¤é»ØÄE¾¤ò»ý¤Ä¥Þ¥Í¡¼¥¸¥ã¤ò¼èÆÀ
+ * @brief }l[WÌXg©çwè¼ðÂ}l[Wðæ¾
* @else
* @brief Obtain Manager's reference by name
* @endif
@@ -989,7 +1123,8 @@
/*!
* @if jp
- * @brief »ØÄê¤Î¥Þ¥Í¡¼¥¸¥ã¤ÇRTC¤òµ¯Æ°¤¹¤E * @else
+ * @brief wèÌ}l[WÅRTCðN®·é
+ * @else
* @brief Launch RTC on specified manager
* @endif
*/
@@ -998,24 +1133,32 @@
{
RTC_TRACE(("createComponentByManagerName(%s)",create_arg.c_str()));
coil::mapstring param = coil::urlparam2map(create_arg);
+
+
+
+
for (coil::mapstring::iterator it(param.begin()); it != param.end(); ++it)
{
RTC_DEBUG(("create_arg[%s] = %s",
it->first.c_str(), it->second.c_str()));
}
-
+
+
std::string mgrstr = param["manager_name"];
+
if (mgrstr.empty())
{
RTC_WARN(("No manager_name found: %s", mgrstr.c_str()));
return RTC::RTObject::_nil();
}
-
+
+
// detect languange
std::string lang = param["language"];
if (lang.empty()) { lang = "C++"; }
+
RTC_INFO(("Specified manager's language: %s", lang.c_str()));
-
+
RTM::Manager_var mgrobj = findManagerByName(mgrstr);
if (CORBA::is_nil(mgrobj))
{
@@ -1038,6 +1181,37 @@
rtcd_cmd += " -o manager.name:" + prop["manger.name"];
rtcd_cmd += " -o manager.instance_name:" + mgrstr;
+
+ coil::vstring slaves_names;
+ if (mgrstr == "manager_%p")
+ {
+ Guard gurad(m_slaveMutex);
+
+ for (CORBA::ULong i(0); i < m_slaves.length(); ++i)
+ {
+ try
+ {
+ RTM::NVList_var nvlist = m_slaves[i]->get_configuration();
+ coil::Properties prop;
+ NVUtil::copyToProperties(prop, nvlist);
+ std::string name = prop["manager.instance_name"];
+
+ if (isProcessIDManager(name))
+ {
+ slaves_names.push_back(name);
+ }
+ }
+ catch (...)
+ {
+ RTC_ERROR(("A slave manager thrown exception."));
+ CORBA_SeqUtil::erase(m_slaves, i);
+ RTC_ERROR(("This slave manager is removed from slave list."));
+ }
+ }
+ }
+
+
+
RTC_DEBUG(("Invoking command: %s.", rtcd_cmd.c_str()));
int ret(coil::launch_shell(rtcd_cmd.c_str()));
if (ret == -1)
@@ -1045,16 +1219,40 @@
RTC_DEBUG(("%s: failed", rtcd_cmd.c_str()));
return RTC::RTObject::_nil();
}
- coil::sleep(0.01);
+
for (size_t i(0); i < 1000; ++i)
{
- RTC_DEBUG(("Detecting new slave manager (%s).", mgrstr.c_str()))
- mgrobj = findManagerByName(mgrstr);
- if (!CORBA::is_nil(mgrobj))
- {
- RTC_INFO(("New slave manager (%s) launched.", mgrstr.c_str()));
- break;
- }
+ coil::sleep(coil::TimeValue(0.01));
+ RTC_DEBUG(("Detecting new slave manager (%s).", mgrstr.c_str()));
+ if (mgrstr == "manager_%p")
+ {
+ Guard gurad(m_slaveMutex);
+
+ for (CORBA::ULong j(0); j < m_slaves.length(); ++j)
+ {
+ RTM::NVList_var nvlist = m_slaves[j]->get_configuration();
+ coil::Properties prop;
+ NVUtil::copyToProperties(prop, nvlist);
+ std::string name = prop["manager.instance_name"];
+
+ if (isProcessIDManager(name))
+ {
+ if (std::count(slaves_names.begin(), slaves_names.end(), name) == 0)
+ {
+ mgrobj = m_slaves[j];
+ }
+ }
+ }
+ }
+ else
+ {
+ mgrobj = findManagerByName(mgrstr);
+ }
+ if (!CORBA::is_nil(mgrobj))
+ {
+ RTC_INFO(("New slave manager (%s) launched.", mgrstr.c_str()));
+ break;
+ }
RTC_DEBUG(("Waiting for slave manager started."));
coil::sleep(0.01);
}
@@ -1064,11 +1262,13 @@
RTC_ERROR(("Launch failed: manager (%s)", mgrstr.c_str()));
return RTC::RTObject::_nil();
}
+ std::string create_arg_str(create_arg);
+ getParameterByModulename("manager_name", create_arg_str);
RTC_DEBUG(("Creating component on %s", mgrstr.c_str()));
- RTC_DEBUG(("arg: %s", create_arg.c_str()));
+ RTC_DEBUG(("arg: %s", create_arg_str.c_str()));
try
{
- return mgrobj->create_component(create_arg.c_str());
+ return mgrobj->create_component(create_arg_str.c_str());
}
catch (CORBA::SystemException& e)
{
@@ -1086,7 +1286,8 @@
/*
* @if jp
- * @brief »ØÄE¢¥É¥E¹¤Î¥Þ¥Í¡¼¥¸¥ã¤ÇRTC¤òµ¯Æ°¤¹¤E * @else
+ * @brief wèAhXÌ}l[WÅRTCðN®·é
+ * @else
* @brief Launch a RTC on the specified IP/Port address manager
* @endif
*/
@@ -1101,10 +1302,10 @@
it->first.c_str(), it->second.c_str()));
}
- std::string mgrstr = param["manager_name"];
+ std::string mgrstr = param["manager_address"];
if (mgrstr.empty())
{
- RTC_WARN(("No manager_name found: %s", mgrstr.c_str()));
+ RTC_WARN(("No manager_address found: %s", mgrstr.c_str()));
return RTC::RTObject::_nil();
}
@@ -1111,7 +1312,7 @@
coil::vstring mgrvstr = coil::split(mgrstr, ":", true);
if (mgrvstr.size() != 2)
{
- RTC_WARN(("Invalid manager name: %s", mgrstr.c_str()));
+ RTC_WARN(("Invalid manager address: %s", mgrstr.c_str()));
return RTC::RTObject::_nil();
}
@@ -1169,11 +1370,13 @@
return RTC::RTObject::_nil();
}
+ std::string create_arg_str(create_arg);
+ getParameterByModulename("manager_address", create_arg_str);
RTC_DEBUG(("Creating component on %s", mgrstr.c_str()));
RTC_DEBUG(("arg: %s", create_arg.c_str()));
try
{
- return mgrobj->create_component(create_arg.c_str());
+ return mgrobj->create_component(create_arg_str.c_str());
}
catch (CORBA::SystemException& e)
{
@@ -1188,4 +1391,145 @@
}
return RTC::RTObject::_nil();
}
+
+
+
+ /*
+ * @if jp
+ * @brief }X^[}l[WÌL³ðmFµÄXgðXV·é
+ *
+ *
+ *
+ * @else
+ * @brief
+ *
+ *
+ * @endif
+ */
+ void ManagerServant::updateMasterManager()
+ {
+ if (!m_isMaster && !CORBA::is_nil(m_objref))
+ {
+ {
+ Guard guardm(m_masterMutex);
+ if (m_masters.length() > 0)
+ {
+ for (CORBA::ULong i = 0; i < m_masters.length(); i++)
+ {
+ try
+ {
+ if (m_masters[i]->_non_existent())
+ {
+ CORBA_SeqUtil::erase(m_masters, i);
+ }
+ }
+ catch (...)
+ {
+ RTC_ERROR(("Unknown exception cought."));
+ CORBA_SeqUtil::erase(m_masters, i);
+ }
+ }
+ }
+ }
+
+ if (m_masters.length() == 0)
+ {
+ coil::Properties config = m_mgr.getConfig();
+ try
+ {
+ RTM::Manager_ptr owner = findManager(config.getProperty("corba.master_manager"));
+ if (CORBA::is_nil(owner))
+ {
+ RTC_INFO(("Master manager not found"));
+ return;
+ }
+ add_master_manager(owner);
+ owner->add_slave_manager(m_objref);
+ }
+ catch (...)
+ {
+ RTC_ERROR(("Unknown exception cought."))
+ }
+ }
+
+ }
+ }
+
+
+ bool ManagerServant::isProcessIDManager(std::string mgrname)
+ {
+ int pos = mgrname.find("manager_");
+ if (pos != -1)
+ {
+ std::string id = mgrname;
+ coil::replaceString(id, "manager_", "");
+
+ bool ret = true;
+
+ int val = 0;
+ if (coil::stringTo<int>(val, id.c_str()))
+ {
+
+ return true;
+ }
+ }
+ return false;
+ }
+
+ const char* CompParam::prof_list[prof_list_size] = { "RTC", "vendor", "category", "implementation_id", "language", "version" };
+
+ CompParam::CompParam(std::string module_name)
+ {
+ module_name = coil::split(module_name, "?")[0];
+ coil::vstring param_list = coil::split(module_name,":");
+
+ if (param_list.size() < prof_list_size)
+ {
+ m_type = "RTC";
+ m_vendor = "";
+ m_category = "";
+ m_impl_id = module_name;
+ m_language = "C++";
+ m_version = "";
+ }
+ else
+ {
+ m_type = param_list[0];
+ m_vendor = param_list[1];
+ m_category = param_list[2];
+ m_impl_id = param_list[3];
+
+ if (!param_list[4].empty())
+ {
+ m_language = param_list[4];
+ }
+ else
+ {
+ m_language = "C++";
+ }
+ m_version = param_list[5];
+ }
+ }
+
+
+ std::string CompParam::vendor()
+ {
+ return m_vendor;
+ }
+ std::string CompParam::category()
+ {
+ return m_category;
+ }
+ std::string CompParam::impl_id()
+ {
+ return m_impl_id;
+ }
+ std::string CompParam::language()
+ {
+ return m_language;
+ }
+ std::string CompParam::version()
+ {
+ return m_version;
+ }
};
Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerServant.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerServant.h 2018-01-17 01:09:28 UTC (rev 3160)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerServant.h 2018-01-17 01:40:05 UTC (rev 3161)
@@ -689,6 +689,21 @@
*/
RTC::RTObject_ptr
createComponentByAddress(const std::string module_name);
+ /*
+ * @if jp
+ * @brief ¥Þ¥¹¥¿¡¼¥Þ¥Í¡¼¥¸¥ã¤ÎÍ̵¤ò³Îǧ¤·¤Æ¥ê¥¹¥È¤ò¹¹¿·¤¹¤ë
+ *
+ *
+ *
+ * @else
+ * @brief
+ *
+ *
+ * @endif
+ */
+ void updateMasterManager();
+ std::string getParameterByModulename(const std::string param_name, std::string &module_name);
+ bool isProcessIDManager(std::string mgrname);
private:
typedef coil::Guard<coil::Mutex> Guard;
@@ -775,6 +790,7 @@
{
RTM::Manager_var m_mgr;
public:
+
is_equiv(RTM::Manager_ptr mgr)
: m_mgr(RTM::Manager::_duplicate(mgr)) {}
bool operator()(RTM::Manager_ptr mgr)
@@ -783,6 +799,30 @@
}
};
+
+
};
+
+ class CompParam
+ {
+ public:
+ CompParam(std::string module_name);
+ static const unsigned int prof_list_size = 6;
+ static const char* prof_list[prof_list_size];
+ std::string vendor();
+ std::string category();
+ std::string impl_id();
+ std::string language();
+ std::string version();
+ private:
+ std::string m_type;
+ std::string m_vendor;
+ std::string m_category;
+ std::string m_impl_id;
+ std::string m_language;
+ std::string m_version;
+
+
+ };
}; // namespace RTM
#endif // RTM_MANAGERSERVANT_H
More information about the openrtm-commit
mailing list