[PATCH] WIP: do per cylinder statistics/usage

Anton Lundin glance at acc.umu.se
Sun Nov 17 03:41:27 UTC 2013


This is a rough attempt to how much of each cylinder was used in liters
---
 qt-ui/maintab.cpp | 13 ++++++++++++-
 statistics.c      |  7 +++++--
 statistics.h      |  2 +-
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 6d22a8d..a18527b 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -348,7 +348,18 @@ void MainTab::updateDiveInfo(int dive)
 		ui.otuText->setText(QString("%1").arg(d->otu));
 		ui.waterTemperatureText->setText(get_temperature_string(d->watertemp, TRUE));
 		ui.airTemperatureText->setText(get_temperature_string(d->airtemp, TRUE));
-		ui.gasUsedText->setText(get_volume_string(get_gas_used(d), TRUE));
+		/*FIXME*/
+		if (1) {
+			volume_t gases[MAX_CYLINDERS];
+			(void) 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(", ");
+				volumes.append(get_volume_string(gases[i], TRUE));
+			}
+			ui.gasUsedText->setText(volumes);
+		} else
+			ui.gasUsedText->setText(get_volume_string(get_gas_used(d, NULL), TRUE));
 		ui.oxygenHeliumText->setText(get_gaslist(d));
 		ui.dateText->setText(get_short_dive_date_string(d->when));
 		ui.diveTimeText->setText(QString::number((int)((d->duration.seconds + 30) / 60)));
diff --git a/statistics.c b/statistics.c
index a151aee..78d1154 100644
--- a/statistics.c
+++ b/statistics.c
@@ -268,7 +268,7 @@ void get_selected_dives_text(char *buffer, int size)
 	}
 }
 
-volume_t get_gas_used(struct dive *dive)
+volume_t get_gas_used(struct dive *dive, volume_t gases[MAX_CYLINDERS])
 {
 	int idx;
 	volume_t gas_used = { 0 };
@@ -278,8 +278,11 @@ volume_t get_gas_used(struct dive *dive)
 
 		start = cyl->start.mbar ? cyl->start : cyl->sample_start;
 		end = cyl->end.mbar ? cyl->end : cyl->sample_end;
-		if (start.mbar && end.mbar)
+		if (start.mbar && end.mbar) {
+			if (gases)
+				gases[idx].mliter = gas_volume(cyl, start) - gas_volume(cyl, end);
 			gas_used.mliter += gas_volume(cyl, start) - gas_volume(cyl, end);
+		}
 	}
 	return gas_used;
 }
diff --git a/statistics.h b/statistics.h
index d5d373d..19adcf4 100644
--- a/statistics.h
+++ b/statistics.h
@@ -40,7 +40,7 @@ extern char *get_time_string(int seconds, int maxdays);
 extern char *get_minutes(int seconds);
 extern void process_all_dives(struct dive *dive, struct dive **prev_dive);
 extern void get_selected_dives_text(char *buffer, int size);
-extern volume_t get_gas_used(struct dive *dive);
+extern volume_t get_gas_used(struct dive *dive, volume_t gases[MAX_CYLINDERS]);
 extern char *get_gaslist(struct dive *dive);
 extern void process_selected_dives(void);
 
-- 
1.8.3.2



More information about the subsurface mailing list