OpenRTM-aist-Python 1.1.2
|
ExecutionContext用基底クラス [詳解]
公開メンバ関数 | |
def | init (self, props) |
ExecutionContextの初期化処理 [詳解] | |
def | bindComponent (self, rtc) |
ExecutionContextの処理を進める(サブクラス実装用) [詳解] | |
def | isRunning (self) |
ExecutionContext 実行状態確認関数 CORBA::Boolean ExecutionContextBase::isRunning() | |
def | start (self) |
ExecutionContext の実行を開始 RTC::ReturnCode_t ExecutionContextBase::start() | |
def | stop (self) |
ExecutionContext の実行を停止 RTC::ReturnCode_t ExecutionContextBase::stop() | |
def | getRate (self) |
ExecutionContext の実行周期(Hz)を取得する [詳解] | |
def | setRate (self, rate) |
ExecutionContext の実行周期(Hz)を設定する [詳解] | |
def | addComponent (self, comp) |
RTコンポーネントを追加する RTC::ReturnCode_t ExecutionContextBase:: addComponent(RTC::LightweightRTObject_ptr comp) | |
def | removeComponent (self, comp) |
RTコンポーネントを参加者リストから削除する RTC::ReturnCode_t ExecutionContextBase:: removeComponent(RTC::LightweightRTObject_ptr comp) | |
def | activateComponent (self, comp) |
RTコンポーネントをアクティブ化する RTC::ReturnCode_t ExecutionContextBase:: activateComponent(RTC::LightweightRTObject_ptr comp) | |
def | deactivateComponent (self, comp) |
RTコンポーネントを非アクティブ化する RTC::ReturnCode_t ExecutionContextBase:: deactivateComponent(RTC::LightweightRTObject_ptr comp) | |
def | resetComponent (self, comp) |
RTコンポーネントをリセットする RTC::ReturnCode_t ExecutionContextBase:: resetComponent(RTC::LightweightRTObject_ptr comp) | |
def | getComponentState (self, comp) |
RTコンポーネントの状態を取得する [詳解] | |
def | getKind (self) |
ExecutionKind を取得する [詳解] | |
def | getProfile (self) |
Profileを取得する [詳解] | |
def | setObjRef (self, ec_ptr) |
CORBA オブジェクト参照の取得 [詳解] | |
def | getObjRef (self) |
CORBA オブジェクト参照の取得 [詳解] | |
def | getKindString (self, kind) |
ExecutionKind を文字列化する [詳解] | |
def | setKind (self, kind) |
ExecutionKind を設定する [詳解] | |
def | setOwner (self, comp) |
Ownerコンポーネントをセットする。 [詳解] | |
def | getOwner (self) |
Ownerコンポーネントの参照を取得する [詳解] | |
def | getComponentList (self) |
RTコンポーネントの参加者リストを取得する [詳解] | |
def | setProperties (self, props) |
Propertiesをセットする [詳解] | |
def | getProperties (self) |
Propertiesを取得する [詳解] | |
def | getProfile (self) |
Profileを取得する [詳解] | |
def | setExecutionRate (self, props) |
Propertiesから実行コンテキストをセットする bool ExecutionContextBase::setExecutionRate(coil::Properties& props) | |
def | setTransitionMode (self, props, key, flag) |
Propertiesから状態遷移モードをセットする bool ExecutionContextBase:: setTransitionMode(coil::Properties& props, const char* key, bool& flag) | |
def | setTimeout (self, props, key, timevalue) |
Propertiesから状態遷移Timeoutをセットする bool ExecutionContextBase:: setTimeout(coil::Properties& props, const char* key, coil::TimeValue& timevalue) | |
ExecutionContext用基底クラス
ECの実装クラスでは、この基底クラスを継承し、かつECのCORBAオペレー ションを実装しなければならない。さらに、実際にロジックを駆動するた め、幾つかの約束に則りExecutionContextBaseの関数を呼び出す必要があ る。ECのCORBAオペレーションは以下のものがあり、それぞれ ExecutionContextBaseのメンバ関数に対応している。
実行状態に関係する関数は、is_running(), start(), stop() の3つがあ る。ExecutionContextBaseでは単純に running/stopped のフラグを持っ ており、start/stopでフラグのON/OFF切り替え、is_running()で状態読み 出しを行っている。通常、ECの実装クラスでは、protected な仮想メン バ関数 onStarting(), onStarted(), onStopping(), onStopped() 関数を 実装したうえで、CORBAオペレーションを以下のように実装する必要がある。
is_running() のCORBAオペレーションでは、単純に ExecutionContextBase の isRunning() を呼び出すだけである。この関数 に関連する protected 仮想関数はonIsRunning() が用意されているが、 通常特に実装する必要はない。あえて、現在の running/stopped 状態を 書き換えたい場合にこの関数を利用することができるが推奨はされない。
public: CORBA::Boolean is_runing() { return ExecutionContextBase::isRunning(); } protected: CORBA::Boolean onIsRunning(CORBA::Boolean running) { return running; }
start(), stop() CORBAオペレーションでは、通常 ExecutionContextBase の start(), stop() 関数を呼び出すよう実装する。 この関数に関連する protected 仮想関数は、start() および stop() に ついてそれぞれ2つづつの onStarting(), onStarted(), および onStopping(), onStopped() 関数がある。ECの実装クラスにおいては、そ れぞれ以下のように実装する。
RTC::ReturnCode_t start() { return ExecutionContextBase::start(); } RTC::ReturnCode_t stop() { return ExecutionContextBase::stop(); } protected: RTC::ReturnCode_t onStarting() { RTC::ReturnCode_t ret = // スレッドを開始する処理など return ret; } RTC::ReturnCode_t onStarted() { RTC::ReturnCode_t ret = // スレッドを開始する処理など return ret; } RTC::ReturnCode_t onStopping() { // スレッドを停止する処理など return retcode; } RTC::ReturnCode_t onStopped() { // スレッドを停止する処理など return retcode; }
実行周期に関する関数は set_rate(), get_rate() の2種類がある。実装 する実行コンテキストがもし set_rate() により指定される周期を利用する 場合、テンプレート関数 onSetRate() をオーバーライドし実装する。 onSetRate() は引数に double 型の周期を取り、この値は正当な値である ことが保証されている。onSetRate() がRTC::RTC_OK 以外の値を返した場 合、ECのProfileの周期は設定される以前の値を保持することが保証され る。
set_rate() 同様 get_rate() 呼び出し時にonGetRate() が呼び出される が、これは通常オーバーライドする必要はない。ただし、get_rate() が 返す値を変更したい場合、onGetRate() をオーバーライドすることでその 値を書き換えることができる。ただし、これは推奨されない。
public: RTC::ReturnCode_t set_rate(double rate) { return setRate(rate); } double get_rate(void) const { return getRate(); } protected: virtual RTC::ReturnCode_t onSetRate(double rate) { RTC::ReturnCode_t ret = // 周期を設定する何らかの処理 if (ret != RTC::RTC_OK) { RTC_ERROR(("Error message")); } return ret; } virtual double onGetRate(rate) { // get_rate() が返す値を加工したい場合 // 通常はこの関数を実装する必要はない。 return rate; }
コンポーネントの追加と削除に関する関数は、add_component(), remove_component() の二種類がある。実行コンテキストの実装クラスに おいては、ExecutionContextBase のそれぞれ addComponent(), removeComponent() を呼び出す形で実装を行う。これらの関数に関連する protected 仮想関数は onAddingComponent(), onAddedComponent(), onRemovingComponent(), onRemovedComponent() の4種類ある。ただし、 これらの仮想関数は通常オーバーライドする必要はなく、使用は推奨され ない。
public: RTC::ReturnCode_t add_component(RTC::LightweightRTObject_ptr comp) { return ExecutionContextBase::addComponent(comp); } RTC::ReturnCode_t remove_component(RTC::LightweightRTObject_ptr comp) { return ExecutionContextBase::removeComponent(comp); } protected: virtual RTC::ReturnCode_t onAddingComponent(RTC::LightweightRTObject rtobj) { // コンポーネント追加時に実行したい処理を記述 // RTC::RTC_OK 以外を返した場合、コンポーネントの追加は行われない。 return RTC::RTC_OK; } virtual RTC::ReturnCode_t onAddedComponent(RTC::LightweightRTObject rtobj) { // コンポーネント追加時に実行したい処理を記述 // RTC::RTC_OK 以外を返した場合、removeComponent() が呼び出され、 // 追加されたコンポーネントが削除される。 return RTC::RTC_OK; } virtual RTC::ReturnCode_t onRemovingComponent(RTC::LightweightRTObject rtobj) { // コンポーネント削除時に実行したい処理を記述 // RTC::RTC_OK 以外を返した場合、コンポーネントの削除は行われない。 return RTC::RTC_OK; } virtual RTC::ReturnCode_t onRemovedComponent(RTC::LightweightRTObject rtobj) { // コンポーネント追加時に実行したい処理を記述 // RTC::RTC_OK 以外を返した場合、addComponent() が呼び出され、 // 削除されたコンポーネントが再び追加される。 return RTC::RTC_OK; }
コンポーネントのアクティブ化等に関する関数は、 activate_component(), deactivate_component(), reset_component() の 三種類がある。実行コンテキストの実装クラスにおいては、 ExecutionContextBase のそれぞれ activateComponent(), deactivateComponent(), resetComponent() を呼び出す形で実装を行う。 これらの関数に関連する protected 仮想関数は onActivatingComponent(), onAtivatingComponent(), onActivatedComponent(), onDeactivatingComponent(), onDeactivatedComponent(), onResettingComponent(), onResetComponent() の6種類ある。ただし、これらの仮想関数は通常オー バーライドする必要はなく、使用は推奨されない。
public: RTC::ReturnCode_t add_component(RTC::LightweightRTObject_ptr comp) { return ExecutionContextBase::addComponent(comp); } RTC::ReturnCode_t remove_component(RTC::LightweightRTObject_ptr comp) { return ExecutionContextBase::removeComponent(comp); } protected: virtual RTC::ReturnCode_t onAddingComponent(RTC::LightweightRTObject rtobj) { // コンポーネント追加時に実行したい処理を記述 // RTC::RTC_OK 以外を返した場合、コンポーネントの追加は行われない。 return RTC::RTC_OK; } virtual RTC::ReturnCode_t onAddedComponent(RTC::LightweightRTObject rtobj) { // コンポーネント追加時に実行したい処理を記述 // RTC::RTC_OK 以外を返した場合、removeComponent() が呼び出され、 // 追加されたコンポーネントが削除される。 return RTC::RTC_OK; } virtual RTC::ReturnCode_t onRemovingComponent(RTC::LightweightRTObject rtobj) { // コンポーネント削除時に実行したい処理を記述 // RTC::RTC_OK 以外を返した場合、コンポーネントの削除は行われない。 return RTC::RTC_OK; } virtual RTC::ReturnCode_t onRemovedComponent(RTC::LightweightRTObject rtobj) { // コンポーネント追加時に実行したい処理を記述 // RTC::RTC_OK 以外を返した場合、addComponent() が呼び出され、 // 削除されたコンポーネントが再び追加される。 return RTC::RTC_OK; }
実行コンテキストの情報取得に関する関数は、get_component_state(), get_kind(), get_profile() の3種類がある。実行コンテキストの実装ク ラスにおいては、ExecutionContextBase のそれぞれ getComponentState(), getKind(), getProfile() を呼び出す形で実装を 行う。これらの関数に関連する protected 仮想関数は onGetComponentState(), onGetKind(), onGetProfile() の3種類ある。こ れらの仮想関数は通常オーバーライドする必要はなく、使用は推奨されな い。ただし、返す情報を変更したい場合は、これらの関数を適切に実装す ることで、呼び出し側に返す値を上書きすることができる。
public: LifeCycleState get_component_state(RTC::LightweightRTObject_ptr comp) { return getComponentState(comp); } ExecutionKind PeriodicExecutionContext::get_kind() { return getKind(); } ExecutionContextProfile* get_profile() { return getProfile(); }
protected: virtual LifeCycleState onGetComponentState(LifeCycleState state) { // 返すstateを書き換えたい場合はこの関数を実装する return state; } virtual ExecutionKind onGetKind(ExecutionKind kind) { // 返すkindを書き換えたい場合はこの関数を実装する return kind; } virtual ExecutionContextProfile* onGetProfile(ExecutionContextProfile*& profile) { // 返すprofileを書き換えたい場合はこの関数を実装する return profile; }
ExecutionContextの基底クラス。
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.bindComponent | ( | self, | |
rtc | |||
) |
ExecutionContextの処理を進める(サブクラス実装用)
ExecutionContextの処理を1周期分進める。
※サブクラスでの実装参照用
self | def tick(self): pass コンポーネントをバインドする。 |
コンポーネントをバインドする。
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.getComponentList | ( | self | ) |
RTコンポーネントの参加者リストを取得する
現在登録されている参加者RTCのリストを取得する。
const RTC::RTCList& getComponentList() const
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.getComponentState | ( | self, | |
comp | |||
) |
RTコンポーネントの状態を取得する
指定したRTコンポーネントの状態(LifeCycleState)を取得する。指定し たRTコンポーネントが参加者リストに含まれない場合は、 UNKNOWN_STATE が返される。
comp | 状態取得対象RTコンポーネント |
RTC::LifeCycleState ExecutionContextBase:: getComponentState(RTC::LightweightRTObject_ptr comp)
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.getKind | ( | self | ) |
ExecutionKind を取得する
本 ExecutionContext の ExecutionKind を取得する
RTC::ExecutionKind ExecutionContextBase::getKind(void) const
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.getKindString | ( | self, | |
kind | |||
) |
ExecutionKind を文字列化する
RTC::ExecutionKind で定義されている PERIODIC, EVENT_DRIVEN, OTHER を文字列化する。
kind | ExecutionKind |
const char* getKindString(RTC::ExecutionKind kind) const
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.getObjRef | ( | self | ) |
CORBA オブジェクト参照の取得
本オブジェクトの ExecutioncontextService としての CORBA オブジェ クト参照を取得する。
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.getOwner | ( | self | ) |
Ownerコンポーネントの参照を取得する
このECのOwnerであるRTCの参照を取得する。
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.getProfile | ( | self | ) |
Profileを取得する
RTC::ExecutionContextProfile を取得する。取得した ExecutionContextProfile の所有権は呼び出し側にある。取得されたオ ブジェクトが不要になった場合、呼び出し側が開放する責任を負う。
RTC::ExecutionContextProfile* ExecutionContextBase::getProfile(void)
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.getProfile | ( | self | ) |
Profileを取得する
RTC::ExecutionContextProfile を取得する。取得した ExecutionContextProfile の所有権は呼び出し側にある。取得されたオ ブジェクトが不要になった場合、呼び出し側が開放する責任を負う。
RTC::ExecutionContextProfile* getProfile(void)
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.getProperties | ( | self | ) |
Propertiesを取得する
ExecutionContextProfile::properties を取得する。
const coil::Properties getProperties() const
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.getRate | ( | self | ) |
ExecutionContext の実行周期(Hz)を取得する
Active 状態にてRTコンポーネントが実行される周期(単位:Hz)を取得す る。
double getRate(void) const
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.init | ( | self, | |
props | |||
) |
ExecutionContextの初期化処理
virtual void init(coil::Properties& props);
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.setKind | ( | self, | |
kind | |||
) |
ExecutionKind を設定する
この ExecutionContext の ExecutionKind を設定する
kind | ExecutionKind |
RTC::ReturnCode_t setKind(RTC::ExecutionKind kind)
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.setObjRef | ( | self, | |
ec_ptr | |||
) |
CORBA オブジェクト参照の取得
本オブジェクトの ExecutioncontextService としての CORBA オブジェ クト参照を取得する。
void setObjRef(RTC::ExecutionContextService_ptr ec_ptr)
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.setOwner | ( | self, | |
comp | |||
) |
Ownerコンポーネントをセットする。
このECのOwnerとなるRTCをセットする。
comp | OwnerとなるRTコンポーネント |
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.setProperties | ( | self, | |
props | |||
) |
Propertiesをセットする
ExecutionContextProfile::properties をセットする。
props | ExecutionContextProfile::properties にセットするプ ロパティー |
void setProperties(coil::Properties& props)
def OpenRTM_aist.ExecutionContextBase.ExecutionContextBase.setRate | ( | self, | |
rate | |||
) |
ExecutionContext の実行周期(Hz)を設定する
Active 状態にてRTコンポーネントが実行される周期(単位:Hz)を設定す る。実行周期の変更は、DataFlowComponentAction の on_rate_changed によって各RTコンポーネントに伝達される。
rate | 処理周期(単位:Hz) |
RTC::ReturnCode_t setRate(double rate)