summaryrefslogtreecommitdiffstats
path: root/core/file.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2017-08-03 11:34:20 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-08-03 13:29:25 -0700
commit8fe24055f025428eabd353f542ab7928cff0a8c1 (patch)
tree649071b7588c922d84399e7b5c3894616273e899 /core/file.c
parentb4063de452c4ebe5f554ffca5f807dc363136b09 (diff)
downloadsubsurface-8fe24055f025428eabd353f542ab7928cff0a8c1.tar.gz
Fix Poseidon MkVI txt file import sensor pressures
When I unified the sample pressures in commit 11a0c0cc7018 ("Unify sample pressure and o2pressure as pressure[2] array") I did all the obvious conversions, including the conversion of the Poseidon txt file import: case POSEIDON_PRESSURE: - sample->cylinderpressure.mbar = lrint(val * 1000); + sample->pressure[0].mbar = lrint(val * 1000); break; case POSEIDON_O2CYLINDER: - sample->o2cylinderpressure.mbar = lrint(val * 1000); + sample->pressure[1].mbar = lrint(val * 1000); break; which was ObviouslyCorrect(tm). But as so often is the case, obvious doesn't actually exist. The old "o2cylinderpressure[]" model had an implicit sensor associated with it, and that implicit sensor mapping wasn't obvious, and didn't get fixed. It turns out that the way the Poseidon sensor mapping works, the O2 cylinder is cylinder 0, and the diluent cylinder is cylinder 1, so just use the add_sample_pressure() helper to set both sensor index and pressure value. And since we now do all the sensor indexing right, we can also get rid of some manual cylinder sample pressure code, because the generic dive fixup will just DTRT. It used to screw up because the diluent sensor number was wrong before, and the import code tried to work around that by hand. Reported-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/file.c')
-rw-r--r--core/file.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/core/file.c b/core/file.c
index b2ff56f49..dddc77826 100644
--- a/core/file.c
+++ b/core/file.c
@@ -275,8 +275,6 @@ enum csv_format {
POSEIDON_SETPOINT,
POSEIDON_SENSOR1,
POSEIDON_SENSOR2,
- POSEIDON_PRESSURE,
- POSEIDON_O2CYLINDER,
POSEIDON_NDL,
POSEIDON_CEILING
};
@@ -308,12 +306,6 @@ static void add_sample_data(struct sample *sample, enum csv_format type, double
case POSEIDON_SENSOR2:
sample->o2sensor[1].mbar = lrint(val * 10);
break;
- case POSEIDON_PRESSURE:
- sample->pressure[0].mbar = lrint(val * 1000);
- break;
- case POSEIDON_O2CYLINDER:
- sample->pressure[1].mbar = lrint(val * 1000);
- break;
case POSEIDON_NDL:
sample->ndl.seconds = lrint(val * 60);
break;
@@ -609,7 +601,7 @@ int parse_txt_file(const char *filename, const char *csv)
int prev_depth = 0, cur_sampletime = 0, prev_setpoint = -1, prev_ndl = -1;
bool has_depth = false, has_setpoint = false, has_ndl = false;
char *lineptr, *key, *value;
- int o2cylinder_pressure = 0, cylinder_pressure = 0, cur_cylinder_index = 0;
+ int cur_cylinder_index = 0;
unsigned int prev_time = 0;
struct dive *dive;
@@ -780,21 +772,11 @@ int parse_txt_file(const char *filename, const char *csv)
break;
case 13:
//O2 Tank Pressure
- add_sample_data(sample, POSEIDON_O2CYLINDER, value);
- if (!o2cylinder_pressure) {
- dive->cylinder[0].sample_start.mbar = value * 1000;
- o2cylinder_pressure = value;
- } else
- o2cylinder_pressure = value;
+ add_sample_pressure(sample, 0, lrint(value * 1000));
break;
case 14:
//Diluent Tank Pressure
- add_sample_data(sample, POSEIDON_PRESSURE, value);
- if (!cylinder_pressure) {
- dive->cylinder[1].sample_start.mbar = value * 1000;
- cylinder_pressure = value;
- } else
- cylinder_pressure = value;
+ add_sample_pressure(sample, 1, lrint(value * 1000));
break;
//16 Remaining dive time #1?
//17 related to O2 injection
@@ -874,10 +856,6 @@ int parse_txt_file(const char *filename, const char *csv)
add_sample_data(sample, POSEIDON_SETPOINT, prev_setpoint);
if (!has_ndl && prev_ndl >= 0)
add_sample_data(sample, POSEIDON_NDL, prev_ndl);
- if (cylinder_pressure)
- dive->cylinder[1].sample_end.mbar = cylinder_pressure * 1000;
- if (o2cylinder_pressure)
- dive->cylinder[0].sample_end.mbar = o2cylinder_pressure * 1000;
finish_sample(dc);
if (!lineptr || !*lineptr)