Add support for parsing tank data in the dive header.
This commit is contained in:
parent
ed0cbf818d
commit
8f9878a1c0
@ -426,6 +426,47 @@ doparse (FILE *fp, dc_device_t *device, const unsigned char data[], unsigned int
|
||||
gasmix.nitrogen * 100.0);
|
||||
}
|
||||
|
||||
// Parse the tanks.
|
||||
message ("Parsing the tanks.\n");
|
||||
unsigned int ntanks = 0;
|
||||
rc = dc_parser_get_field (parser, DC_FIELD_TANK_COUNT, 0, &ntanks);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
WARNING ("Error parsing the tank count.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < ntanks; ++i) {
|
||||
const char *names[] = {"none", "metric", "imperial"};
|
||||
|
||||
dc_tank_t tank = {0};
|
||||
rc = dc_parser_get_field (parser, DC_FIELD_TANK, i, &tank);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
WARNING ("Error parsing the tank.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
fprintf (fp, "<tank>\n");
|
||||
if (tank.gasmix != DC_GASMIX_UNKNOWN) {
|
||||
fprintf (fp,
|
||||
" <gasmix>%u</gasmix>\n",
|
||||
tank.gasmix);
|
||||
}
|
||||
if (tank.type != DC_TANKVOLUME_NONE) {
|
||||
fprintf (fp,
|
||||
" <type>%s</type>\n"
|
||||
" <volume>%.1f</volume>\n"
|
||||
" <workpressure>%.2f</workpressure>\n",
|
||||
names[tank.type], tank.volume, tank.workpressure);
|
||||
}
|
||||
fprintf (fp,
|
||||
" <beginpressure>%.2f</beginpressure>\n"
|
||||
" <endpressure>%.2f</endpressure>\n"
|
||||
"</tank>\n",
|
||||
tank.beginpressure, tank.endpressure);
|
||||
}
|
||||
|
||||
// Parse the salinity.
|
||||
message ("Parsing the salinity.\n");
|
||||
dc_salinity_t salinity = {DC_WATER_FRESH, 0.0};
|
||||
|
||||
@ -56,7 +56,9 @@ typedef enum dc_field_type_t {
|
||||
DC_FIELD_ATMOSPHERIC,
|
||||
DC_FIELD_TEMPERATURE_SURFACE,
|
||||
DC_FIELD_TEMPERATURE_MINIMUM,
|
||||
DC_FIELD_TEMPERATURE_MAXIMUM
|
||||
DC_FIELD_TEMPERATURE_MAXIMUM,
|
||||
DC_FIELD_TANK_COUNT,
|
||||
DC_FIELD_TANK
|
||||
} dc_field_type_t;
|
||||
|
||||
typedef enum parser_sample_event_t {
|
||||
@ -131,6 +133,23 @@ typedef struct dc_gasmix_t {
|
||||
double nitrogen;
|
||||
} dc_gasmix_t;
|
||||
|
||||
#define DC_GASMIX_UNKNOWN 0xFFFFFFFF
|
||||
|
||||
typedef enum dc_tankvolume_t {
|
||||
DC_TANKVOLUME_NONE,
|
||||
DC_TANKVOLUME_METRIC,
|
||||
DC_TANKVOLUME_IMPERIAL,
|
||||
} dc_tankvolume_t;
|
||||
|
||||
typedef struct dc_tank_t {
|
||||
unsigned int gasmix; /* Index of the gas mix, or DC_GASMIX_UNKNOWN */
|
||||
dc_tankvolume_t type;
|
||||
double volume; /* Wet or air volume (depending on the type) in liter */
|
||||
double workpressure; /* Pressure in bar */
|
||||
double beginpressure;
|
||||
double endpressure;
|
||||
} dc_tank_t;
|
||||
|
||||
typedef union dc_sample_value_t {
|
||||
unsigned int time;
|
||||
double depth;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user