What's missing for 4.2?

Anton Lundin glance at acc.umu.se
Wed Jun 11 03:06:36 PDT 2014


On 10 June, 2014 - Dirk Hohndel wrote:

> On Wed, Jun 11, 2014 at 12:30:22AM +0200, Anton Lundin wrote:
> > 
> > Quite ugly thing but it kinda works. You hopefully get the idea.
> > 
> > //Anton
> > 
> > -- 
> > Anton Lundin	+46702-161604
> 
> > diff --git i/helpers.h w/helpers.h
> > index 392dcb5..36ceb1e 100644
> > --- i/helpers.h
> > +++ w/helpers.h
> > @@ -33,7 +33,7 @@ QString get_dive_date_string(timestamp_t when);
> >  QString get_short_dive_date_string(timestamp_t when);
> >  QString get_trip_date_string(timestamp_t when, int nr);
> >  QString uiLanguage(QLocale *callerLoc);
> > -void selectedDivesGasUsed(QVector<QPair<QString, int> > &gasUsed);
> > +void selectedDivesGasUsed(QVector<QPair<struct gasmix*, int> > &gasUsed);
> >  
> >  #define M_OR_FT(_m, _f) ((prefs.units.length == units::METERS) ? ((_m) * 1000) : (feet_to_mm(_f)))
> >  
> > diff --git i/qt-ui/maintab.cpp w/qt-ui/maintab.cpp
> > index ae2876b..770fcb4 100644
> > --- i/qt-ui/maintab.cpp
> > +++ w/qt-ui/maintab.cpp
> > @@ -531,18 +531,37 @@ void MainTab::updateDiveInfo(int dive)
> >  		ui.timeLimits->setMaximum(get_time_string(stats_selection.longest_time.seconds, 0));
> >  		ui.timeLimits->setMinimum(get_time_string(stats_selection.shortest_time.seconds, 0));
> >  		// now let's get some gas use statistics
> > -		QVector<QPair<QString, int> > gasUsed;
> > +		QVector<QPair<struct gasmix*, int> > gasUsed;
> >  		QString gasUsedString;
> > -		QPair<QString, int> topGases[20] = { };
> > -		volume_t vol;
> > +		QPair<struct gasmix*, int> topGases[20] = { };
> >  		selectedDivesGasUsed(gasUsed);
> > +		volume_t vol;
> > +		volume_t he = {}, o2 = {};
> > +		struct gasmix *mix;
> > +		QPair<struct gasmix*, int> gasPair;
> > +		foreach (gasPair, gasUsed) {
> > +			mix = gasPair.first;
> > +			vol.mliter = gasPair.second;
> > +			//Really naive gas computations here, but it gives the picture
> > +			if (gasmix_is_air(mix))
> > +				continue;
> > +			if (get_he(mix) != 0) {
> > +				o2.mliter += (get_he(mix) * get_o2(mix) * vol.mliter) / 1000000;
> 
> Can you explain this line to me?
> 
> > +				he.mliter += (get_he(mix) * vol.mliter) / 1000;
> > +			} else if (get_o2(mix) == 1000) {
> > +				o2.mliter += vol.mliter;
> > +			} else
> > +				o2.mliter += ((get_o2(mix) - O2_IN_AIR) * vol.mliter) / 1000;
> 
> I think that last one is wrong, too. You need to calculate how much N2 you
> have in the mix. That gives you how much air is in the mix. And then the
> rest is O2, right?
> 

Yea, all that math is probably bogus. Just made some up last night that
produced about the same numbers as my gas mixing software. Its more on
the area of trying to show what i ment.

There are some other issues with this code too, like using pointers to
struct gasmix in complete other structures that i can't really rely on
staying around but it was more as said, prof of concept.

> > +		}
> > +		gasUsedString.append(QString("He: %1, O2: %2\n").arg(get_volume_string(he, true)).arg(get_volume_string(o2, true)));
> >  		for (int j = 0; j < 20; j++) {
> >  			if (gasUsed.isEmpty())
> >  				break;
> > -			QPair<QString, int> gasPair = gasUsed.last();
> > +			gasPair = gasUsed.last();
> >  			gasUsed.pop_back();
> > +			mix = gasPair.first;
> >  			vol.mliter = gasPair.second;
> > -			gasUsedString.append(gasPair.first).append(": ").append(get_volume_string(vol, true)).append("\n");
> > +			gasUsedString.append(gasname(mix)).append(": ").append(get_volume_string(vol, true)).append("\n");
> 
> I think the idea itself is workable. I would put the components at the end
> with something like "these gases could be mixed from air and xxxx O2 and
> yyyy He".
> 

Sounds sane. Ill clean this up and produce a patch with less bogus math
and proper passing of data than this kludge.


//Anton


-- 
Anton Lundin	+46702-161604


More information about the subsurface mailing list