subsurface/dives/TestDiveDM4.xml
Linus Torvalds 6c4e890960 Clean up divecomputer 'device' handling
We have this odd legacy notion of a divecomputer 'device', that was
originally just basically the libdivecomputer 'EVENT_DEVINFO' report
that was associated with each dive.  So it had firmware version,
deviceid, and serial number.

It had also gotten extended to do 'nickname' handling, and it was all
confusing, ugly and bad.  It was particularly bad because it wasn't
actually a 'per device' thing at all: due to the firmware field, a dive
computer that got a firmware update forced a new 'device'.

To make matters worse, the 'deviceid' was also almost random, because
we've calculated it a couple of different ways, and libdivecomputer
itself has changed how the legacy 32-bit 'serial number' is expressed.

Finally, because of all these issues, we didn't even try to make the
thing unique, so it really ended up being a random snapshot of the state
of the dive computer at the time of a dive, and sometimes we'd pick one,
and sometimes another, since they weren't really well-defined.

So get rid of all this confusion.

The new rules:

 - the actual random dive computer state at the time of a dive is kept
   in the dive data. So if you want to know the firmware version, it
   should be in the 'extra data'

 - the only serial number that matters is the string one in the extra
   data, because that's the one that actually matches what the dive
   computer reports, and isn't some random 32-bit integer with ambiguous
   formatting.

 - the 'device id' - the thing we match with (together with the model
   name, eg "Suunto EON Steel") is purely a hash of the real serial
   number.

   The device ID that libdivecomputer reports in EVENT_DEVINFO is
   ignored, as is the device ID we've saved in the XML or git files. If
   we have a serial number, the device ID will be uniquely associated
   with that serial number, and if we don't have one, the device ID will
   be zero (for 'match anything').

   So now 'deviceid' is literally just a shorthand for the serial number
   string, and the two are joined at the hip.

 - the 'device' managament is _only_ used to track devices that have
   serial numbers _and_ nicknames. So no more different device
   structures just because one had a nickname and the other didn't etc.

   Without a serial number, the device is 'anonymous' and fundamentally
   cannot be distinguished from other devices of the same model, so a
   nickname is meaningless. And without a nickname, there is no point in
   creating a device data structure, since all the data is in the dive
   itself and the device structure wouldn't add any value..

These rules mean that we no longer have ambiguous 'device' structures,
and we can never have duplicates that can confuse us.

This does mean that you can't give a nickname to a device that cannot be
uniquely identified with a serial number, but those are happily fairly
rare (and mostly older ones).  Dirk said he'd look at what it takes to
give more dive computers proper serial numbers, and I already did it for
the Garmin Descent family yesterday.

(Honesty in advertizing: right now you can't add a nickname to a dive
computer that doesn't already have one, because such a dive computer
will not have a device structure.  But that's a UI issue, and I'll sort
that out separately)

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-08-18 13:22:02 -07:00

196 lines
12 KiB
XML

<divelog program='subsurface' version='3'>
<settings>
</settings>
<divesites>
</divesites>
<dives>
<dive number='1' otu='46' 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>
<depth max='22.44 m' mean='16.291 m' />
<temperature air='28.0 C' water='26.0 C' />
<event time='59:32 min' name='surface' />
<sample time='0:00 min' depth='1.39 m' temp='28.0 C' pressure='206.52 bar' />
<sample time='0:20 min' depth='4.63 m' pressure='205.11 bar' />
<sample time='0:40 min' depth='7.66 m' pressure='203.6 bar' />
<sample time='1:00 min' depth='11.76 m' pressure='201.95 bar' />
<sample time='1:20 min' depth='16.77 m' pressure='200.03 bar' />
<sample time='1:40 min' depth='20.82 m' temp='27.0 C' pressure='198.3 bar' />
<sample time='2:00 min' depth='21.21 m' pressure='195.75 bar' />
<sample time='2:20 min' depth='21.89 m' pressure='194.02 bar' />
<sample time='2:40 min' depth='21.67 m' pressure='192.43 bar' />
<sample time='3:00 min' depth='21.7 m' pressure='191.11 bar' />
<sample time='3:20 min' depth='22.05 m' temp='26.0 C' pressure='189.73 bar' />
<sample time='3:40 min' depth='21.94 m' pressure='188.5 bar' />
<sample time='4:00 min' depth='21.5 m' pressure='187.16 bar' />
<sample time='4:20 min' depth='21.22 m' pressure='186.05 bar' />
<sample time='4:40 min' depth='21.36 m' pressure='185.17 bar' />
<sample time='5:00 min' depth='21.4 m' pressure='184.02 bar' />
<sample time='5:20 min' depth='21.73 m' pressure='182.64 bar' />
<sample time='5:40 min' depth='21.44 m' pressure='181.76 bar' />
<sample time='6:00 min' depth='21.49 m' pressure='180.84 bar' />
<sample time='6:20 min' depth='21.13 m' pressure='179.67 bar' />
<sample time='6:40 min' depth='21.33 m' pressure='178.53 bar' />
<sample time='7:00 min' depth='22.04 m' pressure='178.31 bar' />
<sample time='7:20 min' depth='22.41 m' pressure='177.35 bar' />
<sample time='7:40 min' depth='22.02 m' pressure='175.77 bar' />
<sample time='8:00 min' depth='21.72 m' pressure='174.27 bar' />
<sample time='8:20 min' depth='21.26 m' pressure='173.85 bar' />
<sample time='8:40 min' depth='20.89 m' pressure='172.56 bar' />
<sample time='9:00 min' depth='21.1 m' pressure='171.35 bar' />
<sample time='9:20 min' depth='21.24 m' pressure='170.33 bar' />
<sample time='9:40 min' depth='20.36 m' pressure='169.29 bar' />
<sample time='10:00 min' depth='20.15 m' pressure='168.59 bar' />
<sample time='10:20 min' depth='20.04 m' pressure='167.8 bar' />
<sample time='10:40 min' depth='19.95 m' pressure='166.2 bar' />
<sample time='11:00 min' depth='19.55 m' pressure='165.48 bar' />
<sample time='11:20 min' depth='19.36 m' pressure='164.12 bar' />
<sample time='11:40 min' depth='18.59 m' pressure='163.4 bar' />
<sample time='12:00 min' depth='18.04 m' pressure='162.63 bar' />
<sample time='12:20 min' depth='17.57 m' pressure='161.95 bar' />
<sample time='12:40 min' depth='17.2 m' pressure='160.65 bar' />
<sample time='13:00 min' depth='16.63 m' pressure='159.58 bar' />
<sample time='13:20 min' depth='17.12 m' pressure='158.25 bar' />
<sample time='13:40 min' depth='17.04 m' pressure='157.56 bar' />
<sample time='14:00 min' depth='17.15 m' pressure='156.6 bar' />
<sample time='14:20 min' depth='17.07 m' pressure='156.06 bar' />
<sample time='14:40 min' depth='16.71 m' pressure='155.24 bar' />
<sample time='15:00 min' depth='17.02 m' pressure='154.44 bar' />
<sample time='15:20 min' depth='16.76 m' pressure='153.71 bar' />
<sample time='15:40 min' depth='16.43 m' pressure='152.75 bar' />
<sample time='16:00 min' depth='16.81 m' pressure='152.09 bar' />
<sample time='16:20 min' depth='16.95 m' pressure='151.12 bar' />
<sample time='16:40 min' depth='17.06 m' pressure='150.37 bar' />
<sample time='17:00 min' depth='16.81 m' pressure='149.38 bar' />
<sample time='17:20 min' depth='17.01 m' pressure='148.7 bar' />
<sample time='17:40 min' depth='17.22 m' pressure='147.72 bar' />
<sample time='18:00 min' depth='16.86 m' pressure='146.86 bar' />
<sample time='18:20 min' depth='17.12 m' pressure='146.25 bar' />
<sample time='18:40 min' depth='17.28 m' pressure='145.01 bar' />
<sample time='19:00 min' depth='17.02 m' pressure='144.55 bar' />
<sample time='19:20 min' depth='17.12 m' pressure='143.39 bar' />
<sample time='19:40 min' depth='16.87 m' pressure='142.35 bar' />
<sample time='20:00 min' depth='17.05 m' pressure='141.57 bar' />
<sample time='20:20 min' depth='17.37 m' pressure='140.85 bar' />
<sample time='20:40 min' depth='17.34 m' pressure='140.16 bar' />
<sample time='21:00 min' depth='17.47 m' pressure='139.23 bar' />
<sample time='21:20 min' depth='17.45 m' pressure='138.24 bar' />
<sample time='21:40 min' depth='17.37 m' pressure='137.58 bar' />
<sample time='22:00 min' depth='16.97 m' pressure='136.78 bar' />
<sample time='22:20 min' depth='16.88 m' pressure='135.6 bar' />
<sample time='22:40 min' depth='17.03 m' pressure='134.95 bar' />
<sample time='23:00 min' depth='17.17 m' pressure='133.88 bar' />
<sample time='23:20 min' depth='17.11 m' pressure='133.21 bar' />
<sample time='23:40 min' depth='17.13 m' pressure='132.32 bar' />
<sample time='24:00 min' depth='17.12 m' pressure='131.63 bar' />
<sample time='24:20 min' depth='17.04 m' pressure='130.81 bar' />
<sample time='24:40 min' depth='16.86 m' pressure='130.33 bar' />
<sample time='25:00 min' depth='16.98 m' pressure='129.12 bar' />
<sample time='25:20 min' depth='16.86 m' pressure='128.34 bar' />
<sample time='25:40 min' depth='16.86 m' pressure='127.56 bar' />
<sample time='26:00 min' depth='16.96 m' pressure='126.87 bar' />
<sample time='26:20 min' depth='17.17 m' pressure='126.32 bar' />
<sample time='26:40 min' depth='16.74 m' pressure='125.03 bar' />
<sample time='27:00 min' depth='17.2 m' pressure='124.31 bar' />
<sample time='27:20 min' depth='17.26 m' pressure='123.65 bar' />
<sample time='27:40 min' depth='17.24 m' pressure='123.35 bar' />
<sample time='28:00 min' depth='17.31 m' pressure='122.17 bar' />
<sample time='28:20 min' depth='17.4 m' pressure='121.34 bar' />
<sample time='28:40 min' depth='17.43 m' pressure='120.7 bar' />
<sample time='29:00 min' depth='17.43 m' pressure='120.28 bar' />
<sample time='29:20 min' depth='17.43 m' pressure='119.61 bar' />
<sample time='29:40 min' depth='17.45 m' pressure='119.26 bar' />
<sample time='30:00 min' depth='17.44 m' pressure='119.04 bar' />
<sample time='30:20 min' depth='17.06 m' pressure='117.96 bar' />
<sample time='30:40 min' depth='16.59 m' pressure='117.1 bar' />
<sample time='31:00 min' depth='16.98 m' pressure='115.9 bar' />
<sample time='31:20 min' depth='16.88 m' pressure='115.17 bar' />
<sample time='31:40 min' depth='16.66 m' pressure='114.41 bar' />
<sample time='32:00 min' depth='16.65 m' pressure='113.8 bar' />
<sample time='32:20 min' depth='16.76 m' pressure='112.87 bar' />
<sample time='32:40 min' depth='17.25 m' pressure='112.23 bar' />
<sample time='33:00 min' depth='17.0 m' pressure='111.6 bar' />
<sample time='33:20 min' depth='16.59 m' pressure='110.69 bar' />
<sample time='33:40 min' depth='16.47 m' pressure='109.65 bar' />
<sample time='34:00 min' depth='16.59 m' pressure='108.94 bar' />
<sample time='34:20 min' depth='16.62 m' pressure='108.25 bar' />
<sample time='34:40 min' depth='16.98 m' pressure='107.94 bar' />
<sample time='35:00 min' depth='17.34 m' pressure='106.89 bar' />
<sample time='35:20 min' depth='17.34 m' pressure='105.79 bar' />
<sample time='35:40 min' depth='17.29 m' pressure='105.52 bar' />
<sample time='36:00 min' depth='17.26 m' pressure='104.84 bar' />
<sample time='36:20 min' depth='17.25 m' pressure='104.07 bar' />
<sample time='36:40 min' depth='17.39 m' pressure='103.01 bar' />
<sample time='37:00 min' depth='17.02 m' pressure='102.24 bar' />
<sample time='37:20 min' depth='16.87 m' pressure='101.45 bar' />
<sample time='37:40 min' depth='16.75 m' pressure='100.98 bar' />
<sample time='38:00 min' depth='16.51 m' pressure='99.94 bar' />
<sample time='38:20 min' depth='16.78 m' pressure='99.38 bar' />
<sample time='38:40 min' depth='16.93 m' pressure='98.77 bar' />
<sample time='39:00 min' depth='16.64 m' pressure='98.13 bar' />
<sample time='39:20 min' depth='16.35 m' pressure='97.1 bar' />
<sample time='39:40 min' depth='16.84 m' pressure='96.32 bar' />
<sample time='40:00 min' depth='16.93 m' pressure='95.61 bar' />
<sample time='40:20 min' depth='16.92 m' pressure='94.89 bar' />
<sample time='40:40 min' depth='16.96 m' pressure='93.88 bar' />
<sample time='41:00 min' depth='16.99 m' pressure='93.26 bar' />
<sample time='41:20 min' depth='16.96 m' pressure='92.73 bar' />
<sample time='41:40 min' depth='16.57 m' pressure='91.96 bar' />
<sample time='42:00 min' depth='16.07 m' pressure='91.15 bar' />
<sample time='42:20 min' depth='15.95 m' pressure='90.42 bar' />
<sample time='42:40 min' depth='16.24 m' pressure='89.9 bar' />
<sample time='43:00 min' depth='16.38 m' pressure='88.92 bar' />
<sample time='43:20 min' depth='16.67 m' pressure='88.2 bar' />
<sample time='43:40 min' depth='16.61 m' pressure='87.41 bar' />
<sample time='44:00 min' depth='17.17 m' pressure='86.42 bar' />
<sample time='44:20 min' depth='17.24 m' pressure='85.9 bar' />
<sample time='44:40 min' depth='17.41 m' pressure='85.16 bar' />
<sample time='45:00 min' depth='17.45 m' pressure='84.36 bar' />
<sample time='45:20 min' depth='17.2 m' pressure='83.57 bar' />
<sample time='45:40 min' depth='16.97 m' pressure='82.76 bar' />
<sample time='46:00 min' depth='17.45 m' pressure='81.8 bar' />
<sample time='46:20 min' depth='17.26 m' pressure='81.25 bar' />
<sample time='46:40 min' depth='17.35 m' pressure='80.64 bar' />
<sample time='47:00 min' depth='17.7 m' pressure='79.66 bar' />
<sample time='47:20 min' depth='17.06 m' pressure='78.83 bar' />
<sample time='47:40 min' depth='17.1 m' pressure='78.14 bar' />
<sample time='48:00 min' depth='16.99 m' pressure='77.16 bar' />
<sample time='48:20 min' depth='17.22 m' pressure='76.68 bar' />
<sample time='48:40 min' depth='17.01 m' pressure='75.75 bar' />
<sample time='49:00 min' depth='17.31 m' pressure='74.8 bar' />
<sample time='49:20 min' depth='17.39 m' pressure='74.08 bar' />
<sample time='49:40 min' depth='17.43 m' pressure='73.52 bar' />
<sample time='50:00 min' depth='16.83 m' pressure='73.01 bar' />
<sample time='50:20 min' depth='16.52 m' pressure='72.01 bar' />
<sample time='50:40 min' depth='16.59 m' pressure='71.01 bar' />
<sample time='51:00 min' depth='16.49 m' pressure='69.98 bar' />
<sample time='51:20 min' depth='16.04 m' pressure='69.34 bar' />
<sample time='51:40 min' depth='15.55 m' pressure='68.15 bar' />
<sample time='52:00 min' depth='15.03 m' pressure='67.46 bar' />
<sample time='52:20 min' depth='14.18 m' pressure='66.65 bar' />
<sample time='52:40 min' depth='12.88 m' pressure='65.84 bar' />
<sample time='53:00 min' depth='12.03 m' pressure='65.1 bar' />
<sample time='53:20 min' depth='11.19 m' pressure='64.53 bar' />
<sample time='53:40 min' depth='10.47 m' pressure='63.65 bar' />
<sample time='54:00 min' depth='9.12 m' pressure='62.93 bar' />
<sample time='54:20 min' depth='7.64 m' pressure='62.24 bar' />
<sample time='54:40 min' depth='6.79 m' pressure='61.55 bar' />
<sample time='55:00 min' depth='6.02 m' pressure='61.15 bar' />
<sample time='55:20 min' depth='5.47 m' pressure='60.67 bar' />
<sample time='55:40 min' depth='5.36 m' pressure='60.21 bar' />
<sample time='56:00 min' depth='5.49 m' pressure='59.39 bar' />
<sample time='56:20 min' depth='5.31 m' pressure='59.21 bar' />
<sample time='56:40 min' depth='5.33 m' pressure='56.0 bar' />
<sample time='57:00 min' depth='5.31 m' pressure='56.45 bar' />
<sample time='57:20 min' depth='5.28 m' pressure='56.2 bar' />
<sample time='57:40 min' depth='4.93 m' pressure='55.6 bar' />
<sample time='58:00 min' depth='4.88 m' pressure='55.3 bar' />
<sample time='58:20 min' depth='4.63 m' pressure='54.78 bar' />
<sample time='58:40 min' depth='3.75 m' pressure='54.37 bar' />
<sample time='59:00 min' depth='2.69 m' pressure='54.08 bar' />
<sample time='59:20 min' depth='1.88 m' pressure='53.87 bar' />
</divecomputer>
</dive>
</dives>
</divelog>