Ejemplo n.º 1
0
unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, gboolean smooth)
{
	unsigned int depth, multiples_of_3m;
	gboolean below_gradient_limit;
	double new_gradient_factor;
	double pressure_delta = tissues_tolerance - surface_pressure;
	struct dive_data mydata;

	if (pressure_delta > 0) {
		if (!smooth) {
			multiples_of_3m = (pressure_delta + DIST_FROM_3_MTR) / 0.3;
			depth = 3000 * multiples_of_3m;
		} else {
			depth = rel_mbar_to_depth(pressure_delta * 1000, dive);
		}
	} else {
		depth = 0;
	}
	mydata.pressure = depth_to_mbar(depth, dive) / 1000.0;
	mydata.surface = surface_pressure;

	new_gradient_factor = gradient_factor_calculation(&mydata);
	below_gradient_limit = (new_gradient_factor < actual_gradient_limit(&mydata));
	while(!below_gradient_limit)
	{
		if (!smooth)
			mydata.pressure += PRESSURE_CHANGE_3M;
		else
			mydata.pressure += PRESSURE_CHANGE_3M / 30; /* 4in / 10cm instead */
		new_gradient_factor = gradient_factor_calculation(&mydata);
		below_gradient_limit = (new_gradient_factor < actual_gradient_limit(&mydata));
	}
	depth = rel_mbar_to_depth((mydata.pressure - surface_pressure) * 1000, dive);
	return depth;
}
Ejemplo n.º 2
0
unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, gboolean smooth)
{
	unsigned int depth;
	double pressure_delta;

	/* Avoid negative depths */
	pressure_delta = tissues_tolerance > surface_pressure ? tissues_tolerance - surface_pressure : 0.0;

	depth = rel_mbar_to_depth(pressure_delta * 1000, dive);

	if(!smooth)
		depth = ceil(depth / DECO_STOPS_MULTIPLIER_MM) * DECO_STOPS_MULTIPLIER_MM;

	if(depth > 0 && depth < buehlmann_config.last_deco_stop_in_mtr * 1000)
		depth = buehlmann_config.last_deco_stop_in_mtr * 1000;

	return depth;
}