Commit graph

155 commits

Author SHA1 Message Date
Dirk Hohndel
dcb6574dc4 Improve deco handling and add NDL support
This commit changes the code that was recently introduced to deal with
deco ceilings. Instead of handling these through events we now store the
ceiling (which in reality is the deepest deco stop with all known dive
computers) and the stop time at that ceiling in the samples.

This also adds support for NDL (non stop dive limit) which both dive
computers that appear to give us ceiling / deco information appear to
give us as well (when the diver isn't in deco).

If the mouse hovers over the profile we now add support for displaying the
NDL, the current deco obligation and (if we are able to tell from the
data) whether we are at a safety stop.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-04 21:05:26 -08:00
Linus Torvalds
6fe52ee19e Simplify tripflags: remove tripflag_names[]
This removes the tripflag name array, since it's not actually useful.
The only information we ever save in the XML file is whether a dive is
explicitly not supposed to ever be grouped with a trip ("NOTRIP"), and
everything else is implicit.

I'm going to simplify the trip flags further (possibly removing it
entirely - like I did for dive trips already), and don't like having to
maintain the tripflag_names[] array logic.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-26 21:44:51 -07:00
Linus Torvalds
1ca1fe7994 Improve on divecomputer data handling
This simplifies the vendor/product fields into just a single "model"
string for the dive computer, since we can't really validly ever use it
any other way anyway.

Also, add 'deviceid' and 'diveid' fields: they are just 32-bit hex
values that are unique for that particular dive computer model.  For
libdivecomputer, they are basically the first word of the SHA1 of the
data that libdivecomputer gives us.

(Trying to expose it in some other way is insane - different dive
computers use different models for the ID, so don't try to do some kind
of serial number or something like that)

For the Uemis Zurich, which doesn't use the libdivecomputer import, we
currently only set the model name.  The computer does have some kind of
device ID string, and we could/should just do the same "SHA1 over the
ID" to give it a unique ID, but the pseudo-xml parsing confuses me, so
I'll let Dirk fix that up.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-25 13:05:11 -08:00
Linus Torvalds
1b861ba20e Start merging dives by keeping the dive computer data from both dives
Also, note that we do *not* do the "find_sample_offset()" any more when
we merge two dives that happen at the same time - since we just keep
both sets of dive computer data around.

But we keep the function to find the best offset around, because we may
well want to use it later when *showing* the dive, and trying to match
up the different sample data from the multiple dive computers associated
with the dive.

Because of that, this causes warnings about the now unused function.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-25 13:05:08 -08:00
Linus Torvalds
c019da8fd5 Add basic divecomputer info setup with xml parsing and saving
This also knows how to save and restore multiple dive computers in the
XML data, but there's no way to actually *create* that kind of
information yet (nor do we display it).  Tested by creating fake XML
files with multiple dive computers by hand so far.

The dive computer information right now contains (apart from the sample
and event data that we've always had):

 - the vendor and product name of the dive computer
 - the date of the dive according to the dive computer (so if you change
   the dive date manually, the dive computer date stays around)

Note that if the dive computer date matches the dive date, we won't
bother saving the redundant information in the XML file.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-25 13:04:59 -08:00
Linus Torvalds
25b4fee655 Move events and samples into a 'struct divecomputer'
For now we only have one fixed divecomputer associated with each dive,
so this doesn't really change any current semantics.  But it will make
it easier for us to associate a dive with multiple dive computers.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-23 19:36:27 -08:00
Linus Torvalds
2a78f3436c Fix the XML gps parsing and saving when using non-US locales
The GPS parsing and saving was using sscanf and sprintf respecively, and
since it is using floating point values (boo!) that affects both of
them.  In a C/US locale, we use a period for decimal values, while most
European locales use a comma.

We really should probably just fix things to use integer values (degrees
and nanodegrees?) but this is the simplest fix/workaround for the issue.

Probably nobody ever really noticed until I tested the Swedish locale
for grins, since we don't have a good way to actually set the GPS
coordinates yet.  I've got a few dives with GPS information that I
entered manually.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-19 12:03:44 -08:00
Dirk Hohndel
56f62cc4ab Store and parse salinity and surface pressure
In my excitement about extracting these from libdivecomputer I forgot to
actually store them and then parse them again. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-12 20:57:49 +01:00
Dirk Hohndel
01f1ccff14 Add support for visibility tracking and allow manual entry air temp
Turns out we had a data field for visibility as a length unit - but never
used it. I can never guess how much visibility we actually had on a dive -
but I think most everyone can assign a rating between abysmal (zero stars,
"I couldn't read my dive computer even right in front of my mask" - trust
me, I had some of those dives) to amazing ("five stars, I could see farther
than I though possible" - and I had one or two of those, too). So I
changed this to an integer and am re-using the star infrastructure we have
for the overall dive rating.

When displaying this I was dismayed that we are running out of space in
the "Dive Notes" notbook. So I moved this to the "Dive Info" notebook.
This is not consistent and not logical. I think we need to revisit the
notebooks and think about what we want to display where.

While adding the infrastructure to manually enter the visibility I went
ahead and added the ability to manually enter the air temperature as well
(that was one of the things missing in the previous commit).

Fixes #7

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-28 16:03:03 -07:00
Lubomir I. Ivanov
4f18f83ce9 Use GLib's g_fopen() and g_open() when working with files
On Windows, the GLib wrappers for fopen() and open() deal with the UTF-8
format used for file names when we have to open or save a file with
unicode characters in its name.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-04 02:43:10 -07:00
Linus Torvalds
3244a828f3 New XML format for saving dives
This patch makes the trips nest, and it also fixes the fact that you never
saved the trip notes (you could edit it, but saving would throw it away).

I did *not* change the indentation of the dives, so the trip stuff shows
up the the beginning of the line, at the same level as the <dive> and
<dives> thing. I think it's fairly readable xml, though, and we haven't
really had proper "indentation shows nesting" anyway, since the top-level
"<dives>" thing also didn't indent stuff inside of it.

Anyway, the way I wrote it, it still parses your old "INTRIP" stuff etc,
so as far as I know, it should happily read the old-style XML too. At
least it seemed to work with your xml file that already had the old-style
one (I haven't committed my divetrips, exactly because I didn't like the
new format).

It always saves in the new style, though.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-30 12:36:18 -07:00
Linus Torvalds
c4c636fb4f Fix missing save of (almost empty) cylinder information
If we have no explicit cylinder info at all (it's normal air, no size or
working pressure information, and no beginning/end pressure information),
we don't save the cylinders in question because that would be redundant.

Such non-saved cylinders may still show up in the equipment list because
there may be implicit mention of them elsewhere, notably due to sample
data, so not saving them is the right thing to do - there is nothing to
save.

However, we missed one case: if there were other cylinders that *did* have
explicit information in it following such an uninteresting cylinder, we do
need to save the cylinder information for the useless case - if only in
order to be able to save the non-useless information for subsequent
cylinders.

This patch does that. Now, if you had an air-filled cylinder with no
information as your first cylinder, and a 51% nitrox as your second one,
it will save that information as

  <cylinder />
  <cylinder o2='51.0%' />

rather than dropping the cylinder information entirely.

This bug has been there for a long time, and was hidden by the fact that
normally you'd fill in cylinder descriptions etc after importing new
dives. It also used to be that we saved the cylinder beginning/end
pressure even if that was generated from the sample data, so if you
imported from a air-integrated computer and had samples for that cylinder,
we used to save it even though it was technically redundant.

We stopped saving redundant air sample information in commit 0089dd8819
("Don't save cylinder start/end pressures unless set by hand").

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Removed start and end in save_cylinder_info(). These two variables are no
longer used.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-21 21:01:42 -07:00
Dirk Hohndel
7fa0399949 Fix dive trip saving bug
When switching the dive trips to be stored in a different data structure I
forgot to update the code in save_trip() - and since we were passing the
pointer around via a gpointer the compiler didn't catch this. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-20 15:13:18 -07:00
Linus Torvalds
dce08deb34 Use a 64-bit 'timestamp_t' for all timestamps, rather than 'time_t'
This makes the time type unambiguous, and we can use G_TYPE_INT64 for it
in the divelist too.

It also implements a portable (and thread-safe) "utc_mkdate()" function
that acts kind of like gmtime_r(), but using the 64-bit timestamp_t.  It
matches our original "utc_mktime()".

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-19 17:35:52 -07:00
Miika Turkia
ae33b5ef52 Display yearly/monthly statistics
Display yearly statistics in a statistics window with option to expand
the viewing on monthly level. The amount of dives along with basic
information like duration, depth, water temperature and air consumption
is displayed in yearly and monthly level. Thus you are able to compare
e.g. development of air consumption or diving activity from year to
year.

Using already existing macro for splitting seconds into minutes:seconds.
Moving repetitive code to a function (couldn't think of the suggested
clever macro, but this should pretty much do the trick).
Now the statistics are updated every time the process_all_dives function
is called. It might make sense to actually verify the structures need to
be re-allocated, but such optimization is currently not implemented.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>

Combined two commits.
Minor cleanups for white space and boolean values.
Significant changes to use the correct units for volumes vs. depths and to
avoid unneccesary lookups of the model storage based on the tree.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-11 07:29:06 -07:00
Dirk Hohndel
a5f894d1d3 Clean up macros and auxiliary functions
In preparation for the next stage of the trips handling this commit makes
the macros used to access trips (and some frequently used variables for
the tree and list models) more consistent.

This also changes the way we display un-grouped dives in the dive list,
i.e. dives that are not part of a dive trip. Their dive number is now
printed bold.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-01 20:45:34 -07:00
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
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
d96b504bc4 Only quote the quote characters in xml attributes
The quoting of single and double quotes is only necessary for
attributes, and is irritating for other fields in that it makes the
fields almost unreadable in the xml file.  Single quotes in particular
are common, and turning "it's" into "it&apos;s" is just not reasonable
for dive notes etc.

So add a flag to whether the xml quoting is for an attribute or not, and
take that into account.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-27 13:19:06 -07:00
Dirk Hohndel
162b69828a Add single and double quotes to escaped characters in XML output
We already escape '<', '>', and '&'. This adds the remaining two special
entities in XML: '\'' and '\"'.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-27 09:38:23 -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
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
Dirk Hohndel
52748412ff Fix some issues with star rating code
To waste less space in the tree view heading we simply put a star in the
heading instead of "Rating".

We now treat "zero stars" to mean "not rated" and don't store that value
in the XML file.

Rating is no longer a top level tag in the dive entry but instead a
property of the dive tag.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-07 20:49:22 -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
5c2fca2620 Save cylinder O2/He content after the cylinder type description
This changes the save format xml to be a bit more readable: instead of
putting the gasmix first, put the cylinder type (size, workpressure and
description) first, then gasmix, then pressure details.

It makes no difference for machine parsing, but I think it's a lot more
logical for humans that actually look at the xml file.  And we really do
want to make the xml file readable by humans.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-10 21:42:37 -02:00
Linus Torvalds
0f9d1757a4 Don't drop precision from floating point GP coordinates
Using '%f' limits the precision to 6 decimals, which may well be
perfectly ok.  But at least in theory you *could* have higher precision,
and gps units will report it, so don't mindlessly limit us to what %f
shows.

This arbitrarily uses '%.12g' instead.  %g will drop excess zeroes at
the end, so it actually results in the same (or shorter) ascii
representation unless you have the extra precision.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-09 14:19:16 +12: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
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
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
574a5b808f Don't save empty cylinder descriptions in the xml
They get created when the equipment thing doesn't have a name for the
cylinder, but we don't want to save that lack of description.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12 13:41:37 -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
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
b17c7f0709 Now that we don't mess up import, we can save the cylinder working pressure
We used to have the heuristic that if we saw a cylinder working
pressure, then the cylinder size would be in cuft.  Which meant that we
couldn't export our working pressures, because it would mess things up
on import.

But working pressure is actually nice to know, if you ever work with
cylinders in imperial units.  So now that the import is fixed, add the
working pressure to the export.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-10 15:17:33 -07:00
Linus Torvalds
067506038a Rename 'cylinder.c' as 'equipment.c'
Make it about general equipment management, and start hooking up
functions to show new equipment information when changing dives (and to
flush changes to equipment information for the previously active dive).

Nothing is hooked up yet, and it's now showing just one (really big)
cylinder choice, so this is all broken.  But it should make it possible
to at least get somewhere some day.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-09 17:10:17 -07:00
Linus Torvalds
04c98344b3 Turn dive depth, temperature and duration into xml attributes
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-05 09:48:11 -07:00
Linus Torvalds
5f79a804b9 Sanitize and fix cylinder pressure overview
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-05 09:12:54 -07:00
Linus Torvalds
d8cca5bed3 Save milli-units with variable precision
Instead of always using three decimal digits, use 1-3 digits.  But do
use at least one, even for integer numbers, just because it makes it so
much clearer that we're dealing with potential fractional values.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04 15:14:14 -07:00
Linus Torvalds
c66d60efa1 Use common helper for printing milli-units
I don't necessarily want to show three decimal digits when one or two
would do. So prepare for that by using a helper. This doesn't actually
change the printout yet.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04 15:14:14 -07:00
Linus Torvalds
85921592b0 Properly save/restore cylinder description string
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-04 15:14:14 -07:00
Linus Torvalds
f8de487c2f Make a guess at the cylinder description from the size and pressure
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-04 13:34:22 -07:00
Linus Torvalds
ecff0922d4 Don't save cylinder working pressure
It was a mistake to save it - and I did it just because other dive
managers did.  It's a totally nonsensical measure, and nobody cares.
The only thing that matters is the size of the cylinder, and the
*actual* pressures.  Those give actual air consumption numbers, and are
meaningful and unambiguous.

So the "working pressure" for a cylinder is pointless except for two
things:

 - if you don't know the actual physical size, you need the "working
   pressure" along with the air size (eg "85 cuft") in order to compute
   the physical size.  So we do use the working pressure on *input* from
   systems that report cylinder sizes that way.

 - People may well want to know what kind of cylinder they were diving,
   and again, you can make a good guess about this from the working
   pressure.  So saving information like "HP100+" for the cylinder would
   be a good thing.

But notice how in neither case do we actually want to save the working
pressure itself.  And in fact saving it actually makes the output format
ambiguous: if we give both size and working pressure, what does 'size'
mean? Is it physical size in liters, or air size in cu ft?

So saving working pressure is just wrong. Get rid of it.

I'm going to add some kind of "cylinder description" thing, which we can
save instead (and perhaps guess standard cylinders from input like the
working pressure from dive logs that don't do this sanely - which is all
of them, as far as I can tell).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04 11:34:44 -07:00
Linus Torvalds
a57668127e Oops. I forgot to 'fclose()' the file after saving the xml
It never actually triggered anything for me, but any buffered data might
be lost, especially if you force-exit the application after saving a
dive log.

This probably explains a corrupted (truncated) dive file report from
Nathan Samson.

Reported-by: Nathan Samson <https://github.com/nathansamson>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04 09:50:31 -07:00
Linus Torvalds
6fd86ab6b7 Don't bother saving n2 percentage
It's all calculated anyway, and for the same reason we don't bother even
parsing it at load time, we really shouldn't bother saving it either.

The only thing you can do with that value is "check if the percentages
add up to 100%", and so what?

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-03 20:50:11 -07:00
Linus Torvalds
b176daf6d6 Do better cylinder information management
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-03 20:31:18 -07:00
Linus Torvalds
f7fb74f3a7 Fix wrongly nested watertemp xml entry
Too much cut-and-paste: the ending tag said "airtemp".

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01 22:18:44 -07:00
Linus Torvalds
bafc7e771e We can't save escape characters.
I think it should be legal xml, but whatever.  libxml2 is very unhappy,
and complains when loading - even if I escape them.  So let's just
replace the low escape characters with '?'.

The only thing to ever care was my test-case, I suspect.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01 20:28:17 -07:00
Linus Torvalds
22fcef2ec7 Save and parse notes and locations
It's pretty rough, but it seems to work.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01 19:56:04 -07:00
Linus Torvalds
0189de695c Do gasmix as an empty element XML too
Let's make it a goal that the XML we output is pretty.  That clearly was
never a goal for the Suunto XML, but we can be oh-so-much-better than that.

I still don't love XML, but let's try to make the best of a bad situation,
and take pride in what we do.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01 17:44:13 -07:00
Linus Torvalds
c139aa8d51 Clean up save-file output a bit
Use the "empty element" form for samples that don't have any events
associated with them (and none do, right now).  This avoids that
annoying "</sample>" crud.

And output the units in the output helpers, so that you can't forget
them even if you try.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01 17:37:41 -07:00
Linus Torvalds
adc92d6de2 Always use proper units when saving.
When we see a number like 23.145, we'd better always also see a unit.
It's just good practice.  So add 'min' to duration (and use only two
digits for number of seconds), and 'm' to depth.

And write the date in international standard format.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01 17:17:19 -07:00
Linus Torvalds
1376712f0b Save everything in our current dives and samples into the xml file
Now, as we start parsing more, we just need to also add the code to save
it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01 16:59:10 -07:00
Linus Torvalds
99c111e348 Fix up small details in input/output
Be more careful with FP conversions, and with the Kelvin<->C offset.
And make sure to use the same names when saving as when parsing.

Now when we save a set of dives, then re-load them, and save again, the
second save image is identical to the first one.

Of course, we don't actually save everything we load, so we still do
lose information when we load and then save the result.  But at least we
now don't lose the information that we *do* save.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01 16:41:10 -07:00
Linus Torvalds
1155ad3f0f Add ability to 'save' dives
This just generates another xml file.  Don't get me wrong: I still don't
like xml, but this way we can save in the same format we load things
from.  Except the save-format is a *lot* cleaner than the abortion that
is Suunto or libdivecomputer xml.

Don't bother with some crazy xml library crap for saving. Just do it!

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-01 16:27:52 -07:00