[PATCH] Do per cylinder statistics
Dirk Hohndel
dirk at hohndel.org
Wed Nov 20 07:54:05 UTC 2013
You sent this response to me only, but are talking to me in the third
person, so I assume you wanted this to go to the mailing list?
On Wed, 2013-11-20 at 10:40 +0100, roberto forini wrote:
> Weeks ago i sent to Dirk a simple algo for gas consumption algo. it
> shows the estimated consumption in a graph along the divetime and
> depth. Ask him maybe it was not interesting or i didnt explain it well
>
I decided to implement this slightly differently, not through
approximation but through analytic transformation of the equation.
The end result should be the same - please check how well this matches
your expected values.
The code was pushed out last night (my time).
/D
>
>
> Il giorno mercoledì 20 novembre 2013, Dirk Hohndel ha scritto:
> On Wed, 2013-11-20 at 00:29 +0100, Anton Lundin wrote:
> > 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.
>
> I still think that having the separate SAC rate would be neat.
>
> I'll look into that part :-)
> Time permitting :-(
>
> /D
>
>
> > Design based on idea in #284
> >
> > Signed-off-by: Anton Lundin <glance at acc.umu.se>
> > ---
> > qt-ui/maintab.cpp | 7 ++++++-
> > statistics.c | 19 +++++++++++--------
> > statistics.h | 2 +-
> > 3 files changed, 18 insertions(+), 10 deletions(-)
> >
> > diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
> > index 16c0a1f..cf3cbbc 100644
> > --- a/qt-ui/maintab.cpp
> > +++ b/qt-ui/maintab.cpp
> > @@ -349,7 +349,12 @@ 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));
> > + 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.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..8284dda 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)
> > +void get_gas_used(struct dive *dive, volume_t
> gases[MAX_CYLINDERS])
> > {
> > int idx;
> > 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;
> > end = cyl->end.mbar ? cyl->end :
> cyl->sample_end;
> > 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)
> > @@ -347,15 +346,19 @@ char *get_gaslist(struct dive *dive)
> > cyl = &dive->cylinder[idx];
> > o2 = get_o2(&cyl->gasmix);
> > he = get_he(&cyl->gasmix);
> > + if (offset > 0) {
> > + strncpy(buf + offset, "\n", MAXBUF -
> offset);
> > + offset = strlen(buf);
> > + }
> > 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
> _______________________________________________
> subsurface mailing list
> subsurface at hohndel.org
> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
More information about the subsurface
mailing list