[PATCH] Improved logic in cylinder management and gas change events
jlmulder at planet.nl
Fri Mar 21 08:51:32 PDT 2014
Attached a patch that may result in some discussion. I started looking
at some code due to a question from Tomaz about a "ghost cylinder bug".
Indeed, the code that is referenced by Tomaz seems straightforward, so
where can a ghost-like bug come from?
First, I ran in to an obvious bug. Manually add a 2nd cylinder to a
dive, and try to delete it right away. This should be possible, for
example, in case somebody adds a cylinder by mistake and tries to
correct it. The code to add a cylinder contains the intriguing remark
"mark the cylinder as 'used' since it was manually added". I'm not sure
what the original developers had in mind with the "used" status.
However, I consider a cylinder used in case its being breathed during
the dive. In other words; the set of used cylinders is a subset the
cylinders carried by the diver. For example, bailout of safety cylinders
(supposed only to be used in an emergency), or staging cylinders in a
cave for later (next dive) use. So, the first part of this patch is not
assuming that a manually added cylinder is used automatically.
Second part of the patch is that we now have to ensure that when a
cylinders is getting used (due to a gas change event), it gets the
proper used status, and when it becomes unused vise versa. However, we
may not assume that a cylinder is used only once during a dive, so when
removing a gas change event, we have to inspect the entire dive. A
cylinder can only be removed when it is not used at all.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4745 bytes
Desc: not available
More information about the subsurface