This XSLT imports the UDDF logs that I have received samples of. This
includes kenzooid and Heinrichs Weikamp's DR5.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Commit 28aba5a206 ("Flesh out the UDDF xml parsing a bit more")
improved on parsing UDDF files by teaching "percent()" to also handle
pure fractions like UDDF uses. So in a UDDF file, an o2 value of "1.0"
means "100%".
But it turns out that I have a few dives with "1% He", and the "Turn
fractions into percent" logic also turns that into 100%.
So this makes the 'percent()' function a bit smarter. If it actually
finds a percentage-sign after the number, it knows it is already
percent, not a fraction. That disambiguates the two cases: "1.0" is
100%, but "1.0%" (note the explicit percentage sign) is 1%.
So now our native format cannot get confused, because it generally
tries to avoid naked numbers. Good choice.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This uses the example UDDF file from Jan Schubert's Heinrichs Weikamp
DR5 dives, and now parses the dive dates, the cylinder mixes and the gas
switch events correctly (or at least partially).
It's not perfect: the gas mix has an "id" field that we ignore, and
instead we just depend on the cylinders being in order (which they seem
to be). And I have rather limited test-cases, so maybe something else
is messed up too. But for the six example dives I have, this gives
reasonable data.
Test-data-by: Jan Schubert <Jan.Schubert@gmx.li>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
test_xslt_transforms():
xmlGetProp uses strdup(), so we have to clear the memory if a pointer
is returned.
xmlFree() doesn't seem very portable (strangly enought), so we
use free(..) directly.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This XSLT converts divelogs.de logs into Subsurface format. Data that is
discarded: weather, water visibility, boat name.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We now load and save this in the XML file, we do the right thing when
merging dives and show the edited air temperature in the Dive Info
notebook when a divecomputer doesn't have an air temperature.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Making sure the XSL transformation does not occur on Subsurface's old
XML format. A deeper inspection on the XML content is required as
MacDive and Subsurface (old format) have the same root element (dives).
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This XSLT converts MacDive logs into Subsurface format. It supports both
the current version and the upcoming version of the log format.
Conversion was not tested with Imperial units as no samples were
available of such logs. Thus functionality with Imperial units is not
guaranteed.
Note that the gear inventory is currently discarded.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
MacDive use "o2percent" in its XML export
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This only changes the infrastructure and actually loses functionality as
it no longer does the simplistic "just treat the locations as dives and
merge them".
The new code that does something "smart" with the gps_location_table is
yet to be written. But now we can use the XML parser to put the gps
locations downloaded from the webservice into their own data structure.
In the process I noticed that we never used the two delete functions in
parse-xml.c and removed them.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The "visibility" value in MacDive XML files could be a random
string, while it's a value of 0-5 in Subsurface. Importing an
illegal value (such as "11m") resulted in a segfault from
libpangocairo and an "Invalid UTF-8 string passed to
pango_layout_set_text()".
[Dirk Hohndel: fixed int * vs. int issue]
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
They happen for CDATA content, where libxml2 turns the CDATA fields into
a child of the parent entry, but without a name.
Now, of course, any sane person would just want to use the CDATA as the
string value of the parent itself, but libxml2 probably does this
insanity for a reason. And the reason is probably that some misguided
people want to *write* XML using libxml2, and then the stupid child node
actually acts as a "now I want you to write this data as CDATA".
Whatever the reason, let's just ignore it. We will just traverse such a
nameless child and be happy, and we'll give the nameless child the name
of the parent. Our XML node matching logic will then never see this
insane nameless child at all, and doesn't have to care.
Our whole XML parsing rule-of-thumb is to take the whole "be strict in
what you output, but generous in what you accept" to its logical
conclusion. Because we will literally accept almost anything, in any
format. You can mix tags or attributes wildly, and youc an use CDATA or
not as you see fit. We just don't care.
We're the honeybadger of the divelog world.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Are they ugly and insane tags? Yes. Are they used? Bingo. MacDive uses
this lovely format for specifying dive site location.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Not that we aren't already insanely permissive in parsing just about any
random noise that could _possibly_ be construed as xml and turn it into
a dive, this makes us even laxer.
If somebody wants to have a <date> tag with both date and time, why the
heck not? It's fine. And if it has just the date, that's fine too. And
the date can be in any of several formats. We really don't care, the
more permissive, the better.
We strive to always write beautiful xml, but let's face it, not
everybody else does. If we can turn random line noise into a dive, we
should do so.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This centralizes all occurrences of Kelvin to dive.h and standardizes all
usages to milliKelvin.
[Dirk Hohndel: renamed the constant plus minor white space cleanup]
Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The webservice output uses 'name' as the tag for the dive location. This
was added to the parser as unqualified tag and without this change
test24.xml was suddenly recognized as a dive (the parser was triggering on
the program 'name' attribute). Name should only be recognized as a dive
location if it is indeed a child of dive.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We save the (more complete) dive computer information in the XML file
with serial numbers and firmware version if we know about them, so using
a complicated string in the system config was redundant and confusing.
So remove that code.
NOTE! Since the dive computer nicknames are now only saved if the XML
file is saved, we also mark the dive list "changed" when we edit the
nicknames. That way we'll be prompted to save things before exiting,
even if we don't actually edit any actual dive data.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We had various hacky historical artifacts in our XML parsing, partly
from our legacy of parsing integer and floating point data separately
(we used to recognize certain import format differences based on whether
the data was in a floating point or integer format). And partly from
trying to do a good job of importing crap from other dive log software.
Anyway, that actually meant that we refused to parse negative numbers,
and we ignored temperatures of zero because some diving log would do
that for missing values.
Both of these actually bit us when parsing our native XML. Of course,
only crazy ice divers would ever notice.
Noticed by Henrik Brautaset Aronsen.
Reported-acked-and-tested-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This moves the fields 'duration', 'surfacetime', 'maxdepth',
'meandepth', 'airtemp', 'watertemp', 'salinity' and 'surface_pressure'
to the per-divecomputer data structure. They are filled in by the dive
computer, and normally not edited.
NOTE! All actual *use* of this data was then changed from dive->field to
dive->dc.field programmatically with a shell-script and sed, and the
result then edited for details. So while the XML save and restore code
has been updated, all the displaying etc will currently always just show
the first dive computer entry.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Dive locations marked (and named) via the companion app are downloaded
from the webservice, parsed and merged with the existing dives.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch centralizes the definition for surface pressure, oxygen in
air, (re)defines all such values as plain integers and adapts calculations.
It eliminates 11 (!) occurrences of definitions for surface pressure and
also a few for oxygen in air.
It also rewrites the calculation for EAD, END and EADD using the new
definitons, harmonizing it for OC and CC and fixes a bug for EADD OC
calculation.
And finally it removes the unneeded variable entry_ead in gtk-gui.c.
Jan
Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
.. and rename the badly named 'output_units/input_units' variables.
We used to have this confusing thing where we had two different units
(input vs output) that *look* like they are mirror images, but in fact
"output_units" was the user units, and "input_units" are the XML parsing
units.
So this renames them to be clearer. "output_units" is now just "units"
(it's the units a user would ever see), and "input_units" is now
"xml_parsing_units" and set by the XML file parsers to reflect the units
of the parsed file.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It turns out that the serial number returned by libdivecomputer isn't
really the serial number as interpreted by the vendor. Those tend to be
strings, but libdivecomputer gives us a 32bit number.
Some experimenting showed that for the Suunto devies tested the serial
number is encoded in that 32bit number:
It so happens that the Suunto serial number strings are strings that have
all numbers, but they aren't *one* number. They are four bytes
representing two numbers each, and the "23500027" string is actually the
four bytes 23 50 00 27 (0x17 0x32 0x00 0x1b). And libdivecomputer has
incorrectly parsed those four bytes as one number, not as the encoded
serial number string it is. So the value 389152795 is actually hex
0x1732001b, which is 0x17 0x32 0x00 0x1b, which is - 23 50 00 27.
This should be done by libdivecomputer, but hey, in the meantime this at
least shows the concept. And helps test the XML save/restore code.
It depends on the two patches that create the whole "device.c"
infrastructure, of course. With this, my dive file ends up having the
settings section look like this:
<divecomputerid model='Suunto Vyper Air' deviceid='d4629110'
serial='01201094' firmware='1.1.22'/>
<divecomputerid model='Suunto HelO2' deviceid='995dd566'
serial='23500027' firmware='1.0.4'/>
where the format of the firmware version is something I guessed at,
but it was the obvious choice (again, it's byte-based, I'm ignoring
the high byte that is zero for both of my Suuntos).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Having two spots to toggle autogroup had always been a clear sign of
insanity. The inconsistent ludicrous semantic of when we remembered the
state of autogroup was even worse.
This finally gets rid of that disaster and drops the autogroup setting
from the preferences and makes it instead a per file property. When you
save a file, it saves the state of the autogroup toggle. This seems much
more useful - you may have files where you want to create trips by
default. And others, where you don't.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This clarifies/changes the meaning of our "cylinderindex" entry in our
samples. It has been rather confused, because different dive computers
have done things differently, and the naming really hasn't helped.
There are two totally different - and independent - cylinder "indexes":
- the pressure sensor index, which indicates which cylinder the sensor
data is from.
- the "active cylinder" index, which indicates which cylinder we actually
breathe from.
These two values really are totally independent, and have nothing
what-so-ever to do with each other. The sensor index may well be fixed:
many dive computers only support a single pressure sensor (whether
wireless or wired), and the sensor index is thus always zero.
Other dive computers may support multiple pressure sensors, and the gas
switch event may - or may not - indicate that the sensor changed too. A
dive computer might give the sensor data for *all* cylinders it can read,
regardless of which one is the one we're actively breathing. In fact, some
dive computers might give sensor data for not just *your* cylinder, but
your buddies.
This patch renames "cylinderindex" in the samples as "sensor", making it
quite clear that it's about which sensor index the pressure data in the
sample is about.
The way we figure out which is the currently active gas is with an
explicit has change event. If a computer (like the Uemis Zurich) joins the
two concepts together, then a sensor change should also create a gas
switch event. This patch also changes the Uemis importer to do that.
Finally, it should be noted that the plot info works totally separately
from the sample data, and is about what we actually *display*, not about
the sample pressures etc. In the plot info, the "cylinderindex" does in
fact mean the currently active cylinder, and while it is initially set to
match the sensor information from the samples, we then walk the gas change
events and fix it up - and if the active cylinder differs from the sensor
cylinder, we clear the sensor data.
[Dirk Hohndel: this conflicted with some of my recent changes - I think
I merged things correctly...]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit makes deco handling in Subsurface more compatible with the way
libdivecomputer creates the data. Previously we assumed that having a
stopdepth or stoptime and no ndl meant that we were in deco. But
libdivecomputer supports many dive computers that provide the deco state
of the diver but with no information about the next stop or the time
needed there. In order to be able to model this in Subsurface this adds an
in_deco flag to the samples. This is only stored to the XML file when it
changes so it doesn't add much overhead but will allow us to display some
deco information on dive computers like the Atomic Aquatics Cobalt or many
of the Suuntos (among others).
The commit also removes the old event based deco code that was commented
out already. And fixes the code so that the deco / ndl information is
stored for the very last sample as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
parse-xml.c:
Instead of always allocating a buffer when parsing a node, only
do so for "strings" in the utf8_string() function. Also move the
whitespace trimming of node contents in there.
This change also requires that most parsing functions don't
free the passed buffer, as it will be part of memory allocated
by libxml2.
visit_one_node(), now also has a xmlIsBlankNode() check, where if
1 is returned, the node contains only whitespace or is empty and should
not be processed.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
parse-xml.c:
When parsing events, we allocate memory for the event 'name' attribute,
but also have to free this memory eventually. Let's do that in event_end()
right after add_event() is called.
Fixes a long-running memory leak in the parser.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We only store the model/deviceid/nickname for those dive computers that
are mentioned in the XML file. This should make the XML files nicely
selfcontained.
This also changes the code to consistently use model & deviceid to
identify a dive computer. The deviceid is NOT guaranteed to be collision
free between different libdivecomputer backends...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Having it there with the model information seemed to make sense but on
second thought it's the wrong spot to keep that information, especially
since we were storing it in the XML file in every single dive.
This change removes the nickname member from the divecomputer and makes
the rest of the code reasonably self consistent. It does not add much of
the new code for the new design to handle nicknames.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Miika's xslt patch creates correct XML data without divecomputer entries.
What happens is that the stop information at xml parse time is only
cleared by the divecomputer entries, so if the XML lacks them, we will
bleed stop data from one dive to the next.
This patch makes sure that the deco/ndl information is cleared even if the
dive has no divecomputer entry.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We maintain a list of dive computers that we know about (by deviceid) and
their nicknames in our config. If the user downloads dive from a dive
computer that we haven't seen before, we give them the option to set a
nickname for that dive computer. That nickname is displayed in the profile
(and stored in the XML file, assuming it is not the same as the model).
This implementation attempts to make sure that it correctly deals with
utf8 nicknames.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I foolishly changed visible_columns in both the (ill-named) cns branch and
master...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Conflicts:
divelist.c
gtk-gui.c
profile.c
Now we can simply remember the state of all the preferences at the
beginning of preferences_dialog() and restore them if the user presses
'Cancel'.
Fixes#21
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds the new members to the sample structure and fills them from
supported dive computers (Uemis SDA and OSTC / Shearwater Predator,
assuming you have libdivecomputer 0.3).
Save relvant values of this to the XML file and load it back. Handle the
new fields when merging dives.
At this stage we don't DO anything with this, all we do is extract them
from the dive computer, save them to the XML file and load them back.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This actually makes us internally use 'micro-degrees' for latitude and
longitude, and we never turn them into floating point either at parse
time or save time.
That said, the Uemis downloader internally does still use atof() when
converting things, which is likely a bug (locale issues and all that),
but I'll ask Dirk to check it out.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
This was necessary for the Uemis downloader when we used the SDA file
format as intermediary data format and imported that as XML buffer.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The downloader has been integrated into Subsurface for a while and with
the recent change to no longer have it create the old style SDA files as
intermediary format there is no need anymore to support that format in the
XML parser.
This deletes almost 300 lines of code. Yay!
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
It had become a write-only field (apart from some now useless debugging)
when simplifying the remove_autogen_trips() function.
So remove it.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
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>
We used to avoid some extra allocations by just allocating the dive
samples as part of the 'struct dive' allocation itself, but that ends up
complicating things, and will make it impossible to have multiple
different sets of samples (for multiple dive computers).
So stop doing it. Just allocate the dive samples array separately.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When this was first implemented the assumption was that a downloaded dive
that is to be merged with an existing dive would have the same time stamp.
But as Linus pointed out even back then, this does fail if a dive has been
merged with a download from a different dive computer before (think:
download from computer a, then download same dive from b, then improve
something in the parsing from computer a and try to redownload; the time
stamp could have changed).
This commit also fixes a silly omission in the merge_dives() function
(which ended up ALWAYS prefering the downloaded dive) and finally
implements the necessary changes to mark dives downloaded from a Uemis SDA
as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
This adds a couple of helper functions to manage dive trips
("add_dive_to_trip()" and "remove_dive_from_trip()") and makes those
functions do the trip statistics maintenance (trip beginning times,
number of dives, etc).
This was needed because the dive merge cases for multiple dive
computers showed some rather nasty special cases: especially if the
new dive information has been loaded into an XML file with trips
auto-generated, merging several of these kinds of xml files with
multiple dives in several overlapping trips would completely confuse
our previous code.
In particular, auto-generated trips that had the exact same date as
previous trips (because they were generated from the same dive
computer) really confused the code that used the trip timestamp to
manage the trips.
Adding the helper functions allows us to get the general case right
without having to have each piece of code that handles trip
information having to bother about all the odd rules. It will
eventually also allow us to make the dive trip data structures more
logical: right now the dive trip list is largely designed around the
odd gtk model handling, rather than some more higher-level conceptual
relationship with the actual dives.
But for now, this keeps all the data structures unchanged, and just
modifies them using the new helper functions.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The default filename handling is broken in two different ways:
(a) if we start subsurface with a non-existing file, we warn about
the inability to read that file, and then we exit without setting the
default filename.
This is broken because it means that if the user (perhaps by mistake,
by pressing ^S) now saves the file, he will overwrite the default
filename, even though that was *not* the file we read, and *not* the
file that subsurface was started with.
So just set the default filename even for a failed file open.
The exact same logic is true of a failed parse of an XML file that we
successfully opened. We do *not* want to leave the old default
filename in place just because the XML parsing failed, and possibly
then overwriting some file that was never involved with that failure
in the first place. So just get rid of all the logic to push the
filename saving into the XML parsing layer, it has zero relevance at
that point.
(b) if we do replace the default filename with a NULL file, we need
to set that even if we cannot do a strdup() on the NULL.
This fixes both errors.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
This adds a few fields that we parse, but more importantly it also tries
to dynamically decide if the sample temperatures and pressures are in
imperial or metric units.
Dirk suspects that DivingLog generally always does everything in metric,
and the reason why he has crazy sample data in imperial units (both for
pressure and temperature) may be due to a bug in the early Uemis
importer for DivingLog.
Which would actually make a lot more sense than DivingLog really being
so insane on purpose.
Anyway, Dirk's brother Jurgen seems to have everything in metric units,
which would be much saner. Maybe we should throw away the support for
insane DivingLog files entirely, since it is possible that the only use
ever of the possible source of that bug was Dirk's use of the Uemis
importer.
But for now, we end up just guessing. Current guesses:
- water temperature is below 32 dgC, so 32+ degrees is in Fahrenheit.
- tank pressures are below 400 bar, so higher values than that must be
psi.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is just the first step - convert the string literals, try to catch
all the places where this isn't possible and the program needs to convert
string constants at runtime (those are the N_ macros).
Add a very rough first German localization so I can at least test what I
have done. Seriously, I have never used a localized OS, so I am certain
that I have many of the 'standard' translations wrong. Someone please take
over :-)
Major issues with this:
- right now it hardcodes the search path for the message catalog to be
./locale - that's of course bogus, but it works well while doing initial
testing. Once the tooling support is there we just should use the OS
default.
- even though de_DE defaults to ISO-8859-15 (or ISO-8859-1 - the internets
can't seem to agree) I went with UTF-8 as that is what Gtk appears to
want to use internally. ISO-8859-15 encoded .mo files create funny
looking artefacts instead of Umlaute.
- no support at all in the Makefile - I was hoping someone with more
experience in how to best set this up would contribute a good set of
Makefile rules - likely this will help fix the first issue in that it
will also install the .mo file(s) in the correct place(s)
For now simply run
msgfmt -c -o subsurface.mo deutsch.po
to create the subsurface.mo file and then move it to
./locale/de_DE.UTF-8/LC_MESSAGES/subsurface.mo
If you make changes to the sources and need to add new strings to be
translated, this is what seems to work (again, should be tooled through
the Makefile):
xgettext -o subsurface-new.pot -s -k_ -kN_ --add-comments="++GETTEXT" *.c
msgmerge -s -U po/deutsch.po subsurface-new.pot
If you do this PLEASE do one commit that just has the new msgid as
changes in line numbers create a TON of diff-noise. Do changes to
translations in a SEPARATE commit.
- no testing at all on Windows or Mac
It builds on Windows :-)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Only files that are opened should be considered r/w. Files that are
imported should be treated as if they were r/o.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
Merge the dive trip rewrite by Dirk Hohndel.
This just merges the dive trip changes with the timestamp handling
changes. There were multiple small data conflicts, along with some
newly added 'time_t' cases in the dive trip handling that needed to be
converted to 'timestamp_t' along the way.
* 'divetrip-rewrite' of git://github.com/torvalds/subsurface:
Convert FIND_TRIP into function
Partial rewrite of the dive trip code
Check if trip is NULL before calling DIVE_TRIP
This introduces a new data structure for dive trips - reuseing the struct
dive just got way too messy.
The dive_trip_t datastructure now allows the code to remember if the trip
was auto generated or if its time stamp changed when dives where added to
the trip during auto generation.
The algorithm also distinguishes between dives that were intentionally
added to a trip (either in an XML file or by adding them to trip in the
UI) and dives that were added to trips via autogen. Saving dives that were
added to trips via autogen makes that assignment "intentional".
With this partial rewrite several of the oddities of the old code should
be resolved - especially turning autogen on and off again should get the
divelist back to the previous stage.
Also, when dives are merged during file open or import we now try to pick
the correct tripflag (instead of just ignoring the tripflag completely and
resetting it to TF_NONE by mistake).
Finally, the dive trip debugging code got more verbose and is trying
harder to detect issues at the earliest time possible.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
Previously we could end up with a bogus dive with all zero data in it.
Adding dives/test24.xml to be able to test that we handle this case
correctly.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Previously we always picked the last file that was openend as the file
name to save to. That seems counterintuitive when importing files or when
opening multiple files. Especially if Subsurface was executed without a
file on the command line and we are using the default file.
Now we only remember a file name if it was the first one to ever be
openend or if it was used in save-as.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Pull trip manipulation branch from Dirk Hohndel:
"I have added yet more of the requested features.
I am not aware of any outstanding bugs or crashes (except for the Gtk
problem that causes the import to crash for some people on Ubuntu and
MacOS - but as I mentioned earlier, that bug has been around as long
as the import file selector box)."
* 'trip3' of git://git.hohndel.org/subsurface:
Avoid duplicate dive_trip entries
More trip manipulations: remove selected dives from trip
Add ability to merge trip with trip below
Use the infrastructure for moving dives in more places
Correct the trip related test dives
Fix crash when removing the first dive of a trip
Correctly initialize the toggle state of the autogroup menu entry
Fix copy_tree_node to no longer overwrite dive duration
Add autogen menu command
Fix a crash when changing sort column
Use truth values with gboolean
Allow modification and edits of trips
Clean up macros and auxiliary functions
Store time_t as long value
When inserting a trip into the dive_trip_list we already check for
duplicate trips, but we still kept the additional dive_trip around.
With this change we instead replace it with the existing one.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
GTK messes up the standard C library locales by default (instead of just
taking locale information into account internally). Which breaks
'strtod()' and 'printf()' etc. Since they screwed that up, they then
added helper functions for undoing that braindamage. Use it.
I'd like to blame the GTK people, but the standard C libary people bear
*some* responsibility for this. One of the reasons why people do not
use "setlocale()" in many normal programs is exactly because it messes
up core libc functionality - with number conversion being the main
thing.
Doing things like converting numbers in a locale-specific manner is
something people do want to do, but not *always*. So the C library
locale code should always had defaulted to C locale, with some *extra*
marker (like a printf/scanf modifier) to say "print/scan in the current
locale".
Because many things absoilutely need to be non-localized. You don't
want your internal file format to magically change just because you want
to show things to the user in France, for example.
Reported-by: Ivan Habunek <ivan.habunek@gmail.com>
Root-caused-by: Jef Driesen <jefdriesen@telenet.be>
Cc: Dirk Hohndel <dirk@hohndel.org>
Cc: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>
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
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>
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>
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>
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>
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>
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>
... 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>
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>
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.
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
* '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)
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
There are several sample UDDF files around on the net, so we might as
well start importing some of it.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Looks like Linus misinterpreted the first UEMIS xml files I sent him.
The date_time appears to be in local time - so the time zone info can be
ignored (that seems strange, but it worked for the dives I tested it
with)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* 'open-files' of git://github.com/nathansamson/diveclog:
Report errors when opening files
Make it possible to load multiple files at once.
Open File works. I refactored the code and introduced a new type. I never used it as a pointer (their was no real reason), but I'm not really satisfied.
This is just a very rough draft. It imports all the main stuff I
noticed, but I'm sure it drops a ton of other stuff.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Instead of having each import source recognition routine set a separate
flag for that import source, just enumerate them and set them in one
variable.
I'm adding yet another xml importer - divinglog.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
There's a big comment there now about what is going on. It took me a
while to understand how the crazy seven-tank uemis dive computer
information actually works.
So the Uemis computer has 4 different "tank profiles":
- single tank air (0)
- single tank nitrox (1)
- two-tank nitrox (2)
- three-tank nitrox (3)
and the computer always lists all seven tank cases (because that's how
you fill them in).
Depending on the "gas.template" you are supposed to then *use* just one
particular profile. Why the computer doesn't just give you the tanks
for that one profile, who knows? It seems to be more of the same "Uemis
dive data isn't so much about the dive, it's about dive computer state"
mentality.
So we first get the profile information, and then based on that we need
to pick the right tanks from the set of seven that we're presented with.
All clear?
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>
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>
This is some seriously crazy stuff. Instead of making sense as a
divelog, the uemis xml makes more sense as a "dive computer settings
dump".
And I guess I can see why they'd do that. But it makes parsing it just
incredibly annoying. The thing is more of a "these are the
configurations I support as a dive computer thing" than a "this was the
tank you were diving with".
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>
.. and sort based on the 'time_t' value itself.
This allows us to use a more compact date format that doesn't need to
sort alphabetically, because sorting by date is always based on the date
value. So we can use just a two-digit year, and skip the seconds, to
keep the column narrow, while still sorting correctly.
Also, "Depth" is a nice header string, but it is wider than the column
itself, which makes the whole column wider than necessary. So put the
units in the header instead of in the string, keeping things narrow.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>
Now the dive profile plot *really* needs some units. The pressure is
just a random line otherwise.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
If given multiple dives at the same time, just de-dup the dives. This
happens when you've dumped the whole dive-computer several times, and
some dives show up in multiple dumps.
When de-duping, try to avoid dropping data. So if one dive has notes
attached to it, and the other one does not, pick the notes from the dive
that does have them. Obvious stuff like that.
The sample merge is also written so that it should be possible to merge
two dives. Which we don't actually do yet.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
It looks like the "units.pressure" setting is only about the units that
things are *shown* in on the wrist computer: the units in the file are
always in bar (or rather, centi-bar).
Which is definitely the right thing to do, and means that we shouldn't
care about parsing the units setting. It's purely about how something
is shown, not about parsing.
That's probably true of the other units too, but let's see when I have
more data to go on.
Also, parse water temperatures and tank pressure.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
We still end up guessing based on magnitude of the value, though: it
might be 'bar' or 'mbar', we end up picking one or the other based on
just how big the value is.
I should make it look at any possible explicit units too, since at least
with good xml, they exist. Of course, the only good xml I've seen so
far is the one we generate ourselves ;)
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
I think I'll need to re-organize the handling of per-format code, but
for now we just mix it all up.
The uemis conversion is also questionable even for just the small parts
I do. Does it really do "centiPSI"? That sounds crazy. I'm waiting for
Dirk to send me some actual human-readable output from the dives, right
now some of it is just rough guesses.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The standard way to write a date is yyyy-mm-dd, which is unambiguous and
sorts correctly.
We parsed that right in the 'datetime' case, but not in the normal date
case. And we do want to use that in our output format, exactly because
it's standard.
And also parse 'duration' for the dive duration. It's what we use when
saving, it just so happened that we ended up not parsing it right, but
then picking it up from the samples instead.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>