|
OpenRTM-aist 2.1.0
|
ExecutionContext用基底クラス [詳解]
#include <ExecutionContextBase.h>


公開メンバ関数 | |
| ExecutionContextBase (const char *name) | |
| コンストラクタ | |
| virtual | ~ExecutionContextBase () |
| 仮想デストラクタ | |
| virtual void | init (coil::Properties &props) |
| ExecutionContextの初期化を行う | |
| virtual RTC::ReturnCode_t | bindComponent (RTC::RTObject_impl *rtc) |
| コンポーネントをバインドする。 | |
| CORBA::Boolean | isRunning () |
| ExecutionContext 実行状態確認関数 | |
| RTC::ReturnCode_t | start () |
| ExecutionContext の実行を開始 | |
| virtual RTC::ReturnCode_t | stop () |
| ExecutionContext の実行を停止 | |
| double | getRate () const |
| ExecutionContext の実行周期(Hz)を取得する | |
| std::chrono::nanoseconds | getPeriod () const |
| RTC::ReturnCode_t | setRate (double rate) |
| ExecutionContext の実行周期(Hz)を設定する | |
| RTC::ReturnCode_t | addComponent (RTC::LightweightRTObject_ptr comp) |
| RTコンポーネントを追加する | |
| RTC::ReturnCode_t | removeComponent (RTC::LightweightRTObject_ptr comp) |
| RTコンポーネントを参加者リストから削除する | |
| RTC::ReturnCode_t | activateComponent (RTC::LightweightRTObject_ptr comp) |
| RTコンポーネントをアクティブ化する | |
| RTC::ReturnCode_t | deactivateComponent (RTC::LightweightRTObject_ptr comp) |
| RTコンポーネントを非アクティブ化する | |
| RTC::ReturnCode_t | resetComponent (RTC::LightweightRTObject_ptr comp) |
| RTコンポーネントをリセットする | |
| RTC::LifeCycleState | getComponentState (RTC::LightweightRTObject_ptr comp) |
| RTコンポーネントの状態を取得する | |
| RTC::ExecutionKind | getKind () const |
| ExecutionKind を取得する | |
| RTC::ExecutionContextProfile * | getProfile () |
| Profileを取得する | |
| void | setObjRef (RTC::ExecutionContextService_ptr ec_ptr) |
| CORBA オブジェクト参照の取得 | |
| RTC::ExecutionContextService_ptr | getObjRef () const |
| CORBA オブジェクト参照の取得 | |
| RTC::ReturnCode_t | setKind (RTC::ExecutionKind kind) |
| ExecutionKind を設定する | |
| RTC::ReturnCode_t | setOwner (RTC::LightweightRTObject_ptr comp) |
| Ownerコンポーネントをセットする。 | |
| RTC::RTObject_ptr | getOwner () const |
| Ownerコンポーネントの参照を取得する | |
| const RTC::RTCList & | getComponentList () const |
| RTコンポーネントの参加者リストを取得する | |
| void | setProperties (coil::Properties &props) |
| Propertiesをセットする | |
| coil::Properties | getProperties () const |
| Propertiesを取得する | |
| const RTC::ExecutionContextProfile & | getProfile () const |
| Profileを取得する | |
| bool | isAllCurrentState (RTC::LifeCycleState state) |
| bool | isAllNextState (RTC::LifeCycleState state) |
| bool | isOneOfCurrentState (RTC::LifeCycleState state) |
| bool | isOneOfNextState (RTC::LifeCycleState state) |
| void | invokeWorker () |
| void | invokeWorkerPreDo () |
| void | invokeWorkerDo () |
| void | invokeWorkerPostDo () |
静的公開メンバ関数 | |
| static const char * | getStateString (RTC::LifeCycleState state) |
| static const char * | getKindString (RTC::ExecutionKind kind) |
| ExecutionKind を文字列化する | |
限定公開メンバ関数 | |
| virtual bool | onIsRunning (bool running) |
| virtual RTC::ReturnCode_t | onStarting () |
| virtual RTC::ReturnCode_t | onStarted () |
| virtual RTC::ReturnCode_t | onStopping () |
| virtual RTC::ReturnCode_t | onStopped () |
| virtual double | onGetRate (double rate) const |
| virtual double | onSettingRate (double rate) |
| virtual RTC::ReturnCode_t | onSetRate (double) |
| virtual RTC::ReturnCode_t | onAddingComponent (RTC::LightweightRTObject_ptr) |
| virtual RTC::ReturnCode_t | onAddedComponent (RTC::LightweightRTObject_ptr) |
| virtual RTC::ReturnCode_t | onRemovingComponent (RTC::LightweightRTObject_ptr) |
| virtual RTC::ReturnCode_t | onRemovedComponent (RTC::LightweightRTObject_ptr) |
| virtual RTC::ReturnCode_t | onActivating (RTC::LightweightRTObject_ptr) |
| virtual RTC::ReturnCode_t | onWaitingActivated (RTC_impl::RTObjectStateMachine *, long int) |
| virtual RTC::ReturnCode_t | onActivated (RTC_impl::RTObjectStateMachine *, long int) |
| virtual RTC::ReturnCode_t | onDeactivating (RTC::LightweightRTObject_ptr) |
| virtual RTC::ReturnCode_t | onWaitingDeactivated (RTC_impl::RTObjectStateMachine *, long int) |
| virtual RTC::ReturnCode_t | onDeactivated (RTC_impl::RTObjectStateMachine *, long int) |
| virtual RTC::ReturnCode_t | onResetting (RTC::LightweightRTObject_ptr) |
| virtual RTC::ReturnCode_t | onWaitingReset (RTC_impl::RTObjectStateMachine *, long int) |
| virtual RTC::ReturnCode_t | onReset (RTC_impl::RTObjectStateMachine *, long int) |
| virtual RTC::LifeCycleState | onGetComponentState (RTC::LifeCycleState state) |
| virtual RTC::ExecutionKind | onGetKind (RTC::ExecutionKind kind) const |
| virtual RTC::ExecutionContextProfile * | onGetProfile (RTC::ExecutionContextProfile *&profile) |
限定公開変数類 | |
| RTC::Logger | rtclog |
| RTC_impl::ExecutionContextWorker | m_worker |
| RTC_impl::ExecutionContextProfile | m_profile |
| std::chrono::nanoseconds | m_activationTimeout |
| std::chrono::nanoseconds | m_deactivationTimeout |
| std::chrono::nanoseconds | m_resetTimeout |
| bool | m_syncActivation |
| bool | m_syncDeactivation |
| bool | m_syncReset |
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;
}
[ExecutionContextBase] <> | +–(1 1) [ExecutionContextWorker ] : EC の worker | <> | +–(1 0..) [RTObjectStateMachine] : StateMachine | +–(1 1) [ExecutionContextProfile] : EC Profileの管理
|
explicit |
コンストラクタ
|
virtual |
仮想デストラクタ
| RTC::ReturnCode_t RTC::ExecutionContextBase::activateComponent | ( | RTC::LightweightRTObject_ptr | comp | ) |
RTコンポーネントをアクティブ化する
| RTC::ReturnCode_t RTC::ExecutionContextBase::addComponent | ( | RTC::LightweightRTObject_ptr | comp | ) |
RTコンポーネントを追加する
|
virtual |
コンポーネントをバインドする。
RTC_exp::MultilayerCompositeECで再実装されています。
| RTC::ReturnCode_t RTC::ExecutionContextBase::deactivateComponent | ( | RTC::LightweightRTObject_ptr | comp | ) |
RTコンポーネントを非アクティブ化する
| const RTC::RTCList & RTC::ExecutionContextBase::getComponentList | ( | ) | const |
RTコンポーネントの参加者リストを取得する
| RTC::LifeCycleState RTC::ExecutionContextBase::getComponentState | ( | RTC::LightweightRTObject_ptr | comp | ) |
RTコンポーネントの状態を取得する
| RTC::ExecutionKind RTC::ExecutionContextBase::getKind | ( | ) | const |
ExecutionKind を取得する
|
static |
ExecutionKind を文字列化する
| RTC::ExecutionContextService_ptr RTC::ExecutionContextBase::getObjRef | ( | ) | const |
CORBA オブジェクト参照の取得
| RTC::RTObject_ptr RTC::ExecutionContextBase::getOwner | ( | ) | const |
Ownerコンポーネントの参照を取得する
| std::chrono::nanoseconds RTC::ExecutionContextBase::getPeriod | ( | ) | const |
| RTC::ExecutionContextProfile * RTC::ExecutionContextBase::getProfile | ( | ) |
Profileを取得する
| const RTC::ExecutionContextProfile & RTC::ExecutionContextBase::getProfile | ( | ) | const |
Profileを取得する
| coil::Properties RTC::ExecutionContextBase::getProperties | ( | ) | const |
Propertiesを取得する
| double RTC::ExecutionContextBase::getRate | ( | ) | const |
ExecutionContext の実行周期(Hz)を取得する
|
static |
|
virtual |
ExecutionContextの初期化を行う
RTC::VxWorksInterruptExecutionContext, RTC_exp::VxWorksRTExecutionContext, RTC_exp::MultilayerCompositeEC, RTC_exp::PeriodicExecutionContextで再実装されています。
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| CORBA::Boolean RTC::ExecutionContextBase::isRunning | ( | ) |
ExecutionContext 実行状態確認関数
|
inlineprotectedvirtual |
RTC_exp::PeriodicExecutionContextで再実装されています。
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
RTC_exp::PeriodicExecutionContextで再実装されています。
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
RTC_exp::PeriodicExecutionContextで再実装されています。
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
RTC_exp::PeriodicExecutionContextで再実装されています。
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
| RTC::ReturnCode_t RTC::ExecutionContextBase::removeComponent | ( | RTC::LightweightRTObject_ptr | comp | ) |
RTコンポーネントを参加者リストから削除する
| RTC::ReturnCode_t RTC::ExecutionContextBase::resetComponent | ( | RTC::LightweightRTObject_ptr | comp | ) |
RTコンポーネントをリセットする
| RTC::ReturnCode_t RTC::ExecutionContextBase::setKind | ( | RTC::ExecutionKind | kind | ) |
ExecutionKind を設定する
| void RTC::ExecutionContextBase::setObjRef | ( | RTC::ExecutionContextService_ptr | ec_ptr | ) |
CORBA オブジェクト参照の取得
| RTC::ReturnCode_t RTC::ExecutionContextBase::setOwner | ( | RTC::LightweightRTObject_ptr | comp | ) |
Ownerコンポーネントをセットする。
| void RTC::ExecutionContextBase::setProperties | ( | coil::Properties & | props | ) |
Propertiesをセットする
| RTC::ReturnCode_t RTC::ExecutionContextBase::setRate | ( | double | rate | ) |
ExecutionContext の実行周期(Hz)を設定する
| RTC::ReturnCode_t RTC::ExecutionContextBase::start | ( | ) |
ExecutionContext の実行を開始
|
virtual |
ExecutionContext の実行を停止
RTC::ExtTrigExecutionContext, RTC::OpenHRPExecutionContext, RTC_exp::PeriodicExecutionContext, RTC::VxWorksInterruptExecutionContextで再実装されています。
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
mutableprotected |