diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-30 20:00:51 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-30 20:44:47 -0800 |
commit | d720e133d84d6d468ffab48698d5105849f7d14c (patch) | |
tree | 78b531ab868c901f8077a49d5d8304422698f6a0 /libdivecomputer.c | |
parent | df0ea072920668de4517ad85c742c7169bd24f22 (diff) | |
download | subsurface-d720e133d84d6d468ffab48698d5105849f7d14c.tar.gz |
First step in cleaning up cylinder pressure sensor logic
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>
Diffstat (limited to 'libdivecomputer.c')
-rw-r--r-- | libdivecomputer.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c index 6e01ee3a5..47c7b6367 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -209,7 +209,7 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) sample->depth.mm = value.depth * 1000 + 0.5; break; case DC_SAMPLE_PRESSURE: - sample->cylinderindex = value.pressure.tank; + sample->sensor = value.pressure.tank; sample->cylinderpressure.mbar = value.pressure.value * 1000 + 0.5; break; case DC_SAMPLE_TEMPERATURE: |