mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Do per cylinder statistics
This shows how much gas form each cylinder was used. I would like to add SAC to that list too but it became a mess trying to calculate average depth per cylinder. Design based on idea in #284 Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									732f7a69b0
								
							
						
					
					
						commit
						eb027f2a4b
					
				
					 3 changed files with 18 additions and 10 deletions
				
			
		|  | @ -350,7 +350,12 @@ void MainTab::updateDiveInfo(int dive) | ||||||
| 		ui.otuText->setText(QString("%1").arg(d->otu)); | 		ui.otuText->setText(QString("%1").arg(d->otu)); | ||||||
| 		ui.waterTemperatureText->setText(get_temperature_string(d->watertemp, TRUE)); | 		ui.waterTemperatureText->setText(get_temperature_string(d->watertemp, TRUE)); | ||||||
| 		ui.airTemperatureText->setText(get_temperature_string(d->airtemp, TRUE)); | 		ui.airTemperatureText->setText(get_temperature_string(d->airtemp, TRUE)); | ||||||
| 		ui.gasUsedText->setText(get_volume_string(get_gas_used(d), TRUE)); | 		volume_t gases[MAX_CYLINDERS] = { 0 }; | ||||||
|  | 		get_gas_used(d, gases); | ||||||
|  | 		QString volumes = get_volume_string(gases[0], TRUE); | ||||||
|  | 		for(int i=1; i < MAX_CYLINDERS && gases[i].mliter != 0; i++) | ||||||
|  | 			volumes.append("\n" + get_volume_string(gases[i], TRUE)); | ||||||
|  | 		ui.gasUsedText->setText(volumes); | ||||||
| 		ui.oxygenHeliumText->setText(get_gaslist(d)); | 		ui.oxygenHeliumText->setText(get_gaslist(d)); | ||||||
| 		ui.dateText->setText(get_short_dive_date_string(d->when)); | 		ui.dateText->setText(get_short_dive_date_string(d->when)); | ||||||
| 		ui.diveTimeText->setText(QString::number((int)((d->duration.seconds + 30) / 60))); | 		ui.diveTimeText->setText(QString::number((int)((d->duration.seconds + 30) / 60))); | ||||||
|  |  | ||||||
							
								
								
									
										19
									
								
								statistics.c
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								statistics.c
									
										
									
									
									
								
							|  | @ -268,7 +268,7 @@ void get_selected_dives_text(char *buffer, int size) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| volume_t get_gas_used(struct dive *dive) | void get_gas_used(struct dive *dive, volume_t gases[MAX_CYLINDERS]) | ||||||
| { | { | ||||||
| 	int idx; | 	int idx; | ||||||
| 	volume_t gas_used = { 0 }; | 	volume_t gas_used = { 0 }; | ||||||
|  | @ -279,9 +279,8 @@ volume_t get_gas_used(struct dive *dive) | ||||||
| 		start = cyl->start.mbar ? cyl->start : cyl->sample_start; | 		start = cyl->start.mbar ? cyl->start : cyl->sample_start; | ||||||
| 		end = cyl->end.mbar ? cyl->end : cyl->sample_end; | 		end = cyl->end.mbar ? cyl->end : cyl->sample_end; | ||||||
| 		if (start.mbar && end.mbar) | 		if (start.mbar && end.mbar) | ||||||
| 			gas_used.mliter += gas_volume(cyl, start) - gas_volume(cyl, end); | 			gases[idx].mliter = gas_volume(cyl, start) - gas_volume(cyl, end); | ||||||
| 	} | 	} | ||||||
| 	return gas_used; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool is_gas_used(struct dive *dive, int idx) | bool is_gas_used(struct dive *dive, int idx) | ||||||
|  | @ -347,15 +346,19 @@ char *get_gaslist(struct dive *dive) | ||||||
| 		cyl = &dive->cylinder[idx]; | 		cyl = &dive->cylinder[idx]; | ||||||
| 		o2 = get_o2(&cyl->gasmix); | 		o2 = get_o2(&cyl->gasmix); | ||||||
| 		he = get_he(&cyl->gasmix); | 		he = get_he(&cyl->gasmix); | ||||||
|  | 		if (offset > 0) { | ||||||
|  | 			strncpy(buf + offset, "\n", MAXBUF - offset); | ||||||
|  | 			offset = strlen(buf); | ||||||
|  | 		} | ||||||
| 		if (is_air(o2, he)) | 		if (is_air(o2, he)) | ||||||
| 			snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? ", %s" : "%s", translate("gettextFromC","air")); | 			strncpy(buf + offset, translate("gettextFromC","air"), MAXBUF - offset); | ||||||
| 		else | 		else | ||||||
| 			if (he == 0) | 			if (he == 0) | ||||||
| 				snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? translate("gettextFromC",", EAN%d") : translate("gettextFromC","EAN%d"), | 				snprintf(buf + offset, MAXBUF - offset, | ||||||
| 					 (o2 + 5) / 10); | 					translate("gettextFromC","EAN%d"), (o2 + 5) / 10); | ||||||
| 			else | 			else | ||||||
| 				snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? ", %d/%d" : "%d/%d", | 				snprintf(buf + offset, MAXBUF - offset, | ||||||
| 				 (o2 + 5) / 10, (he + 5) / 10); | 					"%d/%d", (o2 + 5) / 10, (he + 5) / 10); | ||||||
| 		offset = strlen(buf); | 		offset = strlen(buf); | ||||||
| 	} | 	} | ||||||
| 	if (*buf == '\0') | 	if (*buf == '\0') | ||||||
|  |  | ||||||
|  | @ -40,7 +40,7 @@ extern char *get_time_string(int seconds, int maxdays); | ||||||
| extern char *get_minutes(int seconds); | extern char *get_minutes(int seconds); | ||||||
| extern void process_all_dives(struct dive *dive, struct dive **prev_dive); | extern void process_all_dives(struct dive *dive, struct dive **prev_dive); | ||||||
| extern void get_selected_dives_text(char *buffer, int size); | extern void get_selected_dives_text(char *buffer, int size); | ||||||
| extern volume_t get_gas_used(struct dive *dive); | extern void get_gas_used(struct dive *dive, volume_t gases[MAX_CYLINDERS]); | ||||||
| extern char *get_gaslist(struct dive *dive); | extern char *get_gaslist(struct dive *dive); | ||||||
| extern void process_selected_dives(void); | extern void process_selected_dives(void); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue