Commit graph

392 commits

Author SHA1 Message Date
Miika Turkia
f7e86b5838 Import surface event from Suunto DB
This is actually relevant information when someone surfaces
accidentally, thus we should not ignore it.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-21 08:47:19 -07:00
Miika Turkia
21d1903656 Correct dive time in DLF import
Divesoft Freedom records the dive time in count of seconds since
1.1.2000 00:00:00, not noon.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-17 13:39:26 -07:00
Tomaz Canabrava
627de38c01 Get the location information in a separate thread
This makes Subsurface usable faster for those without a good internet
connection when they are opening an older data file.

While parsing, we are only feeding an vector of locations, after the
parsing is done, we traverse the vector searching for the information on
the web.

I need to also add a way to stop if there`s no internet connection - but
this will be another patch.

Also, fixed two small memory leaks from the old imp.

[Dirk Hohndel: cleaned up the whitespace mess]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-10 11:14:20 -07:00
Dirk Hohndel
6f7e3d04cb Handle XSLT based imports correctly
XSLT conversions create V2 XML files, but we shouldn't abort when we parse
those without having the user informed about the potential slowness - all
XSLT based imports are slow, anyway.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-22 13:20:27 -07:00
Dirk Hohndel
216fa8d543 Don't crash if add_gas_switch_event() gets called with invalid index
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-20 23:28:51 -07:00
Claudiu Olteanu
dc32d447c3 Fix a memory leak in parser-xml
Free the temporary memory alocated for a cobalt location.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-24 09:46:56 -07:00
Robert C. Helling
b02bf002a6 Add hashes to images
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-27 06:29:44 +01:00
Dirk Hohndel
0ed4356fc2 Display slowness warning before opening a V2 file
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-25 10:05:37 +01:00
Miika Turkia
0f6f1c7ccf Include DC information on Cobalt import
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-22 10:02:41 -08:00
Miika Turkia
f9cb443c73 Ignore deleted dives on Cobalt import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-22 10:02:31 -08:00
Miika Turkia
44b4ae00ed Discard deleted dives on DM5 import
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-22 07:48:33 -08:00
Miika Turkia
ad5503fec5 Clean DM5 sql query
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-22 07:48:22 -08:00
Miika Turkia
27d0cd68fc Import DC info properly from DM5 log
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-22 07:47:54 -08:00
Miika Turkia
5330a612c5 Support for gas changes in DM5 import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-22 07:46:44 -08:00
Miika Turkia
a76d5fb966 Fix surface pressure on DM5 import
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-22 07:46:14 -08:00
Dirk Hohndel
6a2efd9ff6 The callback function has to return 0 or sql processing fails
Which means we report an error even if there wasn't a problem.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-19 19:52:58 -08:00
Dirk Hohndel
4682002474 Braces are better than indentation to scope if / if / else
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-19 19:47:06 -08:00
Miika Turkia
1301cb9664 Use 12 liter default on DM5 import
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-19 19:45:32 -08:00
Miika Turkia
5d18876e78 Support multiple cylinders on DM5 import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-19 19:45:25 -08:00
Miika Turkia
6c0a6af4aa Adding more Suunto events
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-17 14:07:29 -08:00
Miika Turkia
5632c0b357 Add limits to cylinder maximum pressures on DM5 import
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-17 14:07:11 -08:00
Miika Turkia
56f6df4cd8 Hook up DiveLog import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-17 14:07:01 -08:00
Lubomir I. Ivanov
7d045dd0d9 parse-xml.c: remove unused variables in divinglog_place()
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-15 13:29:44 -08:00
Dirk Hohndel
5bf86f6042 Proof of concept for reverse geo location
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-14 20:26:09 -08:00
Dirk Hohndel
57d5a40e95 Keep conflicting information around when converting v2 to v3 on the fly
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-14 18:00:35 -08:00
Miika Turkia
92f514b081 Associate existing dive site to current dive
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-14 11:37:33 -08:00
Dirk Hohndel
6dd6e90684 Don't force the first divecomputer to CCR just because there's po2 value
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-13 21:07:22 -08:00
Dirk Hohndel
1527cd0d05 More useful debug prints
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 14:45:38 -08:00
Dirk Hohndel
8c3efd2a22 Improve parsing of older XML files in order to auto create dive sites
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-13 12:42:44 -08:00
Dirk Hohndel
d4f2b72148 Make special backup when switching XML versions
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-12 23:35:52 -08:00
Dirk Hohndel
9ca600e114 Fix remaining gps references when parsing XML files
Clearly I didn't run into these before in my testing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 21:30:57 -08:00
Dirk Hohndel
cd28e88bee Improve helper functions
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-12 11:19:27 -08:00
Dirk Hohndel
4b15b9dfe9 Save and parse dive site structures to XML
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-02-12 11:19:27 -08:00
Anton Lundin
4a8e1485e1 DLF import: Correct format for NDL/TTS/Temp
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24 12:33:49 +12:00
Anton Lundin
a4e06bb68e DLF import: Parse CNS value from event to.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24 12:33:42 +12:00
Anton Lundin
87153cefaa DLF import: Add bailout flag to GF-changed event
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24 12:33:38 +12:00
Anton Lundin
f0e68137d7 DLF import: parse and import surfacepressure
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24 12:33:32 +12:00
Anton Lundin
bc3b56a969 DLF import: cleanup start mode decoding
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-24 12:33:23 +12:00
Miika Turkia
9c4a4cb9f8 Different log record types added for DLF import
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-24 07:09:05 +12:00
Miika Turkia
f45602f4f8 Add missing DLF events
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24 07:08:54 +12:00
Anton Lundin
8997fc88a3 DLF import: set no_o2sensors in CCR/PSCR mode
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-22 06:26:49 +12:00
Anton Lundin
e0c0ba4836 Set divemode to FREEDIVE now when we support that
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-22 06:02:34 +12:00
Robert C. Helling
e219bc70f8 Refactor dctype -> divemode
... 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-10 17:27:25 -08:00
Dirk Hohndel
6f25713408 Add more infrastructure for a separate dive table
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-09 15:06:18 -08:00
Anton Lundin
48b091c369 DLF import: Document unknown fields
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2015-01-05 14:09:48 -08:00
Anton Lundin
ea7f861d3d DLF import: Decode and import ceiling information
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-05 14:08:55 -08:00
Anton Lundin
ac6e84c4fd DLF import: Decode and import temperature
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-05 14:08:42 -08:00
Anton Lundin
11542d84f7 DLF import: Decode and import NDL and TTS
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-05 14:08:06 -08:00
Anton Lundin
5e56bbf2aa DLF import: Decode ppO2
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-05 14:07:54 -08:00
Anton Lundin
6f3ef2a964 DLF import: Restructure depth decoding
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-05 14:07:38 -08:00
Anton Lundin
da42b0b79d Record the cylinder idx on DLF gaschange
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-30 08:29:00 -08:00
Anton Lundin
46f4dbf93d Parse more DLF event types
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-29 16:22:06 -08:00
Anton Lundin
aad1fbcf56 Document a DLF-event type more.
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-29 16:21:50 -08:00
Anton Lundin
eda1234621 Use GASCHANGE2 constant for DLF GASCHANGE
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-29 16:21:33 -08:00
Anton Lundin
ab208c8fef Restructure DLF sample parsing
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-29 16:21:23 -08:00
Anton Lundin
ed91a6373c Verify the file header magic before importing DLF
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-29 09:25:13 -08:00
Anton Lundin
123b104d09 Add the dive start DLF event type
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-28 20:31:41 -08:00
Anton Lundin
c2be872f49 Parse info from the DLF header
After some reverse-engineering i managed to figure out a couple of
values stored in the dive header.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-28 20:31:14 -08:00
Anton Lundin
c5467b0d73 Parse time on only one place in DLF import
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-28 20:19:24 -08:00
Anton Lundin
e86d298734 Switch to using unsigned char in DLF import
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-28 20:19:19 -08:00
Dirk Hohndel
542ff7fc36 Fix compiler warning: parse_dlf_buffer needs to return 0 on success
Simply running off the end of a non-void function isn't nice.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-28 06:51:28 -08:00
Miika Turkia
eab52183a8 Set dive_table for Divesoft import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-28 06:43:14 -08:00
Miika Turkia
b000e1b591 Support gaschange events on Divesoft Freedom import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-28 06:42:49 -08:00
Miika Turkia
ce1f69f025 Initial support for Divesoft Freedom
This parses the dive profile from Divesoft Freedom log file. Only the
depth profile is currently supported. There is also something wrong as
the log file cannot be given as parameter but must be opened or imported
once Subsurface is running. Note that so far no metadata is parsed.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-28 06:41:21 -08:00
Miika Turkia
1e04aec7fd Preconfigured import of Subsurface CSV log file
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-26 08:43:43 -08:00
Miika Turkia
7ab71604ec Improve error messages on database imports
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-20 11:30:57 -08:00
Miika Turkia
028b937034 Import location from Cobalt DB
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-20 11:29:46 -08:00
Miika Turkia
f8fc3b9236 Remove placeholder location and buddy fields
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-20 11:29:42 -08:00
Miika Turkia
61002381e9 Stub for collecting visibility on Cobalt DB import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-20 11:29:37 -08:00
Miika Turkia
82dea858eb Add buddy support to Cobalt DB import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-20 11:29:32 -08:00
Miika Turkia
066e95bd38 Fix maximum depth on Cobalt import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-20 11:29:26 -08:00
Miika Turkia
ff81672bd8 Include cylinder information in Cobalt import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-20 11:29:14 -08:00
Miika Turkia
3be4aa47b5 Bare implementation of Cobalt Divelog Program
This implements importing of dive profile and temperature graph along
with some meta data from a Cobalt Divelog database.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-20 11:28:57 -08:00
Dirk Hohndel
d9be07670c Don't ignore when we can't parse a file
We are quite inconsistent when it comes to reporting back errors.
One case where this caused somewhat unexpected behavior was when the
user would try to open a .csv file by passing it as command line
argument. The file was silently ignored, but treated as if it had been
opened successfully.

Now we issue a somewhat reasonable error message.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-08 11:28:23 -08:00
Miika Turkia
7bc5a62ca1 Fix DM4/DM5 import
The implementation of import for DM5 removed the profileBlob from SQL
query, thus breaking the backward compatibility on import of old dives.
Need to have bot profile and sample blobs within the query...

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-04 16:27:08 -06:00
Miika Turkia
65432a1f6c Parse converted DM4 logs on DM5 import
"Converted" DM4 logs are not actually converted, only the database
structure is updated. According to Rainer we should be able to read the
dive profile from the old format in this case.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-03 11:03:03 -08:00
Miika Turkia
5adc3d2cfd Fix crash with converted DM5 log
If DM4 log file is converted to DM5, the sampleBlob is empty.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-03 11:02:58 -08:00
Miika Turkia
299133d7b1 Remove unused variables
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-18 06:08:41 +00:00
Miika Turkia
c7f803b878 Limit pressure and temperature values
Limit temperatures and cylinder pressures to somewhat sensible values.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-18 06:08:37 +00:00
Dirk Hohndel
1739042f34 Use cylinder use helper function
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17 13:52:22 +00:00
Robert C. Helling
0d7c192e6e For CCR dives, the diluent cylinder is the current cylinder
Change the meaning that _the_ cylinder (as we treat it in OC dives) is the
diluent cylinder (rather than the O2 cylinder). This eliminates special
cases. Now, for CCR, we have to handle the O2 cylinder in addition
(rather than the diluent in addition).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17 11:45:06 +00:00
Dirk Hohndel
23304f69c0 Load and save the dc type for CCR dives
Oddly we already had code to load this from XML, but nothing else.
This makes the load from XML work like the rest of our code and adds the
save to XML plus the load and save for the git format.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-16 23:20:39 +00:00
Dirk Hohndel
202c5cbfeb Save CCR cylinder use in XML and git
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-16 22:13:12 +00:00
Miika Turkia
5807e4589f Initial support for Suunto DM5 import
This implements import from Suunto DM5 database, but there is something
wrong with some of the sample dives in the database I received as
sample. It seems that we should detect missing/bogus data and treat it
properly as divelogs.de does with the same dives. Anyway, when we have
proper data, this import appears to produce sensible results.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-15 08:15:15 -08:00
Dirk Hohndel
d6b4109409 Load and save extra data in Subsurface XML format
Includes test dive to test missing attributes and the overall syntax.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07 12:59:15 -08:00
Miika Turkia
70d4b25146 Fix reading of CDATA elements
If the element we are parsing is of type XML_CDATA_SECTION_NODE, we have
to check the node's name from the parent.

Fixes #718

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-28 07:25:29 -07:00
Dirk Hohndel
71826cf776 Make the buffers const char *
Addresses a warning, but also seems more correct.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-26 20:37:12 -07:00
Miika Turkia
8fcc074b49 Support for importing Poseidon MK6 logs
This patch adds support for importing the logs from a Poseidon MK6
rebreather. This DC produces logs that contain of a .txt file that has
all the meta data and a .csv file that contains the sample readings. The
CSV file is different from the others in that it has a line per each
sample reading at given time. Thus we have to merge all the lines from
one point in time into one sample reading of ours.

[Dirk Hohndel: addressed some compiler warnings]

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-26 20:33:50 -07:00
Robert C. Helling
d42b07a30a Set dctype of dives with pO2 setpoint information to CCR.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-22 06:14:24 -07:00
Robert C. Helling
5f44fdd9cf Make planner work again for CCR dives
The latest CCR patches had rendered the planner not usable for CCR dives.
This patch corrects this (and reenables the CCR set point column for
segments). The problem was that a new member setpoint of struct divepoint
had been introduced, but there was already po2 which had the same meaning.
This patch merges the two and renames them setpoint to prevent future
confusion.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-19 07:07:07 -07:00
Linus Torvalds
df4e26c875 Start sanitizing gaschange event information
Decode the gasmix data into a sane format when creating the event, and
add the (currently unused) ability to specify a gas change to a
particular cylinder rather than (or in addition to) the gasmix.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12 07:45:37 -04:00
willem ferguson
46bb02e8fc CCR patch: Import and store oxygen sensor data
This patch allows the importing of oxygen sensor and setpoint data from
Poseidon CCR dive logs.
1) Change parse-xml.c to read up to three oxygen sensor values from xml.
   and to store the information in sample structures
2) Change parse-xml.c to read o2 setpoint values fro xml and to store
   it in sample structures
3) Change dive.c to delete all sensor and setpoint values where
   subsequent samples have sensor/setpoint values that are the same.
4) Change profile.c to store the sensor/setpoint values from the samples
   into plotinfo.
5) Change the sample Poseidon xml log in the dives directory to ensure
   the correct order and hierarchy of the dive and divecomputer nodes.

[Dirk Hohndel: minor cleanup, removed debug code, whitespace]

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-11 07:12:04 -04:00
willem ferguson
d1c521ce5e CCR patch: adapt code for diluent cylinder pressures (3)
This patch implements the cylinder pressure calculations for diluent
gas in CCR dive computers. This is the third patch for achieving this.
The following were performed:

1) Add two lines to try_to_fill_sample() in parse-xml so that
   diluent cylinder pressures are stored from XML dive log file
   into structures of sample.
2) Add one line to populate_plot_entries() in profile.c so that
   the diluent cylinder pressures are copied from structures of
   sample to structures of plot_info.
3) add three constant #defines in profile.h
4) change populate_pressure_information() in gaspressures.c in
   order to take into account pressure calculations for the
   diluent cylinder, calling subordinate functions in the
   appropriate way.
5) change create_plot_info_new() in profile.c in order to initiate
   the pressure calculations for the diluent cylinder.
6) Implement two debugging functions (one in profile.c, another
   in gaspressures.c). These debugging functions are activated
   by means of #defines.

Two function calls dealing with oxygen pressure are currently commented
out.  They will be activated in the following patch that attends to CCR
oxygen partial pressure calculation.

[Dirk Hohndel: rather massive whitespace cleanup]

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-09-11 08:32:10 -07:00
Robert C. Helling
9bf6100aa7 Accept negative pressure readings
Sometimes the planner can produce negative pressures (i.e. when the
cylinders are not properly configured) or when the usser ignored
gas management (for whatever reason). When such a dive gets saved and
reread we should not display a further "Strange pressure reading"
warning on the command line.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-17 08:10:42 -07:00
Miika Turkia
7bbe71ff33 Detect proper event type based on helium content
Select proper SAMPLE_EVENT_GASCHANGE "version" based on helium content
on the mix.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-12 08:05:09 -07:00
Miika Turkia
97597dfd97 Add type for gaschange events, if missing
Subsurface has saved gas change events without type attribute at some
point. Thus we need to add the type when reading in log files, if it is
missing. (Gas change logic relies on the type field nowadays.)

Fixes #617
Fixes #600

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-12 08:04:55 -07:00
Anton Lundin
848a5352c7 Add support divecomputer based TTS
Since earlier have we had support for our own calculated TTS. This adds
support for holding TTS values reported by a dive computer.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09 13:22:00 -07:00
Dirk Hohndel
f297d9f91e Fix picture loading
Signed vs unsigned comparisons are such a pain. Since we want offsets to
be +/- 30 minutes around the dive we need to allow negative offsets - but
duration_t was defined as uint32_t.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-08 12:29:06 -07:00
Henrik Brautaset Aronsen
630ec88dd4 Be more consistent in partial pressure naming
Lets just use pO₂ instead of PO2, ppO2, ppO₂, PO₂.
They all mean the same, but it's better to be
consistent

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-23 06:48:54 +08:00
Dirk Hohndel
0c8dbc2061 Simplify code
Since trimspace() null terminates the string, we can simply use strdup()
here.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-11 19:02:49 -07:00