Add subsurface-specific cylinder descriptor extension

This extends the libdivecomputer notion of "dc_tankvolume_t" to not just
have the tank volume type (imperial or metric), but be a "dc_tankinfo_t"
that shows other information about the cylinder.

The imperial-vs-metric data remains the same two values:

 1 - metric
 2 - imperial

but instead of being an enumeration of volume types, it is extended to a
bitmap of tank information, and the other bits currently are

 4 - CC diluent cylinder
 8 - CC O2 cylinder

with possible future extensions (bailout gas, perhaps).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2018-04-17 10:32:28 -07:00
parent 362fe3f936
commit 167848aa59
2 changed files with 13 additions and 8 deletions

View File

@ -165,11 +165,16 @@ typedef struct dc_gasmix_t {
#define DC_GASMIX_UNKNOWN 0xFFFFFFFF #define DC_GASMIX_UNKNOWN 0xFFFFFFFF
typedef enum dc_tankvolume_t { typedef unsigned int dc_tankinfo_t;
DC_TANKVOLUME_NONE, #define DC_TANKINFO_METRIC 1
DC_TANKVOLUME_METRIC, #define DC_TANKINFO_IMPERIAL 2
DC_TANKVOLUME_IMPERIAL, #define DC_TANKINFO_CC_DILUENT 4
} dc_tankvolume_t; #define DC_TANKINFO_CC_O2 8
// For backwards compatibility
#define DC_TANKVOLUME_NONE 0
#define DC_TANKVOLUME_METRIC DC_TANKINFO_METRIC
#define DC_TANKVOLUME_IMPERIAL DC_TANKINFO_IMPERIAL
/* /*
* Tank volume * Tank volume
@ -196,7 +201,7 @@ typedef enum dc_tankvolume_t {
typedef struct dc_tank_t { typedef struct dc_tank_t {
unsigned int gasmix; /* Gas mix index, or DC_GASMIX_UNKNOWN */ unsigned int gasmix; /* Gas mix index, or DC_GASMIX_UNKNOWN */
dc_tankvolume_t type; /* Tank type */ dc_tankinfo_t type; /* Tank type - metric/imperial and oc/cc */
double volume; /* Volume (liter) */ double volume; /* Volume (liter) */
double workpressure; /* Work pressure (bar) */ double workpressure; /* Work pressure (bar) */
double beginpressure; /* Begin pressure (bar) */ double beginpressure; /* Begin pressure (bar) */

View File

@ -89,7 +89,7 @@ typedef struct suunto_eonsteel_parser_t {
double lowsetpoint; double lowsetpoint;
double highsetpoint; double highsetpoint;
double customsetpoint; double customsetpoint;
dc_tankvolume_t tankinfo[MAXGASES]; dc_tankinfo_t tankinfo[MAXGASES];
double tanksize[MAXGASES]; double tanksize[MAXGASES];
double tankworkingpressure[MAXGASES]; double tankworkingpressure[MAXGASES];
} cache; } cache;
@ -1157,7 +1157,7 @@ static void set_depth_field(suunto_eonsteel_parser_t *eon, unsigned short d)
static int add_gas_type(suunto_eonsteel_parser_t *eon, const struct type_desc *desc, unsigned char type) static int add_gas_type(suunto_eonsteel_parser_t *eon, const struct type_desc *desc, unsigned char type)
{ {
int idx = eon->cache.ngases; int idx = eon->cache.ngases;
dc_tankvolume_t tankinfo = DC_TANKVOLUME_METRIC; dc_tankinfo_t tankinfo = DC_TANKVOLUME_METRIC;
char *name; char *name;
if (idx >= MAXGASES) if (idx >= MAXGASES)