mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix SAC calculations for dives without any samples
We computed a made-up average depth based on the maximum depth, and used that. That's questionable even if we didn't have any explicit average depth to begin with, but it's particularly wrong if we did have an explicit average depth to use. Now, admittedly we have no way to actually create fake dives like this with a particular average depth, so this really doesn't make any difference in real life. But we should do this right. Also, make the XML be in the format that subsurface actually saves things in (mainly things like cylinder sizes having an extra decimal place, but also ordering of XML elements). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6d548d2028
commit
b62e63650a
2 changed files with 22 additions and 11 deletions
3
dive.c
3
dive.c
|
@ -678,7 +678,8 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc)
|
|||
if (asc_desc_time * 2 >= duration)
|
||||
asc_desc_time = duration/2;
|
||||
|
||||
dc->meandepth.mm = depth*(duration-asc_desc_time)/duration;
|
||||
if (!dc->meandepth.mm)
|
||||
dc->meandepth.mm = depth*(duration-asc_desc_time)/duration;
|
||||
if (depth > maxdepth)
|
||||
maxdepth = depth;
|
||||
} else {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<location>SAC test dive 1</location>
|
||||
<notes>SAC should be 20l/min (0.7063 cuft/min)
|
||||
We have exactly 100 ATM of gas in a 10l cylinder, average 10m for 25min</notes>
|
||||
<cylinder size='10 l' description='10l' start='202.6 bar' end='101.3 bar' />
|
||||
<cylinder size='10.0 l' description='10l' start='202.6 bar' end='101.3 bar' />
|
||||
<divecomputer>
|
||||
<depth max='10.0 m' mean='10.0 m' />
|
||||
<sample time='0:00 min' depth='10.0 m' />
|
||||
|
@ -21,7 +21,7 @@ We have exactly 100 ATM of gas in a 10l cylinder, average 10m for 25min</notes>
|
|||
<location>SAC test dive 2</location>
|
||||
<notes>SAC should be 20l/min (0.7063 cuft/min)
|
||||
We have exactly 100 ATM of gas in a 10l cylinder, average 10m for 25min</notes>
|
||||
<cylinder size='10 l' description='10l' start='202.6 bar' end='101.3 bar' />
|
||||
<cylinder size='10.0 l' description='10l' start='202.6 bar' end='101.3 bar' />
|
||||
<divecomputer>
|
||||
<depth max='20.0 m' mean='10.0 m' />
|
||||
<sample time='0:00 min' depth='0.0 m' />
|
||||
|
@ -33,11 +33,11 @@ We have exactly 100 ATM of gas in a 10l cylinder, average 10m for 25min</notes>
|
|||
<location>SAC test dive 3</location>
|
||||
<notes>SAC should be 20l/min (0.7063 cuft/min)
|
||||
We have exactly 100 ATM of gas in 15l of cylinder, average 20m for 25min</notes>
|
||||
<cylinder size='10 l' description='10l' start='202.6 bar' end='101.3 bar' />
|
||||
<cylinder size='5 l' description='10l' start='202.6 bar' end='101.3 bar' />
|
||||
<cylinder size='10.0 l' description='10l' start='202.6 bar' end='101.3 bar' />
|
||||
<cylinder size='5.0 l' description='10l' start='202.6 bar' end='101.3 bar' />
|
||||
<divecomputer>
|
||||
<depth max='40.0 m' mean='20.0 m' />
|
||||
<event time='17:00 min' name='gaschange' />
|
||||
<depth max='20.0 m' mean='10.0 m' />
|
||||
<sample time='0:00 min' depth='0.0 m' />
|
||||
<sample time='5:00 min' depth='20.0 m' />
|
||||
<sample time='10:00 min' depth='40.0 m' />
|
||||
|
@ -46,16 +46,16 @@ We have exactly 100 ATM of gas in 15l of cylinder, average 20m for 25min</notes>
|
|||
<sample time='25:00 min' depth='0.0 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='4' date='2013-02-24' time='12:26:04' duration='25:00 min'>
|
||||
<location>SAC test dive 3</location>
|
||||
<dive number='4' date='2013-02-24' time='12:26:04' duration='30:00 min'>
|
||||
<location>SAC test dive 4</location>
|
||||
<notes>SAC should be 20l/min (0.7063 cuft/min)
|
||||
This adds a 5-minute surface time to the middle of the dive.
|
||||
We have exactly 100 ATM of gas in 15l of cylinder, average 20m for 25min</notes>
|
||||
<cylinder size='10 l' description='10l' start='202.6 bar' end='101.3 bar' />
|
||||
<cylinder size='5 l' description='10l' start='202.6 bar' end='101.3 bar' />
|
||||
<cylinder size='10.0 l' description='10l' start='202.6 bar' end='101.3 bar' />
|
||||
<cylinder size='5.0 l' description='10l' start='202.6 bar' end='101.3 bar' />
|
||||
<divecomputer>
|
||||
<depth max='40.0 m' mean='16.666 m' />
|
||||
<event time='22:00 min' name='gaschange' />
|
||||
<depth max='20.0 m' mean='10.0 m' />
|
||||
<sample time='0:00 min' depth='0.0 m' />
|
||||
<sample time='5:00 min' depth='20.0 m' />
|
||||
<sample time='10:00 min' depth='40.0 m' />
|
||||
|
@ -65,5 +65,15 @@ We have exactly 100 ATM of gas in 15l of cylinder, average 20m for 25min</notes>
|
|||
<sample time='30:00 min' depth='0.0 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='5' date='2013-02-24' time='13:26:04' duration='25:00 min'>
|
||||
<location>SAC test dive 5</location>
|
||||
<notes>SAC should be 20l/min (0.7063 cuft/min)
|
||||
This verifies that it works without any sample data too.
|
||||
We have exactly 100 ATM of gas in 15l of cylinder, average 20m for 25min</notes>
|
||||
<cylinder size='10.0 l' description='10l' start='202.6 bar' end='101.3 bar' />
|
||||
<divecomputer>
|
||||
<depth max='13.5 m' mean='10.0 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
</dives>
|
||||
</divelog>
|
||||
|
|
Loading…
Add table
Reference in a new issue