Skip to content

Commit 323804d

Browse files
committed
Keep track of the actively used gas mixes
The hwOS models support switching to a disabled gas mix. Therefore, the disabled state is not always a good indication whether a gas mix is used or not. Look for gas switches during the parsing step instead to keep track of the actively used gas mixes.
1 parent ecc9e0b commit 323804d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/hw_ostc_parser.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ typedef struct hw_ostc_gasmix_t {
108108
unsigned int helium;
109109
unsigned int type;
110110
unsigned int enabled;
111+
unsigned int active;
111112
unsigned int diluent;
112113
} hw_ostc_gasmix_t;
113114

@@ -290,6 +291,7 @@ hw_ostc_parser_cache (hw_ostc_parser_t *parser)
290291
gasmix[i].helium = 0;
291292
gasmix[i].type = 0;
292293
gasmix[i].enabled = 1;
294+
gasmix[i].active = 0;
293295
gasmix[i].diluent = 0;
294296
}
295297
} else if (version == 0x23 || version == 0x24) {
@@ -299,6 +301,7 @@ hw_ostc_parser_cache (hw_ostc_parser_t *parser)
299301
gasmix[i].helium = data[28 + 4 * i + 1];
300302
gasmix[i].type = data[28 + 4 * i + 3];
301303
gasmix[i].enabled = gasmix[i].type != 0;
304+
gasmix[i].active = 0;
302305
gasmix[i].diluent = ccr;
303306
// Find the first gas marked as the initial gas.
304307
if (initial == UNDEFINED && data[28 + 4 * i + 3] == 1) {
@@ -325,6 +328,7 @@ hw_ostc_parser_cache (hw_ostc_parser_t *parser)
325328
} else {
326329
gasmix[i].enabled = 1;
327330
}
331+
gasmix[i].active = 0;
328332
gasmix[i].diluent = ccr;
329333
}
330334
}
@@ -387,6 +391,7 @@ hw_ostc_parser_create_internal (dc_parser_t **out, dc_context_t *context, const
387391
parser->gasmix[i].helium = 0;
388392
parser->gasmix[i].type = 0;
389393
parser->gasmix[i].enabled = 0;
394+
parser->gasmix[i].active = 0;
390395
parser->gasmix[i].diluent = 0;
391396
}
392397

@@ -802,6 +807,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
802807

803808
// Initial gas mix.
804809
if (time == samplerate && parser->initial != UNDEFINED) {
810+
parser->gasmix[parser->initial].active = 1;
805811
sample.gasmix = parser->initial;
806812
if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
807813
}
@@ -900,6 +906,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
900906
parser->gasmix[idx].helium = he;
901907
parser->gasmix[idx].type = 0;
902908
parser->gasmix[idx].enabled = 1;
909+
parser->gasmix[idx].active = 1;
903910
parser->gasmix[idx].diluent = ccr;
904911
parser->ngasmixes = idx + 1;
905912
}
@@ -926,6 +933,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
926933
return DC_STATUS_DATAFORMAT;
927934
}
928935
idx--; /* Convert to a zero based index. */
936+
parser->gasmix[idx].active = 1;
929937
sample.gasmix = idx;
930938
if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
931939
tank = idx;
@@ -965,6 +973,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
965973
parser->gasmix[idx].helium = he;
966974
parser->gasmix[idx].type = 0;
967975
parser->gasmix[idx].enabled = 1;
976+
parser->gasmix[idx].active = 1;
968977
parser->gasmix[idx].diluent = 0;
969978
parser->ngasmixes = idx + 1;
970979
}
@@ -1100,6 +1109,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
11001109
parser->gasmix[idx].helium = he;
11011110
parser->gasmix[idx].type = 0;
11021111
parser->gasmix[idx].enabled = 1;
1112+
parser->gasmix[idx].active = 1;
11031113
parser->gasmix[idx].diluent = 0;
11041114
parser->ngasmixes = idx + 1;
11051115
}

0 commit comments

Comments
 (0)