summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2016-07-18 16:18:17 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-07-21 20:00:04 +0900
commitb2f2a865eb55f13fb20313eaa7b7785e019a58f7 (patch)
tree551845a47da0d3aec46b6650279a325b873a2dc7 /core
parent7c8073e7eac152d9a7283d036e8c333f21aff444 (diff)
downloadsubsurface-b2f2a865eb55f13fb20313eaa7b7785e019a58f7.tar.gz
Get the cylinder use data from libdivecomputer if provided
This uses the extended tank type information to fill in the cylinder use (OC gas, CC Diluent or CC O2) from libdivecomputer when available. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r--core/libdivecomputer.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c
index a949e582e..70917cf53 100644
--- a/core/libdivecomputer.c
+++ b/core/libdivecomputer.c
@@ -16,6 +16,18 @@
#include <libdivecomputer/version.h>
#include "libdivecomputer.h"
+//
+// If we have an old libdivecomputer, it doesn't
+// have the new DC_TANKINFO bits, but just volume
+// type information.
+//
+#ifndef DC_TANKINFO_METRIC
+#define DC_TANKINFO_METRIC DC_TANKVOLUME_METRIC
+#define DC_TANKINFO_IMPERIAL DC_TANKVOLUME_IMPERIAL
+#define DC_TANKINFO_CC_O2 0
+#define DC_TANKINFO_CC_DILUENT 0
+#endif
+
/* Christ. Libdivecomputer has the worst configuration system ever. */
#ifdef HW_FROG_H
#define NOT_FROG , 0
@@ -127,9 +139,18 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
if (i < ntanks) {
rc = dc_parser_get_field(parser, DC_FIELD_TANK, i, &tank);
if (rc == DC_STATUS_SUCCESS) {
- if (tank.type == DC_TANKVOLUME_IMPERIAL) {
- dive->cylinder[i].type.size.mliter = rint(tank.volume * 1000);
- dive->cylinder[i].type.workingpressure.mbar = rint(tank.workpressure * 1000);
+ cylinder_t *cyl = dive->cylinder + i;
+
+ cyl->type.size.mliter = rint(tank.volume * 1000);
+ cyl->type.workingpressure.mbar = rint(tank.workpressure * 1000);
+
+ cyl->cylinder_use = OC_GAS;
+ if (tank.type & DC_TANKINFO_CC_O2)
+ cyl->cylinder_use = OXYGEN;
+ if (tank.type & DC_TANKINFO_CC_DILUENT)
+ cyl->cylinder_use = DILUENT;
+
+ if (tank.type & DC_TANKINFO_IMPERIAL) {
if (same_string(devdata->model, "Suunto EON Steel")) {
/* Suunto EON Steele gets this wrong. Badly.
* but on the plus side it only supports a few imperial sizes,
@@ -163,8 +184,6 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
dive->cylinder[i].type.size.mliter = cuft_to_l(rounded_size) * 1000 /
mbar_to_atm(dive->cylinder[i].type.workingpressure.mbar);
}
- } else if (tank.type == DC_TANKVOLUME_METRIC) {
- dive->cylinder[i].type.size.mliter = rint(tank.volume * 1000);
}
if (tank.gasmix != i) { // we don't handle this, yet
shown_warning = true;