DC_PARSER_SAMPLES_FOREACH(3)

DC_PARSER_SAMPLES_FOREACH(3) | Library Functions Manual | DC_PARSER_SAMPLES_FOREACH(3)

# NAME

`dc_parser_samples_foreach` — iterate over samples taken during a dive

# LIBRARY

library “libdivecomputer”

# SYNOPSIS

`#include <libdivecomputer/parser.h>`

typedef void
`(*dc_sample_callback_t)`(dc_sample_type_t type, const dc_sample_value_t *value, void *userdata);

dc_status_t
`dc_parser_samples_foreach`(dc_parser_t *parser, dc_sample_callback_t callback, void *userdata);

# DESCRIPTION

Extract the samples taken during a dive as previously initialised with dc_parser_new(3). Each sample is passed to callback with the type of the sample and its data value.

Samples are invoked as a sequence of sample sets. Each sequence begins with a `DC_SAMPLE_TIME`, then a number of sample types in the set. When the next `DC_SAMPLE_TIME` is recorded, the sample set may be closed and a new one reopened. After all samples have been rendered, the last sample set should be closed.

The following sample types may be raised:

`DC_SAMPLE_TIME`
  The time of the sample taken in milliseconds after the dive began. Set in the time field.
`DC_SAMPLE_DEPTH`
  The depth taken at the sample in metres. Set in the depth field.
`DC_SAMPLE_PRESSURE`
  Tank pressure taken at the sample. Sets the tank index (see the `DC_FIELD_TANK_COUNT` in dc_parser_get_field(3)) and the pressure in bar.
`DC_SAMPLE_TEMPERATURE`
  Temperature in celsius. Sets the temperature field.
`DC_SAMPLE_EVENT`
  An diving event raised by the computer. This may have the type value of the event structure set to `SAMPLE_EVENT_NONE`, `SAMPLE_EVENT_DECOSTOP`, `SAMPLE_EVENT_RBT`, `SAMPLE_EVENT_ASCENT`, `SAMPLE_EVENT_CEILING`, `SAMPLE_EVENT_WORKLOAD`, `SAMPLE_EVENT_TRANSMITTER`, `SAMPLE_EVENT_VIOLATION`, `SAMPLE_EVENT_BOOKMARK`, `SAMPLE_EVENT_SURFACE`, `SAMPLE_EVENT_SAFETYSTOP`, `SAMPLE_EVENT_SAFETYSTOP_VOLUNTARY`, `SAMPLE_EVENT_SAFETYSTOP_MANDATORY`, `SAMPLE_EVENT_DEEPSTOP`, `SAMPLE_EVENT_CEILING_SAFETYSTOP`, `SAMPLE_EVENT_FLOOR`, `SAMPLE_EVENT_DIVETIME`, `SAMPLE_EVENT_MAXDEPTH`, `SAMPLE_EVENT_OLF`, `SAMPLE_EVENT_PO2`, `SAMPLE_EVENT_AIRTIME`, `SAMPLE_EVENT_RGBM`, `SAMPLE_EVENT_HEADING`, or `SAMPLE_EVENT_TISSUELEVEL`.
`DC_SAMPLE_RBT`
  The remaining bottom time in seconds. Sets the rbt field.
`DC_SAMPLE_HEARTBEAT`
  The diver's heartbeat in beats per minute. Sets the heartbeat field.
`DC_SAMPLE_BEARING`
  The diver's bearing in degrees. Sets the bearing field.
`DC_SAMPLE_VENDOR`
  A vendor-specific data field.
`DC_SAMPLE_SETPOINT`
  The closed-circuit setpoint (PO2) has changed. Sets the setpoint value in bar.
`DC_SAMPLE_PPO2`
  The partial pressure of oxygen has changed (in bar). Sets the ppo2 field.
`DC_SAMPLE_CNS`
  The CNS (central nervous system oxygen toxicity) value as a unit fraction. Sets the cns value.
`DC_SAMPLE_DECO`
  Decompression phase of type `DC_DECO_NDL` (no decompression limit), `DC_DECO_SAFETYSTOP` (the safety stop), `DC_DECO_DECOSTOP` (a decompression stop), or `DC_DECO_DEEPSTOP` (a mandatory or suggested deep-stop). Also sets the depth in metres and the time in seconds.
`DC_SAMPLE_GASMIX`
  Switch to a given gas mix index (see the `DC_FIELD_GASMIX_COUNT` in dc_parser_get_field(3)). Sets the gasmix field.

# RETURN VALUES

Returns `DC_STATUS_OK` on success and another code on failure.

# SEE ALSO

dc_parser_new(3)

# AUTHORS

The library “libdivecomputer” library was written by Jef Driesen, jef@libdivecomputer.org. The manpages were written by
Kristaps Dzonsons, kristaps@bsd.lv.

January 5, 2017 | NetBSD 11.0