comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 694:921f253117e4 deco_spike

deco-spike-01.patch
author heinrichsweikamp
date Wed, 13 Feb 2013 07:54:41 +0100
parents 6e456a6398e0
children
comparison
equal deleted inserted replaced
693:59e5998931d3 694:921f253117e4
529 // temp_depth_limt 529 // temp_depth_limt
530 // low_depth 530 // low_depth
531 // 531 //
532 static unsigned char calc_nextdecodepth(void) 532 static unsigned char calc_nextdecodepth(void)
533 { 533 {
534 signed short gf_step;
534 //--- Max ascent speed --------------------------------------------------- 535 //--- Max ascent speed ---------------------------------------------------
535 // Recompute leading gas limit, at current depth: 536 // Recompute leading gas limit, at current depth:
536 overlay float depth = (temp_deco - pres_surface) * BAR_TO_METER; 537 overlay float depth = (temp_deco - pres_surface) * BAR_TO_METER;
537 538
538 // At most, ascent 1 minute, at 10m/min == 10.0 m. 539 // At most, ascent 1 minute, at 10m/min == 10.0 m.
547 if( char_I_deco_model != 0 ) 548 if( char_I_deco_model != 0 )
548 { 549 {
549 overlay unsigned char first_stop = 0; 550 overlay unsigned char first_stop = 0;
550 overlay float p; 551 overlay float p;
551 552
552 sim_limit( GF_low ); 553 gf_step = (signed short)(low_depth - depth);
554 if (gf_step < 0)
555 gf_step = 0;
556 assert(GF_low + (gf_step + char_I_depth_last_deco) * locked_GF_step <= GF_high);
557
558 sim_limit( GF_low + gf_step * locked_GF_step);
553 p = sim_lead_tissue_limit - pres_surface; 559 p = sim_lead_tissue_limit - pres_surface;
554 if( p <= 0.0f ) 560 if( p <= 0.0f )
555 goto no_deco_stop; // We can surface directly... 561 goto no_deco_stop; // We can surface directly...
556 562
557 p *= BAR_TO_METER; 563 p *= BAR_TO_METER;
572 if( first_stop > low_depth ) 578 if( first_stop > low_depth )
573 { 579 {
574 low_depth = first_stop; 580 low_depth = first_stop;
575 locked_GF_step = GF_delta / first_stop; 581 locked_GF_step = GF_delta / first_stop;
576 } 582 }
577 583 goto deco_stop_found;
578 // We have a stop candidate.
579 // But maybe ascending to the next stop will diminish the constraint,
580 // because the GF might decrease more than the preassure gradient...
581 while(first_stop > 0)
582 {
583 overlay unsigned char next_stop; // Next depth (0..90m)
584 overlay float pres_stop; // Next pressure (bar)
585
586 // Check max speed, or reaching surface.
587 if( first_stop <= min_depth )
588 goto no_deco_stop;
589
590 if( first_stop <= char_I_depth_last_deco ) // new in v104
591 next_stop = 0;
592 else if( first_stop == 6 )
593 next_stop = char_I_depth_last_deco;
594 else
595 next_stop = first_stop - 3; // Index of next (upper) stop.
596
597 // Just a check we are indeed above LOW ref.
598 assert( next_stop < low_depth );
599
600 // Total preassure at the new stop candidate:
601 pres_stop = next_stop * METER_TO_BAR
602 + pres_surface;
603
604 // Keep GF_low until a first stop depth is found:
605 sim_limit( GF_high - next_stop * locked_GF_step );
606
607 // Check upper limit (lowest pressure tolerated):
608 if( sim_lead_tissue_limit >= pres_stop ) // check if ascent to next deco stop is ok
609 goto deco_stop_found;
610
611 // Else, validate that stop and loop...
612 first_stop = next_stop;
613 }
614 assert( first_stop == 0 );
615 584
616 no_deco_stop: 585 no_deco_stop:
617 temp_depth_limit = min_depth; 586 temp_depth_limit = min_depth;
618 goto done; 587 goto done;
619 588