Repository navigation
halcyon: Improve gas labeling for CC dives #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: Subsurface-DS9
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,6 +81,7 @@ typedef struct halcyon_symbios_gasmix_t { | |
| unsigned int id; | ||
| unsigned int oxygen; | ||
| unsigned int helium; | ||
| dc_usage_t usage; | ||
| } halcyon_symbios_gasmix_t; | ||
|
|
||
| typedef struct halcyon_symbios_tank_t { | ||
|
|
@@ -157,6 +158,7 @@ halcyon_symbios_parser_create (dc_parser_t **out, dc_context_t *context, const u | |
| for (unsigned int i = 0; i < NGASMIXES; ++i) { | ||
| parser->gasmix[i].oxygen = 0; | ||
| parser->gasmix[i].helium = 0; | ||
| parser->gasmix[i].usage = DC_USAGE_NONE; | ||
| } | ||
| for (unsigned int i = 0; i < NTANKS; ++i) { | ||
| parser->tank[i].id = 0; | ||
|
|
@@ -266,7 +268,7 @@ halcyon_symbios_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, u | |
| gasmix->helium = parser->gasmix[flags].helium / 100.0; | ||
| gasmix->oxygen = parser->gasmix[flags].oxygen / 100.0; | ||
| gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; | ||
| gasmix->usage = DC_USAGE_NONE; | ||
| gasmix->usage = parser->gasmix[flags].usage; | ||
| break; | ||
| case DC_FIELD_TANK_COUNT: | ||
| *((unsigned int *) value) = parser->ntanks; | ||
|
|
@@ -632,10 +634,29 @@ halcyon_symbios_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac | |
| ERROR (abstract->context, "Maximum number of tanks reached."); | ||
| return DC_STATUS_NOMEMORY; | ||
| } | ||
| // Find or create a gasmix for the CCR O2 supply. | ||
| // The Symbios does not seem to store the O2 supply | ||
| // composition in its logs, so 100% is assumed. | ||
| unsigned int o2_idx = 0; | ||
| while (o2_idx < ngasmixes && | ||
| gasmix[o2_idx].usage != DC_USAGE_OXYGEN) { | ||
| o2_idx++; | ||
| } | ||
| if (o2_idx >= ngasmixes) { | ||
| if (ngasmixes >= NGASMIXES) { | ||
| ERROR (abstract->context, "Maximum number of gasmixes reached."); | ||
| return DC_STATUS_NOMEMORY; | ||
|
Comment on lines
+646
to
+648
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| gasmix[ngasmixes].oxygen = 100; | ||
| gasmix[ngasmixes].helium = 0; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The synthetic entry keeps the zero-initialised id, which is 0 and equals configured slot 0. ID_GAS_TRANSMITTER and ID_GAS_CONFIG both look up gasmix[] by id only, so:
Giving it an id that no configured slot can have (e.g. UNDEFINED, as ID_GAS_SWITCH entries use) while keeping the usage-based lookup avoids both. Please add a case with slot 0 disabled and a slot-0 transmitter. |
||
| gasmix[ngasmixes].usage = DC_USAGE_OXYGEN; | ||
|
Comment on lines
+650
to
+652
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Give the synthetic oxygen gas a non-slot identity. The synthetic entry retains its zero-initialized Assign an identity that cannot match a configured slot. Add a regression case with disabled slot 0 followed by oxygen synthesis and a slot-0 transmitter.
|
||
| o2_idx = ngasmixes; | ||
| ngasmixes++; | ||
| } | ||
| tank[ntanks].id = serial; | ||
| tank[ntanks].beginpressure = pressure; | ||
| tank[ntanks].endpressure = pressure; | ||
| tank[ntanks].gasmix = DC_GASMIX_UNKNOWN; | ||
| tank[ntanks].gasmix = o2_idx; | ||
| tank[ntanks].usage = usage; | ||
| ntanks++; | ||
| } | ||
|
|
@@ -703,6 +724,18 @@ halcyon_symbios_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac | |
| gasmix[ngasmixes].id = id; | ||
| gasmix[ngasmixes].oxygen = o2; | ||
| gasmix[ngasmixes].helium = he; | ||
| // In CCR mode: slots >= NGAS_SLOTS are diluents; | ||
| // slots 0-4 are OC bailout gases. | ||
| if ((divemode == CCR || divemode == CCR_FSP) && | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set usage before retaining disabled gas configurations. For a CCR dive, configure slot 1 as disabled, then reference slot 1 from a transmitter. The transmitter copies Set usage on the retained configuration and preserve it through both exposure paths. Add a CCR deferred-transmitter test.
|
||
| id >= NGAS_SLOTS) { | ||
| gasmix[ngasmixes].usage = DC_USAGE_DILUENT; | ||
| } | ||
| else if (divemode == CCR || divemode == CCR_FSP) { | ||
| gasmix[ngasmixes].usage = DC_USAGE_OPEN_CIRCUIT; | ||
| } | ||
| else { | ||
| gasmix[ngasmixes].usage = DC_USAGE_NONE; | ||
| } | ||
| ngasmixes++; | ||
| } else { | ||
| if (gasmix[idx].oxygen != o2 || | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a regression for profiles that previously parsed. With ten configured gases and one ID_PO2_REBREATHER record, this returns DC_STATUS_NOMEMORY and the whole dive is lost, whereas before the tank simply got DC_GASMIX_UNKNOWN. In the other order (pressure record first) the tenth ID_GAS_CONFIG fails at the NGASMIXES guard instead.
The synthetic gas should not consume one of the ten configured-gas entries. Either give it its own capacity or, if there is no room, fall back to DC_GASMIX_UNKNOWN rather than failing the parse. A test with ten configured gases in both record orders would cover it.