The suunto xml is just completely crazy. What's the helium percentage
companion to "o2pct"? Would it be "hepct"? No. It's "hepct_0".
Ok, so they didn't number the first o2pct, which could be seen as sane:
that's the only mix value that should always exist. And they clearly
started their indexing with 0. So with multiple mixes, you'd then
expect "o2pct_1" and "hepct_1", right?
Wrong! Because XML people are crazy, the second O2 mix percentage is
obviously "o2pct_2". So the O2 percentages are one-based, with an
implicit one. But the He percentages are zero-based with an explicit
zero. So the second mix is "o2pct_2" and "hepct_1".
I'd like to ask what drugs Suunto people are on, but hey, it's a Finnish
company. No need to ask. Vodka explains everything. LOTS AND LOTS OF
VODKA.
In comparison, the libdivecomputer output is nice and sane, and uses a
'gasmix' node. Of course, now we have so many different XML nesting
nodes to check that I just made it an array of different noces. That
also allows me to mark the suunto case, so that we only do the "check
for crazy alcoholic xml entries" when it's a suunto file.
The "type of file" thing is probably a good idea for deciding on default
units too. Some day.
I'll start doing some kind of "save unparsed things as extended items"
thing, and the ignore rules were just there to get rid of some of the
noise from early parsing.
This requires us to change the way we match things up, because now we
can have things like
dives.dive.sample.event.time
and
dives.dive.sample.time
and they are different things (that "sample.event.time" is a 'time'
property of the 'event').
Now, this is always going to be ambiguous, since our linearized name of
the xml doesn't really care whether it's a xml node "child" or a
"property", but quite frankly, I don't care. XML just isn't worth the pain.
In fact, maybe this ambiguity can end up being a good thing. We will
parse these two different lines of XML the same way:
This tweaks:
- packing to be what you'd kind of expect
- makes the "summary info" always visible
- the "extended info" is now on a notebook page of its own
- dive profile the first notebook page, since the summary
information is visible regardless.
which all just seems a lot more logical.
Linus Torvalds [Wed, 31 Aug 2011 23:33:20 +0000 (16:33 -0700)]
Start cleaning up dive accessors
I'm going to add a menu to import (and eventually export) dives, and so
we'd like to be able to start out with no dives at all. Right now we
croak if that happens - it's not like the code has been written with
actual end users in mind.
So start cleaning things up. First make the 'current_dive' macro work
right even for invalid dives.
Linus Torvalds [Wed, 31 Aug 2011 23:10:11 +0000 (16:10 -0700)]
Use a 'notebook' for Info vs Profile
I dunno. This seems a better interface at least if we get more info for
the dive, but I suspect I'll want to the add basic info to the profile
page too.
This makes the 'table' approach to layout be kind of pointless again,
and the table has become a fancy vbox. Maybe I'll put the core info
back, and use the notebook 'Info' page for extended information.
I should just bite the bullet and start saving the dive data, and adding
editing functions for adding information. But instead I'm playing
around with random gtk widgets.
Linus Torvalds [Wed, 31 Aug 2011 22:35:28 +0000 (15:35 -0700)]
Add some more dive info - and actually update it
It's still the ugliest application ever, but now it at least gives you
some basic dive info.
I'd love to add a way to edit the dives to add new data (name, buddies,
location etc), but that would also require the ability to save the end
result. Maybe some day.
Linus Torvalds [Wed, 31 Aug 2011 21:35:31 +0000 (14:35 -0700)]
dive profile plot: use saner minimum limits
The time minimum was in seconds, not minutes, and we really do want to
show at least to 90ft to make shallow dives look shallow rather than
scaled to some full depth.
Linus Torvalds [Wed, 31 Aug 2011 19:09:19 +0000 (12:09 -0700)]
Add fake 'info' frame contents
It should have depth, time, place etc information, but right now it only
has a fake depth that doesn't even get updated. Just to show the idea
of the table usage.
Linus Torvalds [Wed, 31 Aug 2011 18:07:31 +0000 (11:07 -0700)]
Teach the thing to actually track the currently selected dive
.. and repaint the profile when the selection changes.
Now, if it just wasn't so ugly, it might even be useful. Except it
obviously needs to also show all the other dive information. And allow
the user to fill in details. And save the end results.
Linus Torvalds [Wed, 31 Aug 2011 15:47:13 +0000 (08:47 -0700)]
Draw some kind of profile for the (first) dive
This is all kinds of broken: it doesn't actually follow the selected
dive, and the profile isn't scaled properly etc. But it shows something
new, and not just text.
Linus Torvalds [Wed, 31 Aug 2011 03:56:01 +0000 (20:56 -0700)]
Show the dives as a gtk list/tree widget
Ok, so I'm not very good at this. I'll need to enclose the dang thing
in a scrollable window, and then make that scrollable thing just part of
the whole window.
But hey, it's pixels on the screen. Pixels that show the names of the
dives we've parsed. At least as many as will fit on screen at one time ;)
Linus Torvalds [Tue, 30 Aug 2011 23:59:03 +0000 (16:59 -0700)]
Add 'datetime' parsing for libdivecomputer xml files
I think this gets me dates on all my dives. So now I could start
sorting them and removing duplicates.
But before I try to remove dups, I guess I should compare the
libdivecomputer ones against the suunto ones. Because I bet they have
various "interesting" issues like using Bar vs Atm etc.
Linus Torvalds [Tue, 30 Aug 2011 21:36:34 +0000 (14:36 -0700)]
Fix stupid mis-initialization of current sample
.. nice compiler warning hidden by the crazy gcc pointer sign warnings
that nobody wants to see (yes, we really do want to do 'strlen()' even
on unsigned strings, don't complain, crazy bitch compiler).
So this also makes our CFLAGS set -Wno-pointer-sign.
Linus Torvalds [Tue, 30 Aug 2011 00:51:54 +0000 (17:51 -0700)]
Turn the XML into something almost parseable.
Of course, now the problem is that the different XML files have
different node names, but at least we've turned it into a half-way sane
format, and have a nice callback place per value.
Soon we could use that to actually fill in useful information.
Linus Torvalds [Sun, 28 Aug 2011 23:18:53 +0000 (16:18 -0700)]
Start archiving the stupid XML files
(and add a reminder of how they came to be)
Gaah. XML is *stupid*. It's not easy to parse for humans or for
computers, and some of these XML files are just disgusting. But maybe
they can be turned into something usable with libxml.