Add CNS and pO2 tracking in the samples

This adds the new members to the sample structure and fills them from
supported dive computers (Uemis SDA and OSTC / Shearwater Predator,
assuming you have libdivecomputer 0.3).

Save relvant values of this to the XML file and load it back. Handle the
new fields when merging dives.

At this stage we don't DO anything with this, all we do is extract them
from the dive computer, save them to the XML file and load them back.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-12-07 20:08:29 -08:00
parent a72597189d
commit 9d80e7bfe4
6 changed files with 40 additions and 2 deletions

View file

@ -168,7 +168,7 @@ static struct {
} cur_event;
static struct tm cur_tm;
static int cur_cylinder_index, cur_ws_index;
static int lastndl, laststoptime, laststopdepth;
static int lastndl, laststoptime, laststopdepth, lastcns, lastpo2;
static enum import_source {
UNKNOWN,
@ -484,6 +484,13 @@ static void get_index(char *buffer, void *_i)
free(buffer);
}
static void double_to_permil(char *buffer, void *_i)
{
int *i = _i;
*i = g_ascii_strtod(buffer, NULL) * 1000.0 + 0.5;
free(buffer);
}
static void hex_value(char *buffer, void *_i)
{
uint32_t *i = _i;
@ -675,6 +682,10 @@ static void try_to_fill_sample(struct sample *sample, const char *name, char *bu
return;
if (MATCH(".sample.stopdepth", depth, &sample->stopdepth))
return;
if (MATCH(".sample.cns", get_index, &sample->cns))
return;
if (MATCH(".sample.po2", double_to_permil, &sample->po2))
return;
switch (import_source) {
case DIVINGLOG:
@ -1085,6 +1096,8 @@ static void sample_start(void)
cur_sample->ndl.seconds = lastndl;
cur_sample->stoptime.seconds = laststoptime;
cur_sample->stopdepth.mm = laststopdepth;
cur_sample->cns = lastcns;
cur_sample->po2 = lastpo2;
}
static void sample_end(void)
@ -1096,6 +1109,8 @@ static void sample_end(void)
lastndl = cur_sample->ndl.seconds;
laststoptime = cur_sample->stoptime.seconds;
laststopdepth = cur_sample->stopdepth.mm;
lastcns = cur_sample->cns;
lastpo2 = cur_sample->po2;
cur_sample = NULL;
}
@ -1120,7 +1135,7 @@ static void divecomputer_start(void)
/* .. this is the one we'll use */
cur_dc = dc;
lastndl = laststoptime = laststopdepth = 0;
lastcns = lastpo2 = lastndl = laststoptime = laststopdepth = 0;
}
static void divecomputer_end(void)