From becb8bd36e595b7efec39266b1e590e4f8dc703e Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 14 Jun 2021 20:58:14 +0200 Subject: [PATCH] Add a usage field to the tank and gas mix For gas consumption calculations it's very convenient to know whether a tank is used for example in a sidemount configuration, or as oxygen/diluent tank on a rebreather. For rebreather dives, it's convenient to know whether a gas mix is used as a closed-circuit mix (oxygen/diluent) or as an open circuit mix (bailout). --- examples/output_xml.c | 18 ++++++++++++++++-- include/libdivecomputer/parser.h | 9 +++++++++ src/atomics_cobalt_parser.c | 2 ++ src/cochran_commander_parser.c | 1 + src/cressi_edy_parser.c | 1 + src/cressi_goa_parser.c | 1 + src/cressi_leonardo_parser.c | 1 + src/deepblu_cosmiq_parser.c | 1 + src/deepsix_excursion_parser.c | 1 + src/diverite_nitekq_parser.c | 1 + src/divesoft_freedom_parser.c | 8 ++++++++ src/divesystem_idive_parser.c | 2 ++ src/hw_ostc_parser.c | 2 ++ src/liquivision_lynx_parser.c | 2 ++ src/mares_darwin_parser.c | 2 ++ src/mares_iconhd_parser.c | 2 ++ src/mares_nemo_parser.c | 2 ++ src/mclean_extreme_parser.c | 1 + src/oceanic_atom2_parser.c | 1 + src/oceanic_veo250_parser.c | 1 + src/oceanic_vtpro_parser.c | 2 ++ src/oceans_s1_parser.c | 1 + src/seac_screen_parser.c | 1 + src/shearwater_predator_parser.c | 17 +++++++++++++++++ src/suunto_d9_parser.c | 1 + src/suunto_eon_parser.c | 2 ++ src/suunto_eonsteel_parser.c | 9 +++++++-- src/suunto_solution_parser.c | 1 + src/suunto_vyper_parser.c | 2 ++ src/uwatec_memomouse_parser.c | 2 ++ src/uwatec_smart_parser.c | 2 ++ 31 files changed, 95 insertions(+), 4 deletions(-) diff --git a/examples/output_xml.c b/examples/output_xml.c index 1b66056..3801383 100644 --- a/examples/output_xml.c +++ b/examples/output_xml.c @@ -338,11 +338,19 @@ dctool_xml_output_write (dctool_output_t *abstract, dc_parser_t *parser, const u "\n" " %.1f\n" " %.1f\n" - " %.1f\n" - "\n", + " %.1f\n", gasmix.helium * 100.0, gasmix.oxygen * 100.0, gasmix.nitrogen * 100.0); + if (gasmix.usage) { + const char *usage[] = {"none", "oxygen", "diluent", "sidemount"}; + fprintf (output->ostream, + " %s\n", + usage[gasmix.usage]); + } + fprintf (output->ostream, + "\n"); + } // Parse the tanks. @@ -370,6 +378,12 @@ dctool_xml_output_write (dctool_output_t *abstract, dc_parser_t *parser, const u " %u\n", tank.gasmix); } + if (tank.usage) { + const char *usage[] = {"none", "oxygen", "diluent", "sidemount"}; + fprintf (output->ostream, + " %s\n", + usage[tank.usage]); + } if (tank.type != DC_TANKVOLUME_NONE) { fprintf (output->ostream, " %s\n" diff --git a/include/libdivecomputer/parser.h b/include/libdivecomputer/parser.h index 4a727e7..8a067b6 100644 --- a/include/libdivecomputer/parser.h +++ b/include/libdivecomputer/parser.h @@ -141,10 +141,18 @@ typedef struct dc_salinity_t { double density; } dc_salinity_t; +typedef enum dc_usage_t { + DC_USAGE_NONE, + DC_USAGE_OXYGEN, + DC_USAGE_DILUENT, + DC_USAGE_SIDEMOUNT, +} dc_usage_t; + typedef struct dc_gasmix_t { double helium; double oxygen; double nitrogen; + dc_usage_t usage; } dc_gasmix_t; #define DC_SENSOR_NONE 0xFFFFFFFF @@ -186,6 +194,7 @@ typedef struct dc_tank_t { double workpressure; /* Work pressure (bar) */ double beginpressure; /* Begin pressure (bar) */ double endpressure; /* End pressure (bar) */ + dc_usage_t usage; } dc_tank_t; typedef enum dc_decomodel_type_t { diff --git a/src/atomics_cobalt_parser.c b/src/atomics_cobalt_parser.c index 2fab3b3..6c42020 100644 --- a/src/atomics_cobalt_parser.c +++ b/src/atomics_cobalt_parser.c @@ -171,6 +171,7 @@ atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un *((unsigned int *) value) = p[0x2a]; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = p[SZ_HEADER + SZ_GASMIX * flags + 5] / 100.0; gasmix->oxygen = p[SZ_HEADER + SZ_GASMIX * flags + 4] / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; @@ -202,6 +203,7 @@ atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un tank->gasmix = flags; tank->beginpressure = array_uint16_le(p + 6) * PSI / BAR; tank->endpressure = array_uint16_le(p + 14) * PSI / BAR; + tank->usage = DC_USAGE_NONE; break; case DC_FIELD_DIVEMODE: switch(p[0x24]) { diff --git a/src/cochran_commander_parser.c b/src/cochran_commander_parser.c index 72151df..5609948 100644 --- a/src/cochran_commander_parser.c +++ b/src/cochran_commander_parser.c @@ -514,6 +514,7 @@ cochran_commander_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, // Gas percentages are decimal and encoded as // highbyte = integer portion // lowbyte = decimal portion, divide by 256 to get decimal value + gasmix->usage = DC_USAGE_NONE; gasmix->oxygen = array_uint16_le (data + layout->oxygen + 2 * flags) / 256.0 / 100; if (layout->helium == UNSUPPORTED) { gasmix->helium = 0; diff --git a/src/cressi_edy_parser.c b/src/cressi_edy_parser.c index 4dd3a18..2ce1a9a 100644 --- a/src/cressi_edy_parser.c +++ b/src/cressi_edy_parser.c @@ -152,6 +152,7 @@ cressi_edy_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsign *((unsigned int *) value) = cressi_edy_parser_count_gasmixes(p); break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = 0.0; gasmix->oxygen = bcd2dec (p[0x17 - flags]) / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; diff --git a/src/cressi_goa_parser.c b/src/cressi_goa_parser.c index 80055fc..507e327 100644 --- a/src/cressi_goa_parser.c +++ b/src/cressi_goa_parser.c @@ -250,6 +250,7 @@ cressi_goa_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsign *((unsigned int *) value) = ngasmixes; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = 0.0; gasmix->oxygen = data[layout->gasmix + 2 * flags + 1] / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; diff --git a/src/cressi_leonardo_parser.c b/src/cressi_leonardo_parser.c index 55624b1..849aa87 100644 --- a/src/cressi_leonardo_parser.c +++ b/src/cressi_leonardo_parser.c @@ -146,6 +146,7 @@ cressi_leonardo_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, u } break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = 0.0; gasmix->oxygen = data[0x19] / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; diff --git a/src/deepblu_cosmiq_parser.c b/src/deepblu_cosmiq_parser.c index a6efafd..c6f647b 100644 --- a/src/deepblu_cosmiq_parser.c +++ b/src/deepblu_cosmiq_parser.c @@ -151,6 +151,7 @@ deepblu_cosmiq_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un *((unsigned int *) value) = mode == SCUBA; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->oxygen = data[3] / 100.0; gasmix->helium = 0.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; diff --git a/src/deepsix_excursion_parser.c b/src/deepsix_excursion_parser.c index f6eb05f..13e4453 100644 --- a/src/deepsix_excursion_parser.c +++ b/src/deepsix_excursion_parser.c @@ -322,6 +322,7 @@ deepsix_excursion_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, *((unsigned int *) value) = parser->ngasmixes; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->oxygen = parser->gasmix[flags].oxygen / 100.0; gasmix->helium = parser->gasmix[flags].helium / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; diff --git a/src/diverite_nitekq_parser.c b/src/diverite_nitekq_parser.c index 6cfd9bc..ef67e1b 100644 --- a/src/diverite_nitekq_parser.c +++ b/src/diverite_nitekq_parser.c @@ -161,6 +161,7 @@ diverite_nitekq_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, u *((unsigned int *) value) = parser->ngasmixes; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = parser->he[flags] / 100.0; gasmix->oxygen = parser->o2[flags] / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; diff --git a/src/divesoft_freedom_parser.c b/src/divesoft_freedom_parser.c index 74ac136..6ddad76 100644 --- a/src/divesoft_freedom_parser.c +++ b/src/divesoft_freedom_parser.c @@ -838,6 +838,13 @@ divesoft_freedom_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, *((unsigned int *) value) = parser->ngasmixes; break; case DC_FIELD_GASMIX: + if (parser->gasmix[flags].type == OXYGEN) { + gasmix->usage = DC_USAGE_OXYGEN; + } else if (parser->gasmix[flags].type == DILUENT) { + gasmix->usage = DC_USAGE_DILUENT; + } else { + gasmix->usage = DC_USAGE_NONE; + } gasmix->helium = parser->gasmix[flags].helium / 100.0; gasmix->oxygen = parser->gasmix[flags].oxygen / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; @@ -859,6 +866,7 @@ divesoft_freedom_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, tank->beginpressure = parser->tank[flags].beginpressure * 2.0; tank->endpressure = parser->tank[flags].endpressure * 2.0; tank->gasmix = flags; + tank->usage = DC_USAGE_NONE; break; case DC_FIELD_DECOMODEL: if (parser->vpm) { diff --git a/src/divesystem_idive_parser.c b/src/divesystem_idive_parser.c index 892cda1..6d89a09 100644 --- a/src/divesystem_idive_parser.c +++ b/src/divesystem_idive_parser.c @@ -317,6 +317,7 @@ divesystem_idive_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, *((unsigned int *) value) = parser->ngasmixes; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = parser->gasmix[flags].helium / 100.0; gasmix->oxygen = parser->gasmix[flags].oxygen / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; @@ -331,6 +332,7 @@ divesystem_idive_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, tank->beginpressure = parser->tank[flags].beginpressure; tank->endpressure = parser->tank[flags].endpressure; tank->gasmix = DC_GASMIX_UNKNOWN; + tank->usage = DC_USAGE_NONE; break; case DC_FIELD_ATMOSPHERIC: if (ISIX3M(parser->model)) { diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index 1421a08..f41d747 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -552,6 +552,8 @@ hw_ostc_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned *((unsigned int *) value) = parser->ngasmixes; break; case DC_FIELD_GASMIX: + gasmix->usage = parser->gasmix[flags].diluent ? + DC_USAGE_DILUENT : DC_USAGE_NONE; gasmix->oxygen = parser->gasmix[flags].oxygen / 100.0; gasmix->helium = parser->gasmix[flags].helium / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; diff --git a/src/liquivision_lynx_parser.c b/src/liquivision_lynx_parser.c index 14c86ed..19c1d14 100644 --- a/src/liquivision_lynx_parser.c +++ b/src/liquivision_lynx_parser.c @@ -315,6 +315,7 @@ liquivision_lynx_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, *((unsigned int *) value) = parser->ngasmixes; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = parser->gasmix[flags].helium / 100.0; gasmix->oxygen = parser->gasmix[flags].oxygen / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; @@ -329,6 +330,7 @@ liquivision_lynx_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, tank->beginpressure = parser->tank[flags].beginpressure / 100.0; tank->endpressure = parser->tank[flags].endpressure / 100.0; tank->gasmix = DC_GASMIX_UNKNOWN; + tank->usage = DC_USAGE_NONE; break; default: return DC_STATUS_UNSUPPORTED; diff --git a/src/mares_darwin_parser.c b/src/mares_darwin_parser.c index 56b68d3..ecc5a03 100644 --- a/src/mares_darwin_parser.c +++ b/src/mares_darwin_parser.c @@ -159,6 +159,7 @@ mares_darwin_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi } break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = 0.0; if (mode == NITROX) { gasmix->oxygen = p[0x0E] / 100.0; @@ -185,6 +186,7 @@ mares_darwin_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi tank->gasmix = 0; tank->beginpressure = array_uint16_be (p + 0x17); tank->endpressure = array_uint16_be (p + 0x19); + tank->usage = DC_USAGE_NONE; } else { return DC_STATUS_UNSUPPORTED; } diff --git a/src/mares_iconhd_parser.c b/src/mares_iconhd_parser.c index 9ffb1e6..7ec513e 100644 --- a/src/mares_iconhd_parser.c +++ b/src/mares_iconhd_parser.c @@ -830,6 +830,7 @@ mares_iconhd_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi *((unsigned int *) value) = parser->ngasmixes; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->oxygen = parser->gasmix[flags].oxygen / 100.0; gasmix->helium = parser->gasmix[flags].helium / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; @@ -857,6 +858,7 @@ mares_iconhd_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi } else { tank->gasmix = DC_GASMIX_UNKNOWN; } + tank->usage = DC_USAGE_NONE; break; case DC_FIELD_ATMOSPHERIC: *((double *) value) = array_uint16_le (p + parser->layout->atmospheric) / (1000.0 * parser->layout->atmospheric_divisor); diff --git a/src/mares_nemo_parser.c b/src/mares_nemo_parser.c index a4c2d4b..828fcb3 100644 --- a/src/mares_nemo_parser.c +++ b/src/mares_nemo_parser.c @@ -251,6 +251,7 @@ mares_nemo_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsign } gasmix->helium = 0.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; + gasmix->usage = DC_USAGE_NONE; break; case DC_FIELD_TANK_COUNT: if (parser->extra) @@ -290,6 +291,7 @@ mares_nemo_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsign } else { tank->gasmix = DC_GASMIX_UNKNOWN; } + tank->usage = DC_USAGE_NONE; break; case DC_FIELD_TEMPERATURE_MINIMUM: *((double *) value) = (signed char) p[53 - 11]; diff --git a/src/mclean_extreme_parser.c b/src/mclean_extreme_parser.c index 260c56b..0cf0c5f 100644 --- a/src/mclean_extreme_parser.c +++ b/src/mclean_extreme_parser.c @@ -221,6 +221,7 @@ mclean_extreme_parser_get_field(dc_parser_t *abstract, dc_field_type_t type, uns *((unsigned int *)value) = parser->ngasmixes; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = 0.01 * abstract->data[0x0001 + 1 + 2 * parser->gasmix[flags]]; gasmix->oxygen = 0.01 * abstract->data[0x0001 + 0 + 2 * parser->gasmix[flags]]; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; diff --git a/src/oceanic_atom2_parser.c b/src/oceanic_atom2_parser.c index 272cfa2..8d87174 100644 --- a/src/oceanic_atom2_parser.c +++ b/src/oceanic_atom2_parser.c @@ -516,6 +516,7 @@ oceanic_atom2_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, uns *((unsigned int *) value) = parser->ngasmixes; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->oxygen = parser->oxygen[flags] / 100.0; gasmix->helium = parser->helium[flags] / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; diff --git a/src/oceanic_veo250_parser.c b/src/oceanic_veo250_parser.c index 5f1cac1..d3d9e6e 100644 --- a/src/oceanic_veo250_parser.c +++ b/src/oceanic_veo250_parser.c @@ -170,6 +170,7 @@ oceanic_veo250_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un *((unsigned int *) value) = 1; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = 0.0; if (data[footer + 6]) gasmix->oxygen = data[footer + 6] / 100.0; diff --git a/src/oceanic_vtpro_parser.c b/src/oceanic_vtpro_parser.c index 636f572..49d5937 100644 --- a/src/oceanic_vtpro_parser.c +++ b/src/oceanic_vtpro_parser.c @@ -200,6 +200,7 @@ oceanic_vtpro_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, uns *((unsigned int *) value) = 1; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = 0.0; if (oxygen) gasmix->oxygen = oxygen / 100.0; @@ -220,6 +221,7 @@ oceanic_vtpro_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, uns tank->gasmix = flags; tank->beginpressure = beginpressure * 2 * PSI / BAR; tank->endpressure = endpressure * 2 * PSI / BAR; + tank->usage = DC_USAGE_NONE; break; default: return DC_STATUS_UNSUPPORTED; diff --git a/src/oceans_s1_parser.c b/src/oceans_s1_parser.c index ff034a2..23d4903 100644 --- a/src/oceans_s1_parser.c +++ b/src/oceans_s1_parser.c @@ -166,6 +166,7 @@ oceans_s1_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigne *((unsigned int *) value) = parser->divemode == SCUBA; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = 0.0; gasmix->oxygen = parser->oxygen / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; diff --git a/src/seac_screen_parser.c b/src/seac_screen_parser.c index dfe0cc3..a0f7f3d 100644 --- a/src/seac_screen_parser.c +++ b/src/seac_screen_parser.c @@ -239,6 +239,7 @@ seac_screen_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsig *((unsigned int *)value) = parser->ngasmixes; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = 0.0; gasmix->oxygen = parser->oxygen[flags] / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; diff --git a/src/shearwater_predator_parser.c b/src/shearwater_predator_parser.c index e8f9055..d8512db 100644 --- a/src/shearwater_predator_parser.c +++ b/src/shearwater_predator_parser.c @@ -774,6 +774,7 @@ shearwater_predator_parser_get_field (dc_parser_t *abstract, dc_field_type_t typ *((unsigned int *) value) = parser->ngasmixes; break; case DC_FIELD_GASMIX: + gasmix->usage = parser->gasmix[flags].diluent ? DC_USAGE_DILUENT : DC_USAGE_NONE; gasmix->oxygen = parser->gasmix[flags].oxygen / 100.0; gasmix->helium = parser->gasmix[flags].helium / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; @@ -788,6 +789,22 @@ shearwater_predator_parser_get_field (dc_parser_t *abstract, dc_field_type_t typ tank->beginpressure = parser->tank[flags].beginpressure * 2 * PSI / BAR; tank->endpressure = parser->tank[flags].endpressure * 2 * PSI / BAR; tank->gasmix = DC_GASMIX_UNKNOWN; + switch (parser->tank[flags].name[0]) { + case 'S': + tank->usage = DC_USAGE_SIDEMOUNT; + break; + case 'O': + tank->usage = DC_USAGE_OXYGEN; + break; + case 'D': + tank->usage = DC_USAGE_DILUENT; + break; + case 'T': + case 'B': + default: + tank->usage = DC_USAGE_NONE; + break; + } break; case DC_FIELD_SALINITY: if (parser->density == 1000) diff --git a/src/suunto_d9_parser.c b/src/suunto_d9_parser.c index b61e994..dba1338 100644 --- a/src/suunto_d9_parser.c +++ b/src/suunto_d9_parser.c @@ -388,6 +388,7 @@ suunto_d9_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigne *((unsigned int *) value) = parser->ngasmixes; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = parser->helium[flags] / 100.0; gasmix->oxygen = parser->oxygen[flags] / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; diff --git a/src/suunto_eon_parser.c b/src/suunto_eon_parser.c index 8a048b2..77879d1 100644 --- a/src/suunto_eon_parser.c +++ b/src/suunto_eon_parser.c @@ -225,6 +225,7 @@ suunto_eon_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsign *((unsigned int *) value) = 1; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = 0.0; gasmix->oxygen = oxygen / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; @@ -242,6 +243,7 @@ suunto_eon_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsign tank->gasmix = 0; tank->beginpressure = beginpressure; tank->endpressure = endpressure; + tank->usage = DC_USAGE_NONE; break; case DC_FIELD_TEMPERATURE_MINIMUM: if (parser->spyder) diff --git a/src/suunto_eonsteel_parser.c b/src/suunto_eonsteel_parser.c index 5edd8f6..d7ab999 100644 --- a/src/suunto_eonsteel_parser.c +++ b/src/suunto_eonsteel_parser.c @@ -88,6 +88,7 @@ typedef struct suunto_eonsteel_parser_t { double highsetpoint; double customsetpoint; dc_tankvolume_t tankinfo[MAXGASES]; + dc_usage_t tankusage[MAXGASES]; double tanksize[MAXGASES]; double tankworkingpressure[MAXGASES]; dc_decomodel_t decomodel; @@ -1097,6 +1098,7 @@ suunto_eonsteel_parser_get_field(dc_parser_t *parser, dc_field_type_t type, unsi if (fabs(tank->volume - rint(tank->volume)) > 0.001) tank->type = DC_TANKVOLUME_IMPERIAL; } + tank->usage = eon->cache.tankusage[flags]; break; case DC_FIELD_DECOMODEL: field_value(value, eon->cache.decomodel); @@ -1160,6 +1162,7 @@ static int add_gas_type(suunto_eonsteel_parser_t *eon, const struct type_desc *d { int idx = eon->cache.ngases; dc_tankvolume_t tankinfo = DC_TANKVOLUME_METRIC; + dc_usage_t usage = DC_USAGE_NONE; char *name; if (idx >= MAXGASES) @@ -1170,15 +1173,17 @@ static int add_gas_type(suunto_eonsteel_parser_t *eon, const struct type_desc *d if (!name) DEBUG(eon->base.context, "Unable to look up gas type %u in %s", type, desc->format); else if (!strcasecmp(name, "Diluent")) - ; + usage = DC_USAGE_DILUENT; else if (!strcasecmp(name, "Oxygen")) - ; + usage = DC_USAGE_OXYGEN; else if (!strcasecmp(name, "None")) tankinfo = DC_TANKVOLUME_NONE; else if (strcasecmp(name, "Primary")) DEBUG(eon->base.context, "Unknown gas type %u (%s)", type, name); eon->cache.tankinfo[idx] = tankinfo; + eon->cache.tankusage[idx] = usage; + eon->cache.gasmix[idx].usage = usage; eon->cache.initialized |= 1 << DC_FIELD_GASMIX_COUNT; eon->cache.initialized |= 1 << DC_FIELD_TANK_COUNT; diff --git a/src/suunto_solution_parser.c b/src/suunto_solution_parser.c index 1713a73..1ec82f3 100644 --- a/src/suunto_solution_parser.c +++ b/src/suunto_solution_parser.c @@ -151,6 +151,7 @@ suunto_solution_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, u *((unsigned int *) value) = 1; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = 0.0; gasmix->oxygen = 0.21; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; diff --git a/src/suunto_vyper_parser.c b/src/suunto_vyper_parser.c index 356f64c..8fab31b 100644 --- a/src/suunto_vyper_parser.c +++ b/src/suunto_vyper_parser.c @@ -267,6 +267,7 @@ suunto_vyper_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi *((unsigned int *) value) = parser->ngasmixes; break; case DC_FIELD_GASMIX: + gas->usage = DC_USAGE_NONE; gas->helium = 0.0; gas->oxygen = parser->oxygen[flags] / 100.0; gas->nitrogen = 1.0 - gas->oxygen - gas->helium; @@ -287,6 +288,7 @@ suunto_vyper_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi tank->gasmix = 0; tank->beginpressure = beginpressure; tank->endpressure = endpressure; + tank->usage = DC_USAGE_NONE; break; case DC_FIELD_TEMPERATURE_SURFACE: *((double *) value) = (signed char) data[8]; diff --git a/src/uwatec_memomouse_parser.c b/src/uwatec_memomouse_parser.c index 80c13d5..0e55b4d 100644 --- a/src/uwatec_memomouse_parser.c +++ b/src/uwatec_memomouse_parser.c @@ -166,6 +166,7 @@ uwatec_memomouse_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, *((unsigned int *) value) = 1; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = 0.0; if (size >= header + 18) { if (is_oxygen) @@ -197,6 +198,7 @@ uwatec_memomouse_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, } tank->endpressure = 0.0; tank->gasmix = 0; + tank->usage = DC_USAGE_NONE; break; case DC_FIELD_TEMPERATURE_MINIMUM: *((double *) value) = (signed char) data[15] / 4.0; diff --git a/src/uwatec_smart_parser.c b/src/uwatec_smart_parser.c index 83304a5..017c10b 100644 --- a/src/uwatec_smart_parser.c +++ b/src/uwatec_smart_parser.c @@ -807,6 +807,7 @@ uwatec_smart_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi *((unsigned int *) value) = parser->ngasmixes; break; case DC_FIELD_GASMIX: + gasmix->usage = DC_USAGE_NONE; gasmix->helium = parser->gasmix[flags].helium / 100.0; gasmix->oxygen = parser->gasmix[flags].oxygen / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; @@ -821,6 +822,7 @@ uwatec_smart_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi tank->beginpressure = parser->tank[flags].beginpressure / 128.0; tank->endpressure = parser->tank[flags].endpressure / 128.0; tank->gasmix = parser->tank[flags].gasmix; + tank->usage = DC_USAGE_NONE; break; case DC_FIELD_TEMPERATURE_MINIMUM: *((double *) value) = (signed short) array_uint16_le (data + table->temp_minimum) / 10.0;