aboutsummaryrefslogtreecommitdiffstats
path: root/parse-xml.c
AgeCommit message (Collapse)Author
2015-02-27Add hashes to imagesGravatar Robert C. Helling
Upon successfull reading an image file, this computes a SHA1 hash of the image and saves it with the picture tag in the log file. When a file is not successfully loaded (for example because the log was created on a different computer) we look up the hash in a dictionary that maps hashes to local file names. That dictionary (actually two for both directions), is loaded on startup and saved upon destruction of the main window. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-25Display slowness warning before opening a V2 fileGravatar Dirk Hohndel
This is somewhat invasive as aborting the XML file read requires us to report things up the recursive parsing chain. What we really need to do here is to ask the user how they want to use the data from reverse geo lookup. But for now we only warn about the fact that this can take a while. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-22Include DC information on Cobalt importGravatar Miika Turkia
Note that I use the serial number as device ID as is done with the Suunto DM5 import. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-22Ignore deleted dives on Cobalt importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-22Discard deleted dives on DM5 importGravatar Miika Turkia
I had some double profiles with slight differences in them, until I realized that this was caused by including deleted dives in the import. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-22Clean DM5 sql queryGravatar Miika Turkia
We don't use the data coming from DiveMixture so removing the join. The join did also generate extra rows of the same dive (with differing gas info). Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-22Import DC info properly from DM5 logGravatar Miika Turkia
Using serial number as device ID here for simplicity. We also need the DC info for the divecomputer tag per dive. And it seems that serial number is in SerialNumber, SourceSerialNumber or both. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-22Support for gas changes in DM5 importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-22Fix surface pressure on DM5 importGravatar Miika Turkia
Seems that DM5 uses pascal as pressure unit for surface pressure. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-19The callback function has to return 0 or sql processing failsGravatar Dirk Hohndel
Which means we report an error even if there wasn't a problem. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-19Braces are better than indentation to scope if / if / elseGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-19Use 12 liter default on DM5 importGravatar Miika Turkia
As the comment says, default to 12 liters if cylinder size is zero. This is done only when cylinder has start pressure given. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-19Support multiple cylinders on DM5 importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-17Adding more Suunto eventsGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-17Add limits to cylinder maximum pressures on DM5 importGravatar Miika Turkia
DM5 seems to have occasionally bogus data for cylinder start and end pressures. Need to validate that. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-17Hook up DiveLog importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-15parse-xml.c: remove unused variables in divinglog_place()Gravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-14Proof of concept for reverse geo locationGravatar Dirk Hohndel
When reading a pre-v3 XML file, we now do reverse geo lookups on the GPS coordinates and add the country to the dive site notes. Eventually this wants to be a tag (once we implement tags for dive sites). This is going to add quite a bit of delay when people open a V2 XML file - depending on how many distinct GPS fixes they have. In my case with 127 GPS fixes it took about 20 seconds to open the file... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-14Keep conflicting information around when converting v2 to v3 on the flyGravatar Dirk Hohndel
When reading a v2 XML or git divelog it can happen that we get multiple names for the same GPS fix or multiple GPS fixes for the same name. We'll still consolidate them to one entry, but we should not throw away the conflicting information - instead we should just add this to the notes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-14Associate existing dive site to current diveGravatar Miika Turkia
If the dive site exists, we need to associate the uuid to current dive. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13Don't force the first divecomputer to CCR just because there's po2 valueGravatar Dirk Hohndel
The existing code was bogus as it used cur_dive->dc instead of cur_dc (i.e., it always changed the first dive computer, even if the po2 was found in a different one). But fundamentally I consider this bogus. We are not doing the right thing here - some dive computer send us pO2 values that are just the calculated pO2 at a depth and NOT a setpoint, yet we pretend those are setpoints and then turn these dives into CCR dives. This needs to done differently. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13More useful debug printsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13Improve parsing of older XML files in order to auto create dive sitesGravatar Dirk Hohndel
While the existing code worked with a couple of hand crafted examples it turns out it did a poor job with most of my files. Oops. Depending on whether we find name or coordinates first, we need to identify existing sites in either case and do the right thing. The challeng here are multiple dives at the same site with slightly different GPS coordinates. If the name is read first, these all get merged into one (and we warn about the different GPS data). But if GPS gets read first, we create separate dive sites with the same name. We need a sane UI to consolidate these - but we can't completely automate this... it's possible that these ARE the same site and the GPS data is just imprecise (for example, multiple dives at the same time with GPS locations from the Subsurface companion app). The user should be able to either pick one of the GPS locations, or keep multiple (for example, different buoyes for the same site and you want to keep the different markers). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Make special backup when switching XML versionsGravatar Dirk Hohndel
Since the last few dozen commits change the format in irreversible ways and could therefore be destructive and lose data for testers of the development version, let's try to be extra careful and create "special" backup files that aren't overwritten by subsequent backups. At least this way people can go back to the previous state. Of course people using the git backend don't have to worry about this as they always can go back to any earlier save. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Fix remaining gps references when parsing XML filesGravatar Dirk Hohndel
Clearly I didn't run into these before in my testing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Improve helper functionsGravatar Dirk Hohndel
Sometimes we want to create a dive site just based on a name, sometimes we have both a name and GPS coordinates. Let's make a helper for either case. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Save and parse dive site structures to XMLGravatar Dirk Hohndel
Read and write divesite sections in the XML file. Read divelogs of version 2 and create dive site structures on the fly. Read version 3 files that have divesiteid instead of location / gps. Saves version 3 files where dives no longer have location and gps but instead refer to a divesiteid The commit contains quite a few fprintf(stderr,...) in order to allow better monitoring of the parsing / transforming of locations and gps to dive sites. This will need to be removed later. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24DLF import: Correct format for NDL/TTS/TempGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24DLF import: Parse CNS value from event to.Gravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24DLF import: Add bailout flag to GF-changed eventGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24DLF import: parse and import surfacepressureGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24DLF import: cleanup start mode decodingGravatar Anton Lundin
As i thought, only 3 bits there where dive mode. Only look at those. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24Different log record types added for DLF importGravatar Miika Turkia
The events we decode from DLF file are divided between log record types (1 through 5). Thus we need to parse the events from all of these record types. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24Add missing DLF eventsGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-22DLF import: set no_o2sensors in CCR/PSCR modeGravatar Anton Lundin
This triggers the rest of the code to treat the sensor value as our ppO2 value. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-22Set divemode to FREEDIVE now when we support thatGravatar Anton Lundin
Previous code mapped all our free dive inputs to OC, but now when we actually have a FREEDIVE divemode, we can do better. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10Refactor dctype -> divemodeGravatar Robert C. Helling
... and repair a failed rebase (sorry). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09Add more infrastructure for a separate dive tableGravatar Dirk Hohndel
This will allow us to download the dives from the dive computer into a separate table just for that purpose and not into the main dive_table. I really dislike the code that's in place that dates back to the very earliest code written for Subsurface. Dumping the dives straight into the main dive_table seems really stupid to me. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-05DLF import: Document unknown fieldsGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2015-01-05DLF import: Decode and import ceiling informationGravatar Anton Lundin
This imports the ceiling information as stopdepth, our way of showing a ceiling. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-05DLF import: Decode and import temperatureGravatar Anton Lundin
These decodings and constants makes the numbers line up perfectly with the numbers presented on wetnotes.com. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-05DLF import: Decode and import NDL and TTSGravatar Anton Lundin
The units of these values are guessed, but these values makes they match up well with the values we calculate ourself. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-05DLF import: Decode ppO2Gravatar Anton Lundin
This decodes the ppO2 value stored in the DLF files. It looks like the DiveSoft Freedom computers always stores the ppO2 value, even for OC dives. This import only stores the ppO2 value from CCR and PSCR dives, where these values comes from sensors and makes sense to store. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-05DLF import: Restructure depth decodingGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-30Record the cylinder idx on DLF gaschangeGravatar Anton Lundin
Use the new and fancy cylinder idx to record which cylinder we change to on the DLF import. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-29Parse more DLF event typesGravatar Anton Lundin
These event types and names where found by sending different data to the wetnotes.com web page. I couldn't find where the setpoint settings where stored for the SP-events, but when looking at the web page, it was clearly stating that it saw a setpoint of 0.0 bar somewhere in there. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-29Document a DLF-event type more.Gravatar Anton Lundin
This event type is found in the DLF file Robert got sent. The wetnotes application can't display files containing this event type. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-29Use GASCHANGE2 constant for DLF GASCHANGEGravatar Anton Lundin
And this encodes helium part to in the gaschange. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-29Restructure DLF sample parsingGravatar Anton Lundin
There are more event types than 1, so parse that as a unsigned char and not as a bool. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-29Verify the file header magic before importing DLFGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>