summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar willem ferguson <willemferguson@zoology.up.ac.za>2014-11-17 21:04:36 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-18 08:57:21 +0000
commit514a0e582a7c7a0a1c3b576382c4c4f4ed3da0ec (patch)
tree536f7593511eb0e71a73d82ee4c1de1a296a5ca5
parent55763d3da1c0f154b209c8c8d1ddc97b6ee0c2d7 (diff)
downloadsubsurface-514a0e582a7c7a0a1c3b576382c4c4f4ed3da0ec.tar.gz
Fix issues in CCR handling
In commit 0d7c192e6edc ("For CCR dives, the diluent cylinder is the current cylinder") a few things got broken. This tries to undo those changes and adds expanded XML output. 1) Calculate correct partial pressure of oxygen to be plotted on dive profile, taking into account the oxygen sensor data. Currently, erroneously, OC PO2 values are shown, due to an erroneous calling parameter to fill_pressures(). 2) Read start and end cylinder pressured correctly. some wrong assignments were done in file.c. This is now corrected and the correct cylinder pressures are shown in the equipment tab. 3) Write correct cylinder pressures to XML. Currently the data for the two cylinders are written to XML the wrong way round (diluent pressures = oxygen and vice versa). 4) Expand XML output: a) Write oxygen sensor data to XML b) Write no_of_02sensors to XML Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--file.c4
-rw-r--r--profile.c2
-rw-r--r--save-xml.c21
3 files changed, 22 insertions, 5 deletions
diff --git a/file.c b/file.c
index 97095fd6c..4fe4d3526 100644
--- a/file.c
+++ b/file.c
@@ -597,7 +597,7 @@ int parse_txt_file(const char *filename, const char *csv)
case 13:
add_sample_data(sample, POSEIDON_O2CYLINDER, value);
if (!o2cylinder_pressure) {
- dive->cylinder[1].sample_start.mbar = value * 1000;
+ dive->cylinder[0].sample_start.mbar = value * 1000;
o2cylinder_pressure = value;
} else
o2cylinder_pressure = value;
@@ -605,7 +605,7 @@ int parse_txt_file(const char *filename, const char *csv)
case 14:
add_sample_data(sample, POSEIDON_PRESSURE, value);
if (!cylinder_pressure) {
- dive->cylinder[0].sample_start.mbar = value * 1000;
+ dive->cylinder[1].sample_start.mbar = value * 1000;
cylinder_pressure = value;
} else
cylinder_pressure = value;
diff --git a/profile.c b/profile.c
index 63023b5f4..8e43c21f4 100644
--- a/profile.c
+++ b/profile.c
@@ -905,7 +905,7 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *p
amb_pressure = depth_to_mbar(entry->depth, dive) / 1000.0;
- fill_pressures(&entry->pressures, amb_pressure, &dive->cylinder[cylinderindex].gasmix, entry->pressures.o2, dive->dc.dctype, entry->sac);
+ fill_pressures(&entry->pressures, amb_pressure, &dive->cylinder[cylinderindex].gasmix, entry->o2pressure, dive->dc.dctype, entry->sac);
fn2 = (int) (1000.0 * entry->pressures.n2 / amb_pressure);
fhe = (int) (1000.0 * entry->pressures.he / amb_pressure);
diff --git a/save-xml.c b/save-xml.c
index 52582dbaf..cf7ccfec7 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -214,8 +214,8 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl
put_format(b, " <sample time='%u:%02u min'", FRACTION(sample->time.seconds, 60));
put_milli(b, " depth='", sample->depth.mm, " m'");
put_temperature(b, sample->temperature, " temp='", " C'");
- put_pressure(b, sample->cylinderpressure, " pressure='", " bar'");
- put_pressure(b, sample->o2cylinderpressure, " pdiluent='", " bar'");
+ put_pressure(b, sample->cylinderpressure, " pdiluent='", " bar'");
+ put_pressure(b, sample->o2cylinderpressure, " pressure='", " bar'");
/*
* We only show sensor information for samples with pressure, and only if it
@@ -254,6 +254,21 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl
old->cns = sample->cns;
}
+ if ((sample->o2sensor[0].mbar) && (sample->o2sensor[0].mbar != old->o2sensor[0].mbar)) {
+ put_milli(b, " sensor1='", sample->o2sensor[0].mbar, " bar'");
+ old->o2sensor[0] = sample->o2sensor[0];
+ }
+
+ if ((sample->o2sensor[1].mbar) && (sample->o2sensor[1].mbar != old->o2sensor[1].mbar)) {
+ put_milli(b, " sensor2='", sample->o2sensor[1].mbar, " bar'");
+ old->o2sensor[1] = sample->o2sensor[1];
+ }
+
+ if ((sample->o2sensor[2].mbar) && (sample->o2sensor[2].mbar != old->o2sensor[2].mbar)) {
+ put_milli(b, " sensor3='", sample->o2sensor[2].mbar, " bar'");
+ old->o2sensor[2] = sample->o2sensor[2];
+ }
+
if (sample->setpoint.mbar != old->setpoint.mbar) {
put_milli(b, " po2='", sample->setpoint.mbar, " bar'");
old->setpoint = sample->setpoint;
@@ -355,6 +370,8 @@ static void save_dc(struct membuffer *b, struct dive *dive, struct divecomputer
for (enum dive_comp_type i = 0; i < NUM_DC_TYPE; i++)
if (dc->dctype == i)
show_utf8(b, dctype_text[i], " dctype='", "'", 1);
+ if (dc->no_o2sensors)
+ put_format(b," no_o2sensors='%d'", dc->no_o2sensors);
}
put_format(b, ">\n");
save_depths(b, dc);