mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Planner variations stop time calculation cover all stops
Simplify the sum up of the deco stop times for analysis of the planner variations. Plus rename define for deco stop variations debug output Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
		
							parent
							
								
									8f3ac0402c
								
							
						
					
					
						commit
						1bd2f3fe3e
					
				
					 1 changed files with 17 additions and 20 deletions
				
			
		|  | @ -986,32 +986,29 @@ struct divedatapoint * DivePlannerPointsModel::cloneDiveplan(struct diveplan *pl | |||
| 
 | ||||
| int DivePlannerPointsModel::analyzeVariations(struct decostop *min, struct decostop *mid, struct decostop *max, const char *unit) | ||||
| { | ||||
| 	int minsum = 0; | ||||
| 	int midsum = 0; | ||||
| 	int maxsum = 0; | ||||
| 	int leftsum = 0; | ||||
| 	int rightsum = 0; | ||||
| 	while (mid->depth > min->depth) | ||||
| 		++mid; | ||||
| 	while (max->depth > mid->depth) | ||||
| 		++max; | ||||
| 
 | ||||
| 	while (mid->depth) { | ||||
| 		int left = mid->time - min->time; | ||||
| 		leftsum += left; | ||||
| 		int right = max->time - mid->time; | ||||
| 		rightsum += right; | ||||
| #ifdef SHOWSTOPVARIATIONS | ||||
| 		if (min->time + mid->time + max->time) | ||||
| 			printf("%dm: %dmin + %ds/%s +- %ds/%s\n", mid->depth / 1000, | ||||
| 			       (mid->time + 1)/60, | ||||
| 			       (left + right) / 2, unit, | ||||
| 			       (right - left) / 2, unit); | ||||
| #else | ||||
| 		(void) unit; | ||||
| #endif | ||||
| 	while (min->depth) { | ||||
| 		minsum += min->time; | ||||
| 		++min; | ||||
| 	} | ||||
| 	while (mid->depth) { | ||||
| 		midsum += mid->time; | ||||
| 		++mid; | ||||
| 	} | ||||
| 	while (max->depth) { | ||||
| 		maxsum += max->time; | ||||
| 		++max; | ||||
| 	} | ||||
| #ifdef SHOWSTOPVARIATIONS | ||||
| 
 | ||||
| 	leftsum = midsum - minsum; | ||||
| 	rightsum = maxsum - midsum; | ||||
| 
 | ||||
| #ifdef DEBUG_STOPVAR | ||||
| 	printf("Total + %d:%02d/%s +- %d s/%s\n\n", FRACTION((leftsum + rightsum) / 2, 60), unit, | ||||
| 						       (rightsum - leftsum) / 2, unit); | ||||
| #endif | ||||
|  | @ -1093,7 +1090,7 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, s | |||
| 				FRACTION(analyzeVariations(shorter, original, longer, "min"), 60)); | ||||
| 
 | ||||
| 		emit variationsComputed(QString(buf)); | ||||
| #ifdef SHOWSTOPVARIATIONS | ||||
| #ifdef DEBUG_STOPVAR | ||||
| 		printf("\n\n"); | ||||
| #endif | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue