After some reverse-engineering i managed to figure out a couple of
values stored in the dive header.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
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>
The implementation of import for DM5 removed the profileBlob from SQL
query, thus breaking the backward compatibility on import of old dives.
Need to have bot profile and sample blobs within the query...
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
"Converted" DM4 logs are not actually converted, only the database
structure is updated. According to Rainer we should be able to read the
dive profile from the old format in this case.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If DM4 log file is converted to DM5, the sampleBlob is empty.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
Oddly we already had code to load this from XML, but nothing else.
This makes the load from XML work like the rest of our code and adds the
save to XML plus the load and save for the git format.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
If the element we are parsing is of type XML_CDATA_SECTION_NODE, we have
to check the node's name from the parent.
Fixes#718
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch adds support for importing the logs from a Poseidon MK6
rebreather. This DC produces logs that contain of a .txt file that has
all the meta data and a .csv file that contains the sample readings. The
CSV file is different from the others in that it has a line per each
sample reading at given time. Thus we have to merge all the lines from
one point in time into one sample reading of ours.
[Dirk Hohndel: addressed some compiler warnings]
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The latest CCR patches had rendered the planner not usable for CCR dives.
This patch corrects this (and reenables the CCR set point column for
segments). The problem was that a new member setpoint of struct divepoint
had been introduced, but there was already po2 which had the same meaning.
This patch merges the two and renames them setpoint to prevent future
confusion.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Decode the gasmix data into a sane format when creating the event, and
add the (currently unused) ability to specify a gas change to a
particular cylinder rather than (or in addition to) the gasmix.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch allows the importing of oxygen sensor and setpoint data from
Poseidon CCR dive logs.
1) Change parse-xml.c to read up to three oxygen sensor values from xml.
and to store the information in sample structures
2) Change parse-xml.c to read o2 setpoint values fro xml and to store
it in sample structures
3) Change dive.c to delete all sensor and setpoint values where
subsequent samples have sensor/setpoint values that are the same.
4) Change profile.c to store the sensor/setpoint values from the samples
into plotinfo.
5) Change the sample Poseidon xml log in the dives directory to ensure
the correct order and hierarchy of the dive and divecomputer nodes.
[Dirk Hohndel: minor cleanup, removed debug code, whitespace]
Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch implements the cylinder pressure calculations for diluent
gas in CCR dive computers. This is the third patch for achieving this.
The following were performed:
1) Add two lines to try_to_fill_sample() in parse-xml so that
diluent cylinder pressures are stored from XML dive log file
into structures of sample.
2) Add one line to populate_plot_entries() in profile.c so that
the diluent cylinder pressures are copied from structures of
sample to structures of plot_info.
3) add three constant #defines in profile.h
4) change populate_pressure_information() in gaspressures.c in
order to take into account pressure calculations for the
diluent cylinder, calling subordinate functions in the
appropriate way.
5) change create_plot_info_new() in profile.c in order to initiate
the pressure calculations for the diluent cylinder.
6) Implement two debugging functions (one in profile.c, another
in gaspressures.c). These debugging functions are activated
by means of #defines.
Two function calls dealing with oxygen pressure are currently commented
out. They will be activated in the following patch that attends to CCR
oxygen partial pressure calculation.
[Dirk Hohndel: rather massive whitespace cleanup]
Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Sometimes the planner can produce negative pressures (i.e. when the
cylinders are not properly configured) or when the usser ignored
gas management (for whatever reason). When such a dive gets saved and
reread we should not display a further "Strange pressure reading"
warning on the command line.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Select proper SAMPLE_EVENT_GASCHANGE "version" based on helium content
on the mix.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Subsurface has saved gas change events without type attribute at some
point. Thus we need to add the type when reading in log files, if it is
missing. (Gas change logic relies on the type field nowadays.)
Fixes#617Fixes#600
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since earlier have we had support for our own calculated TTS. This adds
support for holding TTS values reported by a dive computer.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed vs unsigned comparisons are such a pain. Since we want offsets to
be +/- 30 minutes around the dive we need to allow negative offsets - but
duration_t was defined as uint32_t.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Lets just use pO₂ instead of PO2, ppO2, ppO₂, PO₂.
They all mean the same, but it's better to be
consistent
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch lays the foundation for differentiating
between open-circuit(OC)dives and rebreather dives
(CCR). The following were done:
1) In dive.h add an enum type dive_computer_type
2) In dive.h add two more fields to the dc structure:
a) dctype (an enum field indicating dc type)
b) no_o2sensor (indicating number of o2 sensors for this dc)
3) In parse-xml.c add a function trimspace that strips any
whitespace from a string. This is used by two functions:
utf8_string as well as by get_dc_type, described below.
The pointer to buffer is not changed in order to ensure
consistency when the buffer is freed.
4) In parse-xml.c add a function get_dc_type. This parses the
dc_type string from xml and assigns an enum value which will
later be returned to the function that parses
the dc variables.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Also change the on file XML to be even easier to read by making it a
duration as well (which gets us '32:34 min' instead of un-typed seconds).
This is backwards compatible, it will happily read what was written with
the previous commit).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Using XML data files we can now save picture data and load it back in
again. The corresponding code for save-git and load-git is still missing.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
.. and fix the type breakage brought in by commit eaf6d56487 ("CCR code:
Change to sample structure")
The XML parsing callbacks pass a "void *" around, because the helper
function that matches the XML node names ("match()") does so for all the
different dive/sample/dc member nodes that all have different types.
But that also hid the fact that it very much depended on the various types
being regular "int" etc, rather than the denser types that were introduced
so that the CCR data wouldn't expand memory use excessively. As a result,
XML loading would overwrite other members, and possibly even the
allocation, when it wrote an "int" value to something that only was a
8-bit allocation.
I left the "utf8_string()" without type checking - so it still uses
"void *_res" for the result type, with the cast happening inside the
function.
That's because the result destination ends up being a bit mixed-up wrt
"const char **" and just plain "char **". Note that the thing we modify
itself isn't const (it's not "char *const *"), but the pointer, but we
basically sometimes assign a "const char *", and sometimes a "char *".
I considered making two different versions of the callback, but it just
wasn't worth it. So "utf8_string()" users still aren't type-checked, and
you'd better give it a pointer to something that is some kind of "char *"
This patch doesn't really change the calling convention of the matching
function itself, but it makes the wrapper macro ("MATCH()") take a
properly type-checked function pointer instead (with a dummy call to do
type checking), and then casts the pointer to the "void *" type for the
actual real call.
The function pointer call is not really portable (although it works on
all sane architectures, particularly since the cast only changes one
argument from one type of pointer to another), and to make matters worse
uses the gcc statement-expression extension. But all the compilers we use
seem to support that gcc'ism, so in practice this gives us type-safety
with no downsides.
(If we ever want to use MSVC to compile subsurface, I suspect we'll have
to ifdef out the statement expression use and not type-check things. Or
perhaps re-write the thing as a ternary expression instead, or something).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
1) All the variables in the sample structures are strongly typed
2) Two additional types were declared in units.h:
o2pressure_t
bearing_t
3) The following variables were added:
diluentpressure
o2setpoint
o2sensor[3]
4) Changes to a number of files were made to chanf
sample->po2 to sample->po2.mbar
bearing to bearring.degrees
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>