mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
16d37c254c
commit
5c757d5c38
1 changed files with 15 additions and 14 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue