summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.c4
-rw-r--r--dive.h2
-rw-r--r--libdivecomputer.c12
-rw-r--r--parse-xml.c19
-rw-r--r--save-xml.c4
-rw-r--r--uemis.c1
6 files changed, 40 insertions, 2 deletions
diff --git a/dive.c b/dive.c
index d4e0217d7..97b688a6d 100644
--- a/dive.c
+++ b/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);
diff --git a/dive.h b/dive.h
index 4cfa6fa38..3054173ad 100644
--- a/dive.h
+++ b/dive.h
@@ -230,6 +230,8 @@ struct sample {
duration_t ndl;
duration_t stoptime;
depth_t stopdepth;
+ int cns;
+ int po2;
};
/*
diff --git a/libdivecomputer.c b/libdivecomputer.c
index ca91dc892..e62265b7a 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -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;
}
diff --git a/parse-xml.c b/parse-xml.c
index 35299257a..f88d4ef7f 100644
--- a/parse-xml.c
+++ b/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)
diff --git a/save-xml.c b/save-xml.c
index 1d38cc1b8..fb9eb413a 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -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");
}
diff --git a/uemis.c b/uemis.c
index e4a4adb21..8d05a99f9 100644
--- a/uemis.c
+++ b/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;