When I stare at the code enough I can convince myself that cylinderindex
will always be assigned a sane value, but on the flip side, making sure
nothing stupid happens is cheap insurance.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If not cylinder with type DILUENT or OXYGEN is defined, this function
returns -1 which should not be used as an index to an array. This
patch adds code to check for this return value and exit gracefully.
On line I marked with a comment. Someone more knowledgeable of that part of
code than me should double check that return is here what we want.
[Dirk Hohndel: fixed small oversight...]
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In commit d5d7fdc9af ("For CCR dives, show plot for diluent and O2
cylinder pressures") we end up dereferencing current before it is first
initialized. Bad.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Also fixes a bug in the diluent pressure interpolation
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Change the meaning that _the_ cylinder (as we treat it in OC dives) is the
diluent cylinder (rather than the O2 cylinder). This eliminates special
cases. Now, for CCR, we have to handle the O2 cylinder in addition
(rather than the diluent in addition).
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Random constants are bad. Let's use the indices that we already calculated
(and true and false if we mean boolean values).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add a time linear gas interpolation strategy. Some minor changes.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch implements the cylinder pressure calculations for diluent
gas in CCR dive computers. This is the third patch for achieving this.
The following were performed:
1) Add two lines to try_to_fill_sample() in parse-xml so that
diluent cylinder pressures are stored from XML dive log file
into structures of sample.
2) Add one line to populate_plot_entries() in profile.c so that
the diluent cylinder pressures are copied from structures of
sample to structures of plot_info.
3) add three constant #defines in profile.h
4) change populate_pressure_information() in gaspressures.c in
order to take into account pressure calculations for the
diluent cylinder, calling subordinate functions in the
appropriate way.
5) change create_plot_info_new() in profile.c in order to initiate
the pressure calculations for the diluent cylinder.
6) Implement two debugging functions (one in profile.c, another
in gaspressures.c). These debugging functions are activated
by means of #defines.
Two function calls dealing with oxygen pressure are currently commented
out. They will be activated in the following patch that attends to CCR
oxygen partial pressure calculation.
[Dirk Hohndel: rather massive whitespace cleanup]
Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is the second pathch in this series of four, allowing the calculation
of cylinder pressures for CCR equipment.
Change function fill_missing_tank_pressures in order to enable working
with the diuent gas, comprising a complete set of pressures kept separate
from all other tank pressures.
Flag diluent_flag indicates calculations for the diluent cylinder.
[Dirk Hohndel: serious whitespace cleanup]
Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch adapts pressure interpolation (function pr_interpolate_data)
in order to process CCR diluent gas as well. A flag diluent_flag is
added to the variables for calling this function indicating whether the
gas being worked with is diluent gas or not. This is necessitated by
the fact that the diluent gas storage is separate from that of the other
gases. The data used for interpolation are selected from the appropriate
array, depending on nthe value of diluent_flag.
In function fill_missing_tank_pressures, diluent_flag is set to 0
in order for the code to work with the current CCR adaptations.
The above constitutes no. 1 of a four-part set of patches that allows
pressure calculations for CCR gases. There will be CCR functionality
only after the whole set of patches is complete.
Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch does some cleaning up of code after the previous CCR
patch that extracted the contents of gaspressures.c form profile.c
1) Inapplicable #defines were removed
2) static function types were reinstated where practically possible.
3) comments at the start of the file were expanded a bit.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch implements a separation of the code for gas pressure
calculations from the rest of the code in profile.c. The latter
file is now split into: profile.c and gaspressures.c. The
details of the transferred functions is given at the top of
gaspressures.c. The following chnages were made:
1) dive.h: The function types of calculate_depth_to_mbar
and depth_to_mbar were made non-static in order to make them
available within gaspressures.c.
2) profile.c: Prototypes for the functions in gaspressures.c
were inserted at the top of profile. Ten functions were
transferred from profile.c to gaspressures.c
3) gaspressures.c as well as a short header, gaspressures.h
were created.
For the gas pressure calculations for CCR dives, gaspressures.c
forms the immediate basis for further code development.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>