comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 561:57622cb0d80f bug_deco_clearing_missed_stops

Bad deco behaviour when missing a stop...
author JeanDo
date Fri, 24 Feb 2012 00:16:46 +0100
parents 43296991c283
children 56753ea6a791
comparison
equal deleted inserted replaced
560:3a863016cb40 561:57622cb0d80f
79 // 2011/05/02: [jDG] Added "Future TTS" function (CF58). 79 // 2011/05/02: [jDG] Added "Future TTS" function (CF58).
80 // 2011/05/17: [jDG] Various cleanups. 80 // 2011/05/17: [jDG] Various cleanups.
81 // 2011/08/08: [jDG] Computes CNS during deco planning ascent. 81 // 2011/08/08: [jDG] Computes CNS during deco planning ascent.
82 // 2011/11/24: [jDG] Slightly faster and better NDL computation. 82 // 2011/11/24: [jDG] Slightly faster and better NDL computation.
83 // 2011/12/17: [mH] Remove of the useless debug stuff 83 // 2011/12/17: [mH] Remove of the useless debug stuff
84 // 2012/02/24: [jDG] Remove missed stop bug.
84 // 85 //
85 // TODO: 86 // TODO:
86 // + Allow to abort MD2 calculation (have to restart next time). 87 // + Allow to abort MD2 calculation (have to restart next time).
87 // 88 //
88 // Literature: 89 // Literature:
532 { 533 {
533 // Compute tolerated depth, for the leading tissue [metre]: 534 // Compute tolerated depth, for the leading tissue [metre]:
534 overlay float depth_tol = (sim_lead_tissue_limit - pres_surface) * BAR_TO_METER; 535 overlay float depth_tol = (sim_lead_tissue_limit - pres_surface) * BAR_TO_METER;
535 overlay unsigned char first_stop; 536 overlay unsigned char first_stop;
536 537
537 // If ascent is VERY fast, this can be lower than the actual depth... Because 538 // 2012-02-24 NOTE: Do not discard a stop just because we get shallower !
538 // this happends only in simulation, just forget about it: 539 // ---> Better to keep it red until the situation is cleared.
539 if( depth_tol > depth )
540 depth_tol = depth;
541 540
542 // Deepest stop, in multiples of 3 metres. 541 // Deepest stop, in multiples of 3 metres.
543 first_stop = 3 * (short)(0.99999 + depth_tol * 0.33333 ); 542 first_stop = 3 * (short)(0.99999 + depth_tol * 0.33333 );
544 assert( first_stop < 128 ); 543 assert( first_stop < 128 );
545 544
549 { 548 {
550 // Store the deepest stop depth, as reference for GF_low. 549 // Store the deepest stop depth, as reference for GF_low.
551 low_depth = depth_tol; 550 low_depth = depth_tol;
552 locked_GF_step = GF_delta / low_depth; 551 locked_GF_step = GF_delta / low_depth;
553 } 552 }
554
555 #if defined(__DEBUG) || defined(CROSS_COMPILE)
556 {
557 // Extra testing code to make sure the first_stop formula
558 // and rounding provides correct depth:
559 overlay float pres_stop = first_stop * METER_TO_BAR
560 + pres_surface;
561
562 // Keep GF_low until a first stop depth is found:
563 if( first_stop >= low_depth )
564 sim_limit( GF_low );
565 else
566 // current GF is GF_high - alpha (GF_high - GF_low)
567 // With alpha = currentDepth / maxDepth, hence in [0..1]
568 sim_limit( GF_high - first_stop * locked_GF_step );
569
570 // upper limit (lowest pressure tolerated), + 1mbar for rounding...:
571 assert( sim_lead_tissue_limit < (pres_stop + 0.001) );
572 }
573 #endif
574 553
575 // Apply correction for the shallowest stop. 554 // Apply correction for the shallowest stop.
576 if( first_stop == 3 ) // new in v104 555 if( first_stop == 3 ) // new in v104
577 first_stop = char_I_depth_last_deco; // Use last 3m..6m instead. 556 first_stop = char_I_depth_last_deco; // Use last 3m..6m instead.
578 557