[PATCH] Profile support for multiple concurrent pressure sensors

Linus Torvalds torvalds at linux-foundation.org
Sun Jul 30 10:32:56 PDT 2017


On Sun, Jul 30, 2017 at 10:16 AM, Linus Torvalds <
torvalds at linux-foundation.org> wrote:
>
> What happens is that we actually do populate the gas changes, but we
> do it by populating the end pressure to the time of the last sample.
>
> And with the OSTC3, the last sample is actually way beyond the end of
> the dive, because the OSTC3 keeps doing samples for a long time after
> you've already surfaced.
>
> So when we try to populate the fend pressure data for your dive, we
> don't see any plot entries for that time, and we fail.
>
> Easily fixed, I think. Let me try.

Yup, that was it. The attached patch fixes it.

The patch *does* show something a bit odd, though. Your second dive in that
XML file you sent actually has gas data for *four* cylinders:

  'Steel 2L' start='190.0 bar' end='110.0 bar'
  'Steel 2L' o2='100.0%' start='180.0 bar' end='90.0 bar'
  'Steel 6L' o2='32.0%' start='160.0 bar' end='160.0 bar'
  'Steel 6L' o2='50.0%' start='180.0 bar' end='180.0 bar'

but you don't actually have any gas change events for that dive. Oddly, the
"equipment" window only shows two of the cylinders, I think there's some
broken equipment logic that hides the two other ones. Probably related to
the fact that they have no gas use associated with them (beginning and
ending pressures are the same).

But with this patch, we now we show pressure graphs all four of them, and
because none of them has any time associated with them, we show them for
the whole dive:



which is probably not what you really expected.

Anyway, this patch is correct, although I think I'll add the logic to not
show the pressure graph for a cylinder that doesn't have a pressure drop
(unlike the equipment tab, it actually *does* make sense to hide the
cylinders that aren't used on the dive).

So the patch I'll send to Dirk will look slightly different.

           Linus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20170730/937f3b0b/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fourcylinder.png
Type: image/png
Size: 140503 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20170730/937f3b0b/attachment-0001.png>
-------------- next part --------------
 core/profile.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/core/profile.c b/core/profile.c
index e9a625d3..68c56144 100644
--- a/core/profile.c
+++ b/core/profile.c
@@ -804,14 +804,14 @@ static void populate_secondary_sensor_data(struct divecomputer *dc, struct plot_
  */
 static void add_plot_pressure(struct plot_info *pi, int time, int cyl, int mbar)
 {
+	struct plot_data *entry;
 	for (int i = 0; i < pi->nr; i++) {
-		struct plot_data *entry = pi->entry + i;
+		entry = pi->entry + i;
 
-		if (entry->sec < time)
-			continue;
-		SENSOR_PRESSURE(entry, cyl) = mbar;
-		return;
+		if (entry->sec >= time)
+			break;
 	}
+	SENSOR_PRESSURE(entry, cyl) = mbar;
 }
 
 static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc, struct plot_info *pi)
@@ -822,7 +822,7 @@ static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc
 	unsigned int first[MAX_CYLINDERS] = { 0, };
 	unsigned int last[MAX_CYLINDERS] = { 0, };
 	struct divecomputer *secondary;
-	int endtime = dc->samples ? dc->sample[dc->samples-1].time.seconds : dive->duration.seconds;
+	int endtime = pi->entry[pi->nr-1].sec;
 
 	for (i = 0; i < MAX_CYLINDERS; i++)
 		last[i] = endtime;


More information about the subsurface mailing list