Cylinder pressure interpolation and end pressure display for CCR

Willem Ferguson willemferguson at zoology.up.ac.za
Sat Nov 8 22:12:41 PST 2014


Robert,
After a sleep I can think (I hope) more clearly. I attach a function 
from gaspressures.c (not the whole of gasspressures.c).  It is possible 
to use a switch between the cylinder_use types as shown in this example. 
But its utility is limited. The interpolation requires knowledge about 
the specific cylinder that is used for a particular point on the dive 
profile. Think in terms of cylinder changes during the dive.

Now, the cylinder_use constant (i.e. oxygen, diluent, bailout) gives 
information about the VARIABLES to be used for the interpolation, not 
about the RULES to be used for interpolation. So, like in the attached 
code, we can use a C-language switch (cylinder_use constants) to 
initialise some variables. But the rest of the algorithm requires the 
specific cylinder index values. And there is no getting away from using 
explicit cylinder index values using this algorithm. So there is not an 
immediate way of getting away from cylinder indices or "magic numbers" 
as you call them. For that reason, the switch (cylinder_use) construct 
of 12 lines of code can efficiently be achievd by the single line of 
code that is commented out underneath each of the two switches. But the 
issue of code maintainability remains.

The cylinder_use constants(oxyge, diluent, bailout)  do not give any 
information about the ID of particular cylinders when there is more than 
one cylinder of a particular cylinder_use class. For instance, take the 
hypothetical case of a CCR diver that takes a bailout cylinder as well 
as a stage cylinder. Both of these additional cylinders would be classed 
as cylinder_use = bailout. This touches on the topic of being gas-aware 
versus being cylinder-aware. There is a growing need for being 
cylinder-aware, reflected by at least one recent patch from Linus. The 
question is how to address each physical cylinder in an efficient way. 
At the moment magic numbers is probably the only way.

So what have we achieved with the creation of cylinder_use constants 
(oxygen, diluent, bailout)? We created the possibility to use any of the 
possible physical cylinders for any of these three cylinder use 
categories. This is what I still refused to understand when hard-coding 
a cylinder index into file.c: my code change totally defeated the object 
of cylinder_use constants.

Every time you have articulated a pretty convincing argument about these 
things. So I would really like to have your comment.
Kind regards,
willem

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gaspressures.c
Type: text/x-csrc
Size: 9243 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20141109/c764daf6/attachment.c>


More information about the subsurface mailing list