On 08/11/2014 17:57, Robert C. Helling wrote:
Maybe I misunderstood. Are you saying that the Poseidon computer always reports
oxygen as gas 0 and diluent as gas 1?
The Poseidon itself does not know about cylinder IDs, it only reports
oxygen and diluent partial pressures. But when reading the CSV, the data
need to be attached to a particular cylinder, in other words, an index
is required. By default, the indices are 0 and 1. We give the two
cylinder, however, attributes of oxygen or diluent. Here is a small
fragment of Miika's code:
dive->cylinder[cur_cylinder_index].cylinder_use = diluent;
dive->cylinder[cur_cylinder_index].type.size.mliter = 3000;
dive->cylinder[cur_cylinder_index].type.workingpressure.mbar = 200000;
dive->cylinder[cur_cylinder_index].type.description = strdup("3l Mk6");
So the index is required to be able to store the information.
All I meant, in subsurface, it should be possible to assign any cylinder index
to them (even when currently they always happen to get the same, just not make
that assumption about the future and other rebreathers) and then in the
cylinder structure have (as we have) a member that gives you the role of that
cylinder (OC, O2 or diluent) and (as we have) have helper functions that return
the cylinder index of the O2 and (current) diluent (even though one could use
the convention that in CCR mode that is always the “current cylinder”). I think
this abstraction leads to much more readable and extendable code.
I would totally agree. With Poseidon I suppose one could assign
arbitrary indices at CSV read time. And the concept is sound that there
should not be assumptions when dealing with different types of equipment.
The rest of the code (plotting, interpolation, gas use) should then only access
this information via the member and the helper functions, like for example in
interpolation
switch (cylinder.cylinder_use) {
OC:
interpolate_assuming_constant_sac;
break;
O2:
interpolate_assuming_constant_rate;
break;
DILUENT:
dont_try_to_inerpolate;
break;
}
Best
Robert
s.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
Robert, the lookup table employed in the interpolation software
presented a fairly code-effective way of retrieving cylinder-use values.
The alternative was two layers of if-then or of switch-case statements.
But this type of implementation makes maintenance a bit more difficult
compared to if-then or switch-case implementations. What is your opinion?
Kind regards,
willem
_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface