The hash field in the picture-structure was in principle non-operational.
It was set on loading, but never actually changed. The authoritative
hash comes from the filename->hash map.
Therefore, make this explicit by removing the hash field from the
picture structure.
Instead of filling the picture structure on loading, add the
hash directly to the filename->hash map. This is done in the
register_hash() function, which does not overwrite old entries.
I.e. the local hash has priority over the save-file. This
policy might be refined in the future.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since all qt-helpers are defined in qthelper.cpp, there seems to be
no reason to have two include files. By unifying the two files,
duplication and inconsistencies are removed. The C++-only part is
simply compiled away with #ifdefs.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This patch allows the planner to save the last manually-entered
dive planner point of a dive plan. When the plan has been saved
and re-opened for edit, the time of the last-entered dive planner
point is used to ensure that dive planning continues from the same
point in the profile as was when the original dive plan was saved.
Mechanism:
1) In dive.h, create a new dc attribute dc->last_manual_time
with data type of duration_t.
2) In diveplanner.c, ensure that the last manually-entered
dive planner point is saved in dc->last_manual_time.
3) In save-xml.c, create a new XML attribute for the <divecomputer>
element, named last-manual-time. For dive plans, the element would
now look like:
<divecomputer model='planned dive' last-manual-time='31:17 min'>
4) In parse-xml.c, insert code that recognises the last-manual-time
XML attribute, reads the time value and assigns this time to
dc->last_manual_time.
5) In diveplannermodel.cpp, method DiveplannerPointModel::loadfromdive,
insert code that sets the appropriate boolean value to dp->entered
by comparing newtime (i.e. time of dp) with dc->last_manual_time.
6) Diveplannermodel.cpp also accepts profile data from normal dives in
the dive log, whether hand-entered or loaded from dive computer. It
looks like the reduction of dive points for dives with >100 points
continues to work ok.
The result is that when a dive plan is saved with manually entered
points up to e.g. 10 minutes into the dive, it can be re-opened for edit
in the dive planner and the planner re-creates the plan with manually
entered points up to 10 minutes. The rest of the points are "soft"
points, shaped by the deco calculations of the planner.
Improvements: Improve code for profile display in dive planner
This responds to #1052.
Change load-git.c and save-git.c so that the last-manual-time is
also saved in the git-format dive log.
Several stylistic changes in text for consistent C source code.
Improvement of dive planner profile display:
Do some simplification of my alterations to diveplannermodel.cpp
Two small style changes in planner.c and diveplannermodel.cpp
as requested ny @neolit123
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Make functions in core/file.c, core/parse.c and core/import-csv.c
that were not used outside their translation unit of static linkage.
parse_date is moved from core/file.c to core/import-csv.c, since it
is used only there.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The boolean "autogroup" was parsed as an integer. In principle OK, but
let's make the type more explicit by introducing a get_bool() function.
Suggested-by: "Lubomir I. Ivanov" <neolit123@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This should help us to move parsing that is not XML related to other
files, hopefully making the code cleaner.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Store cylinder.depth in XML files and in git storage.
This info is in fact the gas switch depth of a specific gas/cylinder
in the planner.
This change avoids the need of typing in a user specific depth value
again when replanning an existing planned dive.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Commit 9771255919 introduces a compiler warning due to mismatched
pointer types. Fixed here.
Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
The code incorrectly divided the temperature by 10 as an integer,
causing unnecessary precision loss due to truncation.
Fix it, and update the test results for the now improved temperature
import.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The divinglog import did horrible things with the strings returned from
the sqlite queries, and ended up using uninitialized values at the end
of the secondary profile data strings.
This rewrites the import logic to track the length of the strings
properly when importing the divinglog data.
We should run 'valgrind' a whole lot more than we do, I suspect.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The more I looked at the code that added the country to the dive site,
the more it seemed redundant given what we have with the taxonomy.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Dive IDs are unique but same dive number can appear multiple times within
the same database. This can happen for example when user changes the
"next log number" from his computer.
Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
The provided strod_flags(str, 0, 0) should work as a drop in replacement
for atof() but does not care about locales which may cause atof() to fail.
strtod_flags() would allow checking of conversion result, but I did not
change the existing logic. This was just regexp search&replace change
to get rid of atof(). I use flags 0 to get more relaxed conversion.
Fixes#574
Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
Re-do the logic to use add_gas_switch_event() instead of creating event
manually.
Fix the SQL query to find the proper dive id from dive log number.
Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
Prevent button press events from showing on the profile
graph when we import divesoft DLF files.
Reported-by: Marc Arndt
Signed-off-by: Marc Arndt <marc@marcarndt.com>
Reportedly the case 2 corresponds to Perdix, so it might be that both
Petrel and Perdix use same model number (or the model is mistaken
before).
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
There is something with ndl / tts / temp in the Liberty DLF files. If
that bit is set, the values are bogus. There is something more to it
here which I haven't figured out.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
We always step forward 16 bytes, so make it a for loop so a continue
won't throw us into a eternal loop.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
This does both the XML and the git save format, because the changes
really are the same, even if the actual format differs in some details.
See how the two "save_samples()" routines both do the same basic setup,
for example.
This is fairly straightforward, with the possible exception of the odd
sensor = sample->sensor[0];
default in the git pressure loading code.
That line just means that if we do *not* have an explicit cylinder index
for the pressure reading, we will always end up filling in the new
pressure as the first pressure (because the cylinder index will match the
first sensor slot).
So that makes the "add_sample_pressure()" case always do the same thing it
used to do for the legacy case: fill in the first slot. The actual sensor
index may later change, since the legacy format has a "sensor=X" key value
pair that sets the sensor, but it will also use the first sensor slot,
making it all do exactly what it used to do.
And on the other hand, if we're loading new-style data with cylinder
pressure and sensor index together, we just end up using the new semantics
for add_sample_pressure(), which tries to keep the same slot for the same
sensor, but does the right thing if we already have other pressure values.
The XML code has no such issues at all, since it can't share the cases
anyway, and we need to have different node names for the different sensor
values and cannot just have multiple "pressure" entries. Have I mentioned
how much I despise XML lately?
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
good (1) = 5
medium (2) = 3
bad (3) = 1
There seems also to be 0 used in the log, even though it is not
mentioned in the valid selections. This is not giving any stars for this
option...
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Note that I have not been able to do a positive test for this due to
lack of CCR sample data. But at least OC dives are now categorized
correctly.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
"cur_dc" may be NULL when the XML source isn't a subsurface XML file,
and xml parsing is supposed to use "get_dc()" to pick a dive computer
when the nesting of the XML may not be proper.
Now, XML sources that don't have the proper dive computer nesting
markers generally also do not end up having the extra-data string
information, but one example of this is the simple XML that the
libdivecomputer 'dctool' program generates.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Because of how we traditionally did things, the "o2pressure" parsing
depends on implicitly setting the sensor index to the last cylinder that
was marked as being used for oxygen.
We also always defaulted the primary sensor (which is used for the
diluent tank for CCR) to cylinder 0, but that doesn't work when the
oxygen tank is cylinder 0.
This gets that right at file loading time, and unifies the xml and git
sample parsing to make them match. The new defaults are:
- unless anything else is explicitly specified, the primary sensor is
associated with the first tank, and the secondary sensor is
associated with the second tank
- if we're a CCR dive, and have an explicit oxygen tank, we associate
the secondary sensor with that oxygen cylinder. The primary sensor
will be switched over to the second cylinder if the oxygen cylinder
is the first one.
This may sound backwards, but matches our traditional behavior where
the O2 pressure was the secondary pressure.
This is definitely not pretty, but it gets our historical files working
right, and is at least reasonably sensible.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is a very timid start at making us actually use multiple sensors
without the magical special case for just CCR oxygen tracking.
It mainly does:
- turn the "sample->sensor" index into an array of two indexes, to
match the pressures themselves.
- get rid of dive->{oxygen_cylinder_index,diluent_cylinder_index},
since a CCR dive should now simply set the sample->sensor[] indices
correctly instead.
- in a couple of places, start actually looping over the sensors rather
than special-case the O2 case (although often the small "loops" are
just unrolled, since it's just two cases.
but in many cases we still end up only covering the zero sensor case,
because the CCR O2 sensor code coverage was fairly limited.
It's entirely possible (even likely) that this migth break some existing
case: it tries to be a fairly direct ("stupid") translation of the old
code, but unlike the preparatory patch this does actually does change
some semantics.
For example, right now the git loader code assumes that if the git save
data contains a o2pressure entry, it just hardcodes the O2 sensor index
to 1.
In fact, one issue is going to simply be that our file formats do not
have that multiple sensor format, but instead had very clearly encoded
things as being the CCR O2 pressure sensor.
But this is hopefully close to usable, and I will need feedback (and
maybe test cases) from people who have existing CCR dives with pressure
data.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>