Ugh - cylinderindex confusion

Linus Torvalds torvalds at linux-foundation.org
Sun Dec 30 13:14:02 PST 2012


Looking at my the multi-cylinder dives with Uemis data, it shows how
clearly broken the "tank switch in samples" model that the Uemis
parser uses is.

The uemis parts of the xml have all those idiotic repeated
"cylinderindex='n'" things. Even with no pressure data.

I really think that "cylinderindex" should only exist when there is
pressure data, and it should be renamed to "sensor" so that we never
make that mistake again. The cylinderindex naming was wrong (since
sensor 0 is not necessariyl on cylinder 0), and came from
libdivecomputer. And due to the naming, it then is easy to think that
cylinderindex has anything to do with gas changes, which is obvious
crap.

So the gas switch stuff should always be events (or, if we want to,
some totally new model, but right now we have it as events). Thinking
that each event should have a "this is the cylinder you are breathing"
is insane, and has nothing to do with the sensor anyway - even if some
specific dive computers with multiple sensors *might* then decide to
match the two up. It does not make sense as a generic model.

Renaming our "cylinderindex" xml node would also allow us to change
the semantics - instead of "always show it when it is non-zero", the
new "sensor" field should be "show it only when there is a pressure,
and the sensor index is different from the previous sample that had
it".

Renaming it wouldn't just avoid the whole current confusion with gas
switch events, it would also mean that we could be compatible with old
files.

So for legacy cases, "cylinderindex" at parsing time could be turned
into a gas change event if it changes (and when we parse it, a missing
value is zero). But then we never write it out, and we only write out
"sensor" data (with the new semantics, so at parse time, a missing
sensor number would not be 0, but be "same as last sensor".

What do you think?

               Linus


More information about the subsurface mailing list