PublisherPeriodic クラス. [詳細]
#include <PublisherPeriodic.h>
 
  
 | Public 型 | |
| typedef coil::Mutex | Mutex | 
| typedef coil::Condition< Mutex > | Condition | 
| typedef coil::Guard< coil::Mutex > | Guard | 
| Public メソッド | |
| DATAPORTSTATUS_ENUM | PublisherPeriodic (void) | 
| コンストラクタ | |
| virtual | ~PublisherPeriodic (void) | 
| virtual ReturnCode | init (coil::Properties &prop) | 
| 初期化 | |
| virtual ReturnCode | setConsumer (InPortConsumer *consumer) | 
| InPortコンシューマのセット. | |
| virtual ReturnCode | setBuffer (CdrBufferBase *buffer) | 
| バッファのセット | |
| virtual ReturnCode | setListener (ConnectorInfo &info, ConnectorListeners *listeners) | 
| リスナを設定する。 | |
| virtual ReturnCode | write (const cdrMemoryStream &data, unsigned long sec, unsigned long usec) | 
| データを書き込む | |
| virtual bool | isActive () | 
| アクティブ化確認 | |
| virtual ReturnCode | activate () | 
| アクティブ化する | |
| virtual ReturnCode | deactivate () | 
| 非アクティブ化する | |
| virtual int | svc (void) | 
| スレッド実行関数 | |
| Protected 型 | |
| enum | Policy { ALL, FIFO, SKIP, NEW } | 
| Protected メソッド | |
| void | setPushPolicy (const coil::Properties &prop) | 
| PushPolicy の設定. | |
| bool | createTask (const coil::Properties &prop) | 
| Task の設定. | |
| ReturnCode | pushAll () | 
| push "all" policy | |
| ReturnCode | pushFifo () | 
| push "fifo" policy | |
| ReturnCode | pushSkip () | 
| push "skip" policy | |
| ReturnCode | pushNew () | 
| push "new" policy | |
| ReturnCode | convertReturn (BufferStatus::Enum status, const cdrMemoryStream &data) | 
| BufferStatus から DataPortStatus への変換. | |
| ReturnCode | invokeListener (DataPortStatus::Enum status, const cdrMemoryStream &data) | 
| DataPortStatusに従ってリスナへ通知する関数を呼び出す。. | |
| void | onBufferWrite (const cdrMemoryStream &data) | 
| ON_BUFFER_WRITEのリスナへ通知する。. | |
| void | onBufferFull (const cdrMemoryStream &data) | 
| ON_BUFFER_FULLリスナへイベントを通知する。. | |
| void | onBufferWriteTimeout (const cdrMemoryStream &data) | 
| ON_BUFFER_WRITE_TIMEOUTのリスナへ通知する。. | |
| void | onBufferRead (const cdrMemoryStream &data) | 
| ON_BUFFER_READのリスナへ通知する。. | |
| void | onSend (const cdrMemoryStream &data) | 
| ON_SENDのリスナへ通知する。. | |
| void | onReceived (const cdrMemoryStream &data) | 
| ON_RECEIVEDのリスナへ通知する。. | |
| void | onReceiverFull (const cdrMemoryStream &data) | 
| ON_RECEIVER_FULLのリスナへ通知する。. | |
| void | onReceiverTimeout (const cdrMemoryStream &data) | 
| ON_RECEIVER_TIMEOUTのリスナへ通知する。. | |
| void | onReceiverError (const cdrMemoryStream &data) | 
| ON_RECEIVER_ERRORのリスナへ通知する。. | |
| void | onBufferEmpty () | 
| ON_BUFFER_EMPTYのリスナへ通知する。. | |
| void | onSenderEmpty () | 
| ON_SENDER_EMPTYのリスナへ通知する。. | |
| void | onSenderError () | 
| ON_SENDER_ERRORのリスナへ通知する。. | |
PublisherPeriodic クラス.
周期的にデータを送信するための Publisher クラス。このクラスは、通 常 Connector 内にあって、バッファおよびコンシューマに関連付けられ る。一定周期ごとにバッファからデータを取り出しコンシューマに対して データを送出する。
| typedef coil::Condition<Mutex> RTC::PublisherPeriodic::Condition | 
| typedef coil::Guard<coil::Mutex> RTC::PublisherPeriodic::Guard | 
| typedef coil::Mutex RTC::PublisherPeriodic::Mutex | 
| enum RTC::PublisherPeriodic::Policy  [protected] | 
| DATAPORTSTATUS_ENUM RTC::PublisherPeriodic::PublisherPeriodic | ( | void | ) | 
コンストラクタ
| virtual RTC::PublisherPeriodic::~PublisherPeriodic | ( | void | ) |  [virtual] | 
デストラクタ
| virtual ReturnCode RTC::PublisherPeriodic::activate | ( | ) |  [virtual] | 
アクティブ化する
Publisher をアクティブ化する。この関数を呼び出すことにより、 Publisherが持つ、データを送信するスレッドが動作を開始する。初期 化が行われていないなどにより、事前条件を満たさない場合、エラーコー ド PRECONDITION_NOT_MET を返す。
RTC::PublisherBaseを実装しています。
| ReturnCode RTC::PublisherPeriodic::convertReturn | ( | BufferStatus::Enum | status, | |
| const cdrMemoryStream & | data | |||
| ) |  [protected] | 
BufferStatus から DataPortStatus への変換.
バッファからの戻り値を DataPortStatus::Enum 型へ変換する関数。そ れぞれ、以下のように変換される。変換時にコールバックを呼ぶ場合、 コールバク関数も付記する。
| status | BufferStatus | |
| data | cdrMemoryStream | 
| bool RTC::PublisherPeriodic::createTask | ( | const coil::Properties & | prop | ) |  [protected] | 
Task の設定.
| virtual ReturnCode RTC::PublisherPeriodic::deactivate | ( | ) |  [virtual] | 
非アクティブ化する
Publisher を非アクティブ化する。この関数を呼び出すことにより、 Publisherが持つ、データを送信するスレッドが動作を停止する。初期 化が行われていないなどにより、事前条件を満たさない場合、エラーコー ド PRECONDITION_NOT_MET を返す。
RTC::PublisherBaseを実装しています。
| 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 の いずれかを与えることができる。
以下のオプションを与えることができる。
| property | 本Publisherの駆動制御情報を設定したPropertyオブジェクト | 
RTC::PublisherBaseを実装しています。
| ReturnCode RTC::PublisherPeriodic::invokeListener | ( | DataPortStatus::Enum | status, | |
| const cdrMemoryStream & | data | |||
| ) |  [protected] | 
| virtual bool RTC::PublisherPeriodic::isActive | ( | ) |  [virtual] | 
アクティブ化確認
Publisher はデータポートと同期して activate/deactivate される。 activate() / deactivate() 関数によって、アクティブ状態と非アクティ ブ状態が切り替わる。この関数により、現在アクティブ状態か、非アク ティブ状態かを確認することができる。
RTC::PublisherBaseを実装しています。
| void RTC::PublisherPeriodic::onBufferEmpty | ( | ) |  [inline, protected] | 
ON_BUFFER_EMPTYのリスナへ通知する。.
参照先 RTC::ON_BUFFER_EMPTY.
| void RTC::PublisherPeriodic::onBufferFull | ( | const cdrMemoryStream & | data | ) |  [inline, protected] | 
| void RTC::PublisherPeriodic::onBufferRead | ( | const cdrMemoryStream & | data | ) |  [inline, protected] | 
| void RTC::PublisherPeriodic::onBufferWrite | ( | const cdrMemoryStream & | data | ) |  [inline, protected] | 
| void RTC::PublisherPeriodic::onBufferWriteTimeout | ( | const cdrMemoryStream & | data | ) |  [inline, protected] | 
| void RTC::PublisherPeriodic::onReceived | ( | const cdrMemoryStream & | data | ) |  [inline, protected] | 
| void RTC::PublisherPeriodic::onReceiverError | ( | const cdrMemoryStream & | data | ) |  [inline, protected] | 
| void RTC::PublisherPeriodic::onReceiverFull | ( | const cdrMemoryStream & | data | ) |  [inline, protected] | 
| void RTC::PublisherPeriodic::onReceiverTimeout | ( | const cdrMemoryStream & | data | ) |  [inline, protected] | 
| void RTC::PublisherPeriodic::onSend | ( | const cdrMemoryStream & | data | ) |  [inline, protected] | 
| void RTC::PublisherPeriodic::onSenderEmpty | ( | ) |  [inline, protected] | 
ON_SENDER_EMPTYのリスナへ通知する。.
参照先 RTC::ON_SENDER_EMPTY.
| void RTC::PublisherPeriodic::onSenderError | ( | ) |  [inline, protected] | 
ON_SENDER_ERRORのリスナへ通知する。.
参照先 RTC::ON_SENDER_ERROR.
| ReturnCode RTC::PublisherPeriodic::pushAll | ( | ) |  [protected] | 
push "all" policy
| ReturnCode RTC::PublisherPeriodic::pushFifo | ( | ) |  [protected] | 
push "fifo" policy
| ReturnCode RTC::PublisherPeriodic::pushNew | ( | ) |  [protected] | 
push "new" policy
| ReturnCode RTC::PublisherPeriodic::pushSkip | ( | ) |  [protected] | 
push "skip" policy
| virtual ReturnCode RTC::PublisherPeriodic::setBuffer | ( | CdrBufferBase * | buffer | ) |  [virtual] | 
バッファのセット
この関数では、この Publisher に関連付けられるバッファをセットする。 バッファオブジェクトがヌルポインタの場合、INVALID_ARGSが返される。 それ以外の場合は、PORT_OK が返される。
| buffer | CDR buffer へのポインタ | 
| virtual ReturnCode RTC::PublisherPeriodic::setConsumer | ( | InPortConsumer * | consumer | ) |  [virtual] | 
InPortコンシューマのセット.
この関数では、この Publisher に関連付けられるコンシューマをセットする。 コンシューマオブジェクトがヌルポインタの場合、INVALID_ARGSが返される。 それ以外の場合は、PORT_OK が返される。
| consumer | Consumer へのポインタ | 
RTC::PublisherBaseを実装しています。
| virtual ReturnCode RTC::PublisherPeriodic::setListener | ( | ConnectorInfo & | info, | |
| ConnectorListeners * | listeners | |||
| ) |  [virtual] | 
リスナを設定する。
Publisher に対してリスナオブジェクト ConnectorListeners を設定する。 各種リスナオブジェクトを含む ConnectorListeners をセットすることで、 バッファの読み書き、データの送信時等にこれらのリスナをコールする。 ConnectorListeners オブジェクトの所有権はポートまたは RTObject が持ち Publisher 削除時に ConnectorListeners は削除されることはない。 ConnectorListeners がヌルポインタの場合 INVALID_ARGS を返す。
| info | ConnectorProfile をローカル化したオブジェクト ConnectorInfo | |
| listeners | リスナを多数保持する ConnectorListeners オブジェクト | 
RTC::PublisherBaseを実装しています。
| void RTC::PublisherPeriodic::setPushPolicy | ( | const coil::Properties & | prop | ) |  [protected] | 
PushPolicy の設定.
| virtual int RTC::PublisherPeriodic::svc | ( | void | ) |  [virtual] | 
スレッド実行関数
coil::PeriodicTask により周期実行されるタスク実行関数。
| virtual ReturnCode RTC::PublisherPeriodic::write | ( | const 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 | タイムアウト時間 | 
RTC::PublisherBaseを実装しています。
 1.6.3
 1.6.3