PATCH: Poseidon CCR setpoint handling
This patch corrects the bug identified by Miika relating to the
handling of
setpoint data for CCR dives. This specific patch takes the
information from
an XML file, stores the appropriate information in the structures
of data,
and ultimately transfers these to be plotted. The data structures
for working
with setpoints were there but the methods for manipulating the
setpoint were
missing. The specific steps that have been changed are:
1) Parse the XML code for setpoint in an XML input file and store it in
structures of data. The XML part of this does not affect Miika's
code
because he reads the CSV data directly into the appropriate data
structures.
But with this patch, the structures of data are correctly
initialised. This
happens in try_to_fill_sample() in parse-xml.c
2) Change duplicate values of setpoint values in structures of data
to zero
in order to conserve dive log size. This happens in
fixup_dive_dc() in
dive.c
3) Transfer the setpoint data from structures of sample to
structures of
plotdata in order to plot the profile. This happens in
populate_plot_entries()
in profile.c
4) Re-insert all the setpoint data that have zeroes by using the
value of
the last setpoint value that was non-zero. This complements step (2)
above in order to get ready for plotting. This happens in
fill_o2_values()
in profile.c
A few tiny other changes were made, mostly to comments in the code.
Signed-off-by: willem ferguson <willemfergu...@zoology.up.ac.za>
>From e62322fc73f756226c9161c2c4208995fdfea84e Mon Sep 17 00:00:00 2001
From: willem ferguson <willemfergu...@zoology.up.ac.za>
Date: Wed, 29 Oct 2014 19:36:22 +0200
Subject: [PATCH] PATCH: Poseidon CCR setpoint handling
This patch corrects the bug identified by Miika relating to the handling of
setpoint data for CCR dives. This specific patch takes the information from
an XML file, stores the appropriate information in the structures of data,
and ultimately transfers these to be plotted. The data structures for working
with setpoints were there but the methods for manipulating the setpoint were
missing. The specific steps that have been changed are:
1) Parse the XML code for setpoint in an XML input file and store it in
structures of data. The XML part of this does not affect Miika's code
because he reads the CSV data directly into the appropriate data structures.
But with this patch, the structures of data are correctly initialised. This
happens in try_to_fill_sample() in parse-xml.c
2) Change duplicate values of setpoint values in structures of data to zero
in order to conserve dive log size. This happens in fixup_dive_dc() in
dive.c
3) Transfer the setpoint data from structures of sample to structures of
plotdata in order to plot the profile. This happens in populate_plot_entries()
in profile.c
4) Re-insert all the setpoint data that have zeroes by using the value of
the last setpoint value that was non-zero. This complements step (2)
above in order to get ready for plotting. This happens in fill_o2_values()
in profile.c
A few tiny other changes were made, mostly to comments in the code.
Signed-off-by: willem ferguson <willemfergu...@zoology.up.ac.za>
---
dive.c | 6 +++++-
dive.h | 2 +-
parse-xml.c | 2 ++
profile.c | 4 ++--
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/dive.c b/dive.c
index 9f4df56..38b49e0 100644
--- a/dive.c
+++ b/dive.c
@@ -1106,7 +1106,7 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc)
int mintemp = 0;
int lastdepth = 0;
int lasto2val[3] = { 0, 0, 0 };
- int lasttemp = 0, lastpressure = 0, lastdiluentpressure = 0;
+ int lasttemp = 0, lastpressure = 0, lastdiluentpressure = 0, lastsetpoint = 0;
int pressure_delta[MAX_CYLINDERS] = { INT_MAX, };
int first_cylinder;
@@ -1178,6 +1178,10 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc)
mintemp = temp;
}
+ // If there are consecutive identical O2 setpoint readings, throw away the redundant ones.
+ if (sample->setpoint.mbar == lastsetpoint)
+ sample->setpoint.mbar = 0;
+
// If there are consecutive identical O2 sensor readings, throw away the redundant ones.
for (j = 0; j < dc->no_o2sensors; j++) { // for CCR oxygen sensor data:
o2val = sample->o2sensor[j].mbar;
diff --git a/dive.h b/dive.h
index 6809d83..305829f 100644
--- a/dive.h
+++ b/dive.h
@@ -180,7 +180,7 @@ struct sample // BASE TYPE BYTES UNITS RANGE DE
temperature_t temperature; // int32_t 4 mdegrK (0-2 MdegK) ambient temperature
pressure_t cylinderpressure; // int32_t 4 mbar (0-2 Mbar) main cylinder pressure
pressure_t diluentpressure; // int32_t 4 mbar (0-2 Mbar) CCR diluent pressure (rebreather)
- o2pressure_t setpoint; // uint16_t 2 mbar (0-65 bar) O2 partial pressure (will be setpoint)
+ o2pressure_t setpoint; // uint16_t 2 mbar (0-65 bar) O2 partial pressure setpoint
o2pressure_t o2sensor[3]; // uint16_t 6 mbar (0-65 bar) Up to 3 PO2 sensor values (rebreather)
bearing_t bearing; // int16_t 2 degrees (-32k to 32k deg) compass bearing
uint8_t sensor; // uint8_t 1 sensorID (0-255) ID of cylinder pressure sensor
diff --git a/parse-xml.c b/parse-xml.c
index fb55337..4a14609 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -900,6 +900,8 @@ static void try_to_fill_sample(struct sample *sample, const char *name, char *bu
cur_dive->dc.dctype = CCR;
return;
}
+ if (MATCH("setpoint.sample", double_to_o2pressure, &sample->setpoint)) // setpoint
+ return;
if (MATCH("heartbeat", get_uint8, &sample->heartbeat))
return;
if (MATCH("bearing", get_bearing, &sample->bearing))
diff --git a/profile.c b/profile.c
index 4bc9422..9ded762 100644
--- a/profile.c
+++ b/profile.c
@@ -18,7 +18,7 @@
#include "membuffer.h"
-//#define DEBUG_GAS 1
+// #define DEBUG_GAS 1
int selected_dive = -1; /* careful: 0 is a valid value */
unsigned int dc_number = 0;
@@ -984,7 +984,7 @@ static void debug_print_profiledata(struct plot_info *pi)
if (!(f1 = fopen("debug_print_profiledata.dat", "w")))
printf("File open error for: debug_print_profiledata.dat\n");
else {
- fprintf(f1, "id t1 gas gasint t2 t3 dil dilint t4 t5 setpoint sensor1 sensor2 sensor3 t6 po2 fo2\n");
+ fprintf(f1, "id gas gasint dil dilint setpoint sensor1 sensor2 sensor3 po2\n");
for (i = 0; i < pi->nr; i++) {
entry = pi->entry + i;
fprintf(f1, "%d gas=%8d %8d ; dil=%8d %8d ; o2_sp= %f %f %f %f PO2= %f\n", i, SENSOR_PRESSURE(entry),
--
1.9.1
_______________________________________________
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface