mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Only calculate deco stops in planner mode
In add dive mode simply bring the diver safely back to the surface (currently with a fixed ascent rate of 30ft/min (or 9m/min)). We should make that rate configurable (for the planner as well as the dive add function). Also, the dive add function should offer to automatically include a safety stop. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4141c68450
commit
56535e4b3b
4 changed files with 18 additions and 5 deletions
2
dive.h
2
dive.h
|
@ -719,7 +719,7 @@ void free_dps(struct divedatapoint *dp);
|
||||||
void get_gas_string(int o2, int he, char *buf, int len);
|
void get_gas_string(int o2, int he, char *buf, int len);
|
||||||
struct divedatapoint *create_dp(int time_incr, int depth, int o2, int he, int po2);
|
struct divedatapoint *create_dp(int time_incr, int depth, int o2, int he, int po2);
|
||||||
void dump_plan(struct diveplan *diveplan);
|
void dump_plan(struct diveplan *diveplan);
|
||||||
void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, char **error_string_p);
|
void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, bool add_deco, char **error_string_p);
|
||||||
void delete_single_dive(int idx);
|
void delete_single_dive(int idx);
|
||||||
|
|
||||||
struct event *get_next_event(struct event *event, char *name);
|
struct event *get_next_event(struct event *event, char *name);
|
||||||
|
|
15
planner.c
15
planner.c
|
@ -594,7 +594,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, char **error_string_p)
|
void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, bool add_deco, char **error_string_p)
|
||||||
{
|
{
|
||||||
struct dive *dive;
|
struct dive *dive;
|
||||||
struct sample *sample;
|
struct sample *sample;
|
||||||
|
@ -623,6 +623,19 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, c
|
||||||
get_gas_from_events(&dive->dc, sample->time.seconds, &o2, &he);
|
get_gas_from_events(&dive->dc, sample->time.seconds, &o2, &he);
|
||||||
po2 = dive->dc.sample[dive->dc.samples - 1].po2;
|
po2 = dive->dc.sample[dive->dc.samples - 1].po2;
|
||||||
depth = dive->dc.sample[dive->dc.samples - 1].depth.mm;
|
depth = dive->dc.sample[dive->dc.samples - 1].depth.mm;
|
||||||
|
|
||||||
|
/* if all we wanted was the dive just get us back to the surface */
|
||||||
|
if (!add_deco) {
|
||||||
|
transitiontime = depth / 150; /* this still needs to be made configurable */
|
||||||
|
plan_add_segment(diveplan, transitiontime, 0, o2, he, po2);
|
||||||
|
/* re-create the dive */
|
||||||
|
delete_single_dive(dive_table.nr - 1);
|
||||||
|
*divep = dive = create_dive_from_plan(diveplan, error_string_p);
|
||||||
|
if (dive)
|
||||||
|
record_dive(dive);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tissue_tolerance = tissue_at_end(dive, cached_datap, error_string_p);
|
tissue_tolerance = tissue_at_end(dive, cached_datap, error_string_p);
|
||||||
ceiling = deco_allowed_depth(tissue_tolerance, diveplan->surface_pressure / 1000.0, dive, 1);
|
ceiling = deco_allowed_depth(tissue_tolerance, diveplan->surface_pressure / 1000.0, dive, 1);
|
||||||
#if DEBUG_PLAN & 4
|
#if DEBUG_PLAN & 4
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void plan(struct diveplan *diveplan, char **cache_datap, struct dive **divep, char **error_string_p);
|
extern void plan(struct diveplan *diveplan, char **cache_datap, struct dive **divep, bool add_plan, char **error_string_p);
|
||||||
extern int validate_gas(const char *text, int *o2_p, int *he_p);
|
extern int validate_gas(const char *text, int *o2_p, int *he_p);
|
||||||
extern int validate_time(const char *text, int *sec_p, int *rel_p);
|
extern int validate_time(const char *text, int *sec_p, int *rel_p);
|
||||||
extern int validate_depth(const char *text, int *mm_p);
|
extern int validate_depth(const char *text, int *mm_p);
|
||||||
|
|
|
@ -1148,7 +1148,7 @@ void DivePlannerPointsModel::createTemporaryPlan()
|
||||||
char *cache = NULL;
|
char *cache = NULL;
|
||||||
tempDive = NULL;
|
tempDive = NULL;
|
||||||
char *errorString = NULL;
|
char *errorString = NULL;
|
||||||
plan(&diveplan, &cache, &tempDive, &errorString);
|
plan(&diveplan, &cache, &tempDive, isPlanner(), &errorString);
|
||||||
#if DEBUG_PLAN
|
#if DEBUG_PLAN
|
||||||
dump_plan(&diveplan);
|
dump_plan(&diveplan);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1181,7 +1181,7 @@ void DivePlannerPointsModel::createPlan()
|
||||||
char *errorString = NULL;
|
char *errorString = NULL;
|
||||||
|
|
||||||
createTemporaryPlan();
|
createTemporaryPlan();
|
||||||
plan(&diveplan, &cache, &tempDive, &errorString);
|
plan(&diveplan, &cache, &tempDive, isPlanner(), &errorString);
|
||||||
mark_divelist_changed(TRUE);
|
mark_divelist_changed(TRUE);
|
||||||
|
|
||||||
// Remove and clean the diveplan, so we don't delete
|
// Remove and clean the diveplan, so we don't delete
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue