Reference Manual
Chapter
5
Ruler E
Ruler API
All arrays should be one-dimensional arrays of integers or floats, and must have exactly
the same size as the data contained in one buffer, that is:
$
the
x
,
range
,
intensity
and
scatter
arrays should contain
(
PointsPerProfile
*
ProfilesPerBuffer
) elements.
$
the
id
,
mark
and
status
arrays should contain
ProfilesPerBuffer
elements
Note that in Visual Basic you declare arrays by specifying the highest index in the array,
and not the size of the array. Since the first element in an array has the index 0, the decla-
ration should look like the following example:
points = myRuler.ProfileWidth
profiles = myRuler.ProfilesPerBuffer
Dim
x(points * profiles - 1)
As
Single
...
Dim
id(profiles - 1)
As
Integer
...
Before retrieving measurement data, your application can check the Ruler object’s
AvailableBuffer
property to see whether there is any data to retrieve. If the property
has a non-zero value, there is at least one buffer of data to retrieve.
If you try to retrieve data when there is nothing in to retrieve, the method will time out after
a period of time that is specified by the
Timeout
property. If
Timeout
is set to
0
the
method will return immediately if there is no buffer available. If
Timeout
is set to
-1
, the
method will never time out – that is, the thread will be halted until there is data in the
buffer.
If you do not retrieve measurement data quickly enough the internal queue of buffers will
eventually become full. The size of the internal buffer is controlled by the
Memory-
BufferSize
property.
If the buffer gets full,
requestDataSeparate
will return the error code
E_FIFO_FULL
.
This means that profiles have been lost as the queue was full. If you should encounter this
error code, it is recommended to stop the Ruler and restart it.
To solve the overflow problem you can try the following:
$
Increase the
MemoryBufferSize
to make the queue larger.
$
Increase the cycle time in the Ruler parameters.
$
Call
requestDataSeparate
at a more regular interval.
$
Increase the priority of the thread and/or process.
Please note that context switching and other operating system activities will interrupt your
process/thread at random intervals, which can cause the memory buffers to overflow if
you do not have enough processing margin to allow for this overhead.
SICK IVP • Industrial Sensors • www.sickivp.com • All rights reserved
43