jp.go.aist.rtm.RTC.buffer
クラス RingBuffer<DataType>

java.lang.Object
  上位を拡張 jp.go.aist.rtm.RTC.buffer.RingBuffer<DataType>
型パラメータ:
DataType - バッファ内のデータ型を指定します。
すべての実装されたインタフェース:
BufferBase<DataType>

public class RingBuffer<DataType>
extends java.lang.Object
implements BufferBase<DataType>

リング状のバッファを持つバッファ実装です。 バッファ全体がデータで埋まった場合、以降のデータは古いデータから順次上書きされていきます。 これにより、直近のバッファ長分のデータのみが残ります。


入れ子のクラスの概要
protected  class RingBuffer.condition
           
 
フィールドの概要
(package private)  int m_wcount
          書き込みカウント
 
コンストラクタの概要
RingBuffer()
          コンストラクタ
RingBuffer(int length)
          コンストラクタ 指定されたバッファ長でバッファを初期化する。
 
メソッドの概要
 ReturnCode advanceRptr()
           advanceRptr This function advances the reading pointer.
 ReturnCode advanceRptr(int n)
           advanceRptr This function advances the reading pointer.
 ReturnCode advanceWptr()
           advanceWptr This function advances the writing pointer.
 ReturnCode advanceWptr(int n)
          書込みポインタを進める {@.ja 現在の書き込み位置のポインタを n 個進める。
 boolean empty()
           empty Check on whether the buffer is empty.
 boolean full()
           full Check on whether the buffer is full
 DataType get()
          バッファからデータを読み込みます。
 ReturnCode get(DataRef<DataType> value)
           get
 void init(Properties prop)
           init
 boolean isFull()
          バッファがフルかどうか判定します。
 int length()
          バッファ長を取得します。
 ReturnCode length(int n)
           sets the length of the buffer.
 ReturnCode put(DataType data)
          バッファにデータを書き込みます。
 ReturnCode read(DataRef<DataType> valueRef)
          バッファからデータを読み込みます。
 ReturnCode read(DataRef<DataType> valueRef, int sec)
           
 ReturnCode read(DataRef<DataType> valueRef, int sec, int nsec)
          バッファから読み出す {@.ja バッファに格納されたデータを読み出す。
 int readable()
           readable This function returns the number of elements that can be read from the buffer.
 ReturnCode reset()
          バッファの状態をリセットする {@.ja バッファの読み出しポインタと書き込みポインタの位置をリセットする。
 DataType rptr()
           rptr This function returns the pointer of a present reading element of the buffer.
 DataType rptr(int n)
           rptr This function returns the pointer of a present reading element of the buffer.
 DataType wptr()
           wptr This function returns the pointer of a present writing element of the buffer.
 DataType wptr(int n)
           wptr This function returns the object of a present writing element of the buffer.
 int writable()
           writable This function returns the number of elements that can be written in the buffer.
 ReturnCode write(DataType value)
          バッファにデータを書き込みます。
 ReturnCode write(DataType value, int sec)
           
 ReturnCode write(DataType value, int sec, int nsec)
           
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

m_wcount

int m_wcount
書き込みカウント

コンストラクタの詳細

RingBuffer

public RingBuffer()
コンストラクタ


RingBuffer

public RingBuffer(int length)
コンストラクタ

指定されたバッファ長でバッファを初期化する。

パラメータ:
length - バッファ長
メソッドの詳細

length

public int length()

バッファ長を取得します。

定義:
インタフェース BufferBase<DataType> 内の length
戻り値:
バッファ長

length

public ReturnCode length(int n)

sets the length of the buffer.

定義:
インタフェース BufferBase<DataType> 内の length
パラメータ:
n - length
戻り値:
BUFFER_OK

write

public ReturnCode write(DataType value)

バッファにデータを書き込みます。

定義:
インタフェース BufferBase<DataType> 内の write
パラメータ:
value - 書き込むデータ
戻り値:
書き込みに成功した場合はtrueを、さもなくばfalseを返します。

write

public ReturnCode write(DataType value,
                        int sec)

write

public ReturnCode write(DataType value,
                        int sec,
                        int nsec)
定義:
インタフェース BufferBase<DataType> 内の write

read

public ReturnCode read(DataRef<DataType> valueRef)

バッファからデータを読み込みます。

定義:
インタフェース BufferBase<DataType> 内の read
パラメータ:
valueRef - 読み込んだデータを受け取るためのDataRefオブジェクト
戻り値:
読み込みに成功した場合はtrueを、さもなくばfalseを返します。

read

public ReturnCode read(DataRef<DataType> valueRef,
                       int sec)

read

public ReturnCode read(DataRef<DataType> valueRef,
                       int sec,
                       int nsec)
バッファから読み出す

バッファに格納されたデータを読み出す。 第2引数(sec)、第3引数(nsec)が指定されていない場合、バッファ空状 態での読み出しモード (readback, do_nothing, block) は init() で設 定されたモードに従う。 第2引数(sec) に引数が指定された場合は、init() で設定されたモード に関わらず、block モードとなり、バッファが空状態であれば指定時間 待ち、タイムアウトする。第3引数(nsec)は指定されない場合0として扱 われる。タイムアウト待ち中に、書込みスレッド側でバッファへ書込み があれば、ブロッキングは解除されデータが読みだされる。 読み出し時にバッファが空(empty)状態で、別のスレッドがblockモード で書込み待ちをしている場合、signalを発行して書込み側のブロッキン グが解除される。

定義:
インタフェース BufferBase<DataType> 内の read
パラメータ:
valueRef - 読み出し対象データ
sec - タイムアウト時間 sec (default -1: 無効)
nsec - タイムアウト時間 nsec (default 0)
戻り値:
BUFFER_OK 正常終了 BUFFER_EMPTY バッファが空状態 TIMEOUT 書込みがタイムアウトした PRECONDITION_NOT_MET 設定異常

isFull

public boolean isFull()

バッファがフルかどうか判定します。

戻り値:
バッファがフルならばtrue、さもなくばfalseを返します。

put

public ReturnCode put(DataType data)

バッファにデータを書き込みます。

定義:
インタフェース BufferBase<DataType> 内の put
パラメータ:
data - 書き込むデータ
戻り値:
ReturnCode

get

public DataType get()

バッファからデータを読み込みます。

定義:
インタフェース BufferBase<DataType> 内の get
戻り値:
読み込んだデータ

get

public ReturnCode get(DataRef<DataType> value)

get

定義:
インタフェース BufferBase<DataType> 内の get
パラメータ:
value -
戻り値:
ReturnCode

init

public void init(Properties prop)

init

定義:
インタフェース BufferBase<DataType> 内の init
パラメータ:
prop -

reset

public ReturnCode reset()
バッファの状態をリセットする

バッファの読み出しポインタと書き込みポインタの位置をリセットする。 この実装では BUFFER_OK しか返さない。

定義:
インタフェース BufferBase<DataType> 内の reset
戻り値:
BUFFER_OK: 正常終了 NOT_SUPPORTED: リセット不可能 BUFFER_ERROR: 異常終了

wptr

public DataType wptr(int n)

wptr

This function returns the object of a present writing element of the buffer.

定義:
インタフェース BufferBase<DataType> 内の wptr
パラメータ:
n -
戻り値:
DataType

wptr

public DataType wptr()

wptr

This function returns the pointer of a present writing element of the buffer.

定義:
インタフェース BufferBase<DataType> 内の wptr
戻り値:
DataType

advanceWptr

public ReturnCode advanceWptr(int n)
書込みポインタを進める

現在の書き込み位置のポインタを n 個進める。 書き込み可能な要素数以上の数値を指定した場合、PRECONDITION_NOT_MET を返す。

定義:
インタフェース BufferBase<DataType> 内の advanceWptr
パラメータ:
n - 書込みポインタ + n の位置のポインタ
戻り値:
BUFFER_OK: 正常終了 PRECONDITION_NOT_MET: n > writable()

advanceWptr

public ReturnCode advanceWptr()

advanceWptr

This function advances the writing pointer.

定義:
インタフェース BufferBase<DataType> 内の advanceWptr
戻り値:
ReturnCode

writable

public int writable()

writable

This function returns the number of elements that can be written in the buffer.

定義:
インタフェース BufferBase<DataType> 内の writable
戻り値:
int

full

public boolean full()

full

Check on whether the buffer is full

定義:
インタフェース BufferBase<DataType> 内の full
戻り値:
boolean

rptr

public DataType rptr(int n)

rptr

This function returns the pointer of a present reading element of the buffer.

定義:
インタフェース BufferBase<DataType> 内の rptr
パラメータ:
n -
戻り値:
DataType

rptr

public DataType rptr()

rptr

This function returns the pointer of a present reading element of the buffer.

定義:
インタフェース BufferBase<DataType> 内の rptr
戻り値:
DataType

advanceRptr

public ReturnCode advanceRptr(int n)

advanceRptr

This function advances the reading pointer.

定義:
インタフェース BufferBase<DataType> 内の advanceRptr
パラメータ:
n -
戻り値:
ReturnCode

advanceRptr

public ReturnCode advanceRptr()

advanceRptr

This function advances the reading pointer.

定義:
インタフェース BufferBase<DataType> 内の advanceRptr
戻り値:
ReturnCode

readable

public int readable()

readable

This function returns the number of elements that can be read from the buffer.

定義:
インタフェース BufferBase<DataType> 内の readable
戻り値:
int

empty

public boolean empty()

empty

Check on whether the buffer is empty.

定義:
インタフェース BufferBase<DataType> 内の empty
戻り値:
boolean