diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-01-23 10:25:31 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-01-23 12:55:33 -0800 |
commit | b6c9301e584722b9b46dffd4d759e8c60df520ad (patch) | |
tree | 2f963ec75672389692e532a8264dc83396900eb2 /dive.c | |
parent | 3e5a508b15fe28083dfdf5a049d33e8769616395 (diff) | |
download | subsurface-b6c9301e584722b9b46dffd4d759e8c60df520ad.tar.gz |
Move more dive computer filled data to the divecomputer structure
This moves the fields 'duration', 'surfacetime', 'maxdepth',
'meandepth', 'airtemp', 'watertemp', 'salinity' and 'surface_pressure'
to the per-divecomputer data structure. They are filled in by the dive
computer, and normally not edited.
NOTE! All actual *use* of this data was then changed from dive->field to
dive->dc.field programmatically with a shell-script and sed, and the
result then edited for details. So while the XML save and restore code
has been updated, all the displaying etc will currently always just show
the first dive computer entry.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r-- | dive.c | 37 |
1 files changed, 13 insertions, 24 deletions
@@ -516,9 +516,9 @@ struct dive *fixup_dive(struct dive *dive) } if (end < 0) { /* Assume an ascent/descent rate of 9 m/min */ - int depth = dive->maxdepth.mm; + int depth = dive->dc.maxdepth.mm; int asc_desc_time = depth*60/9000; - int duration = dive->duration.seconds; + int duration = dive->dc.duration.seconds; /* Some sanity checks against insane dives */ if (duration < 2) @@ -526,17 +526,17 @@ struct dive *fixup_dive(struct dive *dive) if (asc_desc_time * 2 >= duration) asc_desc_time = duration/2; - dive->meandepth.mm = depth*(duration-asc_desc_time)/duration; + dive->dc.meandepth.mm = depth*(duration-asc_desc_time)/duration; return dive; } - update_duration(&dive->duration, end - start); + update_duration(&dive->dc.duration, end - start); if (start != end) depthtime /= (end - start); - update_depth(&dive->meandepth, depthtime); - update_temperature(&dive->watertemp, mintemp); - update_depth(&dive->maxdepth, maxdepth); + update_depth(&dive->dc.meandepth, depthtime); + update_temperature(&dive->dc.watertemp, mintemp); + update_depth(&dive->dc.maxdepth, maxdepth); for (i = 0; i < MAX_CYLINDERS; i++) { cylinder_t *cyl = dive->cylinder + i; @@ -596,9 +596,6 @@ struct dive *fixup_dive(struct dive *dive) #define MERGE_TXT(res, a, b, n) res->n = merge_text(a->n, b->n) #define MERGE_NONZERO(res, a, b, n) res->n = a->n ? a->n : b->n -#define MERGE_MAX_PREFDL(res, dl, a, b, n) res->n = (dl && dl->n) ? dl->n : MAX(a->n, b->n) -#define MERGE_MIN_PREFDL(res, dl, a, b, n) res->n = (dl && dl->n) ? dl->n : (a->n)?(b->n)?MIN(a->n, b->n):(a->n):(b->n) - static struct sample *add_sample(struct sample *sample, int time, struct divecomputer *dc) { struct sample *p = prepare_sample(dc); @@ -1219,9 +1216,9 @@ static int likely_same_dive(struct dive *a, struct dive *b) * Do some basic sanity testing of the values we * have filled in during 'fixup_dive()' */ - if (!similar(a->maxdepth.mm, b->maxdepth.mm, 1000) || - !similar(a->meandepth.mm, b->meandepth.mm, 1000) || - !similar(a->duration.seconds, b->duration.seconds, 5*60)) + if (!similar(a->dc.maxdepth.mm, b->dc.maxdepth.mm, 1000) || + !similar(a->dc.meandepth.mm, b->dc.meandepth.mm, 1000) || + !similar(a->dc.duration.seconds, b->dc.duration.seconds, 5*60)) return 0; /* See if we can get an exact match on the dive computer */ @@ -1233,7 +1230,7 @@ static int likely_same_dive(struct dive *a, struct dive *b) * Allow a time difference due to dive computer time * setting etc. Check if they overlap. */ - fuzz = max_time(a->duration, b->duration) / 2; + fuzz = max_time(a->dc.duration, b->dc.duration) / 2; if (fuzz < 60) fuzz = 60; @@ -1395,9 +1392,8 @@ static void interleave_dive_computers(struct divecomputer *res, do { struct divecomputer *match; + *res = *a; res->model = a->model ? strdup(a->model) : NULL; - res->deviceid = a->deviceid; - res->diveid = a->diveid; res->next = NULL; match = find_matching_computer(a, b); @@ -1488,16 +1484,9 @@ struct dive *merge_dives(struct dive *a, struct dive *b, int offset, gboolean pr MERGE_MAX(res, a, b, rating); MERGE_TXT(res, a, b, suit); MERGE_MAX(res, a, b, number); - MERGE_MAX_PREFDL(res, dl, a, b, maxdepth.mm); - res->meandepth.mm = 0; - MERGE_NONZERO(res, a, b, salinity); + res->dc.meandepth.mm = 0; MERGE_NONZERO(res, a, b, cns); MERGE_NONZERO(res, a, b, visibility); - MERGE_NONZERO(res, a, b, surface_pressure.mbar); - MERGE_MAX_PREFDL(res, dl, a, b, duration.seconds); - MERGE_MAX_PREFDL(res, dl, a, b, surfacetime.seconds); - MERGE_MAX_PREFDL(res, dl, a, b, airtemp.mkelvin); - MERGE_MIN_PREFDL(res, dl, a, b, watertemp.mkelvin); merge_equipment(res, a, b); if (dl) { /* If we prefer downloaded, do those first, and get rid of "might be same" computers */ |