aboutsummaryrefslogtreecommitdiffstats
path: root/save-xml.c
AgeCommit message (Collapse)Author
2011-09-22Start handling dive eventsGravatar Linus Torvalds
Parse them, save them, take them from libdivecomputer. This doesn't merge them or show them in the profile yet, though. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-15Support gps coordinates for the location infoGravatar Linus Torvalds
Sadly, no way to show them yet. But it would be nice to let people enter them (and it would be doubly nice to have a dive computer that does it at the surface), and then perhaps just do the "point browser at google maps" thing. Saving/parsing tested by hand-feeding the location of Enenui (Molokini Crater) from google maps by hand into my divelog. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-15Rename the project 'subsurface'Gravatar Linus Torvalds
I never really liked 'diveclog' as a name - it's not like the C part is all that important. And while I could try to just make up another slang word for despicable person (in the tradition of naming all my projects after myself), I just can't see it. So let's just call it "subsurface". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-13Add divemaster/buddy field and text entryGravatar Linus Torvalds
I have it in some of my notes, and Dirk seems to fill that in too, so let's just show it, save it, and allow editing of it.. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12Don't save empty cylinder descriptions in the xmlGravatar Linus Torvalds
They get created when the equipment thing doesn't have a name for the cylinder, but we don't want to save that lack of description. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-11Be more careful about unit changesGravatar Linus Torvalds
When we change units, we need to flush any currently active dive information in the old units, and then carefully reload it in the new units. Otherwise crazy stuff happens - like having current cylinder working pressure values that are in PSI because that *used* to be the output unit, but then interpreting those values as BAR, because we changed the units. Also, since we now properly import working pressure from Diving Log, stop importing the (useless) cylinder description. The Diving Log cylinder descriptions are things like "Alu" or "Steel". We're better off just making up our own. Finally, since Diving Log has cylinder size in metric, make sure that we do the "match standard cylinder sizes" *after* we've done all the cylinder size conversions to proper units. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-11Fix up dive number namingGravatar Linus Torvalds
Use "dive->number" instead of "dive->nr". And make the XML match too. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-11Save and restore a "dive number"Gravatar Linus Torvalds
Some people want to know how many dives they have under their belt, so let's save and restore the dive number if it exists. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-10Now that we don't mess up import, we can save the cylinder working pressureGravatar Linus Torvalds
We used to have the heuristic that if we saw a cylinder working pressure, then the cylinder size would be in cuft. Which meant that we couldn't export our working pressures, because it would mess things up on import. But working pressure is actually nice to know, if you ever work with cylinders in imperial units. So now that the import is fixed, add the working pressure to the export. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-09Rename 'cylinder.c' as 'equipment.c'Gravatar Linus Torvalds
Make it about general equipment management, and start hooking up functions to show new equipment information when changing dives (and to flush changes to equipment information for the previously active dive). Nothing is hooked up yet, and it's now showing just one (really big) cylinder choice, so this is all broken. But it should make it possible to at least get somewhere some day. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-05Turn dive depth, temperature and duration into xml attributesGravatar Linus Torvalds
This makes the xml save-file look way nicer: it's both smaller and better organized. Using individual xml nodes for random small details is silly. The duration even parses exactly the same, because it still ends up being '.depth.duration' (now it's the 'duration' attribute of the dive node, it used to be the 'duration' child node of the dive node). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-05Sanitize and fix cylinder pressure overviewGravatar Linus Torvalds
Doing per-dive cylinder start/end pressures is insane, when we can have up to eight cylinders. The cylinder start/end pressure cannot be per dive, it needs to be per cylinder. This makes the save format cleaner too, we have all the cylinder data in just one place. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04Save milli-units with variable precisionGravatar Linus Torvalds
Instead of always using three decimal digits, use 1-3 digits. But do use at least one, even for integer numbers, just because it makes it so much clearer that we're dealing with potential fractional values. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04Use common helper for printing milli-unitsGravatar Linus Torvalds
I don't necessarily want to show three decimal digits when one or two would do. So prepare for that by using a helper. This doesn't actually change the printout yet. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04Properly save/restore cylinder description stringGravatar Linus Torvalds
We saved it under the wrong name, and didn't restore it at all. Fix. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04Make a guess at the cylinder description from the size and pressureGravatar Linus Torvalds
I'll want to also add a way to override/set the cylinder type: both manually by just setting a size in liters, and by picking from some list of standard cylinder sizes. For example, it looks like most of my dives are marked as having 12-liter cylinders. That is probably some default from Suunto Dive Manager, or from whatever Dirk did. It's almost certainly not right for any of them: as far as I know, the standard cylinders for Lahaina Divers (which is likely most of the warm water dives) are AL72's for air, and AL80's for Nitrox. That would be a 10L and a 11.1L tank respectively, afaik. I don't know what a 12-liter tank would be or where that size comes from. Anyway, the LP85+ tank designation for some of the dives looks more likely: that's one of the common sizes I've used for local dives. So the size of that thing is much more probably correct. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04Don't save cylinder working pressureGravatar Linus Torvalds
It was a mistake to save it - and I did it just because other dive managers did. It's a totally nonsensical measure, and nobody cares. The only thing that matters is the size of the cylinder, and the *actual* pressures. Those give actual air consumption numbers, and are meaningful and unambiguous. So the "working pressure" for a cylinder is pointless except for two things: - if you don't know the actual physical size, you need the "working pressure" along with the air size (eg "85 cuft") in order to compute the physical size. So we do use the working pressure on *input* from systems that report cylinder sizes that way. - People may well want to know what kind of cylinder they were diving, and again, you can make a good guess about this from the working pressure. So saving information like "HP100+" for the cylinder would be a good thing. But notice how in neither case do we actually want to save the working pressure itself. And in fact saving it actually makes the output format ambiguous: if we give both size and working pressure, what does 'size' mean? Is it physical size in liters, or air size in cu ft? So saving working pressure is just wrong. Get rid of it. I'm going to add some kind of "cylinder description" thing, which we can save instead (and perhaps guess standard cylinders from input like the working pressure from dive logs that don't do this sanely - which is all of them, as far as I can tell). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04Oops. I forgot to 'fclose()' the file after saving the xmlGravatar Linus Torvalds
It never actually triggered anything for me, but any buffered data might be lost, especially if you force-exit the application after saving a dive log. This probably explains a corrupted (truncated) dive file report from Nathan Samson. Reported-by: Nathan Samson <https://github.com/nathansamson> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-03Don't bother saving n2 percentageGravatar Linus Torvalds
It's all calculated anyway, and for the same reason we don't bother even parsing it at load time, we really shouldn't bother saving it either. The only thing you can do with that value is "check if the percentages add up to 100%", and so what? Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-03Do better cylinder information managementGravatar Linus Torvalds
Instead of just tracking gasmix, track the size and workng pressure of the cylinder too. And use "cylinder" instead of "tank" throughout. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01Fix wrongly nested watertemp xml entryGravatar Linus Torvalds
Too much cut-and-paste: the ending tag said "airtemp". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01We can't save escape characters.Gravatar Linus Torvalds
I think it should be legal xml, but whatever. libxml2 is very unhappy, and complains when loading - even if I escape them. So let's just replace the low escape characters with '?'. The only thing to ever care was my test-case, I suspect. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01Save and parse notes and locationsGravatar Linus Torvalds
It's pretty rough, but it seems to work. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01Do gasmix as an empty element XML tooGravatar Linus Torvalds
Let's make it a goal that the XML we output is pretty. That clearly was never a goal for the Suunto XML, but we can be oh-so-much-better than that. I still don't love XML, but let's try to make the best of a bad situation, and take pride in what we do. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01Clean up save-file output a bitGravatar Linus Torvalds
Use the "empty element" form for samples that don't have any events associated with them (and none do, right now). This avoids that annoying "</sample>" crud. And output the units in the output helpers, so that you can't forget them even if you try. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01Always use proper units when saving.Gravatar Linus Torvalds
When we see a number like 23.145, we'd better always also see a unit. It's just good practice. So add 'min' to duration (and use only two digits for number of seconds), and 'm' to depth. And write the date in international standard format. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01Save everything in our current dives and samples into the xml fileGravatar Linus Torvalds
Now, as we start parsing more, we just need to also add the code to save it. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01Fix up small details in input/outputGravatar Linus Torvalds
Be more careful with FP conversions, and with the Kelvin<->C offset. And make sure to use the same names when saving as when parsing. Now when we save a set of dives, then re-load them, and save again, the second save image is identical to the first one. Of course, we don't actually save everything we load, so we still do lose information when we load and then save the result. But at least we now don't lose the information that we *do* save. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01Add ability to 'save' divesGravatar Linus Torvalds
This just generates another xml file. Don't get me wrong: I still don't like xml, but this way we can save in the same format we load things from. Except the save-format is a *lot* cleaner than the abortion that is Suunto or libdivecomputer xml. Don't bother with some crazy xml library crap for saving. Just do it! Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>