Save SAC, OTU and CNS in the XML export

We do _not_ read them back, since they are calculated values, although I
guess we could aim to do that too at some point in case we have an
import from somewhere else that has these values but not the profile (or
gas use) to actually calculate them.

Fix test-cases that are checked by TestParse (but nothing else) to match.

Requested-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2020-05-14 09:48:09 -07:00
parent 1f942ab556
commit 62e95fdc86
8 changed files with 32 additions and 22 deletions

View file

@ -502,6 +502,16 @@ void save_one_dive_to_mb(struct membuffer *b, struct dive *dive, bool anonymize)
put_format(b, " chill='%d'", dive->chill);
if (dive->invalid)
put_format(b, " invalid='1'");
// These three are calculated, and not read when loading.
// But saving them into the XML is useful for data export.
if (dive->sac > 100)
put_format(b, " sac='%d.%03d l/min'", FRACTION(dive->sac, 1000));
if (dive->otu)
put_format(b, " otu='%d'", dive->otu);
if (dive->maxcns)
put_format(b, " cns='%d%%'", dive->maxcns);
save_tags(b, dive->tag_list);
if (dive->dive_site)
put_format(b, " divesiteid='%8x'", dive->dive_site->uuid);

View file

@ -5,7 +5,7 @@
<divesites>
</divesites>
<dives>
<dive number='1' date='2013-02-02' time='16:14:08' duration='59:20 min'>
<dive number='1' otu='45' cns='15%' date='2013-02-02' time='16:14:08' duration='59:20 min'>
<notes>Notes are here</notes>
<cylinder workpressure='200.0 bar' o2='33.0%' start='205.11 bar' />
<divecomputer>

View file

@ -5,7 +5,7 @@
<divesites>
</divesites>
<dives>
<dive number='1' date='2013-02-02' time='16:14:08' duration='59:20 min'>
<dive number='1' sac='11.046 l/min' otu='45' cns='15%' date='2013-02-02' time='16:14:08' duration='59:20 min'>
<notes>Notes are here</notes>
<cylinder size='12.0 l' o2='33.0%' start='205.11 bar' />
<divecomputer model='Vyper Air' deviceid='013749e4'>
@ -194,7 +194,7 @@
<sample time='59:20 min' depth='1.88 m' pressure='53.87 bar' />
</divecomputer>
</dive>
<dive number='2' tags='boat, photography, tag' date='2013-02-02' time='13:44:21' duration='61:00 min'>
<dive number='2' sac='11.298 l/min' otu='32' cns='11%' tags='boat, photography, tag' date='2013-02-02' time='13:44:21' duration='61:00 min'>
<notes>Testing notes</notes>
<cylinder size='12.0 l' o2='33.0%' start='209.04 bar' />
<divecomputer model='Vyper Air' deviceid='013749e4'>
@ -388,7 +388,7 @@
<sample time='61:00 min' depth='1.67 m' pressure='72.34 bar' />
</divecomputer>
</dive>
<dive number='3' date='2013-02-02' time='10:53:54' duration='66:00 min'>
<dive number='3' sac='10.109 l/min' otu='41' cns='15%' date='2013-02-02' time='10:53:54' duration='66:00 min'>
<notes>Dive notes</notes>
<cylinder size='12.0 l' o2='33.0%' start='212.74 bar' />
<divecomputer model='Vyper Air' deviceid='013749e4'>
@ -597,7 +597,7 @@
<sample time='66:00 min' depth='2.43 m' />
</divecomputer>
</dive>
<dive number='4' date='2013-02-02' time='08:21:50' duration='60:40 min'>
<dive number='4' sac='10.260 l/min' otu='48' cns='17%' date='2013-02-02' time='08:21:50' duration='60:40 min'>
<notes>Notes test</notes>
<cylinder size='12.0 l' o2='33.0%' start='194.74 bar' />
<divecomputer model='Vyper Air' deviceid='013749e4'>

View file

@ -6,7 +6,7 @@
</site>
</divesites>
<dives>
<dive number='1' divesiteid='64785a00' date='2011-05-17' time='11:01:00' duration='32:00 min'>
<dive number='1' sac='15.471 l/min' otu='14' cns='5%' divesiteid='64785a00' date='2011-05-17' time='11:01:00' duration='32:00 min'>
<buddy>Linus</buddy>
<notes>Second deep dive
Linus and I planned and executed - Alex just watching

View file

@ -4,7 +4,7 @@
<divesites>
</divesites>
<dives>
<dive date='2009-10-10' time='05:32:41' duration='7:32 min'>
<dive otu='3' cns='1%' date='2009-10-10' time='05:32:41' duration='7:32 min'>
<divecomputer model='DC text' deviceid='ffffffff'>
<depth max='40.0 m' mean='22.32 m' />
<temperature water='1.0 C' />

View file

@ -211,7 +211,7 @@
<sample time='17:15 min' depth='0.0 m' />
</divecomputer>
</dive>
<dive number='3' date='2012-10-01' time='06:49:00' duration='16:25 min'>
<dive number='3' otu='13' cns='7%' date='2012-10-01' time='06:49:00' duration='16:25 min'>
<divecomputer model='Seabear H3' deviceid='ffffffff'>
<depth max='69.9 m' mean='32.928 m' />
<temperature water='25.0 C' />
@ -418,7 +418,7 @@
<sample time='17:15 min' depth='0.0 m' />
</divecomputer>
</dive>
<dive number='4' date='2012-10-01' time='07:07:00' duration='16:17 min'>
<dive number='4' otu='13' cns='14%' date='2012-10-01' time='07:07:00' duration='16:17 min'>
<divecomputer model='Seabear H3' deviceid='ffffffff' dctype='Freedive'>
<depth max='70.1 m' mean='33.197 m' />
<temperature water='25.0 C' />
@ -1351,7 +1351,7 @@
<sample time='16:24 min' depth='0.1 m' />
</divecomputer>
</dive>
<dive number='5' date='2012-10-01' time='07:24:00' duration='16:25 min'>
<dive number='5' otu='13' cns='21%' date='2012-10-01' time='07:24:00' duration='16:25 min'>
<divecomputer model='Seabear H3' deviceid='ffffffff'>
<depth max='69.9 m' mean='32.928 m' />
<temperature water='25.0 C' />
@ -1557,7 +1557,7 @@
<sample time='17:15 min' depth='0.0 m' />
</divecomputer>
</dive>
<dive number='1' date='2012-10-01' time='06:02:00' duration='16:25 min'>
<dive number='1' otu='16' cns='5%' date='2012-10-01' time='06:02:00' duration='16:25 min'>
<cylinder description='oxygen' o2='100.0%' use='oxygen' />
<cylinder description='diluent' use='diluent' />
<divecomputer model='Seabear T1' deviceid='ffffffff' dctype='CCR' no_o2sensors='3'>
@ -1766,7 +1766,7 @@
<sample time='17:15 min' depth='0.0 m' />
</divecomputer>
</dive>
<dive number='2' date='2012-10-01' time='06:22:00' duration='16:25 min'>
<dive number='2' cns='5%' date='2012-10-01' time='06:22:00' duration='16:25 min'>
<divecomputer model='Seabear T1' deviceid='ffffffff' dctype='CCR'>
<depth max='69.9 m' mean='32.928 m' />
<temperature water='25.0 C' />
@ -1973,7 +1973,7 @@
<sample time='17:15 min' depth='0.0 m' />
</divecomputer>
</dive>
<dive number='3' date='2012-10-01' time='06:49:00' duration='16:25 min'>
<dive number='3' otu='13' cns='12%' date='2012-10-01' time='06:49:00' duration='16:25 min'>
<divecomputer model='Seabear T1' deviceid='ffffffff'>
<depth max='69.9 m' mean='32.928 m' />
<temperature water='25.0 C' />
@ -2180,7 +2180,7 @@
<sample time='17:15 min' depth='0.0 m' />
</divecomputer>
</dive>
<dive number='4' date='2012-10-01' time='07:07:00' duration='16:17 min'>
<dive number='4' otu='13' cns='19%' date='2012-10-01' time='07:07:00' duration='16:17 min'>
<divecomputer model='Seabear T1' deviceid='ffffffff' dctype='Freedive'>
<depth max='70.1 m' mean='33.197 m' />
<temperature water='24.0 C' />
@ -3113,7 +3113,7 @@
<sample time='16:24 min' depth='0.1 m' />
</divecomputer>
</dive>
<dive number='5' date='2012-10-01' time='07:24:00' duration='16:25 min'>
<dive number='5' otu='13' cns='26%' date='2012-10-01' time='07:24:00' duration='16:25 min'>
<divecomputer model='Seabear T1' deviceid='ffffffff'>
<depth max='69.9 m' mean='32.928 m' />
<temperature water='25.0 C' />

View file

@ -6,7 +6,7 @@
<divesites>
</divesites>
<dives>
<dive number='1' date='2017-02-03' time='06:58:00' duration='72:00 min'>
<dive number='1' otu='52' cns='22%' date='2017-02-03' time='06:58:00' duration='72:00 min'>
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' />
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' o2='32.0%' />
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' o2='31.0%' />
@ -103,7 +103,7 @@
<sample time='76:56 min' depth='0.01 m' ndl='0:00 min' cns='0%' />
</divecomputer>
</dive>
<dive number='2' date='2017-02-03' time='10:24:00' duration='66:00 min'>
<dive number='2' otu='39' cns='22%' date='2017-02-03' time='10:24:00' duration='66:00 min'>
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' />
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' o2='32.0%' />
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' o2='31.0%' />
@ -194,7 +194,7 @@
<sample time='70:46 min' depth='0.0 m' ndl='0:00 min' cns='0%' />
</divecomputer>
</dive>
<dive number='1' date='2017-02-03' time='06:59:41' duration='71:40 min'>
<dive number='1' sac='9.026 l/min' otu='53' cns='17%' date='2017-02-03' time='06:59:41' duration='71:40 min'>
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' o2='32.0%' />
<divecomputer model='Suunto Vyper Air' deviceid='11223344' diveid='c51cb31b'>
<depth max='26.72 m' mean='16.837 m' />
@ -420,7 +420,7 @@
<sample time='71:40 min' depth='1.5 m' pressure='53.05 bar' cns='0%' />
</divecomputer>
</dive>
<dive number='2' date='2017-02-03' time='10:25:16' duration='65:40 min'>
<dive number='2' sac='9.173 l/min' otu='40' cns='17%' date='2017-02-03' time='10:25:16' duration='65:40 min'>
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' o2='32.0%' />
<divecomputer model='Suunto Vyper Air' deviceid='20993833' diveid='5372ae57'>
<depth max='27.8 m' mean='14.594 m' />

View file

@ -34,7 +34,7 @@
<depth max='24.9 m' mean='20.1 m' />
</divecomputer>
</dive>
<dive number='417' divesiteid='deadbeef' date='2015-05-23' time='13:23:00' duration='100:00 min'>
<dive number='417' otu='135' cns='54%' divesiteid='deadbeef' date='2015-05-23' time='13:23:00' duration='100:00 min'>
<notes>{\rtf1\ansi\ansicpg1252\deff0\deflang1035{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}
\viewkind4\uc1\pard\f0\fs17\par
}</notes>
@ -747,7 +747,7 @@
<sample time='114:40 min' depth='0.0 m' />
</divecomputer>
</dive>
<dive number='1' date='2014-04-01' time='10:00:00' duration='77:54 min'>
<dive number='1' sac='1.049 l/min' otu='95' cns='34%' date='2014-04-01' time='10:00:00' duration='77:54 min'>
<notes>CCR dive</notes>
<cylinder size='2.0 l' workpressure='232.0 bar' description='Oxy2' o2='100.0%' start='190.0 bar' end='130.0 bar' use='oxygen' />
<cylinder size='2.0 l' workpressure='232.0 bar' description='Dil2' start='185.0 bar' end='130.0 bar' use='diluent' />
@ -3244,7 +3244,7 @@
<sample time='82:50 min' depth='0.235 m' ndl='0:00 min' stoptime='0:00 min' cns='0%' po2='0.0 bar' />
</divecomputer>
</dive>
<dive number='1' date='2014-04-02' time='10:00:00' duration='77:54 min'>
<dive number='1' sac='1.049 l/min' otu='95' cns='34%' date='2014-04-02' time='10:00:00' duration='77:54 min'>
<notes>CCR dive</notes>
<cylinder size='2.0 l' workpressure='232.0 bar' description='Oxy2' o2='100.0%' start='190.0 bar' end='130.0 bar' use='oxygen' />
<cylinder size='2.0 l' workpressure='232.0 bar' description='Dil2' start='185.0 bar' end='130.0 bar' use='diluent' />