PublisherPeriodic クラス
[詳解]
#include <PublisherPeriodic.h>
|
typedef coil::Mutex | Mutex |
|
typedef coil::Condition< Mutex > | Condition |
|
typedef coil::Guard< coil::Mutex > | Guard |
|
enum | Enum {
PORT_OK = 0,
PORT_ERROR,
BUFFER_ERROR,
BUFFER_FULL,
BUFFER_EMPTY,
BUFFER_TIMEOUT,
SEND_FULL,
SEND_TIMEOUT,
RECV_EMPTY,
RECV_TIMEOUT,
INVALID_ARGS,
PRECONDITION_NOT_MET,
CONNECTION_LOST,
UNKNOWN_ERROR
} |
|
PublisherPeriodic クラス
周期的にデータを送信するための Publisher クラス。このクラスは、通 常 Connector 内にあって、バッファおよびコンシューマに関連付けられ る。一定周期ごとにバッファからデータを取り出しコンシューマに対して データを送出する。
◆ Condition
◆ Guard
◆ Mutex
◆ Policy
◆ PublisherPeriodic()
◆ ~PublisherPeriodic()
virtual RTC::PublisherPeriodic::~PublisherPeriodic |
( |
void |
| ) |
|
|
virtual |
◆ activate()
virtual ReturnCode RTC::PublisherPeriodic::activate |
( |
| ) |
|
|
virtual |
アクティブ化する
Publisher をアクティブ化する。この関数を呼び出すことにより、 Publisherが持つ、データを送信するスレッドが動作を開始する。初期 化が行われていないなどにより、事前条件を満たさない場合、エラーコー ド PRECONDITION_NOT_MET を返す。
- 戻り値
- PORT_OK 正常終了 PRECONDITION_NOT_MET 事前条件を満たさない
RTC::PublisherBaseを実装しています。
◆ convertReturn()
ReturnCode RTC::PublisherPeriodic::convertReturn |
( |
BufferStatus::Enum |
status, |
|
|
cdrMemoryStream & |
data |
|
) |
| |
|
protected |
BufferStatus から DataPortStatus への変換
バッファからの戻り値を DataPortStatus::Enum 型へ変換する関数。そ れぞれ、以下のように変換される。変換時にコールバックを呼ぶ場合、 コールバク関数も付記する。
- BUFFER_OK: PORT_OK
- BUFFER_ERROR: BUFFER_ERROR
- BUFFER_FULL: BUFFER_FULL
- NOT_SUPPORTED: PORT_ERROR
- TIMEOUT: BUFFER_TIMEOUT
- PRECONDITION_NOT_MET: PRECONDITION_NOT_MET
- other: PORT_ERROR
- 引数
-
- 戻り値
- DataPortStatu 型のリターンコード
◆ createTask()
bool RTC::PublisherPeriodic::createTask |
( |
const coil::Properties & |
prop | ) |
|
|
protected |
◆ deactivate()
virtual ReturnCode RTC::PublisherPeriodic::deactivate |
( |
| ) |
|
|
virtual |
非アクティブ化する
Publisher を非アクティブ化する。この関数を呼び出すことにより、 Publisherが持つ、データを送信するスレッドが動作を停止する。初期 化が行われていないなどにより、事前条件を満たさない場合、エラーコー ド PRECONDITION_NOT_MET を返す。
- 戻り値
- PORT_OK 正常終了 PRECONDITION_NOT_MET 事前条件を満たさない
RTC::PublisherBaseを実装しています。
◆ init()
virtual ReturnCode RTC::PublisherPeriodic::init |
( |
coil::Properties & |
prop | ) |
|
|
virtual |
初期化
このクラスのオブジェクトを使用するのに先立ち、必ずこの関数を呼び 出す必要がある。引数には、このオブジェクトの各種設定情報を含む Properties を与える。少なくとも、送出処理の呼び出し周期を単位 Hz の数値として Propertyオブジェクトの publisher.push_rate をキー とする要素に設定する必要がある。周期 5ms すなわち、200Hzの場合、 200.0 を設定する。 dataport.publisher.push_rate が未設定の場合、 false が返される。データをプッシュする際のポリシーとして publisher.push_policy をキーとする値に、all, fifo, skip, new の いずれかを与えることができる。
以下のオプションを与えることができる。
- publisher.thread_type: スレッドのタイプ (文字列、デフォルト: default)
- publisher.push_rate: Publisherの送信周期 (数値)
- publisher.push_policy: Pushポリシー (all, fifo, skip, new)
- publisher.skip_count: 上記ポリシが skip のときのスキップ数
- measurement.exec_time: タスク実行時間計測 (enable/disable)
- measurement.exec_count: タスク関数実行時間計測周期 (数値, 回数)
- measurement.period_time: タスク周期時間計測 (enable/disable)
- measurement.period_count: タスク周期時間計測周期 (数値, 回数)
- 引数
-
property | 本Publisherの駆動制御情報を設定したPropertyオブジェクト |
- 戻り値
- ReturnCode PORT_OK 正常終了 INVALID_ARGS Properties が不正な値を含む
RTC::PublisherBaseを実装しています。
◆ invokeListener()
ReturnCode RTC::PublisherPeriodic::invokeListener |
( |
DataPortStatus::Enum |
status, |
|
|
cdrMemoryStream & |
data |
|
) |
| |
|
protected |
DataPortStatusに従ってリスナへ通知する関数を呼び出す。
- 引数
-
- 戻り値
- リターンコード
◆ isActive()
virtual bool RTC::PublisherPeriodic::isActive |
( |
| ) |
|
|
virtual |
アクティブ化確認
Publisher はデータポートと同期して activate/deactivate される。 activate() / deactivate() 関数によって、アクティブ状態と非アクティ ブ状態が切り替わる。この関数により、現在アクティブ状態か、非アク ティブ状態かを確認することができる。
- 戻り値
- 状態確認結果(アクティブ状態:true、非アクティブ状態:false)
RTC::PublisherBaseを実装しています。
◆ onBufferEmpty()
void RTC::PublisherPeriodic::onBufferEmpty |
( |
| ) |
|
|
inlineprotected |
◆ onBufferFull()
void RTC::PublisherPeriodic::onBufferFull |
( |
cdrMemoryStream & |
data | ) |
|
|
inlineprotected |
◆ onBufferRead()
void RTC::PublisherPeriodic::onBufferRead |
( |
cdrMemoryStream & |
data | ) |
|
|
inlineprotected |
◆ onBufferWrite()
void RTC::PublisherPeriodic::onBufferWrite |
( |
cdrMemoryStream & |
data | ) |
|
|
inlineprotected |
◆ onBufferWriteTimeout()
void RTC::PublisherPeriodic::onBufferWriteTimeout |
( |
cdrMemoryStream & |
data | ) |
|
|
inlineprotected |
◆ onReceived()
void RTC::PublisherPeriodic::onReceived |
( |
cdrMemoryStream & |
data | ) |
|
|
inlineprotected |
◆ onReceiverError()
void RTC::PublisherPeriodic::onReceiverError |
( |
cdrMemoryStream & |
data | ) |
|
|
inlineprotected |
◆ onReceiverFull()
void RTC::PublisherPeriodic::onReceiverFull |
( |
cdrMemoryStream & |
data | ) |
|
|
inlineprotected |
◆ onReceiverTimeout()
void RTC::PublisherPeriodic::onReceiverTimeout |
( |
cdrMemoryStream & |
data | ) |
|
|
inlineprotected |
◆ onSend()
void RTC::PublisherPeriodic::onSend |
( |
cdrMemoryStream & |
data | ) |
|
|
inlineprotected |
◆ onSenderEmpty()
void RTC::PublisherPeriodic::onSenderEmpty |
( |
| ) |
|
|
inlineprotected |
◆ onSenderError()
void RTC::PublisherPeriodic::onSenderError |
( |
| ) |
|
|
inlineprotected |
◆ pushAll()
ReturnCode RTC::PublisherPeriodic::pushAll |
( |
| ) |
|
|
protected |
◆ pushFifo()
ReturnCode RTC::PublisherPeriodic::pushFifo |
( |
| ) |
|
|
protected |
◆ pushNew()
ReturnCode RTC::PublisherPeriodic::pushNew |
( |
| ) |
|
|
protected |
◆ pushSkip()
ReturnCode RTC::PublisherPeriodic::pushSkip |
( |
| ) |
|
|
protected |
◆ setBuffer()
virtual ReturnCode RTC::PublisherPeriodic::setBuffer |
( |
CdrBufferBase * |
buffer | ) |
|
|
virtual |
バッファのセット
この関数では、この Publisher に関連付けられるバッファをセットする。 バッファオブジェクトがヌルポインタの場合、INVALID_ARGSが返される。 それ以外の場合は、PORT_OK が返される。
- 引数
-
- 戻り値
- ReturnCode PORT_OK 正常終了 INVALID_ARGS 引数に不正な値が含まれている
RTC::PublisherBaseを実装しています。
◆ setConsumer()
virtual ReturnCode RTC::PublisherPeriodic::setConsumer |
( |
InPortConsumer * |
consumer | ) |
|
|
virtual |
InPortコンシューマのセット
この関数では、この Publisher に関連付けられるコンシューマをセットする。 コンシューマオブジェクトがヌルポインタの場合、INVALID_ARGSが返される。 それ以外の場合は、PORT_OK が返される。
- 引数
-
- 戻り値
- ReturnCode PORT_OK 正常終了 INVALID_ARGS 引数に不正な値が含まれている
RTC::PublisherBaseを実装しています。
◆ setListener()
◆ setPushPolicy()
void RTC::PublisherPeriodic::setPushPolicy |
( |
const coil::Properties & |
prop | ) |
|
|
protected |
◆ svc()
virtual int RTC::PublisherPeriodic::svc |
( |
void |
| ) |
|
|
virtual |
スレッド実行関数
coil::PeriodicTask により周期実行されるタスク実行関数。
◆ write()
virtual ReturnCode RTC::PublisherPeriodic::write |
( |
cdrMemoryStream & |
data, |
|
|
unsigned long |
sec, |
|
|
unsigned long |
usec |
|
) |
| |
|
virtual |
データを書き込む
Publisher が保持するバッファに対してデータを書き込む。コンシュー マ、バッファ、リスナ等が適切に設定されていない等、Publisher オブ ジェクトが正しく初期化されていない場合、この関数を呼び出すとエラー コード PRECONDITION_NOT_MET が返され、バッファへの書き込み等の操 作は一切行われない。
バッファへの書き込みと、InPortへのデータの送信は非同期的に行われ るため、この関数は、InPortへのデータ送信の結果を示す、 CONNECTION_LOST, BUFFER_FULL などのリターンコードを返すことがあ る。この場合、データのバッファへの書き込みは行われない。
バッファへの書き込みに対して、バッファがフル状態、バッファのエ ラー、バッファへの書き込みがタイムアウトした場合、バッファの事前 条件が満たされない場合にはそれぞれ、エラーコード BUFFER_FULL, BUFFER_ERROR, BUFFER_TIMEOUT, PRECONDITION_NOT_MET が返される。
これら以外のエラーの場合、PORT_ERROR が返される。
- 引数
-
data | 書き込むデータ |
sec | タイムアウト時間 |
nsec | タイムアウト時間 |
- 戻り値
- PORT_OK 正常終了 PRECONDITION_NO_MET consumer, buffer, listener等が適切に設定 されていない等、このオブジェクトの事前条件 を満たさない場合。 CONNECTION_LOST 接続が切断されたことを検知した。 BUFFER_FULL バッファがフル状態である。 BUFFER_ERROR バッファに何らかのエラーが生じた場合。 NOT_SUPPORTED サポートされない操作が行われた。 TIMEOUT タイムアウトした。
RTC::PublisherBaseを実装しています。
このクラス詳解は次のファイルから抽出されました: