mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Calculate gas consumption for planned dives
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									eae1624f24
								
							
						
					
					
						commit
						01e3210725
					
				
					 1 changed files with 14 additions and 0 deletions
				
			
		|  | @ -1454,6 +1454,20 @@ void DivePlannerPointsModel::createPlan() | ||||||
| 
 | 
 | ||||||
| 	createTemporaryPlan(); | 	createTemporaryPlan(); | ||||||
| 	plan(&diveplan, &cache, &tempDive, isPlanner(), &errorString); | 	plan(&diveplan, &cache, &tempDive, isPlanner(), &errorString); | ||||||
|  | 	copy_cylinders(stagingDive, tempDive); | ||||||
|  | 	int mean[MAX_CYLINDERS], duration[MAX_CYLINDERS]; | ||||||
|  | 	per_cylinder_mean_depth(tempDive, select_dc(&tempDive->dc), mean, duration); | ||||||
|  | 	for (int i = 0; i < MAX_CYLINDERS; i++) { | ||||||
|  | 		cylinder_t *cyl = tempDive->cylinder+i; | ||||||
|  | 		if (cylinder_none(cyl)) | ||||||
|  | 			continue; | ||||||
|  | 		// FIXME: The epic assumption that all the cylinders after the first is deco
 | ||||||
|  | 		int sac = i ? diveplan.decosac : diveplan.bottomsac; | ||||||
|  | 		cyl->start.mbar = cyl->type.workingpressure.mbar; | ||||||
|  | 		int consumption = ((depth_to_mbar(mean[i], tempDive) * duration[i] / 60) * sac) / ( cyl->type.size.mliter / 1000); | ||||||
|  | 		cyl->end.mbar = cyl->start.mbar - consumption; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	mark_divelist_changed(TRUE); | 	mark_divelist_changed(TRUE); | ||||||
| 
 | 
 | ||||||
| 	// Remove and clean the diveplan, so we don't delete
 | 	// Remove and clean the diveplan, so we don't delete
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue