Commit graph

123 commits

Author SHA1 Message Date
Dirk Hohndel
f4f791ffbd Add verbose debug output to parse_manual_file
This way it's easier to figure out which arguments to use when creating
tests.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-14 18:08:26 -07:00
Dirk Hohndel
9b2c1df8e6 Temporary fix to allow importing of CSV files
In commit 0ed4356fc2 ("Display slowness warning before opening a V2
file") I changed the xml parser to abort if it detects an V2 XML file so
that the main application can show a warning message (and eventually, a
few choices for the user) before parsing and processing older XML files.

The input that gets pre-processed by XSLT files claims to be V2 XML and so
the parser aborts - yet the code to show a warning and restarting the
parse isn't present in this code path, so XSLT based imports always fail.

This hack works around this by temprarily setting the variable that claims
that the warning has been shown to the user.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-14 16:24:24 -07:00
Lubomir I. Ivanov
2a1a868db2 datatrak: some codings style fixes and fopen() usage
- subsurface_fopen() is needed
- translated one puts("") message
- sizeof(unsigned char | char) is always 1
- pointer symbol (*) location
- padding fixes
- braces fixes

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-11 07:38:22 -07:00
Salvador Cuñat
44b55bd1a2 Import Datatrak/WLog files
Sequentially parses a file, expected to be a Datatrak/WLog divelog, and
converts the dive info into Subsurface's dive structure.

As my first DC, back in 90s, was an Aladin Air X, the obvious choice of log
software was DTrak (Win version). After using it for some time we moved to WLog
(shareware software more user friendly than Dtrak, printing capable, and still
better, it runs under wine, which, as linux user, was definitive for me). Then,
some years later, my last Aladin died and I moved to an OSTC, forcing me to
look for a software that support this DC.
I found JDivelog which was capable of import Dtrak logs and used it for some
time until discovered Subsurface existence and devoted to it.

The fact was that importing Dtrak dives in JDivelog and then re-importing them
in Subsurface caused a significant data loss (mainly in the profile events and
alarms) and weird location of some other info in the dive notes (mostly tag
items in the original Dtrak software). This situation can't actually be solved
with tools like divelogs.de which causes similar if no greater data loss.

Although this won't be a core feature for Subsurface, I expect it can be useful
for some other divers as has been for me.

Comments and issues:

Datatrak/Wlog files include a lot of diving data which are not directly
supported in Subsurface, in these cases we choose mostly to use "tags".

The lack of some important info in Datatrak archives (e.g. tank's initial
pressure) forces us to do some arbitrary assumptions (e.g. initial pressure =
200 bar).

There might be archives coming directly from old DOS days, as first versions
of Datatrak run on that OS; they were coded CP437 or CP850, while dive logs
coming from Win versions seems to be coded CP1252. Finally, Wlog seems to use a
mixed confusing style. Program directly converts some of the old encoded chars
to iso8859 but is expected there be some issues with non alphabetic chars, e.g.
"ª".

There are two text fields: "Other activities" and "Dive notes", both limited to
256 char size. We have merged them in Subsurface's "Dive Notes" although the
first one could be "tagged", but we're unsure that the user had filled it in
a tag friendly way.

WLog adds some information to the dive and lets the user to write more than
256 chars notes. This is achieved, while keeping compatibility with DTrak
divelogs, by adding a complementary file named equally as the .log file and
with .add extension where all this info is stored.  We have, still, not worked
with this complementary files.

This work is based on the paper referenced in butracker #194 which has some
errors (e.g. beginning of log and beginning of dive are changed) and a lot of
bytes of unknown meaning. Example.log shows, at least, one more byte than those
referred in the paper for the O2 Aladin computer, this could be a byte referred
to the use of SCR but the lack of an OC dive with O2 computer makes impossible
for us to compare.

The only way we have figured out to distinguish a priori between SCR and non
SCR dives with O2 computers is that the dives are tagged with a "rebreather"
tag. Obviously this is not a very trusty way of doing things. In SCR dives,
the O2% in mix means, probably, the maximum O2% in the circuit, not the O2%
of the EAN mix in the tanks, which would be unknown in this case.

The list of DCs related in bug #194 paper seems incomplete, we have added
one or two from WLog and discarded those which are known to exist but whose
model is unknown, grouping them under the imaginative name of "unknown". The
list can easily be increased in the future if we ever know the models
identifiers.
BTW, in Example.log, 0x00 identifier is used for some DC dives and from my own
divelogs is inferred that 0x00 is used for manually entered dives, this could
easily be an error in Example.log coming from a preproduction DC model.

Example.log which is shipped in datatrak package is included in dives
directory for testing pourposes.

[Dirk Hohndel: some small cleanups, merged with latest master, support
               divesites, remove the pointless memset() before free() calls
	       add to cmake build]

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-10 10:03:08 -07:00
Dirk Hohndel
74fad4a7ce xsltMaxVars was only introduced in libxslt 1.1.27
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-17 22:00:26 -08:00
Miika Turkia
f39962469d Increase the limits for recursion and variables on XSLT parsing
This increases the limits when parsing CSV files with dive profiles,
allowing us to import bigger files in one go.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-10 15:03:28 -08:00
Miika Turkia
2dc1a42b29 Fix crash if one selects incorrectly Seabear CSV
Fixes #814

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-01 07:06:12 -08:00
Miika Turkia
29c6d03dfa Fix a bug if CSV file does not have ending new line
Add a new line when importing a CSV file, so we get the last dive
imported as well (in case file ends without last new line).

See #814

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24 14:49:45 -08:00
Dirk Hohndel
cbab6cc9c8 When importing dives from CSV, mark them accordingly
The dive computer model string should indicate that these were imported
from CSV.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-22 06:54:03 +12:00
Robert C. Helling
e219bc70f8 Refactor dctype -> divemode
... and repair a failed rebase (sorry).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10 17:27:25 -08:00
Anton Lundin
c8c29ac8cf Adjust array size to fit all csv params
Back in e544796199 ("Add missing divemaster field to the manual
import"), divemaster field got added without extending the array length.
This corrects that.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 14:04:44 -08:00
Dirk Hohndel
e544796199 Add missing divemaster field to the manual import
No idea why I didn't notice earlier that this was missing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-06 20:19:45 -08:00
Miika Turkia
48b88f6aca Do not add uninitialized setpoint or ndl
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-04 23:11:03 -08:00
Miika Turkia
65ee482adb Add duration format to XSLT call
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-31 08:35:30 -08:00
Miika Turkia
ce1f69f025 Initial support for Divesoft Freedom
This parses the dive profile from Divesoft Freedom log file. Only the
depth profile is currently supported. There is also something wrong as
the log file cannot be given as parameter but must be opened or imported
once Subsurface is running. Note that so far no metadata is parsed.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-28 06:41:21 -08:00
Miika Turkia
071cea15c0 Glue between GUI and XSLT for additions in CSV import
This code sets the parameters properly to support the new fields in
manual CSV import.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-20 11:30:52 -08:00
Miika Turkia
3be4aa47b5 Bare implementation of Cobalt Divelog Program
This implements importing of dive profile and temperature graph along
with some meta data from a Cobalt Divelog database.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-20 11:28:57 -08:00
Anton Lundin
e6c587ad62 Remove debug printf
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-13 13:36:08 -08:00
Dirk Hohndel
b92a10ea98 Mark new string for translation
This needs to be the same string as used for the entry in the Import
dialog... since translate() is a macro in this .c file and defined to have
only two arguments, I'm using the NOOP3 macro to get this correctly added
to the translation sources, including the comment. That makes the code a
little odd, but seems to work.

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

Now we issue a somewhat reasonable error message.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-08 11:28:23 -08:00
Miika Turkia
5831af3fe2 Fix a crash on CSV import
Seems that there was not enough space reserved for the whole mem buffer
when adding XML tags around CSV file. When unlucky, the metadata of
memory allocation was overwritten.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-08 08:49:12 -08:00
Lubomir I. Ivanov
a04be5a7e4 file.c: fix uninitialized variable
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-01 14:30:56 -08:00
Miika Turkia
1b74947bf5 Allow user to select date format on manual CSV import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-25 13:19:49 -08:00
Tim Wootton
00068c2247 More O₂
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-25 07:57:43 -08:00
Anton Lundin
e883819061 De-obfuscated Poseidon gaschange event building
After some feedback on the mailing list, bitwise XOR wasn't the
preferred way to build the gaschange event.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-20 14:32:27 -08:00
Anton Lundin
72c47a856e Adjust Poseidon Mouth piece event strings
After some feedback on the mailing list, these strings where preferred.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-20 14:32:15 -08:00
Anton Lundin
36b6045460 Document more about fields in Poseidon MkVI logs
This is based on the great work done by Søren Reinke's on his MKVI Logfile
Analyzer.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-19 17:50:33 -08:00
Anton Lundin
e2c9c0bec4 Create more events from Poseidon MkVI logs
This is based on the great work done by Søren Reinke's on his MKVI Logfile
Analyzer.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-19 17:50:10 -08:00
Anton Lundin
8486a32515 Create gaschange events from Poseidon MkVI logs
This is based on the great work done by Søren Reinke's on his MKVI Logfile
Analyzer.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-19 17:50:01 -08:00
Anton Lundin
7caad0c0df Create events from mouthpiece position
This is based on the great work done by Søren Reinke's on his MKVI Logfile
Analyzer.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-19 17:47:19 -08:00
Anton Lundin
f6b2fe3bf0 Add support for importing CEILING from MKVI logs
This is based on the great work done by Søren Reinke's on his MKVI Logfile
Analyzer.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-19 17:46:53 -08:00
Anton Lundin
61239a890c Import NDL from Poseidon MKVI logs
This is based on the great work done by Søren Reinke's on his MKVI Logfile
Analyzer.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-19 17:46:33 -08:00
willem ferguson
514a0e582a Fix issues in CCR handling
In commit 0d7c192e6e ("For CCR dives, the diluent cylinder is the
current cylinder") a few things got broken. This tries to undo those
changes and adds expanded XML output.

1) Calculate correct partial pressure of oxygen to be plotted on
   dive profile, taking into account the oxygen sensor data.
   Currently, erroneously, OC PO2 values are shown, due to an
   erroneous calling parameter to fill_pressures().
2) Read start and end cylinder pressured correctly.  some wrong
   assignments were done in file.c. This is now corrected and the correct
   cylinder pressures are shown in the equipment tab.
3) Write correct cylinder pressures to XML. Currently the data for
   the two cylinders are written to XML the wrong way round
   (diluent pressures = oxygen and vice versa).
4) Expand XML output:
   a) Write oxygen sensor data to XML
   b) Write no_of_02sensors to XML

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-18 08:57:21 +00:00
Robert C. Helling
0d7c192e6e For CCR dives, the diluent cylinder is the current cylinder
Change the meaning that _the_ cylinder (as we treat it in OC dives) is the
diluent cylinder (rather than the O2 cylinder). This eliminates special
cases. Now, for CCR, we have to handle the O2 cylinder in addition
(rather than the diluent in addition).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17 11:45:06 +00:00
Robert C. Helling
84dc8b8962 Some gas handling improvements
Add a time linear gas interpolation strategy. Some minor changes.

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

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-15 08:15:15 -08:00
Miika Turkia
70939a1d84 Fix parsing of Windows new lines on Mk6 import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-15 06:05:22 -08:00
Miika Turkia
4753d5c15c Fix memory leak
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-10 12:17:37 -08:00
Miika Turkia
9cf7a5d968 Use the new extra data interface for Poseidon import
Rather than overflowing the notes field, let's add all the details from
DC using the extra data API.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-10 12:17:32 -08:00
Anton Lundin
a7a022d8db Remove unused variables and code from seabear-csv
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-08 11:17:20 -08:00
John Van Ostrand
8136306911 Added import for Liquivision LVD log files
Support includes cylinder pressures and works for v3.0 log files.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07 13:15:38 -08:00
Miika Turkia
56bfa1b1be Reset counters when importing new MK6 log
Naturally the pressure counters and cylinder index must be reset to zero when
reading in a new Poseidon dive log.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-06 05:22:24 -08:00
willem ferguson
40bdd607c0 Calculate nitrogen and helium gas pressures for CCR after import from CSV
Currently the gas pressures stored in structures of pressure are
calculated using the gasmix composition of the currently selected
cylinder. But with CCR dives the default cylinder is the oxygen
cylinder (here, index 0). However, the gas pressures need to
be calculated using gasmix data from cylinder 1 (the diluent
cylinder). This patch allows setting the appropriate cylinder
for calculating the values in the structures of pressure. It
also allows for correctly calculating gas pressures for any
open circuit cylinders (e.g. bailout) that a CCR diver may
use. This is performed as follows:

1) In dive.h create an enum variable {oxygen, diluent, bailout}

2) Within the definition of cylinder_t, add a member: cylinder_use_type
   This stores an enum variable, one of the above.

3) In file.c where the Poseidon CSV data are read in, assign
   the appropriate enum values to each of the cylinders.

4) Within the definition of structure dive, add two members:
   int oxygen_cylinder_index
   int diluent_cylinder_index
   This will keep the indices of the two main CCR cylinders.

5) In dive.c create a function get_cylinder_use(). This scans the
   cylinders for that dive, looking for a cylinder that has a
   particular cylinder_use_type and returns that cylinder index.

6) In dive.c create a function fixup_cylinder_use() that stores the
   indices of the oxygen and diluent cylinders in the variables
   dive->oxygen_cylinder_index and dive->diluent_cylinder_index,
   making use of the function in 4) above.

7) In profile.c, modify function calculate_gas_information_new()
   to use the above functions for CCR dives to find the oxygen and
   diluent cylinders and to calculate partail gas pressures based
   on the diluent cylinder gas mix.

This results in the correct calculation of gas partial pressures
in the case of CCR dives, displaying the correct partial pressure
graphs in the dive profile widget.

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-03 14:13:55 -08:00
Miika Turkia
dd73f422e0 Add pressures to cylinder declaration for MK6 import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-01 22:09:36 -07:00
Miika Turkia
d4d59dadcf Add .txt to notes on MK6 import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-31 14:58:57 -07:00
Miika Turkia
64f816b472 Add gas mixes to MK6 import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-31 14:58:57 -07:00
Miika Turkia
4a42fdaa71 Set the number of O2 sensors for Poseidon MK6
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-30 13:24:15 -07:00
Dirk Hohndel
70a2e91f1c Assigment in if statements
This is one of the warnings that I agree with. The original code was very
hard on my eyes... the explicit comparison to NULL is just so much easier
to understand when reading the code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-28 07:43:33 -07:00
Miika Turkia
4bc9b7748b Parse meta information from Seaber log
This will parse date information from Seabear log file and skips the
"header" data to allow parsing of the CSV content.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-28 07:25:45 -07:00
John Van Ostrand
49401eec0b Finished Cochran dive log import
I fixed up the decode and finished the parse for Cochran EMC, Commander
and Gemini computers. I suspect that this code may only work with files
from certain versions of Cochran Analyst. It works with my own CAN files
and with the samples that came with Analyst v4.01v.

A seemingly arbitrary offset of 0x4914 is needed to access data.
The previous code uses 0x4a14 and 0x4b14. I suspect these are from
different version of Analyst.

[Dirk Hohndel: whitespace cleanup, add files to subsurface.pro, made sure
	       this compiles without the corresponding patch to
	       libdivecomputer (that isn't upstream, yet), cleaned up the
	       usage of structs, removed a few unused variables]

Signed-off-by: John Van Ostrand <john@vanostrand.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-27 15:21:19 -07:00