Commit graph

81 commits

Author SHA1 Message Date
Linus Torvalds
c89f88378a Merge branch 'trips' of git://git.hohndel.org/subsurface
Merge the initial 'track trips explicitly' code from Dirk Hohndel.

Fix up trivial conflicts in save-xml.c due to the new 'is_attribute'
flag.

* 'trips' of git://git.hohndel.org/subsurface:
  Fix an issue with trips that have dives from multiple input files
  Some simple test dives for the trips code
  First cut of explicit trip tracking
2012-08-27 15:36:27 -07:00
Dirk Hohndel
9cf961249e Fix an issue with trips that have dives from multiple input files
The existing code didn't handle the case of different trips for the same
date coming from different sources. It also got confused if the first dive
processed (which is, chronologically, the last dive) happened to be a
"NOTRIP" dive.

This commit adds a bit of debugging infrastructure for the trip handling,
too.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-27 15:29:40 -07:00
Dirk Hohndel
e315abf645 First cut of explicit trip tracking
This code establishes the explicit trip data structures and loads and
saves them in the XML data. No attempts are made to edit / modify the
trips, yet.

Loading XML files without trip data creates the trips based on timing as
before. Saving out the same, unmodified data will create 'trip' entries in
the XML file with a 'number' that reflects the number of dives in that
trip. The trip tag also stores the beginning time of the first dive in the
trip and the location of the trip (which we display in the summary entries
in the UI).

The logic allows for dives that aren't part of a dive trip. All other
dives simply belong to the "previous" dive trip - i.e. the dive trip with
the latest start time that is earlier or equal to the start time of this
dive.

This logic significantly simplifies the tracking of trips compared to
other approaches that I have tried.

The automatic grouping into trips now is an option that defaults to off
(as it makes changes to the XML file - and people who don't want this
feature shouldn't have trips added to their XML files that they then need
to manually remove).

For now you have to select this option, then exit the program and start it
again. Still to do is to trigger the trip generation at run time.

We also need a way to mark dives as not part of trips and to allow options
to combine trips, split trips, edit trip location data, etc.

The code has only had some limited testing when opening multiple files.

The code is known to fail if a location name contains unquoted special
characters like an "'".

This commit also fixes a visual inconsistency in the preferences dialog
where the font selector button didn't have a frame around it that told you
what this option was about.

Inspired-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-27 14:32:24 -07:00
Linus Torvalds
9380f78c82 Do some whitespace cleanup
The previous commit was a patch from Lubomir, which also had some
whitespace fixes (to go with some new whitespace bugs to replace them)
in it.

I removed the whitespace changes from that patch (don't mix whitespace
fixes with other fixes, unless they are on the same lines!) but decided
to look for other whitespace issues, and this is the result.

I left the non-C files alone, some of the spec and script files also
have whitespace at the end of lines etc.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-26 14:41:05 -07:00
Dirk Hohndel
fe32e51287 Import Divesuit information from DivingLog XML file
Trivial two-liner patch

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-17 20:22:37 -07:00
Dirk Hohndel
e8ec3df371 Add exposure protection tracking
For simplicity and shortness, throughout subsurface exposure protection is
simply referred to as "suit".

Add the fields to the data structures, add the column to the dive_list
and the preferences dialog (once again with it being turned invisible by
default). Support loading and saving of the suit information.

Display the suit information in the Dive Info pane (this may be a bit
controversial as people could argue this should be in the Equipment pane)
and allow editing of the suit info, with our usual support for completion
and drop down lists to pick from.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-14 17:16:00 -07:00
Linus Torvalds
9c7aaed02a Add tankpressure parsing for UDDF files
David McNett sent me some example Cochran CAN file data, along with his
UDDF exports of same.  I still have absolutely no idea how to decode the
CAN files (although the subsurface decrypting code seems to correctly
decrypt the data, and I see binary patters rather than just noise), but
at least I can make sure we parse the UDDF portion better.

See also

  https://github.com/nugget/cochran2uddf

for David's tool to convert the Cochran CSV exports into UDDF.

Data-source: David McNett <nugget@macnugget.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-06-18 12:45:09 -07:00
Linus Torvalds
058b84cca0 Allow overriding the default xslt path
It's very annoying to have to do "make install" to test a new xslt file,
just because the default xslt path has the standard install path as the
first entry.

At the same time, we do want to default to just using the standard
install location first.

So to allow both testing, and having a nice sane default, just add
support for a SUBSURFACE_XSLT_PATH environment variable that overrides
the default one if it exists.

So then you can just do

   SUBSURFACE_XSLT_PATH=xslt ./subsurface

to run subsurface from inside the git tree itself, using the current
files in the git xslt subdirectory.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-05-12 12:53:41 -07:00
Linus Torvalds
9470f713d0 Renumber dives when deleting a dive
... but only do it if the numbering of subsequent dives was consecutive
to begin with.

Note that we do accept unnumbered dives (and will stop the sequence
check if we find one), but in order to renumber dives on delete, we
require that starting with the dive we delete, the subsequent numbered
dives have to be a nice incrementing series.  If that is the case, then
we fix up that numbering as we delete the dive.

Put another way: if the dive numbering was an incrementing sequence
before the delete, then it will be a sane incrementing sequence after it
too.  But if you had missing dives before the delete, we will turn the
delete into just another missing dive.

The basic rule is that we never renumber any dives unless that
renumbering is "obviously correct".  It's better to leave old numbers
as-is (and expect that the user is going to do an explicit re-numbering
operation) than it is to change dive numbers in a sequence that we don't
understand.

I do suspect that we should possibly check the dive number "backwards"
too, but this doesn't do that.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-04-02 22:00:29 -07:00
Linus Torvalds
1cbe2444cc Add the ugliest 'delete dive' model ever
This interface works the same way the "edit dive" menu item does: it's a
text entry meny item on the dive text entries (ie buddy/divemaster/notes
sections).  Except you pick the "Delete" entry rather than the "Edit"
entry.

It kind of works, but it really is a pretty horrible interface.  I'll
need to add a top-level dive menu entry for just deleting all selected
dives instead.  And it would be good to be able to get a drop-down menu
from the divelist instead of having to do it from the dive text entries,
which is just insane.

But that requires gtk work.  I'm not quite ready to get back into that.
Thus the "exact same insane interface as the explicit 'Edit' mode".

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-04-02 19:19:01 -07:00
Linus Torvalds
81fddfa67e Merge branch 'weight' of git://subsurface.hohndel.org/subsurface
Pull weight management from Dirk Hohndel:
 "This is the fifth or sixth version of this code, I'm begining to lose
  track.  I still struggle with the balance between code duplication and
  unnecessary indirectness and complexity.  Maybe I'm just not finding
  the right level of abstraction.  Maybe I'm just trying too hard.

  The code here is reasonably well tested.  Works for me :-)

  It can import DivingLog xml files with weight systems and correctly
  parses those.  It obviously can read and write weight systems in its
  own file format.  It adds a KG/lbs unit default (and correctly stores
  that).

  The thing I still worry about is the code in equipment.c.  You'll see
  that I tried to abstract things in a way that weight systems and
  cylinders share quite a bit of code - but there's more very similar
  code that isn't shared as my attempts to do so turned into ugly and
  hard to read code.  It always felt like trying to write C++ in C..."

* 'weight' of git://subsurface.hohndel.org/subsurface:
  Add weight system tracking

Fix up some trivial conflicts due to various renaming of globals and
simplification in function interfaces.
2012-03-23 21:07:53 -07:00
Dirk Hohndel
854bd0269c Add weight system tracking
- supports multiple weight systems per dive
- supports multiple weight system types
- supports import of weight as tracked by DivingLog

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-03-24 11:44:27 +09:00
Linus Torvalds
4d10bc017a Split up file reading from 'parse-xml.c' into 'file.c'
We're going to eventually import non-xml files too, so let's begin
splitting the logic up.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-01-26 13:00:45 -08:00
Dirk Hohndel
c544226334 Avoiding some potentially confusing name space clashes
We have local variables or function arguments with the same names as
function static variables (or in one case, function arguments).

While all the current code was correct, it could potentially cause
confusion when chasing bugs or reviewing patches. This should make things
clearer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-05 08:55:18 -08:00
Dirk Hohndel
1d6903c65a Oddly, finishing a sample doesn't require a sample
So let's not pass it around

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-05 08:16:50 -08:00
Linus Torvalds
e5b6bfc7ed Move the gasmix cleanups from XML parsing to the generic dive fixup stage
Right now we do certain cylinder info operations only when importing
from an XML file, which is wrong.  In particular, we do the "is the
gasmix air" or "what is the standard cylinder name" only at XML read
time, which means that if you import a dive directly from the dive
computer, it won't have the air sanitization or the proper default
cylinder names.

Of course, most dive computers don't actually save enough cylinder
information for us to do the cylinder name lookup anyway, but some do.
And all Nitrox-capable dive computers do have that O2 percentage that
needs cleanup too.

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-12-30 13:09:17 -08:00
Linus Torvalds
34dcc119fe parse-xml: read the file into memory separately
Using xmlParseFile() was simple, but I'm planning on extending the file
parsing past just XML, since we want to be able to import other formats
too.  And quite frankly, that means that we'll want to read the file
into memory to look at it before we start parsing it.

We could decide do it by file extensions too, and I'll look at that
approach as well, but regardless of how we do things it's almost
certainly a good idea to do the file access in one place.  The XML
parsing might as well happen from a memory buffer instead anyway.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-12-18 18:34:02 -08:00
Dirk Hohndel
af290d5eb2 Add typical 0 to 5 star rating for dives
This works ok-ish, but doesn't allow us to click on the stars and edit
them in the divelist, which a user might expect to be able to do - in
most "star rating UIs" you simply click on the n-th star to set that
rating. Here you need to edit the dive and pick the rating from a drop
down menu.

Minor oddity: you can actually (if you force it) write anything you want
into the star rating. But anything that isn't one of the predefined
strings simply results in a zero star rating.

Overall the UI feels a bit... forced. But I think this is quite useful
anyway.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-07 15:11:06 -08:00
Linus Torvalds
e5471e3fe8 Remove suunto parsing hacks from parse-xml.c
We can just depend on Miika's xslt transform instead.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-21 11:35:06 -08:00
Miika Turkia
61f3114fce XSLT to import SDM dive log
This is tested with Linus' sample data, all basic functionality seems to
be working properly. Gas changes are implemented but not tested as there
was no samples of those. Multiple cylinders are missing because there
was no samples available.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-21 11:33:52 -08:00
Miika Turkia
5a046d94ea Support for importing multiple XSLT formats
Have information of multiple XSLT files on an array for importing
"alien" formatted XML dive log files. Adding support for new XSLT
requires updating the array and adding the XSLT file (provided the
format can be identified by root element of the XML).

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-21 11:33:52 -08:00
Linus Torvalds
6fa702bcbd Make the xslt style sheet finding search a set of possible paths
This allows us to install the xslt files in multiple places.  Right now
the path defaults to the subsurface xslt install directory, the relative
directory "xslt" and the current working directory.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-05 13:51:37 -07:00
Miika Turkia
350462949d Use XSLT file to open JDiveLog logs
Open JDiveLog files by translating them to subsurface format using XSLT.
These files are identified by the name of the first element (JDiveLog)
and transform is applied to only these.

The XSLT feature is compiled in only if libxslt is installed. The
transformation files are installed globally in Linux under
/usr/share/subsurface/xslt. Windows and OSX still need appropriate Makefile
changes and testing.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-05 13:24:53 -07:00
Dirk Hohndel
485b02937d Even more places with pressure and volume conversions
Amazing at how many spots we are re-implementing the wheel.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-01 21:34:06 -07:00
Dirk Hohndel
c4691306c4 Avoid using strptime
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-24 14:36:03 -07:00
Linus Torvalds
04f372f8aa Parse the xml sample cylinder index properly
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-19 10:06:11 -07:00
Dirk Hohndel
254b851e44 Integrate loading of uemis SDA files into the regular xml parsing
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-02 22:20:29 -07:00
Dirk Hohndel
f2566ba561 First steps towards integrating SDA files into the default XML loading
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-02 22:18:41 -07:00
Linus Torvalds
9d8bdee350 We forgot to pick up the 'value' field of a dive event
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-30 21:55:51 -07:00
Linus Torvalds
2a8f7ab78f Merge branch 'otu-tracking-v2' of git://github.com/dirkhh/subsurface
* '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-27 10:46:42 -07:00
Linus Torvalds
d9ca1b6fbf Drop surface events when reading from an XML file too
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-22 20:51:03 -07:00
Linus Torvalds
3a77eb8510 Start handling dive events
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-22 18:02:54 -07:00
Dirk Hohndel
a93641b722 Calculate OTUs for every dive
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-22 16:26:38 -07:00
Dirk Hohndel
a817f4b547 Use the last (or only) filename on command line as default for saving
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-21 11:35:20 -07:00
Linus Torvalds
5804c2970e Support gps coordinates for the location info
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-15 18:16:07 -07:00
Linus Torvalds
3a6652634b Rename the project 'subsurface'
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-15 09:43:14 -07:00
Dirk Hohndel
ed4e71a817 Fix uemis depth calculation in the uemis XML importer
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-15 08:52:55 -07:00
Linus Torvalds
c6b13fad5a Add divemaster/buddy field and text entry
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-13 14:58:06 -07:00
Linus Torvalds
42f627b8b1 Libdivecomputer: start actually importing the dive data
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-12 13:25:05 -07:00
Linus Torvalds
aa416e3c96 Abstract out dive/sample allocation a bit
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-12 12:56:34 -07:00
Linus Torvalds
afffcdbc0d Avoid using type 'gasmix_t': use 'struct gasmix' instead
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-12 09:47:55 -07:00
Linus Torvalds
0282d515db Work around more Diving Log bugs..
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-11 15:49:50 -07:00
Linus Torvalds
27ed16072f Call an LP85 an LP85 even when it's "10% extra".
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-11 15:49:50 -07:00
Linus Torvalds
0c4e1697db Be more careful about unit changes
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-11 15:49:50 -07:00
Linus Torvalds
61d0aa10e1 Parse 'Diving Log' cylinder working pressure
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-11 15:49:50 -07:00
Linus Torvalds
1cc62d5811 Fix up dive number naming
Use "dive->number" instead of "dive->nr". And make the XML match too.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-11 15:49:17 -07:00
Linus Torvalds
6538e5bba0 Save and restore a "dive number"
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-11 11:36:33 -07:00
Linus Torvalds
ed4b739f5f Don't guess input cylinder size as cubic feet
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-10 15:15:40 -07:00
Linus Torvalds
05857e0a05 Start "output unit management" support
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-06 19:07:17 -07:00
Linus Torvalds
d314b05301 Minimally parse some UDDF format dives
Dive dates (at least partial parsing), depths and times.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-06 17:33:52 -07:00