00001 #!/usr/bin/env python 00002 # -*- coding: euc-jp -*- 00003 00004 ## 00005 # @file SdoConfiguration.py 00006 # @brief RT component base class 00007 # @date $Date: 2007/09/06$ 00008 # @author Noriaki Ando <n-ando@aist.go.jp> and Shinji Kurihara 00009 # 00010 # Copyright (C) 2006-2008 00011 # Task-intelligence Research Group, 00012 # Intelligent Systems Research Institute, 00013 # National Institute of 00014 # Advanced Industrial Science and Technology (AIST), Japan 00015 # All rights reserved. 00016 00017 00018 import copy 00019 import threading 00020 00021 import OpenRTM 00022 import SDOPackage, SDOPackage__POA 00023 00024 00025 ## 00026 # @if jp 00027 # @class ScopedLock 00028 # @brief ScopedLock クラス 00029 # 00030 # 排他処理用ロッククラス。 00031 # 00032 # @since 0.4.0 00033 # 00034 # @else 00035 # 00036 # @endif 00037 class ScopedLock: 00038 def __init__(self, mutex): 00039 self.mutex = mutex 00040 self.mutex.acquire() 00041 00042 def __del__(self): 00043 self.mutex.release() 00044 00045 00046 # SdoConfiguration with SeqEx 159120 00047 # SdoConfiguration with SeqUtil 114504 114224 00048 00049 00050 ## 00051 # @if jp 00052 # 00053 # @brief NVList を Properties へコピーする 00054 # 00055 # このオペレーションは NVList を Properties へコピーする。 00056 # 00057 # @param prop NVList の値を格納する Properties 00058 # @param nv コピー元の NVList 00059 # 00060 # @else 00061 # 00062 # @brief Copy to Proeprties from NVList 00063 # 00064 # This operation copies NVList to Properties. 00065 # 00066 # @param prop Properties to store NVList values 00067 # @param nv NVList that is copies from 00068 # 00069 # @endif 00070 def toProperties(prop, conf): 00071 OpenRTM.NVUtil.copyToProperties(prop, conf.configuration_data) 00072 00073 00074 ## 00075 # @if jp 00076 # 00077 # @brief Properties を NVList へコピーする 00078 # 00079 # このオペレーションは Properties を NVList へコピーする。 00080 # NVList の value は全て CORBA::string 型としてコピーする。 00081 # 00082 # @param nv Properties の値を格納する NVList 00083 # @param prop コピー元の Properties 00084 # 00085 # @else 00086 # 00087 # @brief Copy to NVList from Proeprties 00088 # 00089 # This operation copies Properties to NVList. 00090 # Created NVList's values are CORBA::string. 00091 # 00092 # @param nv NVList to store Properties values 00093 # @param prop Properties that is copies from 00094 # 00095 # @endif 00096 def toConfigurationSet(conf, prop): 00097 conf.description = prop.getProperty("description") 00098 conf.id = prop.getName() 00099 OpenRTM.NVUtil.copyFromProperties(conf.configuration_data, prop) 00100 00101 00102 00103 ## 00104 # @if jp 00105 # 00106 # @class Configuration_impl 00107 # @brief SDO Configuration 実装クラス 00108 # 00109 # Configuration interface は Resource Data Model で定義されたデータの 00110 # 追加、削除等の操作を行うためのインターフェースである。 00111 # DeviceProfile, ServiceProfile, ConfigurationProfile および Organization 00112 # の変更を行うためのオペレーションを備えている。SDO の仕様ではアクセス制御 00113 # およびセキュリティに関する詳細については規定していない。 00114 # 00115 # 複数の設定 (Configuration) を保持することにより、容易かつ素早くある設定 00116 # を反映させることができる。事前に定義された複数の設定を ConfigurationSets 00117 # および configuration profile として保持することができる。ひとつの 00118 # ConfigurationSet は特定の設定に関連付けられた全プロパティ値のリストを、 00119 # ユニークID、詳細とともに持っている。これにより、各設定項目の詳細を記述し 00120 # 区別することができる。Configuration interface のオペレーションはこれら 00121 # ConfiguratioinSets の管理を支援する。 00122 # 00123 # 00124 # - ConfigurationSet: id, description, NVList から構成される1セットの設定 00125 # - ConfigurationSetList: ConfigurationSet のリスト 00126 # - Parameter: name, type, allowed_values から構成されるパラメータ定義。 00127 # - ActiveConfigurationSet: 現在有効なコンフィギュレーションの1セット。 00128 # 00129 # 以下、SDO仕様に明記されていないもしくは解釈がわからないため独自解釈 00130 # 00131 # 以下の関数は ParameterList に対して処理を行う。 00132 # - get_configuration_parameters() 00133 # 00134 # 以下の関数はアクティブなConfigurationSetに対する処理を行う 00135 # - get_configuration_parameter_values() 00136 # - get_configuration_parameter_value() 00137 # - set_configuration_parameter() 00138 # 00139 # 以下の関数はConfigurationSetListに対して処理を行う 00140 # - get_configuration_sets() 00141 # - get_configuration_set() 00142 # - set_configuration_set_values() 00143 # - get_active_configuration_set() 00144 # - add_configuration_set() 00145 # - remove_configuration_set() 00146 # - activate_configuration_set() 00147 # 00148 # @since 0.4.0 00149 # 00150 # @else 00151 # 00152 # @class Configuration_impl 00153 # @brief Configuration implementation class 00154 # 00155 # Configuration interface provides operations to add or remove data 00156 # specified in resource data model. These operations provide functions to 00157 # change DeviceProfile, ServiceProfile, ConfigurationProfile, and 00158 # Organization. This specification does not address access control or 00159 # security aspects. Access to operations that modifies or removes profiles 00160 # should be controlled depending upon the application. 00161 # 00162 # Different configurations can be stored for simple and quick activation. 00163 # Different predefined configurations are stored as different 00164 # ConfigurationSets or configuration profile. A ConfigurationSet stores the 00165 # value of all properties assigned for the particular configuration along 00166 # with its unique id and description to identify and describe the 00167 # configuration respectively. Operations in the configuration interface 00168 # help manage these ConfigurationSets. 00169 # 00170 # @since 0.4.0 00171 # 00172 # @endif 00173 class Configuration_impl(SDOPackage__POA.Configuration): 00174 00175 00176 00177 ## 00178 # @if jp 00179 # 00180 # @brief コンストラクタ 00181 # 00182 # コンストラクタ 00183 # 00184 # @param self 00185 # @param configsets ConfigurationSetList 00186 # 00187 # @else 00188 # 00189 # @endif 00190 def __init__(self, configsets): 00191 """ 00192 \var self._deviceProfile SDO DeviceProfile with mutex lock 00193 """ 00194 self._deviceProfile = None 00195 self._dprofile_mutex = threading.RLock() 00196 00197 """ 00198 \var self._serviceProfiles SDO ServiceProfileList 00199 """ 00200 self._serviceProfiles = [] 00201 self._sprofile_mutex = threading.RLock() 00202 00203 self._parameters = [] 00204 self._params_mutex = threading.RLock() 00205 00206 self._configsets = configsets 00207 self._config_mutex = threading.RLock() 00208 00209 """ 00210 \var self._organizations SDO OrganizationList 00211 """ 00212 self._organizations = [] 00213 self._org_mutex = threading.RLock() 00214 00215 self._objref = self._this() 00216 00217 00218 #============================================================ 00219 # 00220 # <<< CORBA interfaces >>> 00221 # 00222 #============================================================ 00223 00224 ## 00225 # @if jp 00226 # 00227 # @brief [CORBA interface] SDO の DeviceProfile のセット 00228 # 00229 # このオペレーションは SDO の DeviceProfile をセットする。SDO が 00230 # DeviceProfile を保持していない場合は新たな DeviceProfile を生成し、 00231 # DeviceProfile をすでに保持している場合は既存のものと置き換える。 00232 # 00233 # @param self 00234 # @param dProfile SDO に関連付けられる DeviceProfile。 00235 # 00236 # @return オペレーションが成功したかどうかを返す。 00237 # 00238 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00239 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00240 # @exception NotAvailable SDOは存在するが応答がない。 00241 # @exception InvalidParameter 引数 "dProfile" が null である。 00242 # @exception InternalError 内部的エラーが発生した。 00243 # 00244 # @else 00245 # 00246 # @brief [CORBA interface] Set DeviceProfile of SDO 00247 # 00248 # This operation sets the DeviceProfile of an SDO. If the SDO does not 00249 # have DeviceProfile, the operation will create a new DeviceProfile, 00250 # otherwise it will replace the existing DeviceProfile. 00251 # 00252 # @param dProfile The device profile that is to be assigned to this SDO. 00253 # 00254 # @return If the operation was successfully completed. 00255 # 00256 # @exception SDONotExists if the target SDO does not exist.(This exception 00257 # is mapped to CORBA standard system exception 00258 # OBJECT_NOT_EXIST.) 00259 # @exception NotAvailable The target SDO is reachable but cannot respond. 00260 # @exception InvalidParameter The argument "dProfile" is null. 00261 # @exception InternalError The target SDO cannot execute the operation 00262 # completely due to some internal error. 00263 # @endif 00264 def set_device_profile(self, dProfile): 00265 if dProfile is None: 00266 raise SDOPackage.InvalidParameter("dProfile is empty.") 00267 00268 try: 00269 guard = ScopedLock(self._dprofile_mutex) 00270 self._deviceProfile = dProfile 00271 except: 00272 raise SDOPackage.InternalError("Unknown Error") 00273 00274 return True 00275 00276 00277 ## 00278 # @if jp 00279 # 00280 # @brief [CORBA interface] SDO の ServiceProfile のセット 00281 # 00282 # このオペレーションはこの Configuration interface を所有する対象 SDO の 00283 # ServiceProfile を追加する。もし引数の ServiceProfile の id が空であれば 00284 # 新しい ID が生成されその ServiceProfile を格納する。もし id が空で 00285 # なければ、SDO は同じ id を持つ ServiceProfile を検索する。 00286 # 同じ id が存在しなければこの ServiceProfile を追加し、id が存在すれば 00287 # 上書きをする。<br> 00288 # (注意:最新バージョンではオペレーション名がadd_service_profile変更) 00289 # 00290 # @param self 00291 # @param sProfile 追加する ServiceProfile 00292 # 00293 # @return オペレーションが成功したかどうかを返す。 00294 # 00295 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00296 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00297 # @exception InvalidParameter 引数 "sProfile" が nullである。 00298 # @exception NotAvailable SDOは存在するが応答がない。 00299 # @exception InternalError 内部的エラーが発生した。 00300 # @else 00301 # 00302 # @brief [CORBA interface] Set SDO's ServiceProfile 00303 # 00304 # This operation adds ServiceProfile to the target SDO that navigates this 00305 # Configuration interface. If the id in argument ServiceProfile is null, 00306 # new id is created and the ServiceProfile is stored. If the id is not 00307 # null, the target SDO searches for ServiceProfile in it with the same id. 00308 # It adds the ServiceProfile if not exist, or overwrites if exist. 00309 # 00310 # @param sProfile ServiceProfile to be added. 00311 # 00312 # @return If the operation was successfully completed. 00313 # 00314 # @exception SDONotExists if the target SDO does not exist.(This exception 00315 # is mapped to CORBA standard system exception 00316 # OBJECT_NOT_EXIST.) 00317 # @exception NotAvailable The target SDO is reachable but cannot respond. 00318 # @exception InvalidParameter The argument "sProfile" is null. 00319 # @exception InternalError The target SDO cannot execute the operation 00320 # completely due to some internal error. 00321 # @endif 00322 def set_service_profile(self, sProfile): 00323 if sProfile is None: 00324 raise SDOPackage.InvalidParameter("sProfile is empty.") 00325 00326 try: 00327 if sProfile.id is None: 00328 prof = sProfile 00329 prof.id = self.getUUID() 00330 OpenRTM.CORBA_SeqUtil.push_back(self._serviceProfiles, prof) 00331 return True 00332 00333 index = OpenRTM.CORBA_SeqUtil.find(self._serviceProfiles, 00334 self.service_id(sProfile.id)) 00335 if index >= 0: 00336 OpenRTM.CORBA_SeqUtil.erase(self._serviceProfiles, index) 00337 00338 OpenRTM.CORBA_SeqUtil.push_back(self._serviceProfiles, sProfile) 00339 return True 00340 except: 00341 raise SDOPackage.InternalError("Configuration.set_service_profile") 00342 00343 return True 00344 00345 00346 ## 00347 # @if jp 00348 # 00349 # @brief [CORBA interface] Organization の追加 00350 # 00351 # このオペレーションは Organization object のリファレンスを追加する。 00352 # 00353 # @param self 00354 # @param org 追加する Organization 00355 # 00356 # @return オペレーションが成功したかどうかを返す。 00357 # 00358 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00359 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00360 # @exception NotAvailable SDOは存在するが応答がない。 00361 # @exception InvalidParameter 引数 "organization" が null である。 00362 # @exception InternalError 内部的エラーが発生した。 00363 # @else 00364 # 00365 # @brief [CORBA interface] Add Organization 00366 # 00367 # This operation adds reference of an Organization object. 00368 # 00369 # @param org Organization to be added. 00370 # 00371 # @return If the operation was successfully completed. 00372 # 00373 # @exception SDONotExists if the target SDO does not exist.(This exception 00374 # is mapped to CORBA standard system exception 00375 # OBJECT_NOT_EXIST.) 00376 # @exception NotAvailable The target SDO is reachable but cannot respond. 00377 # @exception InvalidParameter The argument “organization” is null. 00378 # @exception InternalError The target SDO cannot execute the operation 00379 # completely due to some internal error. 00380 # @endif 00381 def add_organization(self, org): 00382 if org is None: 00383 raise SDOPackage.InvalidParameter("org is empty.") 00384 00385 try: 00386 OpenRTM.CORBA_SeqUtil.push_back(self._organizations, org) 00387 except: 00388 raise SDOPackage.InternalError("Configuration.add_organization") 00389 00390 return True 00391 00392 00393 ## 00394 # @if jp 00395 # 00396 # @brief [CORBA interface] ServiceProfile の削除 00397 # 00398 # このオペレーションはこの Configuration interface を持つ SDO の 00399 # Service の ServiceProfile を削除する。削除する ServiceProfile 00400 # は引数により指定される。 00401 # 00402 # @param self 00403 # @param id_ 削除する ServcieProfile の serviceID。 00404 # 00405 # @return オペレーションが成功したかどうかを返す。 00406 # 00407 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00408 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00409 # @exception InvalidParameter 引数 "id" が null である。もしくは "id" に 00410 # 関連付けられた ServiceProfile が存在しない。 00411 # @exception NotAvailable SDOは存在するが応答がない。 00412 # @exception InternalError 内部的エラーが発生した。 00413 # @else 00414 # 00415 # @brief [CORBA interface] Remove ServiceProfile 00416 # 00417 # This operation removes ServiceProfile object to the SDO that has this 00418 # Configuration interface. The ServiceProfile object to be removed is 00419 # specified by argument. 00420 # 00421 # @param id_ serviceID of a ServiceProfile to be removed. 00422 # 00423 # @return If the operation was successfully completed. 00424 # 00425 # @exception SDONotExists if the target SDO does not exist.(This exception 00426 # is mapped to CORBA standard system exception 00427 # OBJECT_NOT_EXIST.) 00428 # @exception InvalidParameter The argument "sProfile" is null, or if the 00429 # object that is specified by argument "sProfile" does not exist. 00430 # @exception NotAvailable The target SDO is reachable but cannot respond. 00431 # @exception InternalError The target SDO cannot execute the operation 00432 # completely due to some internal error. 00433 # @endif 00434 def remove_service_profile(self, id_): 00435 if id_ is None: 00436 raise SDOPackage.InvalidParameter("id is empty.") 00437 00438 try: 00439 OpenRTM.CORBA_SeqUtil.erase_if(self._serviceProfiles, self.service_id(id_)) 00440 except: 00441 raise SDOPackage.InternalError("Configuration.remove_service_profile") 00442 00443 return True 00444 00445 00446 ## 00447 # @if jp 00448 # 00449 # @brief [CORBA interface] Organization の参照の削除 00450 # 00451 # このオペレーションは Organization の参照を削除する。 00452 # 00453 # @param self 00454 # @param organization_id 削除する Organization の一意な id。 00455 # 00456 # @return オペレーションが成功したかどうかを返す。 00457 # 00458 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00459 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00460 # @exception InvalidParameter 引数 "organization_id" が null である。 00461 # もしくは "organization_id" に関連付けられた 00462 # OrganizationProfile が存在しない。 00463 # @exception NotAvailable SDOは存在するが応答がない。 00464 # @exception InternalError 内部的エラーが発生した。 00465 # @else 00466 # 00467 # @brief [CORBA interface] Remove the reference of Organization 00468 # 00469 # This operation removes the reference of an Organization object. 00470 # 00471 # @param organization_id Unique id of the organization to be removed. 00472 # 00473 # @return If the operation was successfully completed. 00474 # 00475 # @exception SDONotExists if the target SDO does not exist.(This exception 00476 # is mapped to CORBA standard system exception 00477 # OBJECT_NOT_EXIST.) 00478 # @exception InvalidParameter The argument "organizationID" is null, 00479 # or the object which is specified by argument "organizationID" 00480 # does not exist. 00481 # @exception NotAvailable The target SDO is reachable but cannot respond. 00482 # @exception InternalError The target SDO cannot execute the operation 00483 # completely due to some internal error. 00484 # @endif 00485 def remove_organization(self, organization_id): 00486 if organization_id is None: 00487 raise SDOPackage.InvalidParameter("organization_id is empty.") 00488 00489 try: 00490 guard = ScopedLock(self._org_mutex) 00491 OpenRTM.CORBA_SeqUtil.erase_if(self._organizations, 00492 self.org_id(organization_id)) 00493 except: 00494 raise SDOPackage.InternalError("Configuration.remove_organization") 00495 00496 return True 00497 00498 00499 ## 00500 # @if jp 00501 # 00502 # @brief [CORBA interface] 設定パラメータのリストの取得 00503 # 00504 # このオペレーションは configuration parameter のリストを返す。 00505 # SDO が設定可能なパラメータを持たなければ空のリストを返す。 00506 # 00507 # @param self 00508 # 00509 # @return 設定を特徴付けるパラメータ定義のリスト。 00510 # 00511 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00512 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00513 # @exception NotAvailable SDOは存在するが応答がない。 00514 # @exception InternalError 内部的エラーが発生した。 00515 # @else 00516 # 00517 # @brief [CORBA interface] Getting a list of configuration parameter 00518 # 00519 # This operation returns a list of Parameters. An empty list is returned 00520 # if the SDO does not have any configurable parameter. 00521 # 00522 # @return The list with definitions of parameters characterizing the 00523 # configuration. 00524 # 00525 # @exception SDONotExists if the target SDO does not exist.(This exception 00526 # is mapped to CORBA standard system exception 00527 # OBJECT_NOT_EXIST.) 00528 # @exception NotAvailable The target SDO is reachable but cannot respond. 00529 # @exception InternalError The target SDO cannot execute the operation 00530 # completely due to some internal error. 00531 # @endif 00532 def get_configuration_parameters(self): 00533 try: 00534 guard = ScopedLock(self._params_mutex) 00535 param = copy.copy(self._parameters) 00536 return param 00537 except: 00538 raise SDOPackage.InternalError("Configuration.get_configuration_parameters") 00539 00540 return [] 00541 00542 00543 ## 00544 # @if jp 00545 # 00546 # @brief [CORBA interface] Configuration parameter の値のリストの取得 00547 # 00548 # このオペレーションは全ての configuration パラメータおよび値を返す。<br> 00549 # ※本実装では常に空のリストを返す 00550 # 00551 # @param self 00552 # 00553 # @return 全ての configuration パラメータと値のリスト。 00554 # 00555 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00556 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00557 # @exception NotAvailable SDOは存在するが応答がない。 00558 # @exception InternalError 内部的エラーが発生した。 00559 # @else 00560 # 00561 # @brief [CORBA interface] Getting value list of configuration parameter 00562 # 00563 # This operation returns all configuration parameters and their values. 00564 # 00565 # @return List of all configuration parameters and their values. 00566 # 00567 # @exception SDONotExists if the target SDO does not exist.(This exception 00568 # is mapped to CORBA standard system exception 00569 # OBJECT_NOT_EXIST.) 00570 # @exception NotAvailable The target SDO is reachable but cannot respond. 00571 # @exception InternalError The target SDO cannot execute the operation 00572 # completely due to some internal error. 00573 # @endif 00574 def get_configuration_parameter_values(self): 00575 guard = ScopedLock(self._config_mutex) 00576 nvlist = [] 00577 return nvlist 00578 00579 00580 ## 00581 # @if jp 00582 # 00583 # @brief [CORBA interface] Configuration parameter の値の取得 00584 # 00585 # このオペレーションは引数 "name" で指定されたパラメータ値を返す。<br> 00586 # ※本実装では常に None を返す 00587 # 00588 # @param self 00589 # @param name 値を要求するパラメータの名前。 00590 # 00591 # @return 指定されたパラメータの値。 00592 # 00593 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00594 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00595 # @exception InvalidParameter 引数 "name" が null である。 00596 # もしくは "name" に関連付けられたパラメータが存在しない。 00597 # @exception NotAvailable SDOは存在するが応答がない。 00598 # @exception InternalError 内部的エラーが発生した。 00599 # @else 00600 # 00601 # @brief [CORBA interface] Getting value of configuration parameter 00602 # 00603 # This operation returns a value of parameter that is specified by 00604 # argument "name." 00605 # 00606 # @param Name of the parameter whose value is requested. 00607 # 00608 # @return The value of the specified parameter. 00609 # 00610 # @exception SDONotExists if the target SDO does not exist.(This exception 00611 # is mapped to CORBA standard system exception 00612 # OBJECT_NOT_EXIST.) 00613 # @exception InvalidParameter if the value of the argument "name" is 00614 # empty String, or null, or if the parameter 00615 # that is specified by argument "name" 00616 # does not exist. 00617 # @exception NotAvailable The target SDO is reachable but cannot respond. 00618 # @exception InternalError The target SDO cannot execute the operation 00619 # completely due to some internal error. 00620 # @endif 00621 def get_configuration_parameter_value(self, name): 00622 if name is None: 00623 raise SDOPackage.InvalidParameter("Name is empty.") 00624 00625 return None 00626 00627 00628 ## 00629 # @if jp 00630 # 00631 # @brief [CORBA interface] Configuration パラメータの変更 00632 # 00633 # このオペレーションは "name" で指定したパラメータの値を "value" に 00634 # 変更する。<br> 00635 # ※本実装では常にTrueを返す 00636 # 00637 # @param self 00638 # @param name 変更対象パラメータの名前。 00639 # @param value 変更対象パラメータの新しい値。 00640 # 00641 # @return オペレーションが成功したかどうかを返す。 00642 # 00643 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00644 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00645 # @exception InvalidParameter 引数( "name"もしくは"value") が null である。 00646 # もしくは "name" に関連付けられたパラメータが存在しない。 00647 # @exception NotAvailable SDOは存在するが応答がない。 00648 # @exception InternalError 内部的エラーが発生した。 00649 # @else 00650 # 00651 # @brief [CORBA interface] Modify the parameter value 00652 # 00653 # This operation sets a parameter to a value that is specified by argument 00654 # "value." The parameter to be modified is specified by argument " name." 00655 # 00656 # @param name The name of parameter to be modified. 00657 # @param value New value of the specified parameter. 00658 # 00659 # @return If the operation was successfully completed. 00660 # 00661 # @exception SDONotExists if the target SDO does not exist.(This exception 00662 # is mapped to CORBA standard system exception 00663 # OBJECT_NOT_EXIST.) 00664 # @exception InvalidParameter if arguments ("name" and/or "value") is 00665 # null, or if the parameter that is specified by the argument 00666 # "name" does not exist. 00667 # @exception NotAvailable The target SDO is reachable but cannot respond. 00668 # @exception InternalError The target SDO cannot execute the operation 00669 # completely due to some internal error. 00670 # @endif 00671 def set_configuration_parameter(self, name, value): 00672 if name is None or value is None: 00673 raise SDOPackage.InvalidParameter("Name/Value is empty.") 00674 return True 00675 00676 00677 ## 00678 # @if jp 00679 # 00680 # @brief [CORBA interface] ConfigurationSet リストの取得 00681 # 00682 # このオペレーションは ConfigurationProfile が持つ ConfigurationSet の 00683 # リストを返す。 SDO が ConfigurationSet を持たなければ空のリストを返す。 00684 # 00685 # @param self 00686 # 00687 # @return 保持している ConfigurationSet のリストの現在値。 00688 # 00689 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00690 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00691 # @exception NotAvailable SDOは存在するが応答がない。 00692 # @exception InternalError 内部的エラーが発生した。 00693 # @else 00694 # 00695 # @brief [CORBA interface] Getting list of ConfigurationSet 00696 # 00697 # This operation returns a list of ConfigurationSets that the 00698 # ConfigurationProfile has. An empty list is returned if the SDO does not 00699 # have any ConfigurationSets. 00700 # This operation returns a list of all ConfigurationSets of the SDO. 00701 # If no predefined ConfigurationSets exist, then empty list is returned. 00702 # 00703 # @return The list of stored configuration with their current values. 00704 # 00705 # @exception SDONotExists if the target SDO does not exist.(This exception 00706 # is mapped to CORBA standard system exception 00707 # OBJECT_NOT_EXIST.) 00708 # @exception NotAvailable The target SDO is reachable but cannot respond. 00709 # @exception InternalError The target SDO cannot execute the operation 00710 # completely due to some internal error. 00711 # @endif 00712 def get_configuration_sets(self): 00713 try: 00714 guard = ScopedLock(self._config_mutex) 00715 00716 cf = self._configsets.getConfigurationSets() 00717 len_ = len(cf) 00718 00719 config_sets = [SDOPackage.ConfigurationSet("","",[]) for i in range(len_)] 00720 for i in range(len_): 00721 toConfigurationSet(config_sets[i], cf[i]) 00722 00723 return config_sets 00724 00725 except: 00726 raise SDOPackage.InternalError("Configuration.get_configuration_sets") 00727 00728 return [] 00729 00730 ## 00731 # @if jp 00732 # 00733 # @brief [CORBA interface] ConfigurationSet の取得 00734 # 00735 # このオペレーションは引数で指定された ConfigurationSet の ID に関連 00736 # 付けられた ConfigurationSet を返す。 00737 # 00738 # @param self 00739 # @param config_id ConfigurationSet の識別子。 00740 # 00741 # @return 引数により指定された ConfigurationSet。 00742 # 00743 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00744 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00745 # @exception InvalidParameter "config_id" が null か、指定された 00746 # ConfigurationSet が存在しない。 00747 # @exception NotAvailable SDOは存在するが応答がない。 00748 # @exception InternalError 内部的エラーが発生した。 00749 # @else 00750 # 00751 # @brief [CORBA interface] Getting a ConfigurationSet 00752 # 00753 # This operation returns the ConfigurationSet specified by the parameter 00754 # configurationSetID. 00755 # 00756 # @param config_id Identifier of ConfigurationSet requested. 00757 # 00758 # @return The configuration set specified by the parameter config_id. 00759 # 00760 # @exception SDONotExists if the target SDO does not exist.(This exception 00761 # is mapped to CORBA standard system exception 00762 # OBJECT_NOT_EXIST.) 00763 # @exception InvalidParameter If the parameter 'config_id' is null 00764 # or if there are no ConfigurationSets stored with such id. 00765 # @exception NotAvailable The target SDO is reachable but cannot respond. 00766 # @exception InternalError The target SDO cannot execute the operation 00767 # completely due to some internal error. 00768 # @endif 00769 def get_configuration_set(self, config_id): 00770 if config_id is None: 00771 raise SDOPackage.InvalidParameter("ID is empty") 00772 00773 guard = ScopedLock(self._config_mutex) 00774 00775 if not self._configsets.haveConfig(config_id): 00776 raise SDOPackage.InvalidParameter("No such ConfigurationSet") 00777 00778 configset = self._configsets.getConfigurationSet(config_id) 00779 00780 try: 00781 config = SDOPackage.ConfigurationSet("","",[]) 00782 toConfigurationSet(config, configset) 00783 return config 00784 except: 00785 raise SDOPackage.InvalidError("Configuration::get_configuration_set()") 00786 00787 return SDOPackage.ConfigurationSet("","",[]) 00788 00789 00790 ## 00791 # @if jp 00792 # 00793 # @brief [CORBA interface] ConfigurationSet をセットする 00794 # 00795 # このオペレーションは指定された id の ConfigurationSet を更新する。 00796 # 00797 # @param self 00798 # @param config_id 変更する ConfigurationSet の ID。 00799 # @param configuration_set 変更する ConfigurationSet そのもの。 00800 # 00801 # @return ConfigurationSet が正常に更新できた場合は true。 00802 # そうでなければ false を返す。 00803 # 00804 # @exception InvalidParameter config_id が null か、 00805 # 指定された id で格納された ConfigurationSetが存在しないか、 00806 # 指定された configuration_set内の属性の1つが不正。 00807 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00808 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00809 # @exception NotAvailable SDOは存在するが応答がない。 00810 # @exception InternalError 内部的エラーが発生した。 00811 # @else 00812 # 00813 # @brief [CORBA interface] Set ConfigurationSet 00814 # 00815 # This operation modifies the specified ConfigurationSet of an SDO. 00816 # 00817 # ※ パラメータの数が spec と IDL で異なる!!! 00818 # @param configu_id The ID of ConfigurationSet to be modified. 00819 # @param configuration_set ConfigurationSet to be replaced. 00820 # 00821 # @return A flag indicating if the ConfigurationSet was modified 00822 # successfully. "true" - The ConfigurationSet was modified 00823 # successfully. "false" - The ConfigurationSet could not be 00824 # modified successfully. 00825 # 00826 # @exception InvalidParameter if the parameter 'configurationSetID' is 00827 # null or if there is no ConfigurationSet stored with such id. 00828 # This exception is also raised if one of the attributes 00829 # defining ConfigurationSet is not valid. 00830 # @exception SDONotExists if the target SDO does not exist.(This exception 00831 # is mapped to CORBA standard system exception 00832 # OBJECT_NOT_EXIST.) 00833 # @exception NotAvailable The target SDO is reachable but cannot respond. 00834 # @exception InternalError The target SDO cannot execute the operation 00835 # completely due to some internal error. 00836 # @endif 00837 def set_configuration_set_values(self, config_id, configuration_set): 00838 if config_id is None: 00839 raise SDOPackage.InvalidParameter("ID is empty.") 00840 00841 try: 00842 conf = OpenRTM.Properties(key=config_id) 00843 toProperties(conf, configuration_set) 00844 return self._configsets.setConfigurationSetValues(config_id, conf) 00845 except: 00846 raise SDOPackage.InvalidError("Configuration::set_configuration_set_values()") 00847 00848 return True 00849 00850 00851 ## 00852 # @if jp 00853 # 00854 # @brief [CORBA interface] アクティブな ConfigurationSet を取得する 00855 # 00856 # このオペレーションは当該SDOの現在アクティブな ConfigurationSet を返す。 00857 # (もしSDOの現在の設定が予め定義された ConfigurationSet により設定されて 00858 # いるならば。) 00859 # ConfigurationSet は以下の場合にはアクティブではないものとみなされる。 00860 # 00861 # - 現在の設定が予め定義された ConfigurationSet によりセットされていない、 00862 # - SDO の設定がアクティブになった後に変更された、 00863 # - SDO を設定する ConfigurationSet が変更された、 00864 # 00865 # これらの場合には、空の ConfigurationSet が返される。 00866 # 00867 # @param self 00868 # 00869 # @return 現在アクティブな ConfigurationSet。 00870 # 00871 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00872 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00873 # @exception NotAvailable SDOは存在するが応答がない。 00874 # @exception InternalError 内部的エラーが発生した。 00875 # @else 00876 # 00877 # @brief [CORBA interface] Get active ConfigurationSet 00878 # 00879 # This operation returns the current active ConfigurationSet of an 00880 # SDO (i.e., if the current configuration of the SDO was set using 00881 # predefined configuration set). 00882 # ConfigurationSet cannot be considered active if the: 00883 # 00884 # - current configuration of the SDO was not set using any predefined 00885 # ConfigurationSet, or 00886 # - configuration of the SDO was changed after it has been active, or 00887 # - ConfigurationSet that was used to configure the SDO was modified. 00888 # 00889 # Empty ConfigurationSet is returned in these cases. 00890 # 00891 # @return The active ConfigurationSet. 00892 # 00893 # @exception SDONotExists if the target SDO does not exist.(This exception 00894 # is mapped to CORBA standard system exception 00895 # OBJECT_NOT_EXIST.) 00896 # @exception NotAvailable The target SDO is reachable but cannot respond. 00897 # @exception InternalError The target SDO cannot execute the operation 00898 # completely due to some internal error. 00899 # @endif 00900 def get_active_configuration_set(self): 00901 if not self._configsets.isActive(): 00902 raise SDOPackage.NotAvailable() 00903 00904 try: 00905 guard = ScopedLock(self._config_mutex) 00906 config = SDOPackage.ConfigurationSet("","",[]) 00907 toConfigurationSet(config, self._configsets.getActiveConfigurationSet()) 00908 return config 00909 except: 00910 raise SDOPackage.InternalError("Configuration.get_active_configuration_set()") 00911 00912 return SDOPackage.ConfigurationSet("","",[]) 00913 00914 00915 ## 00916 # @if jp 00917 # 00918 # @brief [CORBA interface] ConfigurationSet を追加する 00919 # 00920 # ConfigurationProfile に ConfigurationSet を追加するオペレーション。 00921 # 00922 # @param self 00923 # @param configuration_set 追加する ConfigurationSet。 00924 # 00925 # @return オペレーションが成功したかどうか。 00926 # 00927 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00928 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00929 # @exception InvalidParameter "configurationSet" が null か、 00930 # "configurationSet"で定義された属性の1つが不正か、 00931 # 指定された configurationSet もIDが既に存在する。 00932 # @exception NotAvailable SDOは存在するが応答がない。 00933 # @exception InternalError 内部的エラーが発生した。 00934 # @else 00935 # 00936 # @brief [CORBA interface] Add ConfigurationSet 00937 # 00938 # This operation adds a ConfigurationSet to the ConfigurationProfile. 00939 # 00940 # @param configuration_set The ConfigurationSet that is added. 00941 # 00942 # @return If the operation was successfully completed. 00943 # 00944 # @exception SDONotExists if the target SDO does not exist.(This exception 00945 # is mapped to CORBA standard system exception 00946 # OBJECT_NOT_EXIST.) 00947 # @exception InvalidParameter If the argument "configurationSet" is null, 00948 # or if one of the attributes defining "configurationSet" is 00949 # invalid, or if the specified identifier of the configuration 00950 # set already exists. 00951 # @exception NotAvailable The target SDO is reachable but cannot respond. 00952 # @exception InternalError The target SDO cannot execute the operation 00953 # completely due to some internal error. 00954 # @endif 00955 def add_configuration_set(self, configuration_set): 00956 if configuration_set is None: 00957 raise SDOPackage.InvalidParameter("configuration_set is empty.") 00958 00959 try: 00960 guard = ScopedLock(self._config_mutex) 00961 config_id = configuration_set.id 00962 config = OpenRTM.Properties(key=config_id) 00963 toProperties(config, configuration_set) 00964 return self._configsets.addConfigurationSet(config) 00965 except: 00966 raise SDOPackage.InternalError("Configuration::add_configuration_set()") 00967 00968 return True 00969 00970 00971 ## 00972 # @if jp 00973 # 00974 # @brief [CORBA interface] ConfigurationSet を削除する 00975 # 00976 # ConfigurationProfile から ConfigurationSet を削除する。 00977 # 00978 # @param self 00979 # @param config_id 削除する ConfigurationSet の id。 00980 # 00981 # @return オペレーションが成功したかどうか。 00982 # 00983 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 00984 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 00985 # @exception InvalidParameter 引数 "configurationSetID" が null である、 00986 # もしくは、引数で指定された ConfigurationSet が存在しない。 00987 # @exception NotAvailable SDOは存在するが応答がない。 00988 # @exception InternalError 内部的エラーが発生した。 00989 # @else 00990 # 00991 # @brief [CORBA interface] Remove ConfigurationSet 00992 # 00993 # This operation removes a ConfigurationSet from the ConfigurationProfile. 00994 # 00995 # @param config_id The id of ConfigurationSet which is removed. 00996 # 00997 # @return If the operation was successfully completed. 00998 # 00999 # @exception SDONotExists if the target SDO does not exist.(This exception 01000 # is mapped to CORBA standard system exception 01001 # OBJECT_NOT_EXIST.) 01002 # @exception InvalidParameter The arguments "configurationSetID" is null, 01003 # or if the object specified by the argument 01004 # "configurationSetID" does not exist. 01005 # @exception NotAvailable The target SDO is reachable but cannot respond. 01006 # @exception InternalError The target SDO cannot execute the operation 01007 # completely due to some internal error. 01008 # @endif 01009 def remove_configuration_set(self, config_id): 01010 if config_id is None: 01011 raise SDOPackage.InvalidParameter("ID is empty.") 01012 01013 try: 01014 guard = ScopedLock(self._config_mutex) 01015 return self._configsets.removeConfigurationSet(config_id) 01016 except: 01017 raise SDOPackage.InvalidError("Configuration.remove_configuration_set()") 01018 01019 return False 01020 01021 01022 ## 01023 # @if jp 01024 # 01025 # @brief [CORBA interface] ConfigurationSet のアクティブ化 01026 # 01027 # ConfigurationProfile に格納された ConfigurationSet のうち一つを 01028 # アクティブにする。 01029 # このオペレーションは特定の ConfigurationSet をアクティブにする。 01030 # すなわち、SDO のコンフィギュレーション・プロパティがその格納されている 01031 # ConfigurationSet により設定されるプロパティの値に変更される。 01032 # 指定された ConfigurationSet の値がアクティブ・コンフィギュレーション 01033 # にコピーされるということを意味する。 01034 # 01035 # @param self 01036 # @param config_id アクティブ化する ConfigurationSet の id。 01037 # 01038 # @return オペレーションが成功したかどうか。 01039 # 01040 # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準 01041 # システム例外のOBJECT_NOT_EXISTにマッピングされる) 01042 # @exception InvalidParameter 引数 "config_id" が null である、もしくは 01043 # 引数で指定された ConfigurationSet が存在しない。 01044 # @exception NotAvailable SDOは存在するが応答がない。 01045 # @exception InternalError 内部的エラーが発生した。 01046 # @else 01047 # 01048 # @brief [CORBA interface] Activate ConfigurationSet 01049 # 01050 # This operation activates one of the stored ConfigurationSets in the 01051 # ConfigurationProfile. 01052 # This operation activates the specified stored ConfigurationSets. 01053 # This means that the configuration properties of the SDO are changed as 01054 # the values of these properties specified in the stored ConfigurationSet. 01055 # In other words, values of the specified ConfigurationSet are now copied 01056 # to the active configuration. 01057 # 01058 # @param Identifier of ConfigurationSet to be activated. 01059 # 01060 # @return If the operation was successfully completed. 01061 # 01062 # @exception SDONotExists if the target SDO does not exist.(This exception 01063 # is mapped to CORBA standard system exception 01064 # OBJECT_NOT_EXIST.) 01065 # @exception InvalidParameter if the argument ("configID") is null or 01066 # there is no configuration set with identifier specified by 01067 # the argument. 01068 # @exception NotAvailable The target SDO is reachable but cannot respond. 01069 # @exception InternalError The target SDO cannot execute the operation 01070 # completely due to some internal error. 01071 # @endif 01072 def activate_configuration_set(self, config_id): 01073 if config_id is None: 01074 raise SDOPackage.InvalidParameter("ID is empty.") 01075 01076 try: 01077 return self._configsets.activateConfigurationSet(config_id) 01078 except: 01079 raise SDOPackage.InvalidError("Configuration.activate_configuration_set()") 01080 01081 return False 01082 01083 01084 #============================================================ 01085 # end of CORBA interface definition 01086 #============================================================ 01087 01088 ## 01089 # @if jp 01090 # 01091 # @brief オブジェクト リファレンスを取得する 01092 # 01093 # 対象のオブジェクトリファレンスを取得する 01094 # 01095 # @param self 01096 # 01097 # @return オブジェクトリファレンス 01098 # 01099 # @else 01100 # 01101 # @endif 01102 def getObjRef(self): 01103 return self._objref 01104 01105 01106 ## 01107 # @if jp 01108 # 01109 # @brief SDO の DeviceProfile を取得する 01110 # 01111 # SDO の DeviceProfile を取得する 01112 # 01113 # @param self 01114 # 01115 # @return SDO の DeviceProfile 01116 # 01117 # @else 01118 # 01119 # @endif 01120 def getDeviceProfile(self): 01121 return self._deviceProfile 01122 01123 01124 ## 01125 # @if jp 01126 # 01127 # @brief SDO の ServiceProfile のリストを取得する 01128 # 01129 # SDO の ServiceProfile のリストを取得する 01130 # 01131 # @param self 01132 # 01133 # @return SDO ServiceProfileリスト 01134 # 01135 # @else 01136 # 01137 # @endif 01138 def getServiceProfiles(self): 01139 return self._serviceProfiles 01140 01141 01142 ## 01143 # @if jp 01144 # 01145 # @brief SDO の ServiceProfile を取得する 01146 # 01147 # このオペレーションは引数 "id" で指定されたSDO の ServiceProfileを返す。 01148 # "id" で指定された ServiceProfileが存在しない場合、 01149 # ServiceProfileのインスタンスを生成し返す。 01150 # 01151 # @param self 01152 # @param id ServiceProfile の識別子。 01153 # 01154 # @return 指定された SDO ServiceProfile 01155 # 01156 # @else 01157 # 01158 # @endif 01159 def getServiceProfile(self, id): 01160 index = OpenRTM.CORBA_SeqUtil.find(self._serviceProfiles, 01161 self.service_id(id)) 01162 01163 if index < 0: 01164 return SDOPackage.ServiceProfile("","",[],None) 01165 01166 return self._serviceProfiles[index] 01167 01168 01169 ## 01170 # @if jp 01171 # 01172 # @brief SDO の Organization リストを取得する 01173 # 01174 # SDO の Organization リストを取得する 01175 # 01176 # @param self 01177 # 01178 # @return SDO の Organization リスト 01179 # 01180 # @else 01181 # 01182 # @endif 01183 def getOrganizations(self): 01184 return self._organizations 01185 01186 01187 ## 01188 # @if jp 01189 # 01190 # @brief UUIDを生成する 01191 # 01192 # UUIDを生成する 01193 # 01194 # @param self 01195 # 01196 # @return 生成したUUID 01197 # 01198 # @else 01199 # 01200 # @endif 01201 def getUUID(self): 01202 return OpenRTM.uuid1() 01203 01204 01205 # functor for ServiceProfile 01206 ## 01207 # @if jp 01208 # @class service_id 01209 # @brief ServiceProfile用functor 01210 # @else 01211 # @brief functor for ServiceProfile 01212 # @endif 01213 class service_id: 01214 def __init__(self, id_): 01215 self._id = str(id_) 01216 01217 def __call__(self, s): 01218 id_ = str(s.id) 01219 return self._id == id_ 01220 01221 01222 # functor for Organization 01223 ## 01224 # @if jp 01225 # @class org_id 01226 # @brief Organization用functor 01227 # @else 01228 # @brief functor for Organization 01229 # @endif 01230 class org_id: 01231 def __init__(self, id_): 01232 self._id = str(id_) 01233 01234 def __call__(self, o): 01235 id_ = str(o.get_organization_id()) 01236 return self._id == id_ 01237 01238 01239 # functor for ConfigurationSet 01240 ## 01241 # @if jp 01242 # @class config_id 01243 # @brief ConfigurationSet用functor 01244 # @else 01245 # @brief functor for ConfigurationSet 01246 # @endif 01247 class config_id: 01248 def __init__(self, id_): 01249 self._id = str(id_) 01250 01251 def __call__(self, c): 01252 id_ = str(c.id) 01253 return self._id == id_