[PATCH 4/5] Break calculated deco info to separate vars

Dirk Hohndel dirk at hohndel.org
Tue Nov 12 18:15:46 UTC 2013


On Tue, 2013-11-12 at 23:10 +0100, Anton Lundin wrote:
> Store the calculated values in separate variables in the plot_data
> struct, and display them separate. This makes sure we don't confuse the
> calculated values with the ones from a dc, and now we can compare the
> two.

I like this in principle - here is my issue with your code:

> @@ -1262,9 +1265,37 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
>  		memcpy(buf2, buf, bufsize);
>  		snprintf(buf, bufsize, translate("gettextFromC","%s\nSAC:%2.1fl/min"), buf2, entry->sac / 1000.0);
>  	}
> -	if (entry->tts) {
> +	if (entry->stopdepth_calc) {
> +		depthvalue = get_depth_units(entry->stopdepth_calc, NULL, &depth_unit);
> +		memcpy(buf2, buf, bufsize);
> +		if (entry->ndl_calc) {
> +			/* this is a safety stop as we still have ndl */
> +			if (entry->stoptime_calc)
> +				snprintf(buf, bufsize, translate("gettextFromC","%s\nSafetystop:%umin @ %.0f %s (calc)"), buf2, DIV_UP(entry->stoptime_calc, 60),
> +					depthvalue, depth_unit);
> +			else
> +				snprintf(buf, bufsize, translate("gettextFromC","%s\nSafetystop:unkn time @ %.0f %s (calc)"), buf2,
> +					depthvalue, depth_unit);

These two cases basically handle the oddities in how some dive computers
represent when you are on a safety stop. They do so by showing a stop
depth and/or stop time, but ALSO showing that you have NDL left.

By definition our calculated values will never give you that - so
there's no point in copying this code for the calculated values.

> +		} else {
> +			/* actual deco stop */
> +			if (entry->stoptime_calc)
> +				snprintf(buf, bufsize, translate("gettextFromC","%s\nDeco:%umin @ %.0f %s (calc)"), buf2, DIV_UP(entry->stoptime_calc, 60),
> +					depthvalue, depth_unit);
> +			else
> +				snprintf(buf, bufsize, translate("gettextFromC","%s\nDeco:unkn time @ %.0f %s (calc)"), buf2,
> +					depthvalue, depth_unit);
> +		}
> +	} else if (entry->in_deco_calc) {
> +		/* this means we had in_deco set but don't have a stop depth */
> +		memcpy(buf2, buf, bufsize);
> +		snprintf(buf, bufsize, translate("gettextFromC","%s\nIn deco (calc)"), buf2);

Same for this last "else if" - this also simply deals with the peculiar
ways some dive computers represent deco information. They tell us that
the diver was in deco but give no additional data. This will never
happen in our calculated values.

Can I ask you to resend just this patch of the series with those issues
fixed? I have already applied 1-3 and will be looking at 5/5 in a
moment.

/D



More information about the subsurface mailing list