Here, it explains how to use the buffer and functions for typical patterns
about input transfer (Sampling).
Pattern 1: Finite data number, retrieve data after sampling
It is the case that transfer data once and retrieve data after sampling.
Handling
In this case, it is necessary to allocate the buffer size more than
the size of the number of the data to be retrieved.
Specify "CNTS_WRITE_ONCE" on CntSamplingSetBuffer
function for buffer repetition. When the number of input data is decided,
specify "CNTS_STOP_NUM" on CntSetSamplingStopTrigger
function for stop condition, and use the CntSetSamplingStopNumber
function to stop the transfer with specified times.
After transfer started, use Win32API such as Sleep by loop to wait transfer
to complete or status bit CNTS_STATUS_BMSTOP to be retrieved by status
acquisition function.
Pattern 2: Finite data number, retrieve data while sampling
It is the case that perform transfer once and retrieve data while sampling.
Handling Handling
Handling
In this case, it is necessary to allocate the buffer size more than the size of the number of the data to be retrieved.
Specify "CNTS_WRITE_ONCE" on CntSamplingSetBuffer
function for buffer repetition. When the number of input data is decided,
specify "CNTS_STOP_NUM" on CntSetSamplingStopTrigger
function for stop condition, and use the CntSetSamplingStopNumber
function to stop the transfer with specified times.
During transfer, the handling is performed while the data existing position
is retrieved in the transfer number acquisition function (CntGetSamplingCount).
Perform the process during transfer, and besides, check the status function
and confirm that completion operation does not occur by an error etc.
Use Win32API such as Sleep in loop so as not to overload the system.
Pattern 3: Infinite data number, retrieve all of the data
It is the case that perform transfer infinitely and perform operation such
as storing the data into a file at every specified times interval.
For transfer infinitely, you indicate "CNTS_WRITE_RING" on CntSamplingSetBuffer
function.
Handling Handling
Handling
To confirm the transfer times, use the message of specified time transfer
completion, or use transfer time acquisition function (CntGetSamplingCount)
with system timer etc.
The application periodically perform processing from read pointer to write
pointer according to system timer or event message.
In this case, please note that in user program, it is necessary to handle
the read pointer which indicates the position for marking the handled
data, and the write pointer which indicates the buffer position into where
the data have been written.
The read pointer/write pointer is a counter that will return to 0 when
the transfer is up to the buffer size.
Use the CntGetSamplingWritePointer
function to retrieve the write pointer.
The read pointer is the write pointer when processing data last time.
Pattern 4: Infinite data number, retrieve arbitrary data number from any
part by retrieving write pointer
It is the case that perform transfer infinitely and retrieve arbitrary
data number from any part when an arbitrary condition is satisfied.
For transfer infinitely, you indicate "CNTS_WRITE_RING" on CntSamplingSetBuffer
function.
In this case, it is also necessary to handle the read pointer and the write
pointer.
Please refer to pattern 3.