fwRPC
 All Files Functions Variables
fwRPC_RingBuffer.ctl File Reference

Functions

int fwRPC_RingBuffer_init (string dp_rb, uint size=fwRPC_RingBuffer_DEFAULT_SIZE)
 
int fwRPC_RingBuffer_write (string dp_rb, string value)
 
int fwRPC_RingBuffer_writeMany (string dp_rb, dyn_string values, int to_insert, int &inserted)
 
int fwRPC_RingBuffer_read (string dp_rb, string &value)
 
int fwRPC_RingBuffer_readMany (string dp_rb, dyn_string &values, int max)
 

Variables

private global const string DPE_VALUE = ":_original.._value"
 
public global const string fwRPC_RingBuffer_DPT = "_FwRPC_RingBuffer"
 
public global const string fwRPC_RingBuffer_DPE_READ = ".read_idx"
 
public global const string fwRPC_RingBuffer_DPE_WRITE = ".write_idx"
 
public global const string fwRPC_RingBuffer_DPE_SIZE = ".size"
 
public global const string fwRPC_RingBuffer_DPE_VALUES = ".values"
 
public global const int fwRPC_RingBuffer_ESUCCESS = 0
 
public global const int fwRPC_RingBuffer_EERROR = -1
 
public global const int fwRPC_RingBuffer_EFULL = -2
 
public global const int fwRPC_RingBuffer_EEMPTY = -2
 
public global const int fwRPC_RingBuffer_ENODP = -1
 
public global const int fwRPC_RingBuffer_DEFAULT_SIZE = 50
 

Detailed Description

Datapoint-based ring buffer implementation.

Function Documentation

int fwRPC_RingBuffer_init ( string  dp_rb,
uint  size = fwRPC_RingBuffer_DEFAULT_SIZE 
)

Initialize a ring buffer DP. Creates a new DP if the specified one does not exist.

Parameters
dp_rb(IN, string) DP name
size(IN, uint) size of the ring buffer
Returns
0 on success
Exceptions
ifthe DP could not be created if the DP could not be written to
int fwRPC_RingBuffer_read ( string  dp_rb,
string &  value 
)

Read from a ring buffer

Parameters
dp_rb(IN, string) ring buffer DP
value(OUT, string) value read
Returns
0 on success -1 if the DP doesn't exist -2 if there are no new values to read
Exceptions
ifthe DP could not be read from if the DP could not be written to
int fwRPC_RingBuffer_readMany ( string  dp_rb,
dyn_string &  values,
int  max 
)

Read multiple entries from a ring buffer. Always returns ESUCCESS on successful read, even if the number of entries read does not equal the max number specified. The size of the output value should be checked.

Parameters
dp_rb(IN, string) ring buffer DP
values(OUT, dyn_string) values read (size may != max)
max(IN, int) max number of values to read
Returns
fwRPC_RingBuffer_ESUCCESS on success fwRPC_RingBuffer_EEMPTY if the buffer is empty fwRPC_RingBuffer_ENODP if the DP does not exist
Exceptions
ifthe DP could not be read from if the DP could not be written to
int fwRPC_RingBuffer_write ( string  dp_rb,
string  value 
)

Write to a ring buffer.

If the ring buffer is full, i.e.: read_idx == write_idx, the write will fail.

Parameters
dp_rb(IN, string) ring buffer DP
value(IN, string) value to write
Returns
0 on success -1 if the DP doesn't exist -2 if the buffer is full
Exceptions
ifthe DP could not be written to if the DP could not be read
int fwRPC_RingBuffer_writeMany ( string  dp_rb,
dyn_string  values,
int  to_insert,
int &  inserted 
)

Write many values to a ringbuffer. Always returns fwRPC_RingBuffer_ESUCCESS on successful insertion, even if inserted != to_insert. The value of inserted should always be checked. fwRPC_RingBuffer_EFULL is not returned if only a part of values is inserted.

If to_insert is set to -1, the function will attempt to insert all the elements.

Parameters
dp_rb(IN, string) ring buffer DP
values(IN, dyn_string) values to insert
to_insert(IN, int) number of entries to insert. Attempts to insert all elements if set to -1.
inserted(OUT, int) number of elements actually inserted
Returns
fwRPC_RingBuffer_ESUCCESS on successful insertion fwRPC_RingBuffer_ENODP if the DP does not exist fwRPC_RingBuffer_EFULL if the ring buffer is full