# HG changeset patch # User JeanDo # Date 1307653585 -7200 # Node ID de3b267e1fd99a963d4bca2d570d9fd39338e855 # Parent bdcc5a5aa8d5de09c666cc665347887c4ebcb113 Adding calc_dive_interval() diff -r bdcc5a5aa8d5 -r de3b267e1fd9 code_part1/OSTC_code_c_part2/p2_deco.c --- a/code_part1/OSTC_code_c_part2/p2_deco.c Thu Jun 09 16:05:16 2011 +0200 +++ b/code_part1/OSTC_code_c_part2/p2_deco.c Thu Jun 09 23:06:25 2011 +0200 @@ -131,6 +131,7 @@ static void sim_tissue(PARAMETER unsigned char period); static void sim_limit(PARAMETER float GF_current); static void sim_extra_time(void); +static void calc_dive_interval(void); static void calc_gradient_factor(void); static void calc_wo_deco_step_1_min(void); @@ -963,6 +964,14 @@ ////////////////////////////////////////////////////////////////////////////// +void deco_calc_dive_interval(void) +{ + RESET_C_STACK + calc_dive_interval(); +} + +////////////////////////////////////////////////////////////////////////////// + void deco_debug(void) { RESET_C_STACK @@ -2142,9 +2151,8 @@ } N2_ratio = 0.7902; // FIXED, sum lt. buehlmann - pres_respiration = int_I_pres_respiration * 0.001; // assembler code uses different digit system - pres_surface = int_I_pres_surface * 0.001; // the b"uhlmann formula using pres_surface does not use the N2_ratio - ppN2 = N2_ratio * (pres_respiration - ppWater); // ppWater is the extra pressure in the body + pres_respiration = pres_surface = int_I_pres_surface * 0.001; + ppN2 = N2_ratio * (pres_respiration - ppWater); ppHe = 0.0; float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142) float_saturation_multiplier = char_I_saturation_multiplier * 0.01; @@ -2160,6 +2168,40 @@ } ////////////////////////////////////////////////////////////////////////////// +// calc_dive_interval +// +// Prepare tissue for delay before the next dive simulation. +// +// Inputs: char_I_dive_interval == delay before dive (in 10' steps). +// Outputs: pres_tissue_N2/He[], CNS_fraction +// +// Should be protected by deco_push_tissues_to_vault(), +// deco_pull_tissues_from_vault() +// +// desaturation slowed down to 70,42%. +// +static void calc_dive_interval() +{ + overlay unsigned char t; + + //---- Initialize simulation parameters ---------------------------------- + N2_ratio = 0.7902; // FIXED, sum lt. buehlmann + pres_respiration = pres_surface = int_I_pres_surface * 0.001; + ppN2 = N2_ratio * (pres_respiration - ppWater); + ppHe = 0.0; + float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142) + float_saturation_multiplier = char_I_saturation_multiplier * 0.01; + + //---- Perform simulation ------------------------------------------------ + for(t=0; t