RTObject.py

説明を見る。
00001 #!/usr/bin/env python
00002 # -*- coding: euc-jp -*-
00003 
00004 ##
00005 # @file RTObject.py
00006 # @brief RT component base class
00007 # @date $Date: $
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 
00019 from omniORB import any
00020 from omniORB import CORBA
00021 import string
00022 import sys
00023 import traceback
00024 
00025 import RTC,RTC__POA
00026 import SDOPackage,SDOPackage__POA
00027 import OpenRTM
00028 
00029 default_conf = [
00030   "implementation_id","",
00031   "type_name",         "",
00032   "description",       "",
00033   "version",           "",
00034   "vendor",            "",
00035   "category",          "",
00036   "activity_type",     "",
00037   "max_instance",      "",
00038   "language",          "",
00039   "lang_type",         "",
00040   "conf",              "",
00041   "" ]
00042 
00043 
00044 
00045 ##
00046 # @if jp
00047 # @brief RTコンポーネントクラス
00048 #
00049 # 各RTコンポーネントのベースとなるクラス。
00050 # Robotic Technology Component 仕様中の lightweightRTComponentの実装クラス。
00051 # コンポーネントの機能を提供する ComponentAction インターフェースと
00052 # コンポーネントのライフサイクル管理を行うための LightweightRTObject の実装を
00053 # 提供する。
00054 # 実際にユーザがコンポーネントを作成する場合には、Execution Semantics に対応
00055 # した各サブクラスを利用する。<BR>
00056 # (現状の実装では Periodic Sampled Data Processing のみサポートしているため、
00057 #  dataFlowComponent を直接継承している)
00058 #
00059 # @since 0.2.0
00060 #
00061 # @else
00062 #
00063 # @endif
00064 class RTObject_impl(RTC__POA.DataFlowComponent):
00065 
00066 
00067 
00068   ##
00069   # @if jp
00070   # @brief コンストラクタ
00071   #
00072   # コンストラクタ
00073   #
00074   # @param self
00075   # @param manager マネージャオブジェクト(デフォルト値:None)
00076   # @param orb ORB(デフォルト値:None)
00077   # @param poa POA(デフォルト値:None)
00078   #
00079   # @else
00080   #
00081   # @brief Consructor
00082   #
00083   # @param orb ORB
00084   # @param poa POA
00085   #
00086   # @endif
00087   def __init__(self, manager=None, orb=None, poa=None):
00088     if manager:
00089       self._manager = manager
00090       self._orb = self._manager.getORB()
00091       self._poa = self._manager.getPOA()
00092       self._portAdmin = OpenRTM.PortAdmin(self._manager.getORB(),self._manager.getPOA())
00093     else:
00094       self._manager = None
00095       self._orb = orb
00096       self._poa = poa
00097       self._portAdmin = OpenRTM.PortAdmin(self._orb,self._poa)
00098       
00099     self._created = True
00100     self._alive = False
00101     self._properties = OpenRTM.Properties(defaults_str=default_conf)
00102     self._configsets = OpenRTM.ConfigAdmin(self._properties.getNode("conf"))
00103     self._profile = RTC.ComponentProfile("","","","","","",[],None,[])
00104     
00105     self._SdoConfigImpl = OpenRTM.Configuration_impl(self._configsets)
00106     self._SdoConfig = self._SdoConfigImpl.getObjRef()
00107     self._execContexts = []
00108     self._objref = None
00109     self._sdoOwnedOrganizations = [] #SDOPackage.OrganizationList()
00110     self._sdoSvcProfiles        = [] #SDOPackage.ServiceProfileList()
00111     self._sdoOrganizations      = [] #SDOPackage.OrganizationList()
00112     self._sdoStatus             = [] #SDOPackage.NVList()
00113 
00114     return
00115 
00116 
00117   ##
00118   # @if jp
00119   #
00120   # @brief デストラクタ
00121   #
00122   # @param self
00123   # 
00124   # @else
00125   # 
00126   # @brief destructor
00127   # 
00128   # @endif
00129   def __del__(self):
00130     return
00131 
00132 
00133   #============================================================
00134   # Overridden functions
00135   #============================================================
00136 
00137   ##
00138   # @if jp
00139   #
00140   # @brief 初期化処理用コールバック関数
00141   # 
00142   # ComponentAction::on_initialize が呼ばれた際に実行されるコールバック
00143   # 関数。<BR>
00144   # 本関数は無条件に RTC::RTC_OK を返すようにダミー実装されているので、
00145   # 各コンポーネントの実際の初期化処理は、本関数をオーバーライドして実装する
00146   # 必要がある。
00147   #
00148   # @param self
00149   # 
00150   # @return ReturnCode_t 型のリターンコード
00151   # 
00152   # @else
00153   # 
00154   # @endif
00155   def onInitialize(self):
00156     return RTC.RTC_OK
00157 
00158 
00159   ##
00160   # @if jp
00161   #
00162   # @brief 終了処理用コールバック関数
00163   # 
00164   # ComponentAction::on_finalize が呼ばれた際に実行されるコールバック
00165   # 関数。<BR>
00166   # 本関数は無条件に RTC::RTC_OK を返すようにダミー実装されているので、
00167   # 各コンポーネントの実際の終了処理は、本関数をオーバーライドして実装する
00168   # 必要がある。
00169   #
00170   # @param self
00171   # 
00172   # @return ReturnCode_t 型のリターンコード
00173   # 
00174   # @else
00175   # 
00176   # @endif
00177   def onFinalize(self):
00178     return RTC.RTC_OK
00179 
00180 
00181   ##
00182   # @if jp
00183   #
00184   # @brief 開始処理用コールバック関数
00185   # 
00186   # ComponentAction::on_startup が呼ばれた際に実行されるコールバック
00187   # 関数。<BR>
00188   # 本関数は無条件に RTC::RTC_OK を返すようにダミー実装されているので、
00189   # 各コンポーネントの実際の開始処理は、本関数をオーバーライドして実装する
00190   # 必要がある。
00191   # 
00192   # @param self
00193   # @param ec_id 参加している ExecutionContext の ID
00194   #
00195   # @return ReturnCode_t 型のリターンコード
00196   # 
00197   # @else
00198   # 
00199   # @endif
00200   def onStartup(self, ec_id):
00201     return RTC.RTC_OK
00202 
00203 
00204   ##
00205   # @if jp
00206   #
00207   # @brief 停止処理用コールバック関数
00208   # 
00209   # ComponentAction::on_shutdown が呼ばれた際に実行されるコールバック
00210   # 関数。<BR>
00211   # 本関数は無条件に RTC::RTC_OK を返すようにダミー実装されているので、
00212   # 各コンポーネントの実際の停止処理は、本関数をオーバーライドして実装する
00213   # 必要がある。
00214   # 
00215   # @param self
00216   # @param ec_id 参加している ExecutionContext の ID
00217   #
00218   # @return ReturnCode_t 型のリターンコード
00219   # 
00220   # @else
00221   # 
00222   # @endif
00223   def onShutdown(self, ec_id):
00224     return RTC.RTC_OK
00225 
00226 
00227   ##
00228   # @if jp
00229   #
00230   # @brief 活性化処理用コールバック関数
00231   # 
00232   # ComponentAction::on_activated が呼ばれた際に実行されるコールバック
00233   # 関数。<BR>
00234   # 本関数は無条件に RTC::RTC_OK を返すようにダミー実装されているので、
00235   # 各コンポーネントの実際の活性化処理は、本関数をオーバーライドして実装する
00236   # 必要がある。
00237   # 
00238   # @param self
00239   # @param ec_id 参加している ExecutionContext の ID
00240   #
00241   # @return ReturnCode_t 型のリターンコード
00242   # 
00243   # @else
00244   # 
00245   # @endif
00246   def onActivated(self, ec_id):
00247     return RTC.RTC_OK
00248 
00249 
00250   ##
00251   # @if jp
00252   #
00253   # @brief 非活性化処理用コールバック関数
00254   # 
00255   # ComponentAction::on_deactivated が呼ばれた際に実行されるコールバック
00256   # 関数。<BR>
00257   # 本関数は無条件に RTC::RTC_OK を返すようにダミー実装されているので、
00258   # 各コンポーネントの実際の非活性化処理は、本関数をオーバーライドして実装する
00259   # 必要がある。
00260   # 
00261   # @param self
00262   # @param ec_id 参加している ExecutionContext の ID
00263   #
00264   # @return ReturnCode_t 型のリターンコード
00265   # 
00266   # @else
00267   # 
00268   # @endif
00269   def onDeactivated(self, ec_id):
00270     return RTC.RTC_OK
00271 
00272 
00273   ##
00274   # @if jp
00275   #
00276   # @brief 周期処理用コールバック関数
00277   # 
00278   # DataFlowComponentAction::on_execute が呼ばれた際に実行される
00279   # コールバック関数。<BR>
00280   # 本関数は無条件に RTC::RTC_OK を返すようにダミー実装されているので、
00281   # 各コンポーネントの実際の周期処理は、本関数をオーバーライドして実装する
00282   # 必要がある。<BR>
00283   # 本関数は Periodic Sampled Data Processing における Two-Pass Executionの
00284   # 1回目の実行パスとして定期的に呼び出される。
00285   # 
00286   # @param self
00287   # @param ec_id 参加している ExecutionContext の ID
00288   #
00289   # @return ReturnCode_t 型のリターンコード
00290   # 
00291   # @else
00292   # 
00293   # @endif
00294   def onExecute(self, ec_id):
00295     return RTC.RTC_OK
00296 
00297 
00298   ##
00299   # @if jp
00300   #
00301   # @brief 中断処理用コールバック関数
00302   # 
00303   # ComponentAction::on_aborting が呼ばれた際に実行されるコールバック
00304   # 関数。<BR>
00305   # 本関数は無条件に RTC::RTC_OK を返すようにダミー実装されているので、
00306   # 各コンポーネントの実際の中断処理は、本関数をオーバーライドして実装する
00307   # 必要がある。
00308   # 
00309   # @param self
00310   # @param ec_id 参加している ExecutionContext の ID
00311   #
00312   # @return ReturnCode_t 型のリターンコード
00313   # 
00314   # @else
00315   # 
00316   # @endif
00317   def onAborting(self, ec_id):
00318     return RTC.RTC_OK
00319 
00320 
00321   ##
00322   # @if jp
00323   #
00324   # @brief エラー処理用コールバック関数
00325   # 
00326   # ComponentAction::on_error が呼ばれた際に実行されるコールバック関数。<BR>
00327   # 本関数は無条件に RTC::RTC_OK を返すようにダミー実装されているので、
00328   # 各コンポーネントの実際のエラー処理は、本関数をオーバーライドして実装する
00329   # 必要がある。
00330   # 
00331   # @param self
00332   # @param ec_id 参加している ExecutionContext の ID
00333   #
00334   # @return ReturnCode_t 型のリターンコード
00335   # 
00336   # @else
00337   # 
00338   # @endif
00339   def onError(self, ec_id):
00340     return RTC.RTC_OK
00341 
00342 
00343   ##
00344   # @if jp
00345   #
00346   # @brief リセット処理用コールバック関数
00347   # 
00348   # ComponentAction::on_reset が呼ばれた際に実行されるコールバック関数。<BR>
00349   # 本関数は無条件に RTC::RTC_OK を返すようにダミー実装されているので、
00350   # 各コンポーネントの実際のリセット処理は、本関数をオーバーライドして実装する
00351   # 必要がある。
00352   # 
00353   # @param self
00354   # @param ec_id 参加している ExecutionContext の ID
00355   #
00356   # @return ReturnCode_t 型のリターンコード
00357   # 
00358   # @else
00359   # 
00360   # @endif
00361   def onReset(self, ec_id):
00362     return RTC.RTC_OK
00363 
00364 
00365   ##
00366   # @if jp
00367   #
00368   # @brief 状態変更処理用コールバック関数
00369   # 
00370   # DataFlowComponentAction::on_state_update が呼ばれた際に実行される
00371   # コールバック関数。<BR>
00372   # 本関数は無条件に RTC::RTC_OK を返すようにダミー実装されているので、
00373   # 各コンポーネントの実際の状態変更処理は、本関数をオーバーライドして実装する
00374   # 必要がある。<BR>
00375   # 本関数は Periodic Sampled Data Processing における Two-Pass Executionの
00376   # 2回目の実行パスとして定期的に呼び出される。
00377   #
00378   # @param self
00379   # @param ec_id 参加している ExecutionContext の ID
00380   # 
00381   # @return ReturnCode_t 型のリターンコード
00382   # 
00383   # @else
00384   # 
00385   # @endif
00386   def onStateUpdate(self, ec_id):
00387     return RTC.RTC_OK
00388 
00389 
00390   ##
00391   # @if jp
00392   #
00393   # @brief 動作周期変更通知用コールバック関数
00394   # 
00395   # DataFlowComponentAction::on_rate_changed が呼ばれた際に実行される
00396   # コールバック関数。<BR>
00397   # 本関数は無条件に RTC::RTC_OK を返すようにダミー実装されているので、
00398   # 各コンポーネントの実際の状態変更処理は、本関数をオーバーライドして実装する
00399   # 必要がある。<BR>
00400   # 本関数は Periodic Sampled Data Processing において ExecutionContext の
00401   # 実行が更新された際に呼び出される。
00402   #
00403   # @param self
00404   # @param ec_id 参加している ExecutionContext の ID
00405   # 
00406   # @return ReturnCode_t 型のリターンコード
00407   # 
00408   # @else
00409   # 
00410   # @endif
00411   def onRateChanged(self, ec_id):
00412     return RTC.RTC_OK 
00413 
00414 
00415   #============================================================
00416   # RTC::LightweightRTObject
00417   #============================================================
00418 
00419   ##
00420   # @if jp
00421   #
00422   # @brief [CORBA interface] RTCを初期化する
00423   #
00424   # このオペレーション呼び出しの結果として、ComponentAction::on_initialize
00425   # コールバック関数が呼ばれる。
00426   # 
00427   # 制約
00428   # - RTC は Created状態の場合み初期化が行われる。他の状態にいる場合には
00429   #   ReturnCode_t::PRECONDITION_NOT_MET が返され呼び出しは失敗する。
00430   # - このオペレーションは RTC のミドルウエアから呼ばれることを想定しており、
00431   #   アプリケーション開発者は直接このオペレーションを呼ぶことは想定
00432   #   されていない。
00433   #
00434   # @param self
00435   # 
00436   # @return ReturnCode_t 型のリターンコード
00437   # 
00438   # @else
00439   #
00440   # @brief Initialize the RTC that realizes this interface.
00441   #
00442   # The invocation of this operation shall result in the invocation of the
00443   # callback ComponentAction::on_initialize.
00444   #
00445   # Constraints
00446   # - An RTC may be initialized only while it is in the Created state. Any
00447   #   attempt to invoke this operation while in another state shall fail
00448   #   with ReturnCode_t::PRECONDITION_NOT_MET.
00449   # - Application developers are not expected to call this operation
00450   #   directly; it exists for use by the RTC infrastructure.
00451   #
00452   # @return
00453   # 
00454   # @endif
00455   def initialize(self):
00456     ret = self.on_initialize()
00457     self._created = False
00458 
00459     if ret == RTC.RTC_OK:
00460       if len(self._execContexts) > 0:
00461         self._execContexts[0].start()
00462       self._alive = True
00463     
00464     return ret
00465 
00466 
00467   ##
00468   # @if jp
00469   #
00470   # @brief [CORBA interface] RTC を終了する
00471   #
00472   # このオペレーション呼び出しの結果として ComponentAction::on_finalize()
00473   # を呼び出す。
00474   #
00475   # 制約
00476   # - RTC が ExecutionContext に所属している間は終了されない。この場合は、
00477   #   まず最初に ExecutionContextOperations::remove_component によって参加を
00478   #   解除しなければならない。これ以外の場合は、このオペレーション呼び出しは
00479   #   いかなる場合も ReturnCode_t::PRECONDITION_NOT_ME で失敗する。
00480   # - RTC が Created 状態である場合、終了処理は行われない。
00481   #   この場合、このオペレーション呼び出しはいかなる場合も
00482   #   ReturnCode_t::PRECONDITION_NOT_MET で失敗する。
00483   # - このオペレーションはRTCのミドルウエアから呼ばれることを想定しており、
00484   #   アプリケーション開発者は直接このオペレーションを呼ぶことは想定
00485   #   されていない。
00486   #
00487   # @param self
00488   #
00489   # @return ReturnCode_t 型のリターンコード
00490   # 
00491   # @else
00492   #
00493   # @brief Finalize the RTC for preparing it for destruction
00494   # 
00495   # This invocation of this operation shall result in the invocation of the
00496   # callback ComponentAction::on_finalize.
00497   #
00498   # Constraints
00499   # - An RTC may not be finalized while it is participating in any execution
00500   #   context. It must first be removed with 
00501   #   ExecutionContextOperations::remove_component. Otherwise, this operation
00502   #   shall fail with ReturnCode_t::PRECONDITION_NOT_MET. 
00503   # - An RTC may not be finalized while it is in the Created state. Any 
00504   #   attempt to invoke this operation while in that state shall fail with 
00505   #   ReturnCode_t::PRECONDITION_NOT_MET.
00506   # - Application developers are not expected to call this operation directly;
00507   #  it exists for use by the RTC infrastructure.
00508   #
00509   # @return
00510   # 
00511   # @endif
00512   def finalize(self):
00513     if self._created:
00514       return RTC.PRECONDITION_NOT_MET
00515 
00516     for execContext in self._execContexts:
00517       if execContext.is_running():
00518         return RTC.PRECONDITION_NOT_MET
00519 
00520     ret = self.on_finalize()
00521     self.shutdown()
00522     return ret
00523 
00524 
00525   ##
00526   # @if jp
00527   #
00528   # @brief [CORBA interface] RTC がオーナーである ExecutionContext を
00529   #        停止させ、そのコンテンツと共に終了させる
00530   #
00531   # この RTC がオーナーであるすべての実行コンテキストを停止する。
00532   # この RTC が他の実行コンテキストを所有する RTC に属する実行コンテキスト
00533   # (i.e. 実行コンテキストを所有する RTC はすなわちその実行コンテキストの
00534   # オーナーである。)に参加している場合、当該 RTC はそれらのコンテキスト上
00535   # で非活性化されなければならない。
00536   # RTC が実行中のどの ExecutionContext でも Active 状態ではなくなった後、
00537   # この RTC とこれに含まれる RTC が終了する。
00538   # 
00539   # 制約
00540   # - RTC が初期化されていなければ、終了させることはできない。
00541   #   Created 状態にある RTC に exit() を呼び出した場合、
00542   #   ReturnCode_t::PRECONDITION_NOT_MET で失敗する。
00543   #
00544   # @param self
00545   #
00546   # @return ReturnCode_t 型のリターンコード
00547   # 
00548   # @else
00549   #
00550   # @brief Stop the RTC's execution context(s) and finalize it along with its
00551   #        contents.
00552   # 
00553   # Any execution contexts for which the RTC is the owner shall be stopped. 
00554   # If the RTC participates in any execution contexts belonging to another
00555   # RTC that contains it, directly or indirectly (i.e. the containing RTC
00556   # is the owner of the ExecutionContext), it shall be deactivated in those
00557   # contexts.
00558   # After the RTC is no longer Active in any Running execution context, it
00559   # and any RTCs contained transitively within it shall be finalized.
00560   #
00561   # Constraints
00562   # - An RTC cannot be exited if it has not yet been initialized. Any
00563   #   attempt to exit an RTC that is in the Created state shall fail with
00564   #   ReturnCode_t::PRECONDITION_NOT_MET.
00565   #
00566   # @return
00567   # 
00568   # @endif
00569   def exit(self):
00570     if len(self._execContexts) > 0:
00571       self._execContexts[0].stop()
00572       self._alive = False
00573 
00574     OpenRTM.CORBA_SeqUtil.for_each(self._execContexts,
00575                      self.deactivate_comps(self._objref))
00576     return self.finalize()
00577 
00578 
00579   ##
00580   # @if jp
00581   #
00582   # @brief [CORBA interface] RTC が Alive 状態であるかどうか確認する。
00583   #
00584   # RTC が指定した ExecutionContext に対して Alive状態であるかどうか確認する。
00585   # RTC の状態が Active であるか、Inactive であるか、Error であるかは実行中の
00586   # ExecutionContext に依存する。すなわち、ある ExecutionContext に対しては
00587   # Active  状態であっても、他の ExecutionContext に対しては Inactive 状態と
00588   # なる場合もありえる。従って、このオペレーションは指定された
00589   # ExecutionContext に問い合わせて、この RTC の状態が Active、Inactive、
00590   # Error の場合には Alive 状態として返す。
00591   #
00592   # @param self
00593   #
00594   # @return Alive 状態確認結果
00595   #
00596   # @else
00597   #
00598   # @brief Confirm whether RTC is an Alive state or NOT.
00599   #
00600   # A component is alive or not regardless of the execution context from
00601   # which it is observed. However, whether or not it is Active, Inactive,
00602   # or in Error is dependent on the execution context(s) in which it is
00603   # running. That is, it may be Active in one context but Inactive in
00604   # another. Therefore, this operation shall report whether this RTC is
00605   # either Active, Inactive or in Error; which of those states a component
00606   # is in with respect to a particular context may be queried from the
00607   # context itself.
00608   #
00609   # @return Result of Alive state confirmation
00610   #
00611   # @endif
00612   def is_alive(self):
00613     return self._alive
00614 
00615 
00616   ##
00617   # @if jp
00618   # @brief [CORBA interface] ExecutionContextListを取得する
00619   #
00620   # この RTC が所有する ExecutionContext のリストを取得する。
00621   #
00622   # @param self
00623   #
00624   # @return ExecutionContext リスト
00625   #
00626   # @else
00627   # @brief [CORBA interface] Get ExecutionContextList.
00628   #
00629   # This operation returns a list of all execution contexts owned by this RTC.
00630   #
00631   # @return ExecutionContext List
00632   #
00633   # @endif
00634   def get_contexts(self):
00635     execlist = []
00636     OpenRTM.CORBA_SeqUtil.for_each(self._execContexts, self.ec_copy(execlist))
00637     return execlist
00638 
00639 
00640   ##
00641   # @if jp
00642   # @brief [CORBA interface] ExecutionContextを取得する
00643   #
00644   # 指定したハンドルの ExecutionContext を取得する。
00645   # ハンドルから ExecutionContext へのマッピングは、特定の RTC インスタンスに
00646   # 固有である。ハンドルはこの RTC を attach_context した際に取得できる。
00647   #
00648   # @param self
00649   # @param ec_id 取得対象 ExecutionContext ハンドル
00650   #
00651   # @return ExecutionContext
00652   #
00653   # @else
00654   # @brief [CORBA interface] Get ExecutionContext.
00655   #
00656   # Obtain a reference to the execution context represented by the given 
00657   # handle.
00658   # The mapping from handle to context is specific to a particular RTC 
00659   # instance. The given handle must have been obtained by a previous call to 
00660   # attach_context on this RTC.
00661   #
00662   # @param ec_id ExecutionContext handle
00663   #
00664   # @return ExecutionContext
00665   #
00666   # @endif
00667   def get_context(self, ec_id):
00668     if ec_id > (len(self._execContexts) - 1):
00669       return RTC.ExecutionContext._nil
00670 
00671     return self._execContexts[ec_id]
00672 
00673 
00674   #============================================================
00675   # RTC::RTObject
00676   #============================================================
00677 
00678   ##
00679   # @if jp
00680   #
00681   # @brief [RTObject CORBA interface] コンポーネントプロファイルを取得する
00682   #
00683   # 当該コンポーネントのプロファイル情報を返す。 
00684   #
00685   # @param self
00686   #
00687   # @return コンポーネントプロファイル
00688   #
00689   # @else
00690   #
00691   # @brief [RTObject CORBA interface] Get RTC's profile
00692   #
00693   # This operation returns the ComponentProfile of the RTC
00694   #
00695   # @return ComponentProfile
00696   #
00697   # @endif
00698   def get_component_profile(self):
00699     try:
00700       return RTC.ComponentProfile(self._profile.instance_name,
00701                     self._profile.type_name,
00702                     self._profile.description,
00703                     self._profile.version,
00704                     self._profile.vendor,
00705                     self._profile.category,
00706                     self._profile.port_profiles,
00707                     self._profile.parent,
00708                     self._profile.properties)
00709     
00710     except:
00711       traceback.print_exception(*sys.exc_info())
00712     assert(False)
00713     return 0
00714 
00715 
00716   ##
00717   # @if jp
00718   #
00719   # @brief [RTObject CORBA interface] ポートを取得する
00720   #
00721   # 当該コンポーネントが保有するポートの参照を返す。
00722   #
00723   # @param self
00724   #
00725   # @return ポートリスト
00726   #
00727   # @else
00728   #
00729   # @brief [RTObject CORBA interface] Get Ports
00730   #
00731   # This operation returns a list of the RTCs ports.
00732   #
00733   # @return PortList
00734   #
00735   # @endif
00736   def get_ports(self):
00737     try:
00738       return self._portAdmin.getPortList()
00739     except:
00740       traceback.print_exception(*sys.exc_info())
00741 
00742     assert(False)
00743     return 0
00744 
00745 
00746   ##
00747   # @if jp
00748   #
00749   # @brief [RTObject CORBA interface] ExecutionContextAdmin を取得する
00750   #
00751   # このオペレーションは当該 RTC が所属する ExecutionContextに関連した
00752   # ExecutionContextService のリストを返す。
00753   #
00754   # @param self
00755   #
00756   # @return ExecutionContextService リスト
00757   #
00758   # @else
00759   #
00760   # @brief [RTObject CORBA interface] Get ExecutionContextAdmin
00761   #
00762   # This operation returns a list containing an ExecutionContextAdmin for
00763   # every ExecutionContext owned by the RTC.  
00764   #
00765   # @return ExecutionContextService List
00766   #
00767   # @endif
00768   def get_execution_context_services(self):
00769     try:
00770       return self._execContexts
00771     except:
00772       traceback.print_exception(*sys.exc_info())
00773 
00774     assert(False)
00775     return 0
00776 
00777 
00778   # RTC::ComponentAction
00779 
00780   ##
00781   # @if jp
00782   # @brief [CORBA interface] ExecutionContextをattachする
00783   #
00784   # 指定した ExecutionContext にこの RTC を所属させる。この RTC と関連する 
00785   # ExecutionContext のハンドルを返す。
00786   # このオペレーションは、ExecutionContextOperations::add_component が呼ばれた
00787   # 際に呼び出される。返されたハンドルは他のクライアントで使用することを想定
00788   # していない。
00789   #
00790   # @param self
00791   # @param exec_context 所属先 ExecutionContext
00792   #
00793   # @return ExecutionContext ハンドル
00794   #
00795   # @else
00796   # @brief [CORBA interface] Attach ExecutionContext.
00797   #
00798   # Inform this RTC that it is participating in the given execution context. 
00799   # Return a handle that represents the association of this RTC with the 
00800   # context.
00801   # This operation is intended to be invoked by 
00802   # ExecutionContextOperations::add_component. It is not intended for use by 
00803   # other clients.
00804   #
00805   # @param exec_context Prticipating ExecutionContext
00806   #
00807   # @return ExecutionContext Handle
00808   #
00809   # @endif
00810   def attach_executioncontext(self, exec_context):
00811     ecs = exec_context._narrow(RTC.ExecutionContextService)
00812     if CORBA.is_nil(ecs):
00813       return -1
00814 
00815     self._execContexts.append(ecs)
00816 
00817     return long(len(self._execContexts) -1)
00818 
00819 
00820   ##
00821   # @if jp
00822   # @brief [CORBA interface] ExecutionContextをdetachする
00823   #
00824   # 指定した ExecutionContext からこの RTC の所属を解除する。
00825   # このオペレーションは、ExecutionContextOperations::remove_component が呼ば
00826   # れた際に呼び出される。返されたハンドルは他のクライアントで使用することを
00827   # 想定していない。
00828   # 
00829   # 制約
00830   # - 指定された ExecutionContext に RTC がすでに所属していない場合には、
00831   #   ReturnCode_t::PRECONDITION_NOT_MET が返される。
00832   # - 指定された ExecutionContext にたしいて対して RTC がActive 状態である場
00833   #   合には、 ReturnCode_t::PRECONDITION_NOT_MET が返される。
00834   #
00835   # @param self
00836   # @param ec_id 解除対象 ExecutionContextハンドル
00837   #
00838   # @return ReturnCode_t 型のリターンコード
00839   #
00840   # @else
00841   # @brief [CORBA interface] Attach ExecutionContext.
00842   #
00843   # Inform this RTC that it is no longer participating in the given execution 
00844   # context.
00845   # This operation is intended to be invoked by 
00846   # ExecutionContextOperations::remove_component. It is not intended for use 
00847   # by other clients.
00848   # Constraints
00849   # - This operation may not be invoked if this RTC is not already 
00850   #   participating in the execution context. Such a call shall fail with 
00851   #   ReturnCode_t::PRECONDITION_NOT_MET.
00852   # - This operation may not be invoked if this RTC is Active in the indicated
00853   #   execution context. Otherwise, it shall fail with 
00854   #   ReturnCode_t::PRECONDITION_NOT_MET.
00855   #
00856   # @param ec_id Dettaching ExecutionContext Handle
00857   #
00858   # @return
00859   #
00860   # @endif
00861   def detach_executioncontext(self, ec_id):
00862     if ec_id > (len(self._execContexts) - 1):
00863       return RTC.BAD_PARAMETER
00864 
00865     if CORBA.is_nil(self._execContexts[ec_id]):
00866       return RTC.BAD_PARAMETER
00867     
00868     self._execContexts[ec_id] = RTC.ExecutionContextService._nil
00869     return RTC.RTC_OK
00870 
00871 
00872   ##
00873   # @if jp
00874   #
00875   # @brief [ComponentAction CORBA interface] RTC の初期化
00876   #
00877   # RTC が初期化され、Alive 状態に遷移する。
00878   # RTC 固有の初期化処理はここで実行する。
00879   # このオペレーション呼び出しの結果として onInitialize() コールバック関数が
00880   # 呼び出される。
00881   #
00882   # @param self
00883   #
00884   # @return ReturnCode_t 型のリターンコード
00885   #
00886   # @else
00887   #
00888   # @brief [ComponentAction CORBA interface] Initialize RTC
00889   #
00890   # The RTC has been initialized and entered the Alive state.
00891   # Any RTC-specific initialization logic should be performed here.
00892   #
00893   # @return
00894   #
00895   # @endif
00896   def on_initialize(self):
00897     ret = RTC.RTC_ERROR
00898     try:
00899       ret = self.onInitialize()
00900     except:
00901       return RTC.RTC_ERROR
00902     
00903     return ret
00904 
00905 
00906   ##
00907   # @if jp
00908   #
00909   # @brief [ComponentAction CORBA interface] RTC の終了
00910   #
00911   # RTC が破棄される。
00912   # RTC 固有の終了処理はここで実行する。
00913   # このオペレーション呼び出しの結果として onFinalize() コールバック関数が
00914   # 呼び出される。
00915   #
00916   # @param self
00917   #
00918   # @return ReturnCode_t 型のリターンコード
00919   #
00920   # @else
00921   #
00922   # @brief [ComponentAction CORBA interface] Finalize RTC
00923   #
00924   # The RTC is being destroyed.
00925   # Any final RTC-specific tear-down logic should be performed here.
00926   #
00927   # @return
00928   #
00929   # @endif
00930   def on_finalize(self):
00931     ret = RTC.RTC_ERROR
00932     try:
00933       ret = self.onFinalize()
00934     except:
00935       return RTC.RTC_ERROR
00936     
00937     return ret
00938 
00939 
00940   ##
00941   # @if jp
00942   #
00943   # @brief [ComponentAction CORBA interface] RTC の開始
00944   #
00945   # RTC が所属する ExecutionContext が Stopped 状態から Running 状態へ遷移
00946   # した場合に呼び出される。
00947   # このオペレーション呼び出しの結果として onStartup() コールバック関数が
00948   # 呼び出される。
00949   #
00950   # @param self
00951   # @param ec_id 状態遷移した ExecutionContext の ID
00952   #
00953   # @return ReturnCode_t 型のリターンコード
00954   #
00955   # @else
00956   #
00957   # @brief [ComponentAction CORBA interface] StartUp RTC
00958   #
00959   # The given execution context, in which the RTC is participating, has 
00960   # transitioned from Stopped to Running.
00961   #
00962   # @param ec_id
00963   #
00964   # @return
00965   #
00966   # @endif
00967   def on_startup(self, ec_id):
00968     ret = RTC.RTC_ERROR
00969     try:
00970       ret = self.onStartup(ec_id)
00971     except:
00972       return RTC.RTC_ERROR
00973     
00974     return ret
00975 
00976 
00977   ##
00978   # @if jp
00979   #
00980   # @brief [ComponentAction CORBA interface] RTC の停止
00981   #
00982   # RTC が所属する ExecutionContext が Running 状態から Stopped 状態へ遷移
00983   # した場合に呼び出される。
00984   # このオペレーション呼び出しの結果として onShutdown() コールバック関数が
00985   # 呼び出される。
00986   #
00987   # @param self
00988   # @param ec_id 状態遷移した ExecutionContext の ID
00989   #
00990   # @return ReturnCode_t 型のリターンコード
00991   #
00992   # @else
00993   #
00994   # @brief [ComponentAction CORBA interface] ShutDown RTC
00995   #
00996   # The given execution context, in which the RTC is participating, has 
00997   # transitioned from Running to Stopped.
00998   #
00999   # @param ec_id
01000   #
01001   # @return
01002   #
01003   # @endif
01004   def on_shutdown(self, ec_id):
01005     ret = RTC.RTC_ERROR
01006     try:
01007       ret = self.onShutdown(ec_id)
01008     except:
01009       return RTC.RTC_ERROR
01010     
01011     return ret
01012 
01013 
01014   ##
01015   # @if jp
01016   #
01017   # @brief [ComponentAction CORBA interface] RTC の活性化
01018   #
01019   # 所属する ExecutionContext から RTC が活性化された際に呼び出される。
01020   # このオペレーション呼び出しの結果として onActivated() コールバック関数が
01021   # 呼び出される。
01022   #
01023   # @param self
01024   # @param ec_id 活性化 ExecutionContext の ID
01025   #
01026   # @return ReturnCode_t 型のリターンコード
01027   #
01028   # @else
01029   #
01030   # @brief [ComponentAction CORBA interface] Activate RTC
01031   #
01032   # The RTC has been activated in the given execution context.
01033   #
01034   # @param ec_id
01035   #
01036   # @return
01037   #
01038   # @endif
01039   def on_activated(self, ec_id):
01040     ret = RTC.RTC_ERROR
01041     try:
01042       self._configsets.update()
01043       ret = self.onActivated(ec_id)
01044     except:
01045       return RTC.RTC_ERROR
01046     
01047     return ret
01048 
01049 
01050   ##
01051   # @if jp
01052   #
01053   # @brief [ComponentAction CORBA interface] RTC の非活性化
01054   #
01055   # 所属する ExecutionContext から RTC が非活性化された際に呼び出される。
01056   # このオペレーション呼び出しの結果として onDeactivated() コールバック関数が
01057   # 呼び出される。
01058   #
01059   # @param self
01060   # @param ec_id 非活性化 ExecutionContext の ID
01061   #
01062   # @return ReturnCode_t 型のリターンコード
01063   #
01064   # @else
01065   #
01066   # @brief [ComponentAction CORBA interface] Deactivate RTC
01067   #
01068   # The RTC has been deactivated in the given execution context.
01069   #
01070   # @param ec_id
01071   #
01072   # @return
01073   #
01074   # @endif
01075   def on_deactivated(self, ec_id):
01076     ret = RTC.RTC_ERROR
01077     try:
01078       ret = self.onDeactivated(ec_id)
01079     except:
01080       return RTC.RTC_ERROR
01081     
01082     return ret
01083 
01084 
01085   ##
01086   # @if jp
01087   #
01088   # @brief [ComponentAction CORBA interface] RTC のエラー状態への遷移
01089   #
01090   # RTC が所属する ExecutionContext が Active 状態から Error 状態へ遷移した
01091   # 場合に呼び出される。
01092   # このオペレーションは RTC が Error 状態に遷移した際に一度だけ呼び出される。
01093   # このオペレーション呼び出しの結果として onAborting() コールバック関数が
01094   # 呼び出される。
01095   #
01096   # @param self
01097   # @param ec_id 状態遷移した ExecutionContext の ID
01098   #
01099   # @return ReturnCode_t 型のリターンコード
01100   #
01101   # @else
01102   #
01103   # @brief [ComponentAction CORBA interface] Transition Error State
01104   #
01105   # The RTC is transitioning from the Active state to the Error state in some
01106   # execution context.
01107   # This callback is invoked only a single time for time that the RTC 
01108   # transitions into the Error state from another state. This behavior is in 
01109   # contrast to that of on_error.
01110   #
01111   # @param ec_id
01112   #
01113   # @return
01114   #
01115   # @endif
01116   def on_aborting(self, ec_id):
01117     ret = RTC.RTC_ERROR
01118     try:
01119       ret = self.onAborting(ec_id)
01120     except:
01121       return RTC.RTC_ERROR
01122     
01123     return ret
01124 
01125 
01126   ##
01127   # @if jp
01128   #
01129   # @brief [ComponentAction CORBA interface] RTC のエラー処理
01130   #
01131   # RTC がエラー状態にいる際に呼び出される。
01132   # RTC がエラー状態の場合に、対象となる ExecutionContext のExecutionKind に
01133   # 応じたタイミングで呼び出される。例えば、
01134   # - ExecutionKind が PERIODIC の場合、本オペレーションは
01135   #   DataFlowComponentAction::on_execute と on_state_update の替わりに、
01136   #   設定された順番、設定された周期で呼び出される。
01137   # - ExecutionKind が EVENT_DRIVEN の場合、本オペレーションは
01138   #   FsmParticipantAction::on_action が呼ばれた際に、替わりに呼び出される。
01139   # このオペレーション呼び出しの結果として onError() コールバック関数が呼び出
01140   # される。
01141   #
01142   # @param self
01143   # @param ec_id 対象 ExecutionContext の ID
01144   #
01145   # @return ReturnCode_t 型のリターンコード
01146   #
01147   # @else
01148   #
01149   # @brief [ComponentAction CORBA interface] Error Processing of RTC
01150   #
01151   # The RTC remains in the Error state.
01152   # If the RTC is in the Error state relative to some execution context when
01153   # it would otherwise be invoked from that context (according to the 
01154   # context’s ExecutionKind), this callback shall be invoked instead. 
01155   # For example,
01156   # - If the ExecutionKind is PERIODIC, this operation shall be invoked in 
01157   #   sorted order at the rate of the context instead of 
01158   #   DataFlowComponentAction::on_execute and on_state_update.
01159   # - If the ExecutionKind is EVENT_DRIVEN, this operation shall be invoked 
01160   #   whenever FsmParticipantAction::on_action would otherwise have been 
01161   #   invoked.
01162   #
01163   # @param ec_id
01164   #
01165   # @return
01166   #
01167   # @endif
01168   def on_error(self, ec_id):
01169     ret = RTC.RTC_ERROR
01170     try:
01171       ret = self.onError(ec_id)
01172     except:
01173       return RTC.RTC_ERROR
01174     
01175     return ret
01176 
01177 
01178   ##
01179   # @if jp
01180   #
01181   # @brief [ComponentAction CORBA interface] RTC のリセット
01182   #
01183   # Error 状態にある RTC のリカバリ処理を実行し、Inactive 状態に復帰させる
01184   # 場合に呼び出される。
01185   # RTC のリカバリ処理が成功した場合は Inactive 状態に復帰するが、それ以外の
01186   # 場合には Error 状態に留まる。
01187   # このオペレーション呼び出しの結果として onReset() コールバック関数が呼び
01188   # 出される。
01189   #
01190   # @param self
01191   # @param ec_id リセット対象 ExecutionContext の ID
01192   #
01193   # @return ReturnCode_t 型のリターンコード
01194   #
01195   # @else
01196   #
01197   # @brief [ComponentAction CORBA interface] Resetting RTC
01198   #
01199   # The RTC is in the Error state. An attempt is being made to recover it such
01200   # that it can return to the Inactive state.
01201   # If the RTC was successfully recovered and can safely return to the
01202   # Inactive state, this method shall complete with ReturnCode_t::OK. Any
01203   # other result shall indicate that the RTC should remain in the Error state.
01204   #
01205   # @param ec_id
01206   #
01207   # @return
01208   #
01209   # @endif
01210   def on_reset(self, ec_id):
01211     ret = RTC.RTC_ERROR
01212     try:
01213       ret = self.onReset(ec_id)
01214     except:
01215       return RTC.RTC_ERROR
01216     
01217     return ret
01218 
01219 
01220   ##
01221   # @if jp
01222   #
01223   # @brief [DataFlowComponentAction CORBA interface] RTC の定常処理(第一周期)
01224   #
01225   # 以下の状態が保持されている場合に、設定された周期で定期的に呼び出される。
01226   # - RTC は Alive 状態である。
01227   # - 指定された ExecutionContext が Running 状態である。
01228   # 本オペレーションは、Two-Pass Execution の第一周期で実行される。
01229   # このオペレーション呼び出しの結果として onExecute() コールバック関数が呼び
01230   # 出される。
01231   #
01232   # 制約
01233   # - 指定された ExecutionContext の ExecutionKind は、 PERIODIC でなければな
01234   #   らない
01235   #
01236   # @param self
01237   # @param ec_id 定常処理対象 ExecutionContext の ID
01238   #
01239   # @return ReturnCode_t 型のリターンコード
01240   #
01241   # @else
01242   #
01243   # @brief [DataFlowComponentAction CORBA interface] Primary Periodic 
01244   #        Operation of RTC
01245   #
01246   # This operation will be invoked periodically at the rate of the given
01247   # execution context as long as the following conditions hold:
01248   # - The RTC is Active.
01249   # - The given execution context is Running
01250   # This callback occurs during the first execution pass.
01251   #
01252   # Constraints
01253   # - The execution context of the given context shall be PERIODIC.
01254   #
01255   # @param ec_id
01256   #
01257   # @return
01258   #
01259   # @endif
01260   def on_execute(self, ec_id):
01261     ret = RTC.RTC_ERROR
01262     try:
01263       ret = self.onExecute(ec_id)
01264     except:
01265       return RTC.RTC_ERROR
01266     
01267     return ret
01268 
01269 
01270   ##
01271   # @if jp
01272   #
01273   # @brief [DataFlowComponentAction CORBA interface] RTC の定常処理(第二周期)
01274   #
01275   # 以下の状態が保持されている場合に、設定された周期で定期的に呼び出される。
01276   # - RTC は Alive 状態である。
01277   # - 指定された ExecutionContext が Running 状態である。
01278   # 本オペレーションは、Two-Pass Execution の第二周期で実行される。
01279   # このオペレーション呼び出しの結果として onStateUpdate() コールバック関数が
01280   # 呼び出される。
01281   #
01282   # 制約
01283   # - 指定された ExecutionContext の ExecutionKind は、 PERIODIC でなければな
01284   #   らない
01285   #
01286   # @param self
01287   # @param ec_id 定常処理対象 ExecutionContext の ID
01288   #
01289   # @return ReturnCode_t 型のリターンコード
01290   #
01291   # @else
01292   #
01293   # @brief [DataFlowComponentAction CORBA interface] Secondary Periodic 
01294   #        Operation of RTC
01295   #
01296   # This operation will be invoked periodically at the rate of the given
01297   # execution context as long as the following conditions hold:
01298   # - The RTC is Active.
01299   # - The given execution context is Running
01300   # This callback occurs during the second execution pass.
01301   #
01302   # Constraints
01303   # - The execution context of the given context shall be PERIODIC.
01304   #
01305   # @param ec_id
01306   #
01307   # @return
01308   #
01309   # @endif
01310   def on_state_update(self, ec_id):
01311     ret = RTC.RTC_ERROR
01312     try:
01313       ret = self.onStateUpdate(ec_id)
01314       self._configsets.update()
01315     except:
01316       return RTC.RTC_ERROR
01317     
01318     return ret
01319 
01320 
01321   ##
01322   # @if jp
01323   #
01324   # @brief [DataFlowComponentAction CORBA interface] 実行周期変更通知
01325   #
01326   # 本オペレーションは、ExecutionContext の実行周期が変更されたことを通知する
01327   # 際に呼び出される。
01328   # このオペレーション呼び出しの結果として onRateChanged() コールバック関数が
01329   # 呼び出される。
01330   #
01331   # 制約
01332   # - 指定された ExecutionContext の ExecutionKind は、 PERIODIC でなければな
01333   #   らない
01334   #
01335   # @param self
01336   # @param ec_id 定常処理対象 ExecutionContext の ID
01337   #
01338   # @return ReturnCode_t 型のリターンコード
01339   #
01340   # @else
01341   #
01342   # @brief [DataFlowComponentAction CORBA interface] Notify rate chenged
01343   #
01344   # This operation is a notification that the rate of the indicated execution 
01345   # context has changed.
01346   #
01347   # Constraints
01348   # - The execution context of the given context shall be PERIODIC.
01349   #
01350   # @param ec_id
01351   #
01352   # @return
01353   #
01354   # @endif
01355   def on_rate_changed(self, ec_id):
01356     ret = RTC.RTC_ERROR
01357     try:
01358       ret = self.onRateChanged(ec_id)
01359     except:
01360       return RTC.RTC_ERROR
01361     
01362     return ret
01363 
01364 
01365   #============================================================
01366   # SDOPackage::SdoSystemElement
01367   #============================================================
01368 
01369   ##
01370   # @if jp
01371   # 
01372   # @brief [SDO interface] Organization リストの取得 
01373   #
01374   # SDOSystemElement は0個もしくはそれ以上の Organization を所有することが
01375   # 出来る。 SDOSystemElement が1つ以上の Organization を所有している場合
01376   # には、このオペレーションは所有する Organization のリストを返す。
01377   # もしOrganizationを一つも所有していないければ空のリストを返す。
01378   #
01379   # @param self
01380   #
01381   # @return 所有している Organization リスト
01382   #
01383   # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準
01384   #                         システム例外のOBJECT_NOT_EXISTにマッピングされる)
01385   # @exception NotAvailable SDOは存在するが応答がない。
01386   # @exception InternalError 内部的エラーが発生した。
01387   #
01388   # @else
01389   #
01390   # @brief [SDO interface] Getting Organizations
01391   #
01392   # SDOSystemElement can be the owner of zero or more organizations.
01393   # If the SDOSystemElement owns one or more Organizations, this operation
01394   # returns the list of Organizations that the SDOSystemElement owns.
01395   # If it does not own any Organization, it returns empty list.
01396   #
01397   # @return Owned Organization List
01398   #
01399   # @exception SDONotExists if the target SDO does not exist.(This exception 
01400   #                         is mapped to CORBA standard system exception
01401   #                         OBJECT_NOT_EXIST.)
01402   # @exception NotAvailable if the target SDO is reachable but cannot
01403   #                         respond.
01404   # @exception InternalError if the target SDO cannot execute the operation
01405   #                          completely due to some internal error.
01406   #
01407   # @endif
01408   def get_owned_organizations(self):
01409     try:
01410       return self._sdoOwnedOrganizations
01411     except:
01412       raise SDOPackage.NotAvailable
01413 
01414     return []
01415 
01416 
01417   #============================================================
01418   # SDOPackage::SDO
01419   #============================================================
01420 
01421   ##
01422   # @if jp
01423   # 
01424   # @brief [SDO interface] SDO ID の取得
01425   #
01426   # SDO ID を返すオペレーション。
01427   # このオペレーションは以下の型の例外を発生させる。
01428   #
01429   # @param self
01430   # 
01431   # @return    リソースデータモデルで定義されている SDO の ID
01432   # 
01433   # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準
01434   #                         システム例外のOBJECT_NOT_EXISTにマッピングされる)
01435   # @exception NotAvailable SDOは存在するが応答がない。
01436   # @exception InternalError 内部的エラーが発生した。
01437   #
01438   # @else
01439   #
01440   # @brief [SDO interface] Getting SDO ID
01441   #
01442   # This operation returns id of the SDO.
01443   # This operation throws SDOException with one of the following types.
01444   #
01445   # @return    id of the SDO defined in the resource data model.
01446   #
01447   # @exception SDONotExists if the target SDO does not exist.(This exception 
01448   #                         is mapped to CORBA standard system exception
01449   #                         OBJECT_NOT_EXIST.)
01450   # @exception NotAvailable if the target SDO is reachable but cannot
01451   #                         respond.
01452   # @exception InternalError if the target SDO cannot execute the operation
01453   #                          completely due to some internal error.
01454   #
01455   # @endif
01456   def get_sdo_id(self):
01457     try:
01458       return self._profile.instance_name
01459     except:
01460       raise SDOPackage.InternalError("get_sdo_id()")
01461 
01462 
01463   ##
01464   # @if jp
01465   # 
01466   # @brief [SDO interface] SDO タイプの取得
01467   # 
01468   # SDO Type を返すオペレーション。
01469   # このオペレーションは以下の型の例外を発生させる。
01470   #
01471   # @param self
01472   #
01473   # @return    リソースデータモデルで定義されている SDO の Type
01474   #
01475   # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準
01476   #                         システム例外のOBJECT_NOT_EXISTにマッピングされる)
01477   # @exception NotAvailable SDOは存在するが応答がない。
01478   # @exception InternalError 内部的エラーが発生した。
01479   #
01480   # @else
01481   #
01482   # @brief [SDO interface] Getting SDO type
01483   #
01484   # This operation returns sdoType of the SDO.
01485   # This operation throws SDOException with one of the following types.
01486   #
01487   # @return    Type of the SDO defined in the resource data model.
01488   #
01489   # @exception SDONotExists if the target SDO does not exist.(This exception 
01490   #                         is mapped to CORBA standard system exception
01491   #                         OBJECT_NOT_EXIST.)
01492   # @exception NotAvailable if the target SDO is reachable but cannot
01493   #                         respond.
01494   # @exception InternalError if the target SDO cannot execute the operation
01495   #                          completely due to some internal error.
01496   #
01497   # @endif
01498   def get_sdo_type(self):
01499     try:
01500       return self._profile.description
01501     except:
01502       raise SDOPackage.InternalError("get_sdo_type()")
01503     return ""
01504 
01505 
01506   ##
01507   # @if jp
01508   # 
01509   # @brief [SDO interface] SDO DeviceProfile リストの取得 
01510   #
01511   # SDO の DeviceProfile を返すオペレーション。 SDO がハードウエアデバイス
01512   # に関連付けられていない場合には、空の DeviceProfile が返される。
01513   # このオペレーションは以下の型の例外を発生させる。
01514   #
01515   # @param self
01516   #
01517   # @return    SDO DeviceProfile
01518   #
01519   # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準
01520   #                         システム例外のOBJECT_NOT_EXISTにマッピングされる)
01521   # @exception NotAvailable SDOは存在するが応答がない。
01522   # @exception InternalError 内部的エラーが発生した。
01523   #
01524   # @else
01525   #
01526   # @brief [SDO interface] Getting SDO DeviceProfile
01527   #
01528   # This operation returns the DeviceProfile of the SDO. If the SDO does not
01529   # represent any hardware device, then a DeviceProfile with empty values
01530   # are returned.
01531   # This operation throws SDOException with one of the following types.
01532   #
01533   # @return    The DeviceProfile of the SDO.
01534   #
01535   # @exception SDONotExists if the target SDO does not exist.(This exception 
01536   #                         is mapped to CORBA standard system exception
01537   #                         OBJECT_NOT_EXIST.)
01538   # @exception NotAvailable if the target SDO is reachable but cannot
01539   #                         respond.
01540   # @exception InternalError if the target SDO cannot execute the operation
01541   #                          completely due to some internal error.
01542   #
01543   # @endif
01544   def get_device_profile(self):
01545     try:
01546       dprofile = SDOPackage.DeviceProfile(self._profile.category,
01547                         self._profile.vendor,
01548                         self._profile.type_name,
01549                         self._profile.version,
01550                         self._profile.properties)
01551       return dprofile
01552     except:
01553       raise SDOPackage.InternalError("get_device_profile()")
01554 
01555     return SDOPackage.DeviceProfile("","","","",[])
01556 
01557 
01558   ##
01559   # @if jp
01560   # 
01561   # @brief [SDO interface] SDO ServiceProfile の取得 
01562   #
01563   # SDO が所有している Service の ServiceProfile を返すオペレーション。
01564   # SDO がサービスを一つも所有していない場合には、空のリストを返す。
01565   # このオペレーションは以下の型の例外を発生させる。
01566   #
01567   # @param self
01568   # 
01569   # @return    SDO が提供する全ての Service の ServiceProfile。
01570   # 
01571   # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準
01572   #                         システム例外のOBJECT_NOT_EXISTにマッピングされる)
01573   # @exception NotAvailable SDOは存在するが応答がない。
01574   # @exception InternalError 内部的エラーが発生した。
01575   #
01576   # @else
01577   #
01578   # @brief [SDO interface] Getting SDO ServiceProfile
01579   # 
01580   # This operation returns a list of ServiceProfiles that the SDO has.
01581   # If the SDO does not provide any service, then an empty list is returned.
01582   # This operation throws SDOException with one of the following types.
01583   # 
01584   # @return    List of ServiceProfiles of all the services the SDO is
01585   #            providing.
01586   # 
01587   # @exception SDONotExists if the target SDO does not exist.(This exception 
01588   #                         is mapped to CORBA standard system exception
01589   #                         OBJECT_NOT_EXIST.)
01590   # @exception NotAvailable if the target SDO is reachable but cannot
01591   #                         respond.
01592   # @exception InternalError if the target SDO cannot execute the operation
01593   #                          completely due to some internal error.
01594   #
01595   # @endif
01596   def get_service_profiles(self):
01597     try:
01598       return self._sdoSvcProfiles
01599     except:
01600       raise SDOPackage.InternalError("get_service_profiles()")
01601 
01602     return []
01603 
01604 
01605   ##
01606   # @if jp
01607   # 
01608   # @brief [SDO interface] 特定のServiceProfileの取得 
01609   #
01610   # 引数 "id" で指定された名前のサービスの ServiceProfile を返す。
01611   # 
01612   # @param     self
01613   # @param     _id SDO Service の ServiceProfile に関連付けられた識別子。
01614   # 
01615   # @return    指定された SDO Service の ServiceProfile。
01616   # 
01617   # @exception InvalidParameter "id" で指定した ServiceProfile が存在しない。
01618   #                             "id" が null。
01619   # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準
01620   #                         システム例外のOBJECT_NOT_EXISTにマッピングされる)
01621   # @exception NotAvailable SDOは存在するが応答がない。
01622   # @exception InternalError 内部的エラーが発生した。
01623   #
01624   # @else
01625   #
01626   # @brief [SDO interface] Getting Organizations
01627   #
01628   # This operation returns the ServiceProfile that is specified by the
01629   # argument "id."
01630   # 
01631   # @param     _id The identifier referring to one of the ServiceProfiles.
01632   # 
01633   # @return    The profile of the specified service.
01634   # 
01635   # @exception InvalidParameter if the ServiceProfile that is specified by 
01636   #                             the argument 'id' does not exist or if 'id'
01637   #                             is 'null.'
01638   # @exception SDONotExists if the target SDO does not exist.(This exception 
01639   #                         is mapped to CORBA standard system exception
01640   #                         OBJECT_NOT_EXIST.)
01641   # @exception NotAvailable If the target SDO is reachable but cannot
01642   #                         respond.
01643   # @exception InternalError If the target SDO cannot execute the operation
01644   #                          completely due to some internal error.
01645   #
01646   # @endif
01647   def get_service_profile(self, _id):
01648     if _id is None:
01649       raise SDOPackage.InvalidParameter("get_service_profile(): Empty name.")
01650 
01651     try:
01652       index = OpenRTM.CORBA_SeqUtil.find(self._sdoSvcProfiles, self.svc_name(_id))
01653 
01654       if index < 0:
01655         raise SDOPackage.InvalidParameter("get_service_profile(): Not found")
01656 
01657       return self._sdoSvcProfiles[index]
01658     except:
01659       raise SDOPackage.InternalError("get_service_profile()")
01660 
01661     return SDOPackage.ServiceProfile("", "", [], None)
01662 
01663 
01664   ##
01665   # @if jp
01666   # 
01667   # @brief [SDO interface] 指定された SDO Service の取得
01668   #
01669   # このオペレーションは引数 "id" で指定された名前によって区別される
01670   # SDO の Service へのオブジェクト参照を返す。 SDO により提供される
01671   # Service はそれぞれ一意の識別子により区別される。
01672   #
01673   # @param self
01674   # @param _id SDO Service に関連付けられた識別子。
01675   #
01676   # @return 要求された SDO Service への参照。
01677   #
01678   # 
01679   # @exception InvalidParameter "id" で指定した ServiceProfile が存在しない。
01680   #                             "id" が null。
01681   # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準
01682   #                         システム例外のOBJECT_NOT_EXISTにマッピングされる)
01683   # @exception NotAvailable SDOは存在するが応答がない。
01684   # @exception InternalError 内部的エラーが発生した。
01685   #
01686   # @else
01687   #
01688   # @brief [SDO interface] Getting specified SDO Service's reference
01689   #
01690   # This operation returns an object implementing an SDO's service that
01691   # is identified by the identifier specified as an argument. Different
01692   # services provided by an SDO are distinguished with different
01693   # identifiers. See OMG SDO specification Section 2.2.8, "ServiceProfile,"
01694   # on page 2-12 for more details.
01695   #
01696   # @param _id The identifier referring to one of the SDO Service
01697   # @return The object implementing the requested service.
01698   # @exception InvalidParameter if argument “id” is null, or if the 
01699   #                             ServiceProfile that is specified by argument
01700   #                            “id” does not exist.
01701   # @exception SDONotExists if the target SDO does not exist.(This exception 
01702   #                         is mapped to CORBA standard system exception
01703   #                         OBJECT_NOT_EXIST.)
01704   # @exception NotAvailable If the target SDO is reachable but cannot
01705   #                         respond.
01706   # @exception InternalError If the target SDO cannot execute the operation
01707   #                          completely due to some internal error.
01708   #
01709   # @endif
01710   def get_sdo_service(self, _id):
01711     if _id is None:
01712       raise SDOPackage.InvalidParameter("get_service(): Empty name.")
01713 
01714     try:
01715       index = OpenRTM.CORBA_SeqUtil.find(self._sdoSvcProfiles, self.svc_name(_id))
01716 
01717       if index < 0:
01718         raise SDOPackage.InvalidParameter("get_service(): Not found")
01719 
01720       return self._sdoSvcProfiles[index].service
01721     except:
01722       raise SDOPackage.InternalError("get_service()")
01723     return SDOPackage.SDOService._nil
01724 
01725 
01726   ##
01727   # @if jp
01728   # 
01729   # @brief [SDO interface] Configuration オブジェクトの取得 
01730   #
01731   # このオペレーションは Configuration interface への参照を返す。
01732   # Configuration interface は各 SDO を管理するためのインターフェースの
01733   # ひとつである。このインターフェースは DeviceProfile, ServiceProfile,
01734   # Organization で定義された SDO の属性値を設定するために使用される。
01735   # Configuration インターフェースの詳細については、OMG SDO specification
01736   # の 2.3.5節, p.2-24 を参照のこと。
01737   #
01738   # @param self
01739   #
01740   # @return SDO の Configuration インターフェースへの参照
01741   #
01742   # @exception InterfaceNotImplemented SDOはConfigurationインターフェースを
01743   #                                    持たない。
01744   # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準
01745   #                         システム例外のOBJECT_NOT_EXISTにマッピングされる)
01746   # @exception NotAvailable SDOは存在するが応答がない。
01747   # @exception InternalError 内部的エラーが発生した。
01748   #
01749   # @else
01750   #
01751   # @brief [SDO interface] Getting Configuration object
01752   #
01753   # This operation returns an object implementing the Configuration
01754   # interface. The Configuration interface is one of the interfaces that
01755   # each SDO maintains. The interface is used to configure the attributes
01756   # defined in DeviceProfile, ServiceProfile, and Organization.
01757   # See OMG SDO specification Section 2.3.5, "Configuration Interface,"
01758   # on page 2-24 for more details about the Configuration interface.
01759   #
01760   # @return The Configuration interface of an SDO.
01761   #
01762   # @exception InterfaceNotImplemented The target SDO has no Configuration
01763   #                                    interface.
01764   # @exception SDONotExists if the target SDO does not exist.(This exception 
01765   #                         is mapped to CORBA standard system exception
01766   #                         OBJECT_NOT_EXIST.)
01767   # @exception NotAvailable The target SDO is reachable but cannot respond.
01768   # @exception InternalError The target SDO cannot execute the operation
01769   #                          completely due to some internal error.
01770   # @endif
01771   def get_configuration(self):
01772     if self._SdoConfig is None:
01773       raise SODPackage.InterfaceNotImplemented()
01774     try:
01775       return self._SdoConfig
01776     except:
01777       raise SDOPackage.InternalError("get_configuration()")
01778     return SDOPackage.Configuration._nil
01779 
01780 
01781   ##
01782   # @if jp
01783   # 
01784   # @brief [SDO interface] Monitoring オブジェクトの取得 
01785   #
01786   # このオペレーションは Monitoring interface への参照を返す。
01787   # Monitoring interface は SDO が管理するインターフェースの一つである。
01788   # このインターフェースは SDO のプロパティをモニタリングするために
01789   # 使用される。
01790   # Monitoring interface の詳細については OMG SDO specification の
01791   # 2.3.7節 "Monitoring Interface" p.2-35 を参照のこと。
01792   #
01793   # @param self
01794   #
01795   # @return SDO の Monitoring interface への参照
01796   #
01797   # @exception InterfaceNotImplemented SDOはConfigurationインターフェースを
01798   #                                    持たない。
01799   # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準
01800   #                         システム例外のOBJECT_NOT_EXISTにマッピングされる)
01801   # @exception NotAvailable SDOは存在するが応答がない。
01802   # @exception InternalError 内部的エラーが発生した。
01803   #
01804   # @else
01805   #
01806   # @brief [SDO interface] Get Monitoring object
01807   #
01808   # This operation returns an object implementing the Monitoring interface.
01809   # The Monitoring interface is one of the interfaces that each SDO
01810   # maintains. The interface is used to monitor the properties of an SDO.
01811   # See OMG SDO specification Section 2.3.7, "Monitoring Interface," on
01812   # page 2-35 for more details about the Monitoring interface.
01813   #
01814   # @return The Monitoring interface of an SDO.
01815   #
01816   # @exception InterfaceNotImplemented The target SDO has no Configuration
01817   #                                    interface.
01818   # @exception SDONotExists if the target SDO does not exist.(This exception 
01819   #                         is mapped to CORBA standard system exception
01820   #                         OBJECT_NOT_EXIST.)
01821   # @exception NotAvailable The target SDO is reachable but cannot respond.
01822   # @exception InternalError The target SDO cannot execute the operation
01823   #                          completely due to some internal error.
01824   # @endif
01825   def get_monitoring(self):
01826     raise SDOPackage.InterfaceNotImplemented("Exception: get_monitoring")
01827     return SDOPackage.Monitoring._nil
01828 
01829 
01830   ##
01831   # @if jp
01832   # 
01833   # @brief [SDO interface] Organization リストの取得 
01834   #
01835   # SDO は0個以上の Organization (組織)に所属することができる。 もし SDO が
01836   # 1個以上の Organization に所属している場合、このオペレーションは所属する
01837   # Organization のリストを返す。SDO が どの Organization にも所属していない
01838   # 場合には、空のリストが返される。
01839   #
01840   # @param self
01841   #
01842   # @return SDO が所属する Organization のリスト。
01843   #
01844   # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準
01845   #                         システム例外のOBJECT_NOT_EXISTにマッピングされる)
01846   # @exception NotAvailable SDOは存在するが応答がない。
01847   # @exception InternalError 内部的エラーが発生した。
01848   # @else
01849   #
01850   # @brief [SDO interface] Getting Organizations
01851   #
01852   # An SDO belongs to zero or more organizations. If the SDO belongs to one
01853   # or more organizations, this operation returns the list of organizations
01854   # that the SDO belongs to. An empty list is returned if the SDO does not
01855   # belong to any Organizations.
01856   #
01857   # @return The list of Organizations that the SDO belong to.
01858   #
01859   # @exception SDONotExists if the target SDO does not exist.(This exception 
01860   #                         is mapped to CORBA standard system exception
01861   #                         OBJECT_NOT_EXIST.)
01862   # @exception NotAvailable The target SDO is reachable but cannot respond.
01863   # @exception InternalError The target SDO cannot execute the operation
01864   #                          completely due to some internal error.
01865   # @endif
01866   def get_organizations(self):
01867     try:
01868       return self._sdoOrganizations
01869     except:
01870       raise SDOPackage.InternalError("get_organizations()")
01871     return []
01872 
01873 
01874   ##
01875   # @if jp
01876   # 
01877   # @brief [SDO interface] SDO Status リストの取得 
01878   #
01879   # このオペレーションは SDO のステータスを表す NVList を返す。
01880   #
01881   # @param self
01882   #
01883   # @return SDO のステータス。
01884   #
01885   # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準
01886   #                         システム例外のOBJECT_NOT_EXISTにマッピングされる)
01887   # @exception NotAvailable SDOは存在するが応答がない。
01888   # @exception InternalError 内部的エラーが発生した。
01889   #
01890   # @else
01891   #
01892   # @brief [SDO interface] Get SDO Status
01893   #
01894   # This operation returns an NVlist describing the status of an SDO.
01895   #
01896   # @return The actual status of an SDO.
01897   #
01898   # @exception SDONotExists if the target SDO does not exist.(This exception 
01899   #                         is mapped to CORBA standard system exception
01900   #                         OBJECT_NOT_EXIST.)
01901   # @exception NotAvailable The target SDO is reachable but cannot respond.
01902   # @exception InternalError The target SDO cannot execute the operation
01903   #                          completely due to some internal error.
01904   #
01905   # @endif
01906   def get_status_list(self):
01907     try:
01908       return self._sdoStatus
01909     except:
01910       raise SDOPackage.InternalError("get_status_list()")
01911     return []
01912 
01913 
01914   ##
01915   # @if jp
01916   # 
01917   # @brief [SDO interface] SDO Status の取得 
01918   #
01919   # This operation returns the value of the specified status parameter.
01920   #
01921   # @param self
01922   # @param name SDO のステータスを定義するパラメータ。
01923   # 
01924   # @return 指定されたパラメータのステータス値。
01925   # 
01926   # @exception SDONotExists ターゲットのSDOが存在しない。(本例外は、CORBA標準
01927   #                         システム例外のOBJECT_NOT_EXISTにマッピングされる)
01928   # @exception NotAvailable SDOは存在するが応答がない。
01929   # @exception InvalidParameter 引数 "name" が null あるいは存在しない。
01930   # @exception InternalError 内部的エラーが発生した。
01931   # @else
01932   #
01933   # @brief [SDO interface] Get SDO Status
01934   #
01935   # @param name One of the parameters defining the "status" of an SDO.
01936   #
01937   # @return The value of the specified status parameter.
01938   #
01939   # @exception SDONotExists if the target SDO does not exist.(This exception 
01940   #                         is mapped to CORBA standard system exception
01941   #                         OBJECT_NOT_EXIST.)
01942   # @exception NotAvailable The target SDO is reachable but cannot respond.
01943   # @exception InvalidParameter The parameter defined by "name" is null or
01944   #                             does not exist.
01945   # @exception InternalError The target SDO cannot execute the operation
01946   #                          completely due to some internal error.
01947   #
01948   #
01949   # @endif
01950   def get_status(self, name):
01951     index = OpenRTM.CORBA_SeqUtil.find(self._sdoStatus, self.nv_name(name))
01952     if index < 0:
01953       raise SDOPackage.InvalidParameter("get_status(): Not found")
01954 
01955     try:
01956       return any.to_any(self._sdoStatus[index].value)
01957     except:
01958       raise SDOPackage.InternalError("get_status()")
01959     return any.to_any("")
01960 
01961 
01962   #============================================================
01963   # Local interfaces
01964   #============================================================
01965 
01966   ##
01967   # @if jp
01968   #
01969   # @brief [local interface] インスタンス名の取得
01970   # 
01971   # ComponentProfile に設定されたインスタンス名を返す。
01972   #
01973   # @param self
01974   # 
01975   # @return インスタンス名
01976   # 
01977   # @else
01978   # 
01979   # @endif
01980   def getInstanceName(self):
01981     return self._profile.instance_name
01982 
01983 
01984   ##
01985   # @if jp
01986   #
01987   # @brief [local interface] インスタンス名の設定
01988   # 
01989   # ComponentProfile に指定されたインスタンス名を設定する。
01990   #
01991   # @param self
01992   # 
01993   # @param instance_name インスタンス名
01994   # 
01995   # @else
01996   # 
01997   # @endif
01998   def setInstanceName(self, instance_name):
01999     self._properties.setProperty("instance_name",instance_name)
02000     self._profile.instance_name = self._properties.getProperty("instance_name")
02001 
02002 
02003   ##
02004   # @if jp
02005   #
02006   # @brief [local interface] 型名の取得
02007   # 
02008   # ComponentProfile に設定された型名を返す。
02009   #
02010   # @param self
02011   # 
02012   # @return 型名
02013   # 
02014   # @else
02015   # 
02016   # @endif
02017   def getTypeName(self):
02018     return self._profile.type_name
02019 
02020 
02021   ##
02022   # @if jp
02023   #
02024   # @brief [local interface] Description の取得
02025   # 
02026   # ComponentProfile に設定された Description を返す。
02027   #
02028   # @param self
02029   # 
02030   # @return Description
02031   # 
02032   # @else
02033   # 
02034   # @endif
02035   def getDescription(self):
02036     return self._profile.description
02037 
02038 
02039   ##
02040   # @if jp
02041   #
02042   # @brief [local interface] バージョン情報の取得
02043   # 
02044   # ComponentProfile に設定されたバージョン情報を返す。
02045   #
02046   # @param self
02047   # 
02048   # @return バージョン情報
02049   # 
02050   # @else
02051   # 
02052   # @endif
02053   def getVersion(self):
02054     return self._profile.version
02055 
02056 
02057   ##
02058   # @if jp
02059   #
02060   # @brief [local interface] ベンダー情報の取得
02061   # 
02062   # ComponentProfile に設定されたベンダー情報を返す。
02063   #
02064   # @param self
02065   # 
02066   # @return ベンダー情報
02067   # 
02068   # @else
02069   # 
02070   # @endif
02071   def getVendor(self):
02072     return self._profile.vendor
02073 
02074 
02075   ##
02076   # @if jp
02077   #
02078   # @brief [local interface] カテゴリ情報の取得
02079   # 
02080   # ComponentProfile に設定されたカテゴリ情報を返す。
02081   #
02082   # @param self
02083   # 
02084   # @return カテゴリ情報
02085   # 
02086   # @else
02087   # 
02088   # @endif
02089   def getCategory(self):
02090     return self._profile.category
02091 
02092 
02093   ##
02094   # @if jp
02095   #
02096   # @brief [local interface] Naming Server 情報の取得
02097   # 
02098   # 設定された Naming Server 情報を返す。
02099   #
02100   # @param self
02101   # 
02102   # @return Naming Server リスト
02103   # 
02104   # @else
02105   # 
02106   # @endif
02107   def getNamingNames(self):
02108     return string.split(self._properties.getProperty("naming.names"), ",")
02109 
02110 
02111   ##
02112   # @if jp
02113   #
02114   # @brief [local interface] オブジェクトリファレンスの設定
02115   # 
02116   # RTC の CORBA オブジェクトリファレンスを設定する。
02117   # 
02118   # @param self
02119   # @param rtobj オブジェクトリファレンス
02120   # 
02121   # @else
02122   # 
02123   # @endif
02124   def setObjRef(self, rtobj):
02125     self._objref = rtobj
02126     return
02127 
02128 
02129   ##
02130   # @if jp
02131   #
02132   # @brief [local interface] オブジェクトリファレンスの取得
02133   # 
02134   # 設定された CORBA オブジェクトリファレンスを取得する。
02135   # 
02136   # @param self
02137   # 
02138   # @return オブジェクトリファレンス
02139   # 
02140   # @else
02141   # 
02142   # @endif
02143   def getObjRef(self):
02144     return self._objref
02145 
02146 
02147   ##
02148   # @if jp
02149   # 
02150   # @brief [local interface] RTC のプロパティを設定する
02151   #
02152   # RTC が保持すべきプロパティを設定する。与えられるプロパティは、
02153   # ComponentProfile 等に設定されるべき情報を持たなければならない。
02154   # このオペレーションは通常 RTC が初期化される際に Manager から
02155   # 呼ばれることを意図している。
02156   # 
02157   # @param self
02158   # @param prop RTC のプロパティ
02159   #
02160   # @else
02161   #
02162   # @brief [local interface] Set RTC property
02163   #
02164   # This operation sets the properties to the RTC. The given property
02165   # values should include information for ComponentProfile.
02166   # Generally, this operation is designed to be called from Manager, when
02167   # RTC is initialized
02168   #
02169   # @param prop Property for RTC.
02170   #
02171   # @endif
02172   def setProperties(self, prop):
02173     self._properties = self._properties.mergeProperties(prop)
02174     self._profile.instance_name = self._properties.getProperty("instance_name")
02175     self._profile.type_name     = self._properties.getProperty("type_name")
02176     self._profile.description   = self._properties.getProperty("description")
02177     self._profile.version       = self._properties.getProperty("version")
02178     self._profile.vendor        = self._properties.getProperty("vendor")
02179     self._profile.category      = self._properties.getProperty("category")
02180 
02181 
02182   ##
02183   # @if jp
02184   # 
02185   # @brief [local interface] RTC のプロパティを取得する
02186   #
02187   # RTC が保持しているプロパティを返す。
02188   # RTCがプロパティを持たない場合は空のプロパティが返される。
02189   # 
02190   # @param self
02191   # 
02192   # @return RTC のプロパティ
02193   #
02194   # @else
02195   #
02196   # @brief [local interface] Get RTC property
02197   #
02198   # This operation returns the properties of the RTC.
02199   # Empty property would be returned, if RTC has no property.
02200   #
02201   # @return Property for RTC.
02202   #
02203   # @endif
02204   def getProperties(self):
02205     return self._properties
02206 
02207 
02208   ##
02209   # @if jp
02210   #
02211   # @brief コンフィギュレーションパラメータの設定
02212   # 
02213   # コンフィギュレーションパラメータと変数をバインドする
02214   # <VarType>としてコンフィギュレーションパラメータのデータ型を指定する。
02215   #
02216   # @param self
02217   # @param param_name コンフィギュレーションパラメータ名
02218   # @param var コンフィギュレーションパラメータ格納用変数
02219   # @param def_val コンフィギュレーションパラメータデフォルト値
02220   # @param trans 文字列変換用関数(デフォルト値:None)
02221   #
02222   # @return 設定結果(設定成功:true,設定失敗:false)
02223   # 
02224   # @else
02225   #
02226   # @endif
02227   def bindParameter(self, param_name, var,
02228             def_val, trans=None):
02229     if trans is None:
02230       _trans = OpenRTM.stringTo
02231     else:
02232       _trans = trans
02233     self._configsets.bindParameter(param_name, var, def_val, _trans)
02234     return True
02235 
02236 
02237   ##
02238   # @if jp
02239   #
02240   # @brief コンフィギュレーションパラメータの更新(ID指定)
02241   # 
02242   # 指定したIDのコンフィギュレーションセットに設定した値で、
02243   # コンフィギュレーションパラメータの値を更新する
02244   #
02245   # @param self
02246   # @param config_set 設定対象のコンフィギュレーションセットID
02247   # 
02248   # @else
02249   #
02250   # @endif
02251   def updateParameters(self, config_set):
02252     self._configsets.update(config_set)
02253     return
02254 
02255 
02256   ##
02257   # @if jp
02258   # 
02259   # @brief [local interface] Port を登録する
02260   #
02261   # RTC が保持するPortを登録する。
02262   # Port を外部からアクセス可能にするためには、このオペレーションにより
02263   # 登録されていなければならない。登録される Port はこの RTC 内部において
02264   # PortProfile.name により区別される。したがって、Port は RTC 内において、
02265   # ユニークな PortProfile.name を持たなければならない。
02266   # 登録された Port は内部で適切にアクティブ化された後、その参照と
02267   # オブジェクト参照がリスト内に保存される。
02268   # 
02269   # @param self
02270   # @param port RTC に登録する Port
02271   #
02272   # @else
02273   #
02274   # @brief [local interface] Register Port
02275   #
02276   # This operation registers a Port to be held by this RTC.
02277   # In order to enable access to the Port from outside of RTC, the Port
02278   # must be registered by this operation. The Port that is registered by
02279   # this operation would be identified by PortProfile.name in the inside of
02280   # RTC. Therefore, the Port should have unique PortProfile.name in the RTC.
02281   # The registering Port would be activated properly, and the reference
02282   # and the object reference would be stored in lists in RTC.
02283   #
02284   # @param port Port which is registered in the RTC
02285   #
02286   # @endif
02287   def registerPort(self, port):
02288     self._portAdmin.registerPort(port)
02289     return
02290 
02291 
02292   ##
02293   # @if jp
02294   # 
02295   # @brief [local interface] DataInPort を登録する
02296   #
02297   # RTC が保持する DataInPort を登録する。
02298   # Port のプロパティにデータポートであること("port.dataport")、
02299   # TCPを使用すること("tcp_any")を設定するとともに、 DataInPort の
02300   # インスタンスを生成し、登録する。
02301   # 
02302   # @param self
02303   # @param name port 名称
02304   # @param inport 登録対象 DataInPort
02305   #
02306   # @else
02307   #
02308   # @endif
02309   def registerInPort(self, name, inport):
02310     port = OpenRTM.DataInPort(name, inport)
02311     self.registerPort(port)
02312     return
02313 
02314 
02315   ##
02316   # @if jp
02317   # 
02318   # @brief [local interface] DataOutPort を登録する
02319   #
02320   # RTC が保持する DataOutPor tを登録する。
02321   # Port のプロパティにデータポートであること("port.dataport")、
02322   # TCPを使用すること("tcp_any")を設定するとともに、 DataOutPort の
02323   # インスタンスを生成し、登録する。
02324   # 
02325   # @param self
02326   # @param name port 名称
02327   # @param outport 登録対象 DataInPort
02328   #
02329   # @else
02330   #
02331   # @endif
02332   def registerOutPort(self, name, outport):
02333     port = OpenRTM.DataOutPort(name, outport)
02334     self.registerPort(port)
02335     return
02336 
02337 
02338   ##
02339   # @if jp
02340   # 
02341   # @brief [local interface] Port の登録を削除する
02342   #
02343   # RTC が保持するPortの登録を削除する。
02344   # 
02345   # @param self
02346   # @param port 削除対象 Port
02347   #
02348   # @else
02349   #
02350   # @brief [local interface] Unregister Port
02351   #
02352   # This operation unregisters a Port to be held by this RTC.
02353   #
02354   # @param port Port which is unregistered in the RTC
02355   #
02356   # @endif
02357   def deletePort(self, port):
02358     self._portAdmin.deletePort(port)
02359     return
02360 
02361 
02362   ##
02363   # @if jp
02364   # 
02365   # @brief [local interface] 名前指定により Port の登録を削除する
02366   #
02367   # 名称を指定して RTC が保持するPortの登録を削除する。
02368   # 
02369   # @param self
02370   # @param port_name 削除対象 Port 名
02371   #
02372   # @else
02373   #
02374   # @endif
02375   def deletePortByName(self, port_name):
02376     self._portAdmin.deletePortByName(port_name)
02377     return
02378 
02379 
02380   ##
02381   # @if jp
02382   #
02383   # @brief 全 Port の登録を削除する
02384   #
02385   # RTC が保持する全ての Port を削除する。
02386   # 
02387   # @param self
02388   #
02389   # @else
02390   #
02391   # @brief Unregister the All Portse
02392   #
02393   # This operation deactivates the all Port and deletes the all Port's
02394   # registrations in the RTC..
02395   #
02396   # @endif
02397   def finalizePorts(self):
02398     self._portAdmin.finalizePorts()
02399     return
02400 
02401 
02402   ##
02403   # @if jp
02404   #
02405   # @brief RTC を終了する
02406   #
02407   # RTC の終了処理を実行する。
02408   # 保持している全 Port の登録を解除するとともに、該当する CORBA オブジェクト
02409   # を非活性化し、RTC を終了する。
02410   # 
02411   # @param self
02412   #
02413   # @else
02414   #
02415   # @endif
02416   def shutdown(self):
02417     try:
02418       self.finalizePorts()
02419       self._poa.deactivate_object(self._poa.servant_to_id(self._SdoConfigImpl))
02420       self._poa.deactivate_object(self._poa.servant_to_id(self))
02421     except:
02422       traceback.print_exception(*sys.exc_info())
02423 
02424     if self._manager:
02425       self._manager.cleanupComponent(self)
02426       
02427     return
02428 
02429 
02430 
02431   ##
02432   # @if jp
02433   # @class svc_name
02434   # @brief SDOService のプロファイルリストからidでサーチするための
02435   # ファンクタクラス
02436   # @else
02437   #
02438   # @endif
02439   class svc_name:
02440     def __init__(self, _id):
02441       self._id= _id
02442 
02443     def __call__(self, prof):
02444       return self._id == prof.id
02445 
02446 
02447   #------------------------------------------------------------
02448   # Functor
02449   #------------------------------------------------------------
02450 
02451   ##
02452   # @if jp
02453   # @class nv_name
02454   # @brief NVList 検索用ファンクタ
02455   # @else
02456   #
02457   # @endif
02458   class nv_name:
02459     def __init__(self, _name):
02460       self._name = _name
02461 
02462     def __call__(self, nv):
02463       return self._name == nv.name
02464 
02465   ##
02466   # @if jp
02467   # @class ec_copy
02468   # @brief ExecutionContext 検索用ファンクタ
02469   # @else
02470   #
02471   # @endif
02472   class ec_copy:
02473     def __init__(self, eclist):
02474       self._eclist = eclist
02475 
02476     def __call__(self, ecs):
02477       self._eclist.append(ecs)
02478 
02479   ##
02480   # @if jp
02481   # @class deactivate_comps
02482   # @brief RTC 非活性化用ファンクタ
02483   # @else
02484   #
02485   # @endif
02486   class deactivate_comps:
02487     def __init__(self, comp):
02488       self._comp = comp
02489 
02490     def __call__(self, ec):
02491       ec.deactivate_component(self._comp)
02492 
02493 
02494 # RtcBase = RTObject_impl

OpenRTMに対してMon Mar 17 15:11:06 2008に生成されました。  doxygen 1.5.4