SdoConfiguration.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
19 #include <coil/UUID.h>
20 #include "rtm/SdoConfiguration.h"
21 #include <rtm/CORBA_SeqUtil.h>
22 #include <rtm/NVUtil.h>
24 #include <memory>
25 #include <iostream>
26 // ACE
27 
28 namespace SDOPackage
29 {
51  void
52  toProperties(coil::Properties& prop, const SDOPackage::ConfigurationSet& conf)
53  {
54  NVUtil::copyToProperties(prop, conf.configuration_data);
55  }
56 
78  void
79  toConfigurationSet(SDOPackage::ConfigurationSet& conf,
80  const coil::Properties& prop)
81  {
82 #ifndef ORB_IS_RTORB
83  conf.description = CORBA::string_dup(prop["description"].c_str());
84  conf.id = CORBA::string_dup(prop.getName());
85 #else // ORB_IS_RTORB
86  conf.description = (char *)prop["description"].c_str();
87  conf.id = (char *)prop.getName();
88 #endif // ORB_IS_RTORB
89  NVUtil::copyFromProperties(conf.configuration_data, prop);
90  }
91 
92  //============================================================
93  // Ctor and Dtor
94  //============================================================
95 
96  /* @if jp
97  * @brief コンストラクタ
98  * @else
99  * @brief Constructor
100  * @endif
101  */
103  RTC::SdoServiceAdmin& sdoServiceAdmin)
104  : rtclog("sdo_config"), m_configsets(configsets),
105  m_sdoservice(sdoServiceAdmin)
106  {
107  m_objref = this->_this();
108  }
109 
110  /* @if jp
111  * @brief 仮想デストラクタ
112  * @else
113  * @brief Virtual destructor
114  * @endif
115  */
117  {
118  }
119 
120 
121  //============================================================
122  // Basic Configuration
123  //============================================================
124  /* @if jp
125  * @brief [CORBA interface] SDO の DeviceProfile をセットする * @else * @brief [CORBA interface] Set DeviceProfile of SDO * @endif */ CORBA::Boolean Configuration_impl::set_device_profile(const DeviceProfile& dProfile) throw (CORBA::SystemException, InvalidParameter, NotAvailable, InternalError) { RTC_TRACE(("set_device_profile()")); try { Guard gurad(m_dprofile_mutex); m_deviceProfile = dProfile; } catch (...) { throw InternalError("Unknown Error"); // never reach here return false; } return true; } /*! * @if jp * @brief [CORBA interface] SDO の ServiceProfile のセット * @else * @brief [CORBA interface] Set SDO's ServiceProfile * @endif */ CORBA::Boolean Configuration_impl::add_service_profile(const ServiceProfile& sProfile) throw (CORBA::SystemException, InvalidParameter, NotAvailable, InternalError) { RTC_TRACE(("add_service_profile()")); // SDO specification defines that InvalidParameter() exception // is thrown when sProfile is null. // But sProfile is reference and it becomes never null. // So this operation does not throw InvalidParameter exception. // if (CORBA::is_nil(sProfile.service)) throw InvalidParameter(); try { return m_sdoservice.addSdoServiceConsumer(sProfile); } catch (...) { throw InternalError("Configuration::set_service_profile"); } return false; } /*! * @if jp * @brief [CORBA interface] Organization の追加 * @else * @brief [CORBA interface] Add Organization * @endif */ CORBA::Boolean Configuration_impl::add_organization(Organization_ptr org) throw (CORBA::SystemException, InvalidParameter, NotAvailable, InternalError) { RTC_TRACE(("add_organization()")); try { CORBA_SeqUtil::push_back(m_organizations, ::SDOPackage::Organization::_duplicate(org)); } catch (...) { throw InternalError("Configuration::set_service_profile"); // never reach here return false; } return true; } /*! * @if jp * @brief [CORBA interface] ServiceProfile の削除 * @else * @brief [CORBA interface] Remove ServiceProfile * @endif */ CORBA::Boolean Configuration_impl::remove_service_profile(const char* id) throw (CORBA::SystemException, InvalidParameter, NotAvailable, InternalError) { RTC_TRACE(("remove_service_profile(%s)", id)); try { return m_sdoservice.removeSdoServiceConsumer(id); } catch (...) { throw InternalError("Configuration::remove_service_profile"); } return false; } /*! * @if jp * @brief [CORBA interface] Organization の参照の削除 * @else * @brief [CORBA interface] Remove the reference of Organization * @endif */ CORBA::Boolean Configuration_impl::remove_organization(const char* organization_id) throw (CORBA::SystemException, InvalidParameter, NotAvailable, InternalError) { RTC_TRACE(("remove_organization(%s)", organization_id)); try { Guard gurad(m_org_mutex); CORBA_SeqUtil::erase_if(m_organizations, org_id(organization_id)); } catch (...) { throw InternalError("Configuration::remove_organization"); // never reach here return false; } return true; } //============================================================ // Configuration Parameter manipulation //============================================================ /*! * @if jp * @brief [CORBA interface] 設定パラメータのリストの取得 * @else * @brief [CORBA interface] Get a list of configuration parameters * @endif */ ParameterList* Configuration_impl::get_configuration_parameters() throw (CORBA::SystemException, NotAvailable, InternalError) { RTC_TRACE(("get_configuration_parameters()")); try { Guard gaurd(m_params_mutex); ParameterList_var param; param = new ParameterList(m_parameters); return param._retn(); } catch (...) { throw InternalError("Configuration::get_configuration_parameters()"); //never reach here } // never reach here return new ParameterList(0); } /*! * @if jp * @brief [CORBA interface] Configuration parameter の値のリストの取得 * @else * @brief [CORBA interface] Get a list of the value of configuration parameters * @endif */ NVList* Configuration_impl::get_configuration_parameter_values() throw (CORBA::SystemException, NotAvailable, InternalError) { RTC_TRACE(("get_configuration_parameter_values()")); Guard guard(m_config_mutex); NVList_var nvlist; nvlist = new NVList((CORBA::ULong)0); /* CORBA::Long index; index = getActiveConfigIndex(); if (index >= 0) { nvlist = new NVList(m_configurations[index].configuration_data); } */ return nvlist._retn(); } /*! * @if jp * @brief [CORBA interface] Configuration parameter の値の取得 * @else * @brief [CORBA interface] Get the value of configuration parameter * @endif */ CORBA::Any* Configuration_impl::get_configuration_parameter_value(const char* name) throw (CORBA::SystemException, InvalidParameter, NotAvailable, InternalError) { RTC_TRACE(("get_configuration_parameter_value(%s)", name)); if (std::string(name).empty()) throw InvalidParameter("Name is empty."); // CORBA::Long index; CORBA::Any_var value; value = new CORBA::Any(); /* index = getActiveConfigIndex(); if (index < 0) throw InternalError("No active configuration."); CORBA::Long item; item = CORBA_SeqUtil::find(m_configurations[index].configuration_data, nv_name(name)); if (item < 0) throw InvalidParameter("No such name."); value = new CORBA::Any(m_configurations[index].configuration_data[item].value); */ return value._retn(); } /*! * @if jp * @brief [CORBA interface] Configuration パラメータの変更 * @else * @brief [CORBA interface] Modify the configuration parameter value * @endif */ CORBA::Boolean Configuration_impl::set_configuration_parameter(const char* name, const CORBA::Any& value) throw (CORBA::SystemException, InvalidParameter, NotAvailable, InternalError) { RTC_TRACE(("set_configuration_parameter(%s, value)", name)); /* if (name == "") throw InvalidParameter("Name is empty."); CORBA::Long index(getActiveConfigIndex()); if (index < 0) throw InternalError("No active config."); CORBA::Long item; item = CORBA_SeqUtil::find(m_configurations[index].configuration_data, nv_name(name)); if (item < 0) throw InvalidParameter("No such name."); m_configurations[index].configuration_data[item].value = value; */ return true; } /*! * @if jp * @brief [CORBA interface] ConfigurationSet リストの取得 * @else * @brief [CORBA interface] Get a list of ConfigurationSet * @endif */ ConfigurationSetList* Configuration_impl::get_configuration_sets() throw (CORBA::SystemException, NotAvailable, InternalError) { RTC_TRACE(("get_configuration_sets()")); try { Guard guard(m_config_mutex); std::vector<coil::Properties*> cf(m_configsets.getConfigurationSets()); ConfigurationSetList_var config_sets = new ConfigurationSetList((CORBA::ULong)cf.size()); // Ctor's first arg is max length. Actual length has to be set. config_sets->length((CORBA::ULong)cf.size()); for (CORBA::ULong i(0), len(cf.size()); i < len; ++i) { toConfigurationSet(config_sets[i], *(cf[i])); } return config_sets._retn(); } catch (CORBA::SystemException& e) { #ifndef ORB_IS_RTORB RTC_ERROR(("CORBA::SystemException cought: %s", e._name())); #else RTC_ERROR(("CORBA::SystemException cought.")); #endif throw InternalError("Configuration::get_configuration_sets()"); } catch (...) { RTC_ERROR(("Unknown exception cought.")); throw InternalError("Configuration::get_configuration_sets()"); } // never reach here return new ConfigurationSetList(0); } /*! * @if jp * @brief [CORBA interface] ConfigurationSet の取得 * @else * @brief [CORBA interface] Get a ConfigurationSet * @endif */ ConfigurationSet* Configuration_impl::get_configuration_set(const char* id) throw (CORBA::SystemException, NotAvailable, InternalError) { RTC_TRACE(("get_configuration_set(%s)", id)); if (std::string(id).empty()) throw InternalError("ID is empty"); // Originally getConfigurationSet raises InvalidParameter according to the // SDO specification. However, SDO's IDL lacks InvalidParameter. Guard guard(m_config_mutex); try { if (!m_configsets.haveConfig(id)) { RTC_ERROR(("No such ConfigurationSet")); throw InvalidParameter("No such ConfigurationSet"); } } catch(...) { RTC_ERROR(("Unknown exception")); throw InternalError("Unknown exception"); } const coil::Properties& configset(m_configsets.getConfigurationSet(id)); try { ConfigurationSet_var config; config = new ConfigurationSet(); toConfigurationSet(config, configset); return config._retn(); } catch (...) { throw InternalError("Configuration::get_configuration_set()"); } // never reach here RTC_FATAL(("never reach here")); return new ConfigurationSet(); } /*! * @if jp * @brief [CORBA interface] ConfigurationSet をセットする * @else * @brief [CORBA interface] Set ConfigurationSet * @endif */ CORBA::Boolean Configuration_impl:: set_configuration_set_values(const ConfigurationSet& configuration_set) throw (CORBA::SystemException, InvalidParameter, NotAvailable, InternalError) { RTC_TRACE(("set_configuration_set_values()")); std::string id(configuration_set.id); if (id.empty()) throw InvalidParameter("ID is empty."); try { coil::Properties conf(id.c_str()); toProperties(conf, configuration_set); //------------------------------------------------------------ // Because the format of port-name had been changed from // <port_name> to <instance_name>.<port_name>, the following // processing was added. (since r1648) if (conf.findNode("exported_ports") != 0) { coil::vstring exported_ports(coil::split(conf["exported_ports"], ",")); std::string exported_ports_str(""); for (size_t i(0), len(exported_ports.size()); i < len; ++i) { coil::vstring keyval(coil::split(exported_ports[i], ".")); if (keyval.size() > 2) { exported_ports_str += (keyval[0] + "." + keyval.back()); } else { exported_ports_str += exported_ports[i]; } if (i != exported_ports.size() - 1) { exported_ports_str += ","; } } conf["exported_ports"] = exported_ports_str; } //------------------------------------------------------------ return m_configsets.setConfigurationSetValues(conf); } catch (...) { throw InternalError("Configuration::set_configuration_set_values()"); } return true; } /*! * @if jp * @brief [CORBA interface] アクティブな ConfigurationSet を取得する * @else * @brief [CORBA interface] Get active ConfigurationSet * @endif */ ConfigurationSet* Configuration_impl::get_active_configuration_set() throw (CORBA::SystemException, NotAvailable, InternalError) { RTC_TRACE(("get_active_configuration_set()")); // activeなConfigurationSetは無い if (!m_configsets.isActive()) throw NotAvailable(); try { Guard gurad(m_config_mutex); // activeなConfigurationSetを返す ConfigurationSet_var config; config = new ConfigurationSet(); toConfigurationSet(config, m_configsets.getActiveConfigurationSet()); return config._retn(); } catch (...) { throw InternalError("Configuration::get_active_configuration_set()"); } // never reach here return new ConfigurationSet(); } /*! * @if jp * @brief [CORBA interface] ConfigurationSet を追加する * @else * @brief [CORBA interface] Add ConfigurationSet * @endif */ CORBA::Boolean Configuration_impl:: add_configuration_set(const ConfigurationSet& configuration_set) throw (CORBA::SystemException, InvalidParameter, NotAvailable, InternalError) { RTC_TRACE(("add_configuration_set()")); try { Guard gurad(m_config_mutex); const char* config_id(configuration_set.id); // const char* config_value(configuration_set.description); // RTC::Properties config(config_id); coil::Properties config(config_id); // coil::Properties config(config_id,config_value); toProperties(config, configuration_set); // config["description"] = configuration_set.description; return m_configsets.addConfigurationSet(config); } catch (...) { throw InternalError("Configuration::add_configuration_set()"); return false; } return true; } /*! * @if jp * @brief [CORBA interface] ConfigurationSet を削除する * @else * @brief [CORBA interface] Remove ConfigurationSet * @endif */ CORBA::Boolean Configuration_impl::remove_configuration_set(const char* id) throw (CORBA::SystemException, InvalidParameter, NotAvailable, InternalError) { RTC_TRACE(("remove_configuration_set(%s)", id)); if (std::string(id).empty()) throw InvalidParameter("ID is empty."); try { Guard guard(m_config_mutex); return m_configsets.removeConfigurationSet(id); } catch (...) { throw InternalError("Configuration::remove_configuration_set()"); return false; } return false; } /*! * @if jp * @brief [CORBA interface] ConfigurationSet のアクティブ化 * @else * @brief [CORBA interface] Activate ConfigurationSet * @endif */ CORBA::Boolean Configuration_impl::activate_configuration_set(const char* id) throw (CORBA::SystemException, InvalidParameter, NotAvailable, InternalError) { RTC_TRACE(("activate_configuration_set(%s)", id)); if (std::string(id).empty()) throw InvalidParameter("ID is empty."); if(m_configsets.activateConfigurationSet(id)) { return true; } else { throw InvalidParameter("Configuration::activate_configuration_set()"); } /* try { return m_configsets.activateConfigurationSet(id); } catch (...) { throw InternalError("Configuration::activate_configuration_set()"); return false; } */ return false; } //============================================================ // Local interfaces //============================================================ /*! * @if jp * @brief オブジェクト リファレンスを取得する * @else * @brief Get object reference * @endif */ Configuration_ptr Configuration_impl::getObjRef() { return m_objref; } /*! * @if jp * @brief SDO の DeviceProfile を取得する * @else * @brief Get the DeviceProfile of SDO * @endif */ const DeviceProfile Configuration_impl::getDeviceProfile() { return m_deviceProfile; } /*! * @if jp * @brief SDO の Organization リストを取得する * @else * @brief Get a list of Organization of SDO * @endif */ const OrganizationList Configuration_impl::getOrganizations() { return m_organizations; } /*! * @if jp * @brief UUIDを生成する * @else * @brief Generate UUID * @endif */ const std::string Configuration_impl::getUUID() const { coil::UUID_Generator uugen; uugen.init(); std::auto_ptr<coil::UUID> uuid(uugen.generateUUID(2,0x01)); return (const char*) uuid->to_string(); } };
126  * @else
127  * @brief [CORBA interface] Set DeviceProfile of SDO
128  * @endif
129  */
130  CORBA::Boolean
131  Configuration_impl::set_device_profile(const DeviceProfile& dProfile)
132  throw (CORBA::SystemException,
133  InvalidParameter, NotAvailable, InternalError)
134  {
135  RTC_TRACE(("set_device_profile()"));
136  try
137  {
138  Guard gurad(m_dprofile_mutex);
139  m_deviceProfile = dProfile;
140  }
141  catch (...)
142  {
143  throw InternalError("Unknown Error");
144  // never reach here
145  return false;
146  }
147  return true;
148  }
149 
157  CORBA::Boolean
158  Configuration_impl::add_service_profile(const ServiceProfile& sProfile)
159  throw (CORBA::SystemException,
160  InvalidParameter, NotAvailable, InternalError)
161  {
162  RTC_TRACE(("add_service_profile()"));
163  // SDO specification defines that InvalidParameter() exception
164  // is thrown when sProfile is null.
165  // But sProfile is reference and it becomes never null.
166  // So this operation does not throw InvalidParameter exception.
167  // if (CORBA::is_nil(sProfile.service)) throw InvalidParameter();
168  try
169  {
170  return m_sdoservice.addSdoServiceConsumer(sProfile);
171  }
172  catch (...)
173  {
174  throw InternalError("Configuration::set_service_profile");
175  }
176  return false;
177  }
178 
186  CORBA::Boolean
188  throw (CORBA::SystemException,
189  InvalidParameter, NotAvailable, InternalError)
190  {
191  RTC_TRACE(("add_organization()"));
192  try
193  {
195  ::SDOPackage::Organization::_duplicate(org));
196  }
197  catch (...)
198  {
199  throw InternalError("Configuration::set_service_profile");
200  // never reach here
201  return false;
202  }
203  return true;
204  }
205 
213  CORBA::Boolean
215  throw (CORBA::SystemException,
216  InvalidParameter, NotAvailable, InternalError)
217  {
218  RTC_TRACE(("remove_service_profile(%s)", id));
219  try
220  {
222  }
223  catch (...)
224  {
225  throw InternalError("Configuration::remove_service_profile");
226  }
227  return false;
228  }
229 
237  CORBA::Boolean
238  Configuration_impl::remove_organization(const char* organization_id)
239  throw (CORBA::SystemException,
240  InvalidParameter, NotAvailable, InternalError)
241  {
242  RTC_TRACE(("remove_organization(%s)", organization_id));
243  try
244  {
245  Guard gurad(m_org_mutex);
247  }
248  catch (...)
249  {
250  throw InternalError("Configuration::remove_organization");
251  // never reach here
252  return false;
253  }
254  return true;
255  }
256 
257  //============================================================
258  // Configuration Parameter manipulation
259  //============================================================
267  ParameterList*
269  throw (CORBA::SystemException,
270  NotAvailable, InternalError)
271  {
272  RTC_TRACE(("get_configuration_parameters()"));
273  try
274  {
275  Guard gaurd(m_params_mutex);
276  ParameterList_var param;
277  param = new ParameterList(m_parameters);
278  return param._retn();
279  }
280  catch (...)
281  {
282  throw InternalError("Configuration::get_configuration_parameters()");
283  //never reach here
284  }
285  // never reach here
286  return new ParameterList(0);
287  }
288 
296  NVList*
298  throw (CORBA::SystemException,
299  NotAvailable, InternalError)
300  {
301  RTC_TRACE(("get_configuration_parameter_values()"));
302  Guard guard(m_config_mutex);
303  NVList_var nvlist;
304  nvlist = new NVList((CORBA::ULong)0);
305 
306  /*
307  CORBA::Long index;
308  index = getActiveConfigIndex();
309  if (index >= 0)
310  {
311  nvlist = new NVList(m_configurations[index].configuration_data);
312  }
313  */
314  return nvlist._retn();
315  }
316 
324  CORBA::Any*
326  throw (CORBA::SystemException,
327  InvalidParameter, NotAvailable, InternalError)
328  {
329  RTC_TRACE(("get_configuration_parameter_value(%s)", name));
330  if (std::string(name).empty()) throw InvalidParameter("Name is empty.");
331 
332  // CORBA::Long index;
333  CORBA::Any_var value;
334  value = new CORBA::Any();
335  /*
336  index = getActiveConfigIndex();
337  if (index < 0) throw InternalError("No active configuration.");
338 
339  CORBA::Long item;
340  item = CORBA_SeqUtil::find(m_configurations[index].configuration_data,
341  nv_name(name));
342  if (item < 0) throw InvalidParameter("No such name.");
343 
344  value = new CORBA::Any(m_configurations[index].configuration_data[item].value);
345  */
346  return value._retn();
347  }
348 
356  CORBA::Boolean
358  const CORBA::Any& value)
359  throw (CORBA::SystemException,
360  InvalidParameter, NotAvailable, InternalError)
361  {
362  RTC_TRACE(("set_configuration_parameter(%s, value)", name));
363  /*
364  if (name == "") throw InvalidParameter("Name is empty.");
365 
366  CORBA::Long index(getActiveConfigIndex());
367  if (index < 0) throw InternalError("No active config.");
368 
369  CORBA::Long item;
370  item = CORBA_SeqUtil::find(m_configurations[index].configuration_data,
371  nv_name(name));
372  if (item < 0) throw InvalidParameter("No such name.");
373 
374  m_configurations[index].configuration_data[item].value = value;
375  */
376  return true;
377  }
378 
386  ConfigurationSetList*
388  throw (CORBA::SystemException,
389  NotAvailable, InternalError)
390  {
391  RTC_TRACE(("get_configuration_sets()"));
392  try
393  {
394  Guard guard(m_config_mutex);
395 
396  std::vector<coil::Properties*> cf(m_configsets.getConfigurationSets());
397  ConfigurationSetList_var config_sets =
398  new ConfigurationSetList((CORBA::ULong)cf.size());
399  // Ctor's first arg is max length. Actual length has to be set.
400  config_sets->length((CORBA::ULong)cf.size());
401 
402  for (CORBA::ULong i(0), len(cf.size()); i < len; ++i)
403  {
404  toConfigurationSet(config_sets[i], *(cf[i]));
405  }
406 
407  return config_sets._retn();
408  }
409  catch (CORBA::SystemException& e)
410  {
411 #ifndef ORB_IS_RTORB
412  RTC_ERROR(("CORBA::SystemException cought: %s", e._name()));
413 #else
414  RTC_ERROR(("CORBA::SystemException cought."));
415 #endif
416  throw InternalError("Configuration::get_configuration_sets()");
417 
418  }
419  catch (...)
420  {
421  RTC_ERROR(("Unknown exception cought."));
422  throw InternalError("Configuration::get_configuration_sets()");
423  }
424  // never reach here
425  return new ConfigurationSetList(0);
426  }
427 
435  ConfigurationSet*
437  throw (CORBA::SystemException,
438  NotAvailable, InternalError)
439  {
440  RTC_TRACE(("get_configuration_set(%s)", id));
441  if (std::string(id).empty()) throw InternalError("ID is empty");
442  // Originally getConfigurationSet raises InvalidParameter according to the
443  // SDO specification. However, SDO's IDL lacks InvalidParameter.
444 
445  Guard guard(m_config_mutex);
446 
447  try
448  {
449  if (!m_configsets.haveConfig(id))
450  {
451  RTC_ERROR(("No such ConfigurationSet"));
452  throw InvalidParameter("No such ConfigurationSet");
453  }
454  }
455  catch(...)
456  {
457  RTC_ERROR(("Unknown exception"));
458  throw InternalError("Unknown exception");
459  }
460 
462 
463  try
464  {
465  ConfigurationSet_var config;
466  config = new ConfigurationSet();
467  toConfigurationSet(config, configset);
468 
469  return config._retn();
470  }
471  catch (...)
472  {
473  throw InternalError("Configuration::get_configuration_set()");
474  }
475 
476  // never reach here
477  RTC_FATAL(("never reach here"));
478  return new ConfigurationSet();
479  }
480 
488  CORBA::Boolean
490  set_configuration_set_values(const ConfigurationSet& configuration_set)
491  throw (CORBA::SystemException,
492  InvalidParameter, NotAvailable, InternalError)
493  {
494  RTC_TRACE(("set_configuration_set_values()"));
495  std::string id(configuration_set.id);
496  if (id.empty()) throw InvalidParameter("ID is empty.");
497 
498  try
499  {
500  coil::Properties conf(id.c_str());
501  toProperties(conf, configuration_set);
502 
503  //------------------------------------------------------------
504  // Because the format of port-name had been changed from
505  // <port_name> to <instance_name>.<port_name>, the following
506  // processing was added. (since r1648)
507  if (conf.findNode("exported_ports") != 0)
508  {
510  exported_ports(coil::split(conf["exported_ports"], ","));
511  std::string exported_ports_str("");
512  for (size_t i(0), len(exported_ports.size()); i < len; ++i)
513  {
514  coil::vstring keyval(coil::split(exported_ports[i], "."));
515  if (keyval.size() > 2)
516  {
517  exported_ports_str += (keyval[0] + "." + keyval.back());
518  }
519  else
520  {
521  exported_ports_str += exported_ports[i];
522  }
523  if (i != exported_ports.size() - 1)
524  {
525  exported_ports_str += ",";
526  }
527  }
528  conf["exported_ports"] = exported_ports_str;
529  }
530  //------------------------------------------------------------
531 
533  }
534  catch (...)
535  {
536  throw InternalError("Configuration::set_configuration_set_values()");
537  }
538  return true;
539  }
540 
548  ConfigurationSet*
550  throw (CORBA::SystemException,
551  NotAvailable, InternalError)
552  {
553  RTC_TRACE(("get_active_configuration_set()"));
554  // activeなConfigurationSetは無い
555  if (!m_configsets.isActive()) throw NotAvailable();
556 
557  try
558  {
559  Guard gurad(m_config_mutex);
560  // activeなConfigurationSetを返す
561  ConfigurationSet_var config;
562  config = new ConfigurationSet();
564  return config._retn();
565  }
566  catch (...)
567  {
568  throw InternalError("Configuration::get_active_configuration_set()");
569  }
570  // never reach here
571  return new ConfigurationSet();
572  }
573 
581  CORBA::Boolean
583  add_configuration_set(const ConfigurationSet& configuration_set)
584  throw (CORBA::SystemException,
585  InvalidParameter, NotAvailable, InternalError)
586  {
587  RTC_TRACE(("add_configuration_set()"));
588  try
589  {
590  Guard gurad(m_config_mutex);
591  const char* config_id(configuration_set.id);
592 // const char* config_value(configuration_set.description);
593 // RTC::Properties config(config_id);
594  coil::Properties config(config_id);
595 // coil::Properties config(config_id,config_value);
596  toProperties(config, configuration_set);
597 // config["description"] = configuration_set.description;
598  return m_configsets.addConfigurationSet(config);
599  }
600  catch (...)
601  {
602  throw InternalError("Configuration::add_configuration_set()");
603  return false;
604  }
605  return true;
606  }
607 
615  CORBA::Boolean
617  throw (CORBA::SystemException,
618  InvalidParameter, NotAvailable, InternalError)
619  {
620  RTC_TRACE(("remove_configuration_set(%s)", id));
621  if (std::string(id).empty())
622  throw InvalidParameter("ID is empty.");
623 
624  try
625  {
626  Guard guard(m_config_mutex);
628  }
629  catch (...)
630  {
631  throw InternalError("Configuration::remove_configuration_set()");
632  return false;
633  }
634  return false;
635  }
636 
644  CORBA::Boolean
646  throw (CORBA::SystemException,
647  InvalidParameter, NotAvailable, InternalError)
648  {
649  RTC_TRACE(("activate_configuration_set(%s)", id));
650  if (std::string(id).empty())
651  throw InvalidParameter("ID is empty.");
652 
654  {
655  return true;
656  }
657  else
658  {
659  throw InvalidParameter("Configuration::activate_configuration_set()");
660  }
661 /*
662  try
663  {
664  return m_configsets.activateConfigurationSet(id);
665  }
666  catch (...)
667  {
668  throw InternalError("Configuration::activate_configuration_set()");
669  return false;
670  }
671 */
672  return false;
673  }
674 
675  //============================================================
676  // Local interfaces
677  //============================================================
678 
686  Configuration_ptr Configuration_impl::getObjRef()
687  {
688  return m_objref;
689  }
690 
699  {
700  return m_deviceProfile;
701  }
702 
710  const OrganizationList Configuration_impl::getOrganizations()
711  {
712  return m_organizations;
713  }
714 
722  const std::string Configuration_impl::getUUID() const
723  {
724  coil::UUID_Generator uugen;
725  uugen.init();
726  std::auto_ptr<coil::UUID> uuid(uugen.generateUUID(2,0x01));
727 
728  return (const char*) uuid->to_string();
729  }
730 };
#define RTC_ERROR(fmt)
Error log output macro.
Definition: SystemLogger.h:422
virtual CORBA::Boolean add_configuration_set(const ConfigurationSet &configuration_set)
[CORBA interface] Add ConfigurationSet
virtual CORBA::Boolean set_configuration_set_values(const ConfigurationSet &configuration_set)
[CORBA interface] Set ConfigurationSet
virtual NVList * get_configuration_parameter_values()
[CORBA interface] Get a list of the value of configuration parameters
void toConfigurationSet(SDOPackage::ConfigurationSet &conf, const coil::Properties &prop)
Convert properties into SDO ConfigurationSet.
virtual ConfigurationSet * get_active_configuration_set()
[CORBA interface] Get active ConfigurationSet
bool activateConfigurationSet(const char *config_id)
Activate the configuration set.
bool isActive(void)
Confirm to activate configuration set.
Definition: ConfigAdmin.h:847
std::vector< std::pair< std::string, std::string > > NVList
Definition: IRTC.h:67
ConfigAdmin class.
Definition: ConfigAdmin.h:534
void init()
Initialization.
const std::vector< coil::Properties * > & getConfigurationSets(void)
Get all configuration sets.
virtual CORBA::Boolean set_configuration_parameter(const char *name, const CORBA::Any &value)
[CORBA interface] Modify the configuration parameter value
Configuration_impl(RTC::ConfigAdmin &configAdmin, RTC::SdoServiceAdmin &sdoServiceAdmin)
Constructor.
vstring split(const std::string &input, const std::string &delimiter, bool ignore_empty)
Split string by delimiter.
Definition: stringutil.cpp:346
virtual CORBA::Boolean remove_organization(const char *organization_id)
[CORBA interface] Remove the reference of Organization
const coil::Properties & getActiveConfigurationSet(void)
Get the active configuration set.
ExecutionContext base class.
virtual CORBA::Boolean add_organization(Organization_ptr org)
[CORBA interface] Add Organization
virtual CORBA::Boolean add_service_profile(const ServiceProfile &sProfile)
[CORBA interface] Set SDO&#39;s ServiceProfile
virtual CORBA::Any * get_configuration_parameter_value(const char *name)
[CORBA interface] Get the value of configuration parameter
const coil::Properties & getConfigurationSet(const char *config_id)
Get a configuration set by specified ID.
SDO Package.
const char * getName(void) const
Get Names.
Definition: Properties.h:283
virtual CORBA::Boolean activate_configuration_set(const char *config_id)
[CORBA interface] Activate ConfigurationSet
#define RTC_FATAL(fmt)
Error log output macro.
Definition: SystemLogger.h:400
std::vector< std::string > vstring
Definition: stringutil.h:37
coil::UUID * generateUUID(ACE_UINT16 version=0x0001, u_char variant=0x80)
Definition: ace/coil/UUID.h:45
void copyToProperties(coil::Properties &prop, const SDOPackage::NVList &nv)
Copy NVList to the Proeprties.
Definition: NVUtil.cpp:137
#define RTC_TRACE(fmt)
bool addConfigurationSet(const coil::Properties &configuration_set)
Add the configuration value to configuration set.
Properties *const findNode(const std::string &key) const
Get node of properties.
Definition: Properties.cpp:444
const OrganizationList getOrganizations()
Get a list of Organization of SDO.
NameValue and NVList utility functions.
Configuration_var m_objref
The reference to CORBA object.
OrganizationList m_organizations
SDO OrganizationList with mutex lock.
CORBA sequence utility template functions.
void erase_if(CorbaSequence &seq, Functor f)
Remove an element of a sequence according to a predicate.
virtual CORBA::Boolean set_device_profile(const DeviceProfile &dProfile)
[CORBA interface] Set DeviceProfile of SDO
virtual ConfigurationSetList * get_configuration_sets()
[CORBA interface] Get a list of ConfigurationSet
prop
Organization::get_organization_property ();.
Class represents a set of properties.
Definition: Properties.h:101
virtual ConfigurationSet * get_configuration_set(const char *config_id)
[CORBA interface] Get a ConfigurationSet
RTC::SdoServiceAdmin & m_sdoservice
SDO Service admin object with mutex lock.
const std::string getUUID() const
Generate UUID.
bool addSdoServiceConsumer(const SDOPackage::ServiceProfile &sProfile)
Add Service Consumer.
DeviceProfile m_deviceProfile
SDO DeviceProfile with mutex lock.
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.
void copyFromProperties(SDOPackage::NVList &nv, const coil::Properties &prop)
Copy the properties to NVList.
Definition: NVUtil.cpp:108
ParameterList m_parameters
SDO Parameter.
Configuration_ptr getObjRef()
Get object reference.
bool haveConfig(const char *config_id)
Check the existence of configuration set.
Definition: ConfigAdmin.h:822
bool setConfigurationSetValues(const coil::Properties &configuration_set)
Add to configuration set from specified property.
RTC::ConfigAdmin & m_configsets
SDO ConfigurationSetList with mutex lock.
const DeviceProfile getDeviceProfile()
Get the DeviceProfile of SDO.
RT component base class.
bool removeConfigurationSet(const char *config_id)
Remove the configuration set.
virtual CORBA::Boolean remove_service_profile(const char *id)
[CORBA interface] Remove ServiceProfile
bool removeSdoServiceConsumer(const char *id)
Remove Service Consumer.
virtual ParameterList * get_configuration_parameters()
[CORBA interface] Get a list of configuration parameters
void toProperties(coil::Properties &prop, const SDOPackage::ConfigurationSet &conf)
Store SDO ConfigurationSet to properties.
virtual ~Configuration_impl(void)
Virtual destractor.
virtual CORBA::Boolean remove_configuration_set(const char *config_id)
[CORBA interface] Remove ConfigurationSet


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Feb 28 2022 23:00:45