
Choosing the logging frequency
The logging frequency can be set up individually for each sensor, using the method
set_logFrequency()
. The frequency is specified as a string (same as for timed report
callbacks), by specifying the number of calls per second (/s), per minute (/m) or per hour (/h). The
default value is "1/s".
The following example configures the logging frequency at 15 measures per minute for the first
sensor found, whatever its type:
YSensor sensor = YSensor.
FirstSensor
()
;
sensor.
set_logFrequency
(
"15/m"
)
;
To avoid wasting flash memory, it is possible to disable logging for specified functions. In order to do
so, simply use the value "OFF":
sensor.
set_logFrequency
(
"OFF"
)
;
Limitation
: The Yocto-RangeFinder cannot use a different frequency for timed-report callbacks and
for recording data into the datalogger. You can disable either of them individually, but if you enable
both timed-report callbacks and logging for a given function, the two will work at the same frequency.
Retrieving the data
To load recorded measures from the Yocto-RangeFinder flash memory, you must call the
get_recordedData()
method of the desired sensor, and specify the time interval for which you
want to retrieve measures. The time interval is given by the start and stop UNIX timestamp. You can
also specify 0 if you don't want any start or stop limit.
The
get_recordedData()
method does not return directly am array of measured values, since
in some cases it would cause a huge load that could affect the responsiveness of the application.
Instead, this function will return an
YDataSet
object that can be used to retrieve immediately an
overview of the measured data (summary), and then to load progressively the details when desired.
Here are the main methods used to retrieve recorded measures:
1.
dataset = sensor.get_recordedData(0,0)
: select the desired time interval
2.
dataset.loadMore()
: load data from the device, progressively
3.
dataset.get_summary()
: get a single measure summarizing the full time interval
4.
dataset.get_preview()
: get an array of measures representing a condensed version of the
whole set of measures on the selected time interval (reduced by a factor of approx. 200)
5.
dataset.get_measures()
: get an array with all detailled measures (that grows while
loadMore
is being called repeteadly)
Measures are instances of
YMeasure
2
. They store simultaneously the minimal, average and
maximal value at a given time, that you can retrieve using methods
get_minValue()
,
get_averageValue()
and
get_maxValue()
respectively. Here is a small example that uses the
functions above:
// We will retrieve all measures, without time limit
YDataSet dataset = sensor.
get_recordedData
(
0
,
0
)
;
// First call to loadMore() loads the summary/preview
dataset.
loadMore
()
;
YMeasure summary = dataset.
get_summary
()
;
string
timeFmt =
"dd MMM yyyy hh:mm:ss,fff"
;
string
logFmt =
"from {0} to {1} : average={2:0.00}{3}"
;
Console
.
WriteLine
(
String.
Format
(
logFmt,
summary.
get_startTimeUTC_asDateTime
()
.
ToString
(
timeFmt
)
,
summary.
get_endTimeUTC_asDateTime
()
.
ToString
(
timeFmt
)
,
summary.
get_averageValue
()
, sensor.
get_unit
()))
;
2
The
YMeasure
objects used by the data logger are exactly the same kind as those passed as argument to the timed
report callbacks.
18. Advanced programming
www.yoctopuce.com
119
Содержание Yocto-RangeFinder
Страница 1: ...Yocto RangeFinder User s guide...
Страница 2: ......
Страница 18: ...12 www yoctopuce com...
Страница 26: ...20 www yoctopuce com...
Страница 42: ...36 www yoctopuce com...
Страница 70: ...gcc lyocto lm lpthread lusb 1 0 lstdc 10 Using Yocto RangeFinder with C 64 www yoctopuce com...
Страница 90: ...84 www yoctopuce com...
Страница 120: ...114 www yoctopuce com...
Страница 130: ...124 www yoctopuce com...
Страница 158: ...21 High level API Reference On failure throws an exception or returns a negative error code 152 www yoctopuce com...
Страница 484: ...478 www yoctopuce com...
Страница 488: ...482 www yoctopuce com...
Страница 490: ...23 Characteristics 484 www yoctopuce com...
Страница 491: ......
Страница 492: ......