mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
general: simplify a few unit manipulations
Now that we have defined addition and subtraction on unit classes, let's use them in a few examples. Yes, some of these are a bit pointless, because they are of the kind a.mbar - b.mbar => (a-b).mbar However, these probably should be further simplified by storing the result in a unit type. This commit is mostly a proof-of-concept. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
729cc16fc5
commit
110e64bc66
14 changed files with 59 additions and 68 deletions
|
@ -151,10 +151,9 @@ static int calculate_otu(const struct dive &dive)
|
|||
double otu = 0.0;
|
||||
const struct divecomputer *dc = &dive.dcs[0];
|
||||
for (auto [psample, sample]: pairwise_range(dc->samples)) {
|
||||
int t;
|
||||
int po2i, po2f;
|
||||
double pm;
|
||||
t = sample.time.seconds - psample.time.seconds;
|
||||
int t = (sample.time - psample.time).seconds;
|
||||
// if there is sensor data use sensor[0]
|
||||
if ((dc->divemode == CCR || dc->divemode == PSCR) && sample.o2sensor[0].mbar) {
|
||||
po2i = psample.o2sensor[0].mbar;
|
||||
|
@ -215,7 +214,7 @@ static double calculate_cns_dive(const struct dive &dive)
|
|||
double rate;
|
||||
/* Calculate the CNS for each sample in this dive and sum them */
|
||||
for (auto [psample, sample]: pairwise_range(dc->samples)) {
|
||||
int t = sample.time.seconds - psample.time.seconds;
|
||||
int t = (sample.time - psample.time).seconds;
|
||||
int po2 = get_sample_o2(dive, dc, sample, psample);
|
||||
/* Don't increase CNS when po2 below 500 matm */
|
||||
if (po2 <= 500)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue