クラス RTC::ExecutionContextBase
ExecutionContext用基底クラス.
[詳細]
#include <ExecutionContextBase.h>
すべてのメンバ一覧
説明
ExecutionContext用基底クラス.
ECの実装クラスでは、この基底クラスを継承し、かつECのCORBAオペレー ションを実装しなければならない。さらに、実際にロジックを駆動するた め、幾つかの約束に則りExecutionContextBaseの関数を呼び出す必要があ る。ECのCORBAオペレーションは以下のものがあり、それぞれ ExecutionContextBaseのメンバ関数に対応している。
- get_rate(): ExecutionContextBase::gatRate()
- set_rate(): ExecutioinContextBase::setRate()
- 実行状態に関係する関数と実装方法
-
実行状態に関係する関数は、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;
}
- 実行周期に関する関数と実装方法
- get_rate(): ExecutionContextBase::gatRate()
- set_rate(): ExecutioinContextBase::setRate()
実行周期に関する関数は set_rate(), get_rate() の2種類がある。実装 する実行コンテキストがもし set_rate() により指定される周期を利用する 場合、テンプレート関数 onSetRate() をオーバーライドし実装する。 onSetRate() は引数に double 型の周期を取り、この値は正当な値である ことが保証されている。onSetRate() がRTCRTC_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の基底クラス。
- から:
- 0.4.0
コンストラクタとデストラクタ
RTC::ExecutionContextBase::ExecutionContextBase |
( |
const char * |
name |
) |
|
virtual RTC::ExecutionContextBase::~ExecutionContextBase |
( |
void |
|
) |
[virtual] |
関数
RTC::ReturnCode_t RTC::ExecutionContextBase::activateComponent |
( |
RTC::LightweightRTObject_ptr |
comp |
) |
|
RTコンポーネントをアクティブ化する.
Inactive 状態にあるRTコンポーネントをActive に遷移させ、アクティ ブ化する。この操作が呼ばれた結果、on_activate が呼び出される。指 定したRTコンポーネントが参加者リストに含まれない場合は、 BAD_PARAMETER が返される。指定したRTコンポーネントの状態が Inactive 以外の場合は、PRECONDITION_NOT_MET が返される。
- 引数:
-
- 戻り値:
- ReturnCode_t 型のリターンコード
RTC::ReturnCode_t RTC::ExecutionContextBase::addComponent |
( |
RTC::LightweightRTObject_ptr |
comp |
) |
|
RTコンポーネントを追加する.
指定したRTコンポーネントを参加者リストに追加する。追加されたRTコ ンポーネントは attach_context が呼ばれ、Inactive 状態に遷移する。 指定されたRTコンポーネントがnullの場合は、BAD_PARAMETER が返され る。指定されたRTコンポーネントが DataFlowComponent 以外の場合は、 BAD_PARAMETER が返される。
- 引数:
-
- 戻り値:
- ReturnCode_t 型のリターンコード
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::bindComponent |
( |
RTC::RTObject_impl * |
rtc |
) |
[virtual] |
RTC::ReturnCode_t RTC::ExecutionContextBase::deactivateComponent |
( |
RTC::LightweightRTObject_ptr |
comp |
) |
|
RTコンポーネントを非アクティブ化する.
Inactive 状態にあるRTコンポーネントを非アクティブ化し、Inactive に遷移させる。この操作が呼ばれた結果、on_deactivate が呼び出され る。指定したRTコンポーネントが参加者リストに含まれない場合は、 BAD_PARAMETER が返される。指定したRTコンポーネントの状態が Active 以外の場合は、PRECONDITION_NOT_MET が返される。
|
- 引数:
-
- 戻り値:
- ReturnCode_t 型のリターンコード
const RTC::RTCList& RTC::ExecutionContextBase::getComponentList |
( |
|
) |
const |
RTコンポーネントの参加者リストを取得する.
現在登録されている参加者RTCのリストを取得する。
- 戻り値:
- 参加者RTCのリスト
RTC::LifeCycleState RTC::ExecutionContextBase::getComponentState |
( |
RTC::LightweightRTObject_ptr |
comp |
) |
|
RTコンポーネントの状態を取得する.
指定したRTコンポーネントの状態(LifeCycleState)を取得する。指定し たRTコンポーネントが参加者リストに含まれない場合は、 UNKNOWN_STATE が返される。
- 引数:
-
- 戻り値:
- 現在の状態(LifeCycleState)
RTC::ExecutionKind RTC::ExecutionContextBase::getKind |
( |
void |
|
) |
const |
ExecutionKind を取得する.
本 ExecutionContext の ExecutionKind を取得する
- 戻り値:
- ExecutionKind
const char* RTC::ExecutionContextBase::getKindString |
( |
RTC::ExecutionKind |
kind |
) |
const |
ExecutionKind を文字列化する.
RTC::ExecutionKind で定義されている PERIODIC, EVENT_DRIVEN, OTHER を文字列化する。
- 引数:
-
- 戻り値:
- 文字列化されたExecutionKind
RTC::ExecutionContextService_ptr RTC::ExecutionContextBase::getObjRef |
( |
void |
|
) |
const |
CORBA オブジェクト参照の取得.
本オブジェクトの ExecutioncontextService としての CORBA オブジェ クト参照を取得する。
- 戻り値:
- CORBA オブジェクト参照
const RTC::RTObject_ptr RTC::ExecutionContextBase::getOwner |
( |
|
) |
const |
Ownerコンポーネントの参照を取得する.
このECのOwnerであるRTCの参照を取得する。
- 戻り値:
- OwnerRTコンポーネントの参照
const RTC::ExecutionContextProfile& RTC::ExecutionContextBase::getProfile |
( |
void |
|
) |
const |
Profileを取得する.
RTC::ExecutionContextProfile を取得する。
- 戻り値:
- RTC::ExecutionContextProfile
RTC::ExecutionContextProfile* RTC::ExecutionContextBase::getProfile |
( |
void |
|
) |
|
Profileを取得する.
RTC::ExecutionContextProfile を取得する。取得した ExecutionContextProfile の所有権は呼び出し側にある。取得されたオ ブジェクトが不要になった場合、呼び出し側が開放する責任を負う。
- 戻り値:
- RTC::ExecutionContextProfile
Propertiesを取得する.
ExecutionContextProfile::properties を取得する。
- 戻り値:
- coil::Propertiesに変換された ExecutionContextProfile::properties
double RTC::ExecutionContextBase::getRate |
( |
void |
|
) |
const |
ExecutionContext の実行周期(Hz)を取得する.
Active 状態にてRTコンポーネントが実行される周期(単位:Hz)を取得す る。
- 戻り値:
- 処理周期(単位:Hz)
const char* RTC::ExecutionContextBase::getStateString |
( |
RTC::LifeCycleState |
state |
) |
|
virtual void RTC::ExecutionContextBase::init |
( |
coil::Properties & |
props |
) |
[virtual] |
ExecutionContextの処理を進める.
ExecutionContextの処理を1周期分進める。
void RTC::ExecutionContextBase::invokeWorker |
( |
|
) |
[inline] |
void RTC::ExecutionContextBase::invokeWorkerDo |
( |
|
) |
[inline] |
void RTC::ExecutionContextBase::invokeWorkerPostDo |
( |
|
) |
[inline] |
void RTC::ExecutionContextBase::invokeWorkerPreDo |
( |
|
) |
[inline] |
bool RTC::ExecutionContextBase::isAllCurrentState |
( |
RTC::LifeCycleState |
state |
) |
[inline] |
bool RTC::ExecutionContextBase::isAllNextState |
( |
RTC::LifeCycleState |
state |
) |
[inline] |
bool RTC::ExecutionContextBase::isOneOfCurrentState |
( |
RTC::LifeCycleState |
state |
) |
[inline] |
bool RTC::ExecutionContextBase::isOneOfNextState |
( |
RTC::LifeCycleState |
state |
) |
[inline] |
CORBA::Boolean RTC::ExecutionContextBase::isRunning |
( |
|
) |
|
ExecutionContext 実行状態確認関数.
この操作は ExecutionContext が Runnning 状態の場合に true を返す。 返り値は、start() 関数が呼ばれたあとはRunning状態となり true を、stop() 関数が呼ばれたあとはStopped状態となりfalseを返す。
- 戻り値:
- 動作状態 (Running状態:true、Stopped状態: false)
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onActivated |
( |
RTC_impl::RTObjectStateMachine * |
comp, |
|
|
long int |
count | |
|
) |
| | [inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onActivating |
( |
RTC::LightweightRTObject_ptr |
comp |
) |
[inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onAddedComponent |
( |
RTC::LightweightRTObject_ptr |
rtobj |
) |
[inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onAddingComponent |
( |
RTC::LightweightRTObject_ptr |
rtobj |
) |
[inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onDeactivated |
( |
RTC_impl::RTObjectStateMachine * |
comp, |
|
|
long int |
count | |
|
) |
| | [inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onDeactivating |
( |
RTC::LightweightRTObject_ptr |
comp |
) |
[inline, protected, virtual] |
virtual RTC::LifeCycleState RTC::ExecutionContextBase::onGetComponentState |
( |
RTC::LifeCycleState |
state |
) |
[inline, protected, virtual] |
virtual RTC::ExecutionKind RTC::ExecutionContextBase::onGetKind |
( |
RTC::ExecutionKind |
kind |
) |
const [inline, protected, virtual] |
virtual RTC::ExecutionContextProfile* RTC::ExecutionContextBase::onGetProfile |
( |
RTC::ExecutionContextProfile *& |
profile |
) |
[inline, protected, virtual] |
virtual double RTC::ExecutionContextBase::onGetRate |
( |
double |
rate |
) |
const [inline, protected, virtual] |
virtual bool RTC::ExecutionContextBase::onIsRunning |
( |
bool |
running |
) |
[inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onRemovedComponent |
( |
RTC::LightweightRTObject_ptr |
rtobj |
) |
[inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onRemovingComponent |
( |
RTC::LightweightRTObject_ptr |
rtobj |
) |
[inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onResetting |
( |
RTC::LightweightRTObject_ptr |
comp |
) |
[inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onSetRate |
( |
double |
rate |
) |
[inline, protected, virtual] |
virtual double RTC::ExecutionContextBase::onSettingRate |
( |
double |
rate |
) |
[inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onStarted |
( |
|
) |
[inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onStarting |
( |
|
) |
[inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onStopped |
( |
|
) |
[inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onStopping |
( |
|
) |
[inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onWaitingActivated |
( |
RTC_impl::RTObjectStateMachine * |
comp, |
|
|
long int |
count | |
|
) |
| | [inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onWaitingDeactivated |
( |
RTC_impl::RTObjectStateMachine * |
comp, |
|
|
long int |
count | |
|
) |
| | [inline, protected, virtual] |
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onWaitingReset |
( |
RTC_impl::RTObjectStateMachine * |
comp, |
|
|
long int |
count | |
|
) |
| | [inline, protected, virtual] |
RTC::ReturnCode_t RTC::ExecutionContextBase::removeComponent |
( |
RTC::LightweightRTObject_ptr |
comp |
) |
|
RTコンポーネントを参加者リストから削除する.
指定したRTコンポーネントを参加者リストから削除する。削除された RTコンポーネントは detach_context が呼ばれる。指定されたRTコンポー ネントが参加者リストに登録されていない場合は、BAD_PARAMETER が返 される。
- 引数:
-
- 戻り値:
- ReturnCode_t 型のリターンコード
RTC::ReturnCode_t RTC::ExecutionContextBase::resetComponent |
( |
RTC::LightweightRTObject_ptr |
comp |
) |
|
RTコンポーネントをリセットする.
Error 状態のRTコンポーネントの復帰を試みる。この操作が呼ばれた結 果、on_reset が呼び出される。指定したRTコンポーネントが参加者リ ストに含まれない場合は、BAD_PARAMETER が返される。指定したRTコン ポーネントの状態が Error 以外の場合は、PRECONDITION_NOT_MET が返 される。
- 引数:
-
- 戻り値:
- ReturnCode_t 型のリターンコード
RTC::ReturnCode_t RTC::ExecutionContextBase::setKind |
( |
RTC::ExecutionKind |
kind |
) |
|
ExecutionKind を設定する.
この ExecutionContext の ExecutionKind を設定する
- 引数:
-
void RTC::ExecutionContextBase::setObjRef |
( |
RTC::ExecutionContextService_ptr |
ec_ptr |
) |
|
CORBA オブジェクト参照の取得.
本オブジェクトの ExecutioncontextService としての CORBA オブジェ クト参照を取得する。
- 戻り値:
- CORBA オブジェクト参照
RTC::ReturnCode_t RTC::ExecutionContextBase::setOwner |
( |
RTC::LightweightRTObject_ptr |
comp |
) |
|
Ownerコンポーネントをセットする。.
このECのOwnerとなるRTCをセットする。
- 引数:
-
- 戻り値:
- ReturnCode_t 型のリターンコード
Propertiesをセットする.
ExecutionContextProfile::properties をセットする。
- 引数:
-
| props | ExecutionContextProfile::properties にセットするプ ロパティー |
RTC::ReturnCode_t RTC::ExecutionContextBase::setRate |
( |
double |
rate |
) |
|
ExecutionContext の実行周期(Hz)を設定する.
Active 状態にてRTコンポーネントが実行される周期(単位:Hz)を設定す る。実行周期の変更は、DataFlowComponentAction の on_rate_changed によって各RTコンポーネントに伝達される。
- 引数:
-
- 戻り値:
- ReturnCode_t 型のリターンコード RTC_OK: 正常終了 BAD_PARAMETER: 設定値が負の値
RTC::ReturnCode_t RTC::ExecutionContextBase::start |
( |
void |
|
) |
|
virtual RTC::ReturnCode_t RTC::ExecutionContextBase::stop |
( |
void |
|
) |
[virtual] |
変数