summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-22 20:15:33 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-22 20:35:02 +0900
commit6495b629fedff6b7bb0ada72c8ddfe322043c28d (patch)
tree7f6ffc7e541e6f5ba1aa2442bcd9e9bba7bb1117
parentf1c682b55a52c11d7cb57da0fc66d6edb118ba77 (diff)
downloadsubsurface-6495b629fedff6b7bb0ada72c8ddfe322043c28d.tar.gz
Interpretive dance to parse Suunto EON Steel tank sizes
Admittedly, imperial tank sizes are a bit weird. But it must have taken some effort to break things as creatievly as Suunto did. The UI allows only multiples of 100psi and multiples of 10cuft. Which shows that the developers have no idea what typical imperial tanks look like. AL72? AL63? HP tanks at 3440psi? LP+ at 2640psi? Yeah, I get it - you had no idea, someone showed you an AL80 and you made silly assumptions. But even then, what the heck are you storing in your data, dear Suunto? The pressures are off by the very logical factor of 1.00069182389937. And then regardless whether I use the wrong pressure or the corrected pressure, the wet sizes are too small by a non-constant factor. So this code takes the junk that libdivecomputer truthfully passes through from the Suunto parser and tries to convert it into something that matches what the user most likely entered in the EON Steel UI. Ugly. Stupid. But it seems to work. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--libdivecomputer.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c
index 26f5e59bd..a9d90d837 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -126,6 +126,39 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
if (tank.type == DC_TANKVOLUME_IMPERIAL) {
dive->cylinder[i].type.size.mliter = rint(tank.volume * 1000);
dive->cylinder[i].type.workingpressure.mbar = rint(tank.workpressure * 1000);
+ if (same_string(devdata->model, "Suunto EON Steel")) {
+ /* Suunto EON Steele gets this wrong. Badly.
+ * but on the plus side it only supports a few imperial sizes,
+ * so let's try and guess at least the most common ones.
+ * First, the pressures are off by a constant factor. WTF?
+ * Then we can round the wet sizes so we get to multiples of 10
+ * for cuft sizes (as that's all that you can enter) */
+ dive->cylinder[i].type.workingpressure.mbar *= 206.843 / 206.7;
+ char name_buffer[9];
+ int rounded_size = ml_to_cuft(gas_volume(&dive->cylinder[i],
+ dive->cylinder[i].type.workingpressure));
+ rounded_size = (int)((rounded_size + 5) / 10) * 10;
+ switch (dive->cylinder[i].type.workingpressure.mbar) {
+ case 206843:
+ snprintf(name_buffer, 9, "AL%d", rounded_size);
+ break;
+ case 234422: /* this is wrong - HP tanks tend to be 3440, but Suunto only allows 3400 */
+ snprintf(name_buffer, 9, "HP%d", rounded_size);
+ break;
+ case 179263:
+ snprintf(name_buffer, 9, "LP+%d", rounded_size);
+ break;
+ case 165474:
+ snprintf(name_buffer, 9, "LP%d", rounded_size);
+ break;
+ default:
+ snprintf(name_buffer, 9, "%d cuft", rounded_size);
+ break;
+ }
+ dive->cylinder[i].type.description = copy_string(name_buffer);
+ dive->cylinder[i].type.size.mliter = cuft_to_l(rounded_size) * 1000 /
+ mbar_to_atm(dive->cylinder[i].type.workingpressure.mbar);
+ }
} else if (tank.type == DC_TANKVOLUME_METRIC) {
dive->cylinder[i].type.size.mliter = rint(tank.volume * 1000);
}