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>
This patch responds to the side effects that the CCR code has had with
respect to ceilings in OC dives and dive plans. Dive ceilings are now
calculated correctly again.
The following were performed:
1) remove the oxygen sensor and setpoint fields from the gas_pressures
structure.
2) Re-insert setpoint and oxygen sensor fields in the plot_data structure.
3) Remove the algorithm that reads the o2 sensor data and calculates the
pressures.po2 value from function fill_pressures() in dive.c and save
it as a separate function calc_ccr_po2() in profile.c.
4) Activate calc_ccr_po2 from function fill_pressures() in profile.c.
5) Move the relative position of the call to fill_pressures() within the
function create_polt_info_new() in profile.c.
Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch adds code to the function fillpressures() in dive.c to
allow calculating o2 pressures, based on the data from the po2
sensors in the system. The following changes were made:
1) add code to perform po2 calculations for CCR with 1, 2 or 3
oxygen sesnors.
2) Add four fields to the gas_pressures structure in dive.h. This
allows communication of data between the function that calls
get_pressures() and the return of partail pressure values to the
calling function.
3) Delete the fields for setpoint and gas partial pressures from
the structure plot_info. All partial pressures (from instruments
as well as calculated) now reside in the pressures structure
that forms part of plot_info.
4) Perform changes in several parts of profile.c to make use of the
pressures structure in plot_info.
[Dirk Hohndel: yet again massive whitespace cleanup]
Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch does three things:
1) A new function fill_o2_values() is added to profile.c. This
fills all oxygen sesnsor and setpoint values that have been
zeroed before in order to save space in the dive log. This
recreates the full set of sensor values obtained from the
original CCR xml log file.
2) Function fill_o2_values() is activated in function create_
plot_info_new() in profile.c
3) The calling parameters to function fill_pressures() in dive.c
are changed. The last parameter is now a pointer to a structure
of divecomputer. This will be needed in the last patch of the
present series of three patches.
[Dirk Hohndel: minor whitespace cleanup]
Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
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 introduces a new structure holding partial pressures (doubles in bar) for
all three gases and a helper function to compute them from gasmix (which holds fractions)
and ambient pressure. Currentlty this works for OC and CCR, to be extended later to PSCR.
Currently the dive_comp_type argument is unused.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch implements a separation of the code for gas pressure
calculations from the rest of the code in profile.c. The latter
file is now split into: profile.c and gaspressures.c. The
details of the transferred functions is given at the top of
gaspressures.c. The following chnages were made:
1) dive.h: The function types of calculate_depth_to_mbar
and depth_to_mbar were made non-static in order to make them
available within gaspressures.c.
2) profile.c: Prototypes for the functions in gaspressures.c
were inserted at the top of profile. Ten functions were
transferred from profile.c to gaspressures.c
3) gaspressures.c as well as a short header, gaspressures.h
were created.
For the gas pressure calculations for CCR dives, gaspressures.c
forms the immediate basis for further code development.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
With this information, when we re-plan a dive we can bring the user right
back to the point where they ended - they have the waypoints in the dive
pointes table and handles are shown on the right points in the profile -
and the rest of the dive is once again calculated by the planning
algorithm.
For now this state is lost when saving the dive file as we don't add this
flag in the sample to our saved files. So if we don't find any samples
marked as manually added we add ALL of the samples as way points on the
diveplan and the user has to manually remove the ones that were
calculated.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The old implementation was... let's call it creative.
This tries to actually get things right instead of using magic.
Don't pretend that double values are ints.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit doesn't do anything, yet. It just puts in place helper
infrastructure that will later allow us to cut and paste parts of the data
of one dive into another dive (or set of dives).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
So far, the fields for the two SAC rates did not show a unit and were implictly l/min.
Now they respect the settings for volume units. This was harder than I thought for two reasons:
1) Imperial units for SAC are cuft/min but a typical value would be .70. So I made the point
the field prefix and what is entered is actually hundreth of cuft per minute.
2) I had to get the rounding right in order not to get effects like 20l/min become .70 cuft/min (19800 ml/min
internally) which would then become 19l/min when switching back.
While being at it, I gave the gradient factors '%'-signs as units.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We had pointers to data structures on the stack which we frequently
reallocated. These data structure contain basically a filename and an
offset. We then create a hash of the pointers to those datastructures with
the filename being the key. And then we passed those pointers around
through a Qt model(!!!) only in order to then later look up by filename
what the offset might be.
I am at a loss for words for the lunacy behind this design.
How about we just remember the offsets and pass the integers around?
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
With very low values of GFhigh and setting the last stop depth to 6m it
is possible to create dives that need infintie decompression time.
This ends deco after 48h and replaces the dive plan with an error message.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Almost invisible, mostly looking like an odd bug in the profile code,
there was a tiny red line at depth 0 in the planned profile. Turns out
that was the missing mean depth. We didn't populate enough data in the
dive computer of the dive we generated from the plan (and the length of
the depth line was incorrectly determined by the duration of the dive
instead of the duration stored in the dive computer).
Fixes#570
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This gets us consistent date format everywhere. The reordering of month
name and day of the month didn't work correctly on Windows, anyway.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Added the remove_picture functionality, with code
shamelessy stolen from remove_event, and hoock it
up with the interface.
Fixes#650
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
is_cylinder_used uses get_cylinder_index as underlaying function that
does the right thing with with respect on how to find the closest
matching cylinder, and handles both types of gaschange events correctly.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
To obey <xsl:output omit-xml-declaration="yes"/> element
one should rely on libxslt to do its job instead of writing
document himself.
Discussion on this subject can be found at
http://comments.gmane.org/gmane.comp.gnome.lib.xslt/3839
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We were actually searching dives which match the dowloaded position
fixes. So we're also trying to take into account if the fix is automatic
or no based on a limited amount of predefined strings (bad idea, as the
user can change in companion app settings the predefined string).
This way, in actual implementation, if program concludes that a fix has
been manually got or, simply, the user is unlucky enough to have all the
position fixes out of the dive time, find_dive_n_near() function will
pair fix and dive in an ordered way (1st fix -> 1st dive; 2nd fix -> 2nd
dive ...) which is probably erroneous, except for manual position fixes.
BTW actual implementation can't pair the same gps position with more
than one dive, which would be the case, e.g. in repetitive dives while at
anchor in the same point.
The patch changes the logic:
- Search positions for defined dives (instead of dives for defined
positions) without care if position has manually or automatically been
set.
- Only take care of those dives that don't have a position yet.
- It makes two assumptions:
a.- If the position fix has been taken during the dive time, is
correct. If there are more than one inside the dive time, takes the
first one (closest to the DC's reported time).
b.- If not during diving time, the correct one is the nearest fix
before the dive begins (also the usual case if manually fixed from the
smartphone just before jump into the water). But will work too if there
is only one fix *in SAME_GROUP range* after the dive (another usual
case).
- Finally, as copy_gps_location() in dive.h is used only here, let it
take care of naming the dive if user hasn't named it yet.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I don't like that the event structure includes the variable length array.
That really makes it a pain to change the name of an event (on the flip
side, freeing events is easier I guess).
Anyway, to correctly rename an event we need to actually remove the event
from the correct dc and then add a new event with the new name. The
previous code was insane (it only worked if the new name was of smaller or
equal length, otherwise it had a beautiful buffer overflow).
And of course we need to do this both for the current_dive and the
displayed_dive.
Fixes#616
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>
The semantic of fo2==fhe==0 to mean "same gasmix as before" apparently
is not used anywhere and gets in the way of the semantic "this is air".
If there is really need for mix meaning "same as before", please use another
value, e.g. one with a specific negative percentage.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When adding a dive we don't have SAC data so we should simply have the
user manually enter their gas consumption. That still doesn't work, but
this is one required step to get it to work.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is kind of the inverse to copy_dive(). Instead of duplicating all the
data that the dive points to, it moves it to a new struct dive and zeroes
out the old one so there are no two sets of pointers to these data.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This way we can safely copy around dives (specifically, copy the dive to
be displayed / edited into the displayed_dive).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There is massive confusion about what we display when and where and which
dive structure (or pointer to a dive structure) contains which information
at which stage. This is the first step towards restructuring all of this.
This creates a global variable displayed_dive which at any point in time
should be what is displayed on screen (both in the profile and in the
maintab). It removes the editedDive concept from MainTab.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In the worst gase you have to provide gas for your buddy during all the
ascent. So you should have the amount of gas used in ascent as a reserve.
This patch makes the planner notes display that value separately.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Spin boxes for pO2 are now hooked up to preference values. Adding new
cylinders (or changing their fo2) computes the MOD accordin to the current
value of decopo2. Note that chaning the limits for deco pO2 does _not_
automatically update the switch depth of all cylinders as those might have
been manually entered.
Furthermore, MOD has now to option of rounding to multiples of a given
depth. That is used for the automatic switch depth which are now always
multiples of 3m (so that EAN50 is switched to at 21m rather than 22m).
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This allows us to compile Subsurface with strict C or C++ mode.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
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>
This can't be the only dive computer, of course. Goes nicely with the
ability to reprder them.
Fixes#551
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>
It makes no sense to store a 64bit time stamp with every picture. Even the
32bit offset (in seconds) from the dive start is WAY overkill. But
switching to that makes the code much more simple in a number of spots.
And makes what is saved to the XML file easier to read, too.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This was only semi-implemented the first time around. Now we really only
copy the ones that are indeed used.
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>
The picture list is a single linked list where the pictures have a node to
their next element. When adding the same picture to two dives, things got
way way wrong and crashes were appearing.
This will replicate the information (filename, latitude and longitude) for
each dive that has the picture, BUT it still tries to save as much as
possible on the actual pixmap.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>