mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
a72597189d
commit
9d80e7bfe4
6 changed files with 40 additions and 2 deletions
4
dive.c
4
dive.c
|
@ -703,6 +703,10 @@ add_sample_b:
|
|||
sample.cylinderpressure = as->cylinderpressure;
|
||||
if (as->cylinderindex)
|
||||
sample.cylinderindex = as->cylinderindex;
|
||||
if (as->cns)
|
||||
sample.cns = as->cns;
|
||||
if (as->po2)
|
||||
sample.po2 = as->po2;
|
||||
|
||||
merge_one_sample(&sample, at, res);
|
||||
|
||||
|
|
2
dive.h
2
dive.h
|
@ -230,6 +230,8 @@ struct sample {
|
|||
duration_t ndl;
|
||||
duration_t stoptime;
|
||||
depth_t stopdepth;
|
||||
int cns;
|
||||
int po2;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -185,6 +185,18 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
|
|||
printf("%02X", ((unsigned char *) value.vendor.data)[i]);
|
||||
printf("</vendor>\n");
|
||||
break;
|
||||
#if DC_VERSION_CHECK(0, 3, 0)
|
||||
case DC_SAMPLE_SETPOINT:
|
||||
/* for us a setpoint means constant pO2 from here */
|
||||
sample->po2 = value.setpoint * 1000 + 0.5;
|
||||
break;
|
||||
case DC_SAMPLE_PPO2:
|
||||
sample->po2 = value.ppo2 * 1000 + 0.5;
|
||||
break;
|
||||
case DC_SAMPLE_CNS:
|
||||
sample->cns = value.cns * 100 + 0.5;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
19
parse-xml.c
19
parse-xml.c
|
@ -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)
|
||||
|
|
|
@ -334,6 +334,10 @@ static void save_sample(FILE *f, struct sample *sample, const struct sample *pre
|
|||
fprintf(f, " stoptime='%u:%02u min'", FRACTION(sample->stoptime.seconds, 60));
|
||||
if (sample->stopdepth.mm != prev->stopdepth.mm)
|
||||
show_milli(f, " stopdepth='", sample->stopdepth.mm, " m", "'");
|
||||
if (sample->cns != prev->cns)
|
||||
fprintf(f, " cns='%u%%'", sample->cns);
|
||||
if (sample->po2 != prev->po2)
|
||||
fprintf(f, " po2='%u.%2u bar'", FRACTION(sample->po2, 1000));
|
||||
fprintf(f, " />\n");
|
||||
}
|
||||
|
||||
|
|
1
uemis.c
1
uemis.c
|
@ -349,6 +349,7 @@ void uemis_parse_divelog_binary(char *base64, void *datap) {
|
|||
sample->cylinderindex = u_sample->active_tank;
|
||||
sample->cylinderpressure.mbar =
|
||||
(u_sample->tank_pressure_high * 256 + u_sample->tank_pressure_low) * 10;
|
||||
sample->cns = u_sample->cns;
|
||||
uemis_event(dive, dc, sample, u_sample);
|
||||
finish_sample(dc);
|
||||
i += 0x25;
|
||||
|
|
Loading…
Add table
Reference in a new issue