mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Add planner infra structure for bailout
Add a divemode column to the planner model and a corresponding field to struct divepoint and fill it in the corresponding functions. Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
		
							parent
							
								
									6b0ecb012d
								
							
						
					
					
						commit
						69de9d8f98
					
				
					 5 changed files with 86 additions and 59 deletions
				
			
		| 
						 | 
					@ -874,6 +874,7 @@ struct divedatapoint {
 | 
				
			||||||
	int setpoint;
 | 
						int setpoint;
 | 
				
			||||||
	bool entered;
 | 
						bool entered;
 | 
				
			||||||
	struct divedatapoint *next;
 | 
						struct divedatapoint *next;
 | 
				
			||||||
 | 
						enum dive_comp_type divemode;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct diveplan {
 | 
					struct diveplan {
 | 
				
			||||||
| 
						 | 
					@ -890,7 +891,7 @@ struct diveplan {
 | 
				
			||||||
	int surface_interval;
 | 
						int surface_interval;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct divedatapoint *plan_add_segment(struct diveplan *diveplan, int duration, int depth, int cylinderid, int po2, bool entered);
 | 
					struct divedatapoint *plan_add_segment(struct diveplan *diveplan, int duration, int depth, int cylinderid, int po2, bool entered, enum dive_comp_type divemode);
 | 
				
			||||||
struct divedatapoint *create_dp(int time_incr, int depth, int cylinderid, int po2);
 | 
					struct divedatapoint *create_dp(int time_incr, int depth, int cylinderid, int po2);
 | 
				
			||||||
#if DEBUG_PLAN
 | 
					#if DEBUG_PLAN
 | 
				
			||||||
void dump_plan(struct diveplan *diveplan);
 | 
					void dump_plan(struct diveplan *diveplan);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -336,6 +336,11 @@ static void create_dive_from_plan(struct diveplan *diveplan, struct dive *dive,
 | 
				
			||||||
			finish_sample(dc);
 | 
								finish_sample(dc);
 | 
				
			||||||
			lastcylid = dp->cylinderid;
 | 
								lastcylid = dp->cylinderid;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							if (dp->divemode != type) {
 | 
				
			||||||
 | 
								type = dp->divemode;
 | 
				
			||||||
 | 
								add_event(dc, lasttime, 50 + type, 0, 0, divemode_text[type]);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* Create sample */
 | 
							/* Create sample */
 | 
				
			||||||
		sample = prepare_sample(dc);
 | 
							sample = prepare_sample(dc);
 | 
				
			||||||
		/* set po2 at beginning of this segment */
 | 
							/* set po2 at beginning of this segment */
 | 
				
			||||||
| 
						 | 
					@ -409,10 +414,11 @@ void add_to_end_of_diveplan(struct diveplan *diveplan, struct divedatapoint *dp)
 | 
				
			||||||
		dp->time += lasttime;
 | 
							dp->time += lasttime;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct divedatapoint *plan_add_segment(struct diveplan *diveplan, int duration, int depth, int cylinderid, int po2, bool entered)
 | 
					struct divedatapoint *plan_add_segment(struct diveplan *diveplan, int duration, int depth, int cylinderid, int po2, bool entered, enum dive_comp_type divemode)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct divedatapoint *dp = create_dp(duration, depth, cylinderid, po2);
 | 
						struct divedatapoint *dp = create_dp(duration, depth, cylinderid, po2);
 | 
				
			||||||
	dp->entered = entered;
 | 
						dp->entered = entered;
 | 
				
			||||||
 | 
						dp->divemode = divemode;
 | 
				
			||||||
	add_to_end_of_diveplan(diveplan, dp);
 | 
						add_to_end_of_diveplan(diveplan, dp);
 | 
				
			||||||
	return dp;
 | 
						return dp;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -690,6 +696,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
 | 
				
			||||||
	int laststoptime = timestep;
 | 
						int laststoptime = timestep;
 | 
				
			||||||
	bool o2breaking = false;
 | 
						bool o2breaking = false;
 | 
				
			||||||
	int decostopcounter = 0;
 | 
						int decostopcounter = 0;
 | 
				
			||||||
 | 
						enum dive_comp_type divemode = dive->dc.divemode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	set_gf(diveplan->gflow, diveplan->gfhigh);
 | 
						set_gf(diveplan->gflow, diveplan->gfhigh);
 | 
				
			||||||
	set_vpmb_conservatism(diveplan->vpmb_conservatism);
 | 
						set_vpmb_conservatism(diveplan->vpmb_conservatism);
 | 
				
			||||||
| 
						 | 
					@ -724,6 +731,8 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
 | 
				
			||||||
	bottom_time = clock = previous_point_time = dive->dc.sample[dive->dc.samples - 1].time.seconds;
 | 
						bottom_time = clock = previous_point_time = dive->dc.sample[dive->dc.samples - 1].time.seconds;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	current_cylinder = get_cylinderid_at_time(dive, &dive->dc, sample->time);
 | 
						current_cylinder = get_cylinderid_at_time(dive, &dive->dc, sample->time);
 | 
				
			||||||
 | 
						// FIXME: This needs a function to find the divemode at the end of the dive like in
 | 
				
			||||||
 | 
						// divemode = get_divemode_at_time(dive, &dive->dc, sample->time);
 | 
				
			||||||
	gas = dive->cylinder[current_cylinder].gasmix;
 | 
						gas = dive->cylinder[current_cylinder].gasmix;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	po2 = sample->setpoint.mbar;
 | 
						po2 = sample->setpoint.mbar;
 | 
				
			||||||
| 
						 | 
					@ -737,7 +746,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
 | 
				
			||||||
		 * same ascent rate as in fake_dc(). If you change it here, also change it there.
 | 
							 * same ascent rate as in fake_dc(). If you change it here, also change it there.
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
		transitiontime = lrint(depth / (double)prefs.ascratelast6m);
 | 
							transitiontime = lrint(depth / (double)prefs.ascratelast6m);
 | 
				
			||||||
		plan_add_segment(diveplan, transitiontime, 0, current_cylinder, po2, false);
 | 
							plan_add_segment(diveplan, transitiontime, 0, current_cylinder, po2, false, divemode);
 | 
				
			||||||
		create_dive_from_plan(diveplan, dive, is_planner);
 | 
							create_dive_from_plan(diveplan, dive, is_planner);
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -794,13 +803,13 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
 | 
				
			||||||
		// so we don't really have to compute the deco state.
 | 
							// so we don't really have to compute the deco state.
 | 
				
			||||||
		update_cylinder_pressure(dive, depth, depth, -timestep, prefs.bottomsac, &dive->cylinder[current_cylinder], false);
 | 
							update_cylinder_pressure(dive, depth, depth, -timestep, prefs.bottomsac, &dive->cylinder[current_cylinder], false);
 | 
				
			||||||
		clock -= timestep;
 | 
							clock -= timestep;
 | 
				
			||||||
		plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, true);
 | 
							plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, true, divemode);
 | 
				
			||||||
		previous_point_time = clock;
 | 
							previous_point_time = clock;
 | 
				
			||||||
		do {
 | 
							do {
 | 
				
			||||||
			/* Ascend to surface */
 | 
								/* Ascend to surface */
 | 
				
			||||||
			int deltad = ascent_velocity(depth, avg_depth, bottom_time) * TIMESTEP;
 | 
								int deltad = ascent_velocity(depth, avg_depth, bottom_time) * TIMESTEP;
 | 
				
			||||||
			if (ascent_velocity(depth, avg_depth, bottom_time) != last_ascend_rate) {
 | 
								if (ascent_velocity(depth, avg_depth, bottom_time) != last_ascend_rate) {
 | 
				
			||||||
				plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, false);
 | 
									plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, false, divemode);
 | 
				
			||||||
				previous_point_time = clock;
 | 
									previous_point_time = clock;
 | 
				
			||||||
				last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time);
 | 
									last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					@ -810,15 +819,15 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
 | 
				
			||||||
			clock += TIMESTEP;
 | 
								clock += TIMESTEP;
 | 
				
			||||||
			depth -= deltad;
 | 
								depth -= deltad;
 | 
				
			||||||
			if (depth <= 5000 && depth >= (5000 - deltad) && safety_stop) {
 | 
								if (depth <= 5000 && depth >= (5000 - deltad) && safety_stop) {
 | 
				
			||||||
				plan_add_segment(diveplan, clock - previous_point_time, 5000, current_cylinder, po2, false);
 | 
									plan_add_segment(diveplan, clock - previous_point_time, 5000, current_cylinder, po2, false, divemode);
 | 
				
			||||||
				previous_point_time = clock;
 | 
									previous_point_time = clock;
 | 
				
			||||||
				clock += 180;
 | 
									clock += 180;
 | 
				
			||||||
				plan_add_segment(diveplan, clock - previous_point_time, 5000, current_cylinder, po2, false);
 | 
									plan_add_segment(diveplan, clock - previous_point_time, 5000, current_cylinder, po2, false, divemode);
 | 
				
			||||||
				previous_point_time = clock;
 | 
									previous_point_time = clock;
 | 
				
			||||||
				safety_stop = false;
 | 
									safety_stop = false;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} while (depth > 0);
 | 
							} while (depth > 0);
 | 
				
			||||||
		plan_add_segment(diveplan, clock - previous_point_time, 0, current_cylinder, po2, false);
 | 
							plan_add_segment(diveplan, clock - previous_point_time, 0, current_cylinder, po2, false, divemode);
 | 
				
			||||||
		create_dive_from_plan(diveplan, dive, is_planner);
 | 
							create_dive_from_plan(diveplan, dive, is_planner);
 | 
				
			||||||
		add_plan_to_notes(diveplan, dive, show_disclaimer, error);
 | 
							add_plan_to_notes(diveplan, dive, show_disclaimer, error);
 | 
				
			||||||
		fixup_dc_duration(&dive->dc);
 | 
							fixup_dc_duration(&dive->dc);
 | 
				
			||||||
| 
						 | 
					@ -891,7 +900,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
 | 
				
			||||||
				int deltad = ascent_velocity(depth, avg_depth, bottom_time) * TIMESTEP;
 | 
									int deltad = ascent_velocity(depth, avg_depth, bottom_time) * TIMESTEP;
 | 
				
			||||||
				if (ascent_velocity(depth, avg_depth, bottom_time) != last_ascend_rate) {
 | 
									if (ascent_velocity(depth, avg_depth, bottom_time) != last_ascend_rate) {
 | 
				
			||||||
					if (is_final_plan)
 | 
										if (is_final_plan)
 | 
				
			||||||
						plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, false);
 | 
											plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, false, divemode);
 | 
				
			||||||
					previous_point_time = clock;
 | 
										previous_point_time = clock;
 | 
				
			||||||
					stopping = false;
 | 
										stopping = false;
 | 
				
			||||||
					last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time);
 | 
										last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time);
 | 
				
			||||||
| 
						 | 
					@ -917,7 +926,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
 | 
				
			||||||
				/* We have reached a gas change.
 | 
									/* We have reached a gas change.
 | 
				
			||||||
				 * Record this in the dive plan */
 | 
									 * Record this in the dive plan */
 | 
				
			||||||
				if (is_final_plan)
 | 
									if (is_final_plan)
 | 
				
			||||||
					plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, false);
 | 
										plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, false, divemode);
 | 
				
			||||||
				previous_point_time = clock;
 | 
									previous_point_time = clock;
 | 
				
			||||||
				stopping = true;
 | 
									stopping = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -975,7 +984,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
 | 
				
			||||||
					/* The last segment was an ascend segment.
 | 
										/* The last segment was an ascend segment.
 | 
				
			||||||
					 * Add a waypoint for start of this deco stop */
 | 
										 * Add a waypoint for start of this deco stop */
 | 
				
			||||||
					if (is_final_plan)
 | 
										if (is_final_plan)
 | 
				
			||||||
						plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, false);
 | 
											plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, false, divemode);
 | 
				
			||||||
					previous_point_time = clock;
 | 
										previous_point_time = clock;
 | 
				
			||||||
					stopping = true;
 | 
										stopping = true;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					@ -1029,7 +1038,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
 | 
				
			||||||
							o2break_next = true;
 | 
												o2break_next = true;
 | 
				
			||||||
							breakfrom_cylinder = current_cylinder;
 | 
												breakfrom_cylinder = current_cylinder;
 | 
				
			||||||
							if (is_final_plan)
 | 
												if (is_final_plan)
 | 
				
			||||||
								plan_add_segment(diveplan, laststoptime, depth, current_cylinder, po2, false);
 | 
													plan_add_segment(diveplan, laststoptime, depth, current_cylinder, po2, false, divemode);
 | 
				
			||||||
							previous_point_time = clock + laststoptime;
 | 
												previous_point_time = clock + laststoptime;
 | 
				
			||||||
							current_cylinder = break_cylinder;
 | 
												current_cylinder = break_cylinder;
 | 
				
			||||||
							gas = dive->cylinder[current_cylinder].gasmix;
 | 
												gas = dive->cylinder[current_cylinder].gasmix;
 | 
				
			||||||
| 
						 | 
					@ -1041,7 +1050,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
 | 
				
			||||||
							o2breaking  = true;
 | 
												o2breaking  = true;
 | 
				
			||||||
							o2break_next = false;
 | 
												o2break_next = false;
 | 
				
			||||||
							if (is_final_plan)
 | 
												if (is_final_plan)
 | 
				
			||||||
								plan_add_segment(diveplan, laststoptime, depth, current_cylinder, po2, false);
 | 
													plan_add_segment(diveplan, laststoptime, depth, current_cylinder, po2, false, divemode);
 | 
				
			||||||
							previous_point_time = clock + laststoptime;
 | 
												previous_point_time = clock + laststoptime;
 | 
				
			||||||
							current_cylinder = breakfrom_cylinder;
 | 
												current_cylinder = breakfrom_cylinder;
 | 
				
			||||||
							gas = dive->cylinder[current_cylinder].gasmix;
 | 
												gas = dive->cylinder[current_cylinder].gasmix;
 | 
				
			||||||
| 
						 | 
					@ -1062,7 +1071,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
 | 
				
			||||||
			if (stopping) {
 | 
								if (stopping) {
 | 
				
			||||||
				/* Next we will ascend again. Add a waypoint if we have spend deco time */
 | 
									/* Next we will ascend again. Add a waypoint if we have spend deco time */
 | 
				
			||||||
				if (is_final_plan)
 | 
									if (is_final_plan)
 | 
				
			||||||
					plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, false);
 | 
										plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, false, divemode);
 | 
				
			||||||
				previous_point_time = clock;
 | 
									previous_point_time = clock;
 | 
				
			||||||
				stopping = false;
 | 
									stopping = false;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					@ -1075,7 +1084,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
 | 
				
			||||||
	} while (!is_final_plan);
 | 
						} while (!is_final_plan);
 | 
				
			||||||
	decostoptable[decostopcounter].depth = 0;
 | 
						decostoptable[decostopcounter].depth = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	plan_add_segment(diveplan, clock - previous_point_time, 0, current_cylinder, po2, false);
 | 
						plan_add_segment(diveplan, clock - previous_point_time, 0, current_cylinder, po2, false, divemode);
 | 
				
			||||||
	if (decoMode() == VPMB) {
 | 
						if (decoMode() == VPMB) {
 | 
				
			||||||
		diveplan->eff_gfhigh = lrint(100.0 * regressionb());
 | 
							diveplan->eff_gfhigh = lrint(100.0 * regressionb());
 | 
				
			||||||
		diveplan->eff_gflow = lrint(100.0 * (regressiona() * first_stop_depth + regressionb()));
 | 
							diveplan->eff_gflow = lrint(100.0 * (regressiona() * first_stop_depth + regressionb()));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -252,6 +252,8 @@ QVariant DivePlannerPointsModel::data(const QModelIndex &index, int role) const
 | 
				
			||||||
				return (p.time - divepoints.at(index.row() - 1).time) / 60;
 | 
									return (p.time - divepoints.at(index.row() - 1).time) / 60;
 | 
				
			||||||
			else
 | 
								else
 | 
				
			||||||
				return p.time / 60;
 | 
									return p.time / 60;
 | 
				
			||||||
 | 
							case DIVEMODE:
 | 
				
			||||||
 | 
								return QString(divemode_text[p.divemode]);
 | 
				
			||||||
		case GAS:
 | 
							case GAS:
 | 
				
			||||||
			/* Check if we have the same gasmix two or more times
 | 
								/* Check if we have the same gasmix two or more times
 | 
				
			||||||
			 * If yes return more verbose string */
 | 
								 * If yes return more verbose string */
 | 
				
			||||||
| 
						 | 
					@ -330,6 +332,12 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v
 | 
				
			||||||
				CylindersModel::instance()->moveAtFirst(value.toInt());
 | 
									CylindersModel::instance()->moveAtFirst(value.toInt());
 | 
				
			||||||
			CylindersModel::instance()->updateTrashIcon();
 | 
								CylindersModel::instance()->updateTrashIcon();
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
							case DIVEMODE:
 | 
				
			||||||
 | 
								if (value.toInt() < FREEDIVE) // FIXME: I want to be a combo box and translate strings to enum values
 | 
				
			||||||
 | 
									p.divemode = (enum dive_comp_type) value.toInt();
 | 
				
			||||||
 | 
								if (index.row() == 0)
 | 
				
			||||||
 | 
									displayed_dive.dc.divemode = (enum dive_comp_type) value.toInt();
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		editStop(index.row(), p);
 | 
							editStop(index.row(), p);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -367,6 +375,8 @@ QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orienta
 | 
				
			||||||
			return tr("Used gas");
 | 
								return tr("Used gas");
 | 
				
			||||||
		case CCSETPOINT:
 | 
							case CCSETPOINT:
 | 
				
			||||||
			return tr("CC setpoint");
 | 
								return tr("CC setpoint");
 | 
				
			||||||
 | 
							case DIVEMODE:
 | 
				
			||||||
 | 
								return tr("Dive mode");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else if (role == Qt::FontRole) {
 | 
						} else if (role == Qt::FontRole) {
 | 
				
			||||||
		return defaultModelFont();
 | 
							return defaultModelFont();
 | 
				
			||||||
| 
						 | 
					@ -457,8 +467,10 @@ void DivePlannerPointsModel::setRebreatherMode(int mode)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
	displayed_dive.dc.divemode = (dive_comp_type) mode;
 | 
						displayed_dive.dc.divemode = (dive_comp_type) mode;
 | 
				
			||||||
	for (i=0; i < rowCount(); i++)
 | 
						for (i=0; i < rowCount(); i++) {
 | 
				
			||||||
		divepoints[i].setpoint = mode == CCR ? prefs.defaultsetpoint : 0;
 | 
							divepoints[i].setpoint = mode == CCR ? prefs.defaultsetpoint : 0;
 | 
				
			||||||
 | 
							divepoints[i].divemode = (enum dive_comp_type) mode;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	emitDataChanged();
 | 
						emitDataChanged();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -661,6 +673,7 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, int cylinderid_
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int cylinderid = 0;
 | 
						int cylinderid = 0;
 | 
				
			||||||
	bool usePrevious = false;
 | 
						bool usePrevious = false;
 | 
				
			||||||
 | 
						enum dive_comp_type divemode = displayed_dive.dc.divemode;
 | 
				
			||||||
	if (cylinderid_in >= 0)
 | 
						if (cylinderid_in >= 0)
 | 
				
			||||||
		cylinderid = cylinderid_in;
 | 
							cylinderid = cylinderid_in;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
| 
						 | 
					@ -703,8 +716,10 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, int cylinderid_
 | 
				
			||||||
	if (usePrevious) {
 | 
						if (usePrevious) {
 | 
				
			||||||
		if (row  < divepoints.count()) {
 | 
							if (row  < divepoints.count()) {
 | 
				
			||||||
			cylinderid = divepoints.at(row).cylinderid;
 | 
								cylinderid = divepoints.at(row).cylinderid;
 | 
				
			||||||
 | 
								divemode = divepoints.at(row).divemode;
 | 
				
			||||||
		} else if (row > 0) {
 | 
							} else if (row > 0) {
 | 
				
			||||||
			cylinderid = divepoints.at(row - 1).cylinderid;
 | 
								cylinderid = divepoints.at(row - 1).cylinderid;
 | 
				
			||||||
 | 
								divemode = divepoints.at(row - 1).divemode;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -716,6 +731,7 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, int cylinderid_
 | 
				
			||||||
	point.cylinderid = cylinderid;
 | 
						point.cylinderid = cylinderid;
 | 
				
			||||||
	point.setpoint = ccpoint;
 | 
						point.setpoint = ccpoint;
 | 
				
			||||||
	point.entered = entered;
 | 
						point.entered = entered;
 | 
				
			||||||
 | 
						point.divemode = divemode;
 | 
				
			||||||
	point.next = NULL;
 | 
						point.next = NULL;
 | 
				
			||||||
	divepoints.append(point);
 | 
						divepoints.append(point);
 | 
				
			||||||
	std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan);
 | 
						std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan);
 | 
				
			||||||
| 
						 | 
					@ -864,11 +880,11 @@ void DivePlannerPointsModel::createTemporaryPlan()
 | 
				
			||||||
		lastIndex = i;
 | 
							lastIndex = i;
 | 
				
			||||||
		if (i == 0 && mode == PLAN && prefs.drop_stone_mode) {
 | 
							if (i == 0 && mode == PLAN && prefs.drop_stone_mode) {
 | 
				
			||||||
			/* Okay, we add a first segment where we go down to depth */
 | 
								/* Okay, we add a first segment where we go down to depth */
 | 
				
			||||||
			plan_add_segment(&diveplan, p.depth.mm / prefs.descrate, p.depth.mm, p.cylinderid, p.setpoint, true);
 | 
								plan_add_segment(&diveplan, p.depth.mm / prefs.descrate, p.depth.mm, p.cylinderid, p.setpoint, true, p.divemode);
 | 
				
			||||||
			deltaT -= p.depth.mm / prefs.descrate;
 | 
								deltaT -= p.depth.mm / prefs.descrate;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (p.entered)
 | 
							if (p.entered)
 | 
				
			||||||
			plan_add_segment(&diveplan, deltaT, p.depth.mm, p.cylinderid, p.setpoint, true);
 | 
								plan_add_segment(&diveplan, deltaT, p.depth.mm, p.cylinderid, p.setpoint, true, p.divemode);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// what does the cache do???
 | 
						// what does the cache do???
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,6 +18,7 @@ public:
 | 
				
			||||||
		RUNTIME,
 | 
							RUNTIME,
 | 
				
			||||||
		GAS,
 | 
							GAS,
 | 
				
			||||||
		CCSETPOINT,
 | 
							CCSETPOINT,
 | 
				
			||||||
 | 
							DIVEMODE,
 | 
				
			||||||
		COLUMNS
 | 
							COLUMNS
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	enum Mode {
 | 
						enum Mode {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,10 +58,10 @@ void setupPlan(struct diveplan *dp)
 | 
				
			||||||
	free_dps(dp);
 | 
						free_dps(dp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int droptime = M_OR_FT(79, 260) * 60 / M_OR_FT(23, 75);
 | 
						int droptime = M_OR_FT(79, 260) * 60 / M_OR_FT(23, 75);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&ean36, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&ean36, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, droptime, M_OR_FT(79, 260), 0, 0, 1);
 | 
						plan_add_segment(dp, droptime, M_OR_FT(79, 260), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 30*60 - droptime, M_OR_FT(79, 260), 0, 0, 1);
 | 
						plan_add_segment(dp, 30*60 - droptime, M_OR_FT(79, 260), 0, 0, 1, OC);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setupPlanVpmb45m30mTx(struct diveplan *dp)
 | 
					void setupPlanVpmb45m30mTx(struct diveplan *dp)
 | 
				
			||||||
| 
						 | 
					@ -86,10 +86,10 @@ void setupPlanVpmb45m30mTx(struct diveplan *dp)
 | 
				
			||||||
	free_dps(dp);
 | 
						free_dps(dp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int droptime = M_OR_FT(45, 150) * 60 / M_OR_FT(23, 75);
 | 
						int droptime = M_OR_FT(45, 150) * 60 / M_OR_FT(23, 75);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, droptime, M_OR_FT(45, 150), 0, 0, 1);
 | 
						plan_add_segment(dp, droptime, M_OR_FT(45, 150), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 30*60 - droptime, M_OR_FT(45, 150), 0, 0, 1);
 | 
						plan_add_segment(dp, 30*60 - droptime, M_OR_FT(45, 150), 0, 0, 1, OC);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setupPlanVpmb60m10mTx(struct diveplan *dp)
 | 
					void setupPlanVpmb60m10mTx(struct diveplan *dp)
 | 
				
			||||||
| 
						 | 
					@ -114,10 +114,10 @@ void setupPlanVpmb60m10mTx(struct diveplan *dp)
 | 
				
			||||||
	free_dps(dp);
 | 
						free_dps(dp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(23, 75);
 | 
						int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(23, 75);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&tx50_15, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&tx50_15, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1);
 | 
						plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 10*60 - droptime, M_OR_FT(60, 200), 0, 0, 1);
 | 
						plan_add_segment(dp, 10*60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setupPlanVpmb60m30minAir(struct diveplan *dp)
 | 
					void setupPlanVpmb60m30minAir(struct diveplan *dp)
 | 
				
			||||||
| 
						 | 
					@ -136,8 +136,8 @@ void setupPlanVpmb60m30minAir(struct diveplan *dp)
 | 
				
			||||||
	free_dps(dp);
 | 
						free_dps(dp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
 | 
						int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
 | 
				
			||||||
	plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1);
 | 
						plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 30*60 - droptime, M_OR_FT(60, 200), 0, 0, 1);
 | 
						plan_add_segment(dp, 30*60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setupPlanVpmb60m30minEan50(struct diveplan *dp)
 | 
					void setupPlanVpmb60m30minEan50(struct diveplan *dp)
 | 
				
			||||||
| 
						 | 
					@ -159,9 +159,9 @@ void setupPlanVpmb60m30minEan50(struct diveplan *dp)
 | 
				
			||||||
	free_dps(dp);
 | 
						free_dps(dp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
 | 
						int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1);
 | 
						plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 30*60 - droptime, M_OR_FT(60, 200), 0, 0, 1);
 | 
						plan_add_segment(dp, 30*60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setupPlanVpmb60m30minTx(struct diveplan *dp)
 | 
					void setupPlanVpmb60m30minTx(struct diveplan *dp)
 | 
				
			||||||
| 
						 | 
					@ -183,9 +183,9 @@ void setupPlanVpmb60m30minTx(struct diveplan *dp)
 | 
				
			||||||
	free_dps(dp);
 | 
						free_dps(dp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
 | 
						int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1);
 | 
						plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 30*60 - droptime, M_OR_FT(60, 200), 0, 0, 1);
 | 
						plan_add_segment(dp, 30*60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setupPlanVpmbMultiLevelAir(struct diveplan *dp)
 | 
					void setupPlanVpmbMultiLevelAir(struct diveplan *dp)
 | 
				
			||||||
| 
						 | 
					@ -204,10 +204,10 @@ void setupPlanVpmbMultiLevelAir(struct diveplan *dp)
 | 
				
			||||||
	free_dps(dp);
 | 
						free_dps(dp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int droptime = M_OR_FT(20, 66) * 60 / M_OR_FT(99, 330);
 | 
						int droptime = M_OR_FT(20, 66) * 60 / M_OR_FT(99, 330);
 | 
				
			||||||
	plan_add_segment(dp, droptime, M_OR_FT(20, 66), 0, 0, 1);
 | 
						plan_add_segment(dp, droptime, M_OR_FT(20, 66), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 10*60 - droptime, M_OR_FT(20, 66), 0, 0, 1);
 | 
						plan_add_segment(dp, 10*60 - droptime, M_OR_FT(20, 66), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 1*60, M_OR_FT(60, 200), 0, 0, 1);
 | 
						plan_add_segment(dp, 1*60, M_OR_FT(60, 200), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 29*60, M_OR_FT(60, 200), 0, 0, 1);
 | 
						plan_add_segment(dp, 29*60, M_OR_FT(60, 200), 0, 0, 1, OC);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setupPlanVpmb100m60min(struct diveplan *dp)
 | 
					void setupPlanVpmb100m60min(struct diveplan *dp)
 | 
				
			||||||
| 
						 | 
					@ -231,10 +231,10 @@ void setupPlanVpmb100m60min(struct diveplan *dp)
 | 
				
			||||||
	free_dps(dp);
 | 
						free_dps(dp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
 | 
						int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1);
 | 
						plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 60*60 - droptime, M_OR_FT(100, 330), 0, 0, 1);
 | 
						plan_add_segment(dp, 60*60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setupPlanVpmb100m10min(struct diveplan *dp)
 | 
					void setupPlanVpmb100m10min(struct diveplan *dp)
 | 
				
			||||||
| 
						 | 
					@ -258,10 +258,10 @@ void setupPlanVpmb100m10min(struct diveplan *dp)
 | 
				
			||||||
	free_dps(dp);
 | 
						free_dps(dp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
 | 
						int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1);
 | 
						plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 10*60 - droptime, M_OR_FT(100, 330), 0, 0, 1);
 | 
						plan_add_segment(dp, 10*60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setupPlanVpmb30m20min(struct diveplan *dp)
 | 
					void setupPlanVpmb30m20min(struct diveplan *dp)
 | 
				
			||||||
| 
						 | 
					@ -280,8 +280,8 @@ void setupPlanVpmb30m20min(struct diveplan *dp)
 | 
				
			||||||
	free_dps(dp);
 | 
						free_dps(dp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int droptime = M_OR_FT(30, 100) * 60 / M_OR_FT(18, 60);
 | 
						int droptime = M_OR_FT(30, 100) * 60 / M_OR_FT(18, 60);
 | 
				
			||||||
	plan_add_segment(dp, droptime, M_OR_FT(30, 100), 0, 0, 1);
 | 
						plan_add_segment(dp, droptime, M_OR_FT(30, 100), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 20*60 - droptime, M_OR_FT(30, 100), 0, 0, 1);
 | 
						plan_add_segment(dp, 20*60 - droptime, M_OR_FT(30, 100), 0, 0, 1, OC);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setupPlanVpmb100mTo70m30min(struct diveplan *dp)
 | 
					void setupPlanVpmb100mTo70m30min(struct diveplan *dp)
 | 
				
			||||||
| 
						 | 
					@ -307,13 +307,13 @@ void setupPlanVpmb100mTo70m30min(struct diveplan *dp)
 | 
				
			||||||
	free_dps(dp);
 | 
						free_dps(dp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(18, 60);
 | 
						int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(18, 60);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&tx21_35, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&tx21_35, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 3, 0, 1);
 | 
						plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 3, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1);
 | 
						plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 20*60 - droptime, M_OR_FT(100, 330), 0, 0, 1);
 | 
						plan_add_segment(dp, 20*60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, 3*60, M_OR_FT(70, 230), 0, 0, 1);
 | 
						plan_add_segment(dp, 3*60, M_OR_FT(70, 230), 0, 0, 1, OC);
 | 
				
			||||||
	plan_add_segment(dp, (30 - 20 - 3) * 60, M_OR_FT(70, 230), 0, 0, 1);
 | 
						plan_add_segment(dp, (30 - 20 - 3) * 60, M_OR_FT(70, 230), 0, 0, 1, OC);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* We compare the calculated runtimes against two values:
 | 
					/* We compare the calculated runtimes against two values:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue