Mercurial > public > mk2
changeset 368:de3b267e1fd9
Adding calc_dive_interval()
author | JeanDo |
---|---|
date | Thu, 09 Jun 2011 23:06:25 +0200 |
parents | bdcc5a5aa8d5 |
children | 93c0cb14b0d2 |
files | code_part1/OSTC_code_c_part2/p2_deco.c code_part1/OSTC_code_c_part2/p2_deco.o code_part1/OSTC_code_c_part2/p2_definitions.h code_part1/OSTC_code_c_part2/shared_definitions.h |
diffstat | 4 files changed, 47 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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<char_I_dive_interval; ++t) + { + calc_tissue(2); // period = 10min. + CNS_fraction = 0.92587471 * CNS_fraction; // Half-time = 90min: (1/2)^(1/9) + } + char_O_CNS_fraction = (char)(CNS_fraction * 100.0 + 0.5); +} + +////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// deco_hash ///////////////////////////////// //////////////////////////////////////////////////////////////////////////////
--- a/code_part1/OSTC_code_c_part2/p2_definitions.h Thu Jun 09 16:05:16 2011 +0200 +++ b/code_part1/OSTC_code_c_part2/p2_definitions.h Thu Jun 09 23:06:25 2011 +0200 @@ -83,6 +83,7 @@ extern void deco_clear_tissue(void); extern void deco_calc_percentage(void); extern void deco_calc_wo_deco_step_1_min(void); +extern void deco_calc_dive_interval(void); extern void deco_debug(void); extern void deco_gradient_array(void); extern void deco_hash(void);
--- a/code_part1/OSTC_code_c_part2/shared_definitions.h Thu Jun 09 16:05:16 2011 +0200 +++ b/code_part1/OSTC_code_c_part2/shared_definitions.h Thu Jun 09 23:06:25 2011 +0200 @@ -156,6 +156,7 @@ VAR_UCHAR (char_I_deco_model); // new in v.102. 0 == ZH-L16, 1 = ZH-L16-GF (Grandiant facttor) VAR_UCHAR (char_I_bottom_depth); // Bottom depth for planning (used in gas volume evaluation). VAR_UCHAR (char_I_bottom_time); // Bottom time for planning (used in gas volume evaluation). +VAR_UCHAR (char_I_dive_interval); // Delay before next dive simulation. TAB_UCHAR (char_I_deco_gas_change,NUM_GAS);// new in v.101 TAB_UCHAR (char_I_deco_N2_ratio, NUM_GAS); // new in v.101