[PATCH] Only return gas volumes for gases used
Anton Lundin
glance at acc.umu.se
Wed Nov 27 13:59:18 UTC 2013
We check in get_gaslist is_gas_used, so if were going to be consistent
about what we return from get_gaslist and in get_gas_used, only return
gasvolumes that we actually consumed during the dive.
Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
dives/test10.xml | 23 +++++++++++++++--------
statistics.c | 31 +++++++++++++++++--------------
2 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/dives/test10.xml b/dives/test10.xml
index e5449d4..ac22047 100644
--- a/dives/test10.xml
+++ b/dives/test10.xml
@@ -1,14 +1,21 @@
+<divelog program='subsurface' version='2'>
+<settings>
+</settings>
<dives>
-<program name='subsurface' version='1'></program>
<dive number='10' date='2011-01-01' time='18:00:00' duration='30:00 min'>
+ <location gps='63.010430 7.312430'>10th test dive, 3 tanks, 1 tank change</location>
+ <notes>Shows two pressure plots, each from 200 to 100bar and gaschange event at 10 min mark.</notes>
+ <cylinder size='9.987 l' workpressure='206.843 bar' description='AL72' o2='33.0%' start='200.0 bar' end='100.0 bar' />
+ <cylinder size='9.987 l' workpressure='206.843 bar' description='AL72' o2='50.0%' start='200.0 bar' end='100.0 bar' />
+ <cylinder size='9.987 l' workpressure='206.843 bar' description='AL72' o2='75.0%' start='200.0 bar' end='100.0 bar' />
+ <weightsystem weight='1.0 kg' description='integrated' />
+ <weightsystem weight='0.0 kg' description='belt' />
+ <weightsystem weight='3.0 kg' description='ankle' />
+ <divecomputer>
<depth max='30.0 m' mean='15.0 m' />
<temperature air='27.0 C' water='26.0 C' />
- <location>10th test dive, 3 tanks, 1 tank change</location>
- <gps>63.01043 7.31243</gps>
- <notes>Shows two pressure plots, each from 200 to 100bar and gaschange event at 10 min mark.</notes>
- <cylinder o2='33.0%' size='9.987 l' workpressure='206.843 bar' description='AL72' start='200.0 bar' end='100.0 bar' />
- <cylinder o2='50.0%' size='9.987 l' workpressure='206.843 bar' description='AL72' start='200.0 bar' end='100.0 bar' />
- <cylinder o2='75.0%' size='9.987 l' workpressure='206.843 bar' description='AL72' start='200.0 bar' end='100.0 bar' />
- <event time='10:00 min' name='gaschange' value='50' />
+ <event time='10:00 min' value='50' name='gaschange' />
+ </divecomputer>
</dive>
</dives>
+</divelog>
diff --git a/statistics.c b/statistics.c
index 51b8d60..c4beba3 100644
--- a/statistics.c
+++ b/statistics.c
@@ -293,20 +293,6 @@ void get_selected_dives_text(char *buffer, int size)
}
}
-void get_gas_used(struct dive *dive, volume_t gases[MAX_CYLINDERS])
-{
- int idx;
- for (idx = 0; idx < MAX_CYLINDERS; idx++) {
- cylinder_t *cyl = &dive->cylinder[idx];
- pressure_t start, end;
-
- start = cyl->start.mbar ? cyl->start : cyl->sample_start;
- end = cyl->end.mbar ? cyl->end : cyl->sample_end;
- if (start.mbar && end.mbar)
- gases[idx].mliter = gas_volume(cyl, start) - gas_volume(cyl, end);
- }
-}
-
bool is_gas_used(struct dive *dive, int idx)
{
cylinder_t *cyl = &dive->cylinder[idx];
@@ -354,6 +340,23 @@ bool is_gas_used(struct dive *dive, int idx)
return used;
}
+void get_gas_used(struct dive *dive, volume_t gases[MAX_CYLINDERS])
+{
+ int idx;
+ for (idx = 0; idx < MAX_CYLINDERS; idx++) {
+ cylinder_t *cyl = &dive->cylinder[idx];
+ pressure_t start, end;
+
+ if (!is_gas_used(dive, idx))
+ continue;
+
+ start = cyl->start.mbar ? cyl->start : cyl->sample_start;
+ end = cyl->end.mbar ? cyl->end : cyl->sample_end;
+ if (start.mbar && end.mbar)
+ gases[idx].mliter = gas_volume(cyl, start) - gas_volume(cyl, end);
+ }
+}
+
#define MAXBUF 80
/* for the O2/He readings just create a list of them */
char *get_gaslist(struct dive *dive)
--
1.8.3.2
More information about the subsurface
mailing list