summaryrefslogtreecommitdiffstats
path: root/smtk-import
diff options
context:
space:
mode:
authorGravatar Salvador Cuñat <salvador.cunat@gmail.com>2017-03-16 17:07:56 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-03-18 08:33:31 -0700
commit5c757d5c387f47482556eab6292818b7eba27ce8 (patch)
tree0325d573a8b0be4dd063f12d33640d643c29a23d /smtk-import
parent16d37c254caf99484849bf9e7c8d72da1f3e4faf (diff)
downloadsubsurface-5c757d5c387f47482556eab6292818b7eba27ce8.tar.gz
smtk-import - Change cylinder import logic
Until now, we did the cylinder import based on its initial pressure (a tank without pressure is an unused tank). Based in this assumption, we just dropped those tanks whose initial press was 0, losing user introduced tank definitions and getting some duplicities due to one cylinder being numbered (e.g.) 2 by libdivecomputer and 3 by SmartTrak. The new workflow is: get every single tank reported by SmartTrak (giving preference to libdivecomputer parsed data), then clean the cylinder table reverse order, dropping tanks without description and init or end pressures, and checkig them against the previous cylinder to do a merge, if they look the same, and try to avoid duplicities. The new logic assumes a heavier workload for the benefit of lower data loss (e.g. a user may get his/her tanks descriptions despite he/she hasn't recorded their pressures because forgot the values or had an issue with the gas transmitter). Suggested-by: Alessandro Volpi <volpial@gmail.com> Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Diffstat (limited to 'smtk-import')
-rw-r--r--smtk-import/smartrak.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/smtk-import/smartrak.c b/smtk-import/smartrak.c
index 5e4becd83..a525409b6 100644
--- a/smtk-import/smartrak.c
+++ b/smtk-import/smartrak.c
@@ -863,26 +863,27 @@ void smartrak_import(const char *file, struct dive_table *divetable)
int hefraccol = coln(HEFRAC);
int tankidxcol = coln(TANKIDX);
- for (i = 0; i < numtanks; i++) {
- if (smtkdive->cylinder[i].start.mbar == 0) {
- smtkdive->cylinder[i].start.mbar = strtod(col[(i*2)+pstartcol]->bind_ptr, NULL) * 1000;
- smtkdive->cylinder[i].gasmix.o2.permille = strtod(col[i+o2fraccol]->bind_ptr, NULL) * 10;
- if (smtk_version == 10213)
- smtkdive->cylinder[i].gasmix.he.permille = strtod(col[i+hefraccol]->bind_ptr, NULL) * 10;
- else
- smtkdive->cylinder[i].gasmix.he.permille = 0;
- }
+ for (i = 0; i < tanks; i++) {
+ if (smtkdive->cylinder[i].start.mbar == 0)
+ smtkdive->cylinder[i].start.mbar = lrint(strtod(col[(i * 2) + pstartcol]->bind_ptr, NULL) * 1000);
/*
* If there is a start pressure ensure that end pressure is not zero as
* will be registered in DCs which only keep track of differential pressures,
* and collect the data registered by the user in mdb
*/
- if (smtkdive->cylinder[i].start.mbar != 0) {
- if (smtkdive->cylinder[i].end.mbar == 0)
- smtkdive->cylinder[i].end.mbar = strtod(col[(i * 2) + 1 + pstartcol]->bind_ptr, NULL) * 1000 ? : 1000;
- smtk_build_tank_info(mdb_clon, smtkdive, i, col[i + tankidxcol]->bind_ptr);
- }
+ if (smtkdive->cylinder[i].end.mbar == 0 && smtkdive->cylinder[i].start.mbar != 0)
+ smtkdive->cylinder[i].end.mbar = lrint(strtod(col[(i * 2) + 1 + pstartcol]->bind_ptr, NULL) * 1000 ? : 1000);
+ if (smtkdive->cylinder[i].gasmix.o2.permille == 0)
+ smtkdive->cylinder[i].gasmix.o2.permille = lrint(strtod(col[i + o2fraccol]->bind_ptr, NULL) * 10);
+ if (smtk_version == 10213)
+ if (smtkdive->cylinder[i].gasmix.he.permille == 0)
+ smtkdive->cylinder[i].gasmix.he.permille = lrint(strtod(col[i + hefraccol]->bind_ptr, NULL) * 10);
+ else
+ smtkdive->cylinder[i].gasmix.he.permille = 0;
+ smtk_build_tank_info(mdb_clon, &smtkdive->cylinder[i], col[i + tankidxcol]->bind_ptr);
}
+ /* Check for duplicated cylinders and clean them */
+ smtk_clean_cylinders(smtkdive);
/* Date issues with libdc parser - Take date time from mdb */
smtk_date_to_tm(col[coln(DATE)]->bind_ptr, tm_date);