summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
AgeCommit message (Collapse)Author
2011-11-01Even more places with pressure and volume conversionsGravatar Dirk Hohndel
Amazing at how many spots we are re-implementing the wheel. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-24Avoid using strptimeGravatar Dirk Hohndel
It's less portable (missing on Windows, for example) and it's kind of overkill here - the same is easily done with a sscanf. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-19Parse the xml sample cylinder index properlyGravatar Linus Torvalds
We would save it in the xml file, but then not actually read it back properly. Oops. Not that we actually have any multi-tank dives yet, so it doesn't matter. Yet. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-02Integrate loading of uemis SDA files into the regular xml parsingGravatar Dirk Hohndel
There are a few interesting issues with this: - this requires a change to the SDA file format; thankfully I control that format, too (the default files are not valid XML files) - once again, the fact that adding samples can change the dive pointer messes with me - I decided to change the interface of ALL of the XXX_dive_match functions to take a struct dive** I know this is not ideal as all the other functions don't need that - but I would have hated the inconsistency - there is the issue that we now overload two _different_ uemis formats in the same function - that's certainly a potential point of confusion - a minor detail is the problem that the SDA format is kinda odd to parse and that we trigger on the duration field by it being the only float. Yeah, that's not ideal - but again, I control the format, so I _know_ this is true. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-02First steps towards integrating SDA files into the default XML loadingGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-30We forgot to pick up the 'value' field of a dive eventGravatar Linus Torvalds
Just missed that one entirely in the xml parser for some reason. Probably because the fields don't have much semantic meaning, so I didn't even realize that I had missed one of the random integer values in an event. On my suunto, the 'value' field seems to contain things like the new Oxygen percentage of a gas change event etc. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-27Merge branch 'otu-tracking-v2' of git://github.com/dirkhh/subsurfaceGravatar Linus Torvalds
* 'otu-tracking-v2' of git://github.com/dirkhh/subsurface: Make OTU column invisible by default Add OTU to divelist Calculate OTUs for every dive Fix up trivial conflicts in dive.h (due to dive event handling also adding a field to the dive structure)
2011-09-22Drop surface events when reading from an XML file tooGravatar Linus Torvalds
Remember those useless surface events that we ignore when we import a dive from a dive computer? Yeah, they exist in the libdivelog xml files too. So ignore them when we see them there too. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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-22Calculate OTUs for every diveGravatar Dirk Hohndel
The calculation assumes that the cylinderindex in each sample tells us which PO2 the dive was breathing at that time. This needs to be verified with dives where there is an actual gas switch. No idea where to display them, yet. Far fewer people will care about this than care about SAC - does this still rate a spot in the dive_list? I guess I could make it part of the dive_info - but it's not editable. It doesn't seem to fit with the equipment page (even though this is the one editable field that is related - nitrox %) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-21Use the last (or only) filename on command line as default for savingGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.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-15Fix uemis depth calculation in the uemis XML importerGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org> 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-12Libdivecomputer: start actually importing the dive dataGravatar Linus Torvalds
So this actually reports the dive data that libdivecomputer generates. It doesn't import special events etc, but neither do we for the xml importer. It is also slow as heck, since it doesn't try to do the "hey, I already have this dive" logic and always imports everything, but the basics are definitely there. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12Abstract out dive/sample allocation a bitGravatar Linus Torvalds
We're going to start to want to allocate dives and samples for the libdivecomputer import too, so let's clean things up a bit for that. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12Avoid using type 'gasmix_t': use 'struct gasmix' insteadGravatar Linus Torvalds
libdivecomputer already uses 'gasmix_t' for its own gasmix thing. I don't like th eway we step on each others name spaces, but hey, might as well just use 'struct gasmix' and avoid the typedef. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-11Work around more Diving Log bugs..Gravatar Linus Torvalds
The Diving Log temperature reading is in Fahrenheit for the samples (for the per-dive water/air temperature it's in Celsius). But it seems to have a bug where a lack of a sample has been turned into 32 Fahrenheit (which is 0 celsius). This is despite the dive itself having a water temperature of 8 degF. Just throw away those bogus freezing temperatures. Sure, they can happen, and ice divers are crazy - but in this case I know it's just an error in the log, and it looks very much like a Diving Log bug. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-11Call an LP85 an LP85 even when it's "10% extra".Gravatar Linus Torvalds
The LP85+ name is not something we'd normally want to recognize. The LP cylinder names all tend to be by the "+" pressure anyway, and that's what we do in the equipment handling naming. 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-11Parse 'Diving Log' cylinder working pressureGravatar Linus Torvalds
Oh Gods. Why are all other scuba programs so f*&% messed up? The Diving Log cylinder working pressure is in bar - which is all good. But their pressure *samples* are in PSI. Why the h*ll do people mix up units in the same damn file like that? I despair at the pure incompetence sometimes. I suspect the pressure samples aren't "really" in PSI: they are probably in some user-specified 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-10Don't guess input cylinder size as cubic feetGravatar Linus Torvalds
That just screws up the good xml files that have everything in well-defined units and chose the sane metric units. So do the cuft -> liter conversion only if the input units are explicitly CUFT, or known ambiguous input (SUUNTO). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-06Start "output unit management" supportGravatar Linus Torvalds
This doesn't actually *do* anything yet, but it introduces the notion of output units, and allows you to pick metric or imperial. Of course, since the output doesn't currently care, the units you pick are irrelevant. But just wait.. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-06Minimally parse some UDDF format divesGravatar Linus Torvalds
Dive dates (at least partial parsing), depths and times. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-06Add framework for UDDF importerGravatar Linus Torvalds
There are several sample UDDF files around on the net, so we might as well start importing some of it. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-05update UEMIS date_time parsingGravatar Dirk Hohndel
Looks like Linus misinterpreted the first UEMIS xml files I sent him. The date_time appears to be in local time - so the time zone info can be ignored (that seems strange, but it worked for the dives I tested it with) Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-05Merge branch 'open-files' of git://github.com/nathansamson/diveclogGravatar Linus Torvalds
* 'open-files' of git://github.com/nathansamson/diveclog: Report errors when opening files Make it possible to load multiple files at once. Open File works. I refactored the code and introduced a new type. I never used it as a pointer (their was no real reason), but I'm not really satisfied.
2011-09-05Add support from importing from Diving Log xml filesGravatar Linus Torvalds
This is just a very rough draft. It imports all the main stuff I noticed, but I'm sure it drops a ton of other stuff. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-05Make the import source an enumerationGravatar Linus Torvalds
Instead of having each import source recognition routine set a separate flag for that import source, just enumerate them and set them in one variable. I'm adding yet another xml importer - divinglog. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-05Report errors when opening filesGravatar Nathan Samson
Signed-off-by: Nathan Samson <nathansamson@gmail.com>
2011-09-05Parse Uemis cylinder data correctly.Gravatar Linus Torvalds
There's a big comment there now about what is going on. It took me a while to understand how the crazy seven-tank uemis dive computer information actually works. So the Uemis computer has 4 different "tank profiles": - single tank air (0) - single tank nitrox (1) - two-tank nitrox (2) - three-tank nitrox (3) and the computer always lists all seven tank cases (because that's how you fill them in). Depending on the "gas.template" you are supposed to then *use* just one particular profile. Why the computer doesn't just give you the tanks for that one profile, who knows? It seems to be more of the same "Uemis dive data isn't so much about the dive, it's about dive computer state" mentality. So we first get the profile information, and then based on that we need to pick the right tanks from the set of seven that we're presented with. All clear? 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-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-04Parse uemis cylinder dataGravatar Linus Torvalds
This is some seriously crazy stuff. Instead of making sense as a divelog, the uemis xml makes more sense as a "dive computer settings dump". And I guess I can see why they'd do that. But it makes parsing it just incredibly annoying. The thing is more of a "these are the configurations I support as a dive computer thing" than a "this was the tank you were diving with". 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-04Generate date string for the dive list dynamicallyGravatar Linus Torvalds
.. and sort based on the 'time_t' value itself. This allows us to use a more compact date format that doesn't need to sort alphabetically, because sorting by date is always based on the date value. So we can use just a two-digit year, and skip the seconds, to keep the column narrow, while still sorting correctly. Also, "Depth" is a nice header string, but it is wider than the column itself, which makes the whole column wider than necessary. So put the units in the header instead of in the string, keeping things narrow. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04Split the dive list in columns. Columns are sortable now (name = date, ↵Gravatar Nathan Samson
depth, duration) Signed-off-by: Nathan Samson <nathansamson@gmail.com>
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-03Add various dive fixups, and show pressure (if any) in the plotGravatar Linus Torvalds
Now the dive profile plot *really* needs some units. The pressure is just a random line otherwise. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-02Do a dive de-dup passGravatar Linus Torvalds
If given multiple dives at the same time, just de-dup the dives. This happens when you've dumped the whole dive-computer several times, and some dives show up in multiple dumps. When de-duping, try to avoid dropping data. So if one dive has notes attached to it, and the other one does not, pick the notes from the dive that does have them. Obvious stuff like that. The sample merge is also written so that it should be possible to merge two dives. Which we don't actually do yet. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-02Improve uemis xml parsing a bitGravatar Linus Torvalds
It looks like the "units.pressure" setting is only about the units that things are *shown* in on the wrist computer: the units in the file are always in bar (or rather, centi-bar). Which is definitely the right thing to do, and means that we shouldn't care about parsing the units setting. It's purely about how something is shown, not about parsing. That's probably true of the other units too, but let's see when I have more data to go on. Also, parse water temperatures and tank pressure. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-02Silently ignore zero pressureGravatar Linus Torvalds
Don't complain about them, they're just missing values Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-02Use 'units' value instead of guessing based on integer/FPGravatar Linus Torvalds
We still end up guessing based on magnitude of the value, though: it might be 'bar' or 'mbar', we end up picking one or the other based on just how big the value is. I should make it look at any possible explicit units too, since at least with good xml, they exist. Of course, the only good xml I've seen so far is the one we generate ourselves ;) Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-02Hack up some very rudimentary support for the Uemis xml formatGravatar Linus Torvalds
I think I'll need to re-organize the handling of per-format code, but for now we just mix it all up. The uemis conversion is also questionable even for just the small parts I do. Does it really do "centiPSI"? That sounds crazy. I'm waiting for Dirk to send me some actual human-readable output from the dives, right now some of it is just rough guesses. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01Generate 'watertemp' field from samples if requiredGravatar Linus Torvalds
Sure, it's redundant, but it's convenient for the general dive info. 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>