On 03-01-15 07:39, Linus Torvalds wrote:
The really sad part is that the EON Steel handles gas change events correctly, by actually saying which cylinder it switches to. But the libdivecomputer interfaces are broken, and only contain the gas *mix* you switch to, which is ambiguous since you could have the same mix in multiple cylinders.
Unfortunately I can't really fix this mistake right now, without breaking backwards compatibility. Otherwise I would have addressed this already.
Maybe we could put the one-based cylinder index into the "flags" field? With zero meaning "unknown". That would be a straightforward extension.
I really don't like this. First of all, the flags field are supposed to be used for the begin/end flags. Abusing that field for storing the gasmix index is the same kind of ugly hack that resulted in the SAMPLE_EVENT_GASCHANGE2 encoding. I would like to get rid of those, not add more! A one based index is also very confusing, especially because we already use a zero based index in the dc_tank_t structure.
How about an alternative solution? Instead of trying to re-use the existing SAMPLE_EVENT_GASCHANGE2 event, why not introduce a new SAMPLE_EVENT_GASCHANGE3 containing just the gasmix index? It maintains backwards compatibility without needing any ugly hacks. After v0.5 is released, we can deprecate the other two (but leave the constants in place) and port all backends to the new event for a v0.5.1 release shortly afterwards. That way, applications will have a clear timeframe for migrating to the new model. So that looks like a sane compromise to me.
Actually, instead of yet another gas change event, I believe we should model the active gasmix as a DC_SAMPLE_GASMIX sample type (also containing the zero based gasmix index as the value). That's similar to what we already have for setpoint changes, and also a move in the right direction for the new api design. See the attached patch.
Jef
>From a199e068d32ec6f51f1b55c8ed3d9939c238ea97 Mon Sep 17 00:00:00 2001 From: Jef Driesen <[email protected]> Date: Sun, 4 Jan 2015 08:56:10 +0100 Subject: [PATCH] Add support for the active gas mix. The new gasmix sample contains the index of the active gas mix. This new sample is intended as a replacement for the existing gas change events (SAMPLE_EVENT_GASCHANGE and SAMPLE_EVENT_GASCHANGE2). However, to maintain backwards compatibility, none of the backends is migrated yet. That will be done at a later stage. --- include/libdivecomputer/parser.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/libdivecomputer/parser.h b/include/libdivecomputer/parser.h index 774e5e3..c22d26e 100644 --- a/include/libdivecomputer/parser.h +++ b/include/libdivecomputer/parser.h @@ -43,7 +43,8 @@ typedef enum dc_sample_type_t { DC_SAMPLE_SETPOINT, DC_SAMPLE_PPO2, DC_SAMPLE_CNS, - DC_SAMPLE_DECO + DC_SAMPLE_DECO, + DC_SAMPLE_GASMIX } dc_sample_type_t; typedef enum dc_field_type_t { @@ -211,6 +212,7 @@ typedef union dc_sample_value_t { unsigned int time; double depth; } deco; + unsigned int gasmix; /* Gas mix index */ } dc_sample_value_t; typedef struct dc_parser_t dc_parser_t; -- 1.9.1
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
