From d396f4afd8411ec8f17c7a9015f0c615e720a27d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 7 Jan 2013 12:49:07 -0800 Subject: Add simple debug function to planner This allows you to dump the diveplan structure Signed-off-by: Dirk Hohndel --- planner.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'planner.c') diff --git a/planner.c b/planner.c index 45da6f157..0ea1234e4 100644 --- a/planner.c +++ b/planner.c @@ -14,6 +14,31 @@ int stoplevels[] = { 0, 3000, 6000, 9000, 12000, 15000, 21000, 30000, 42000, 60000, 90000 }; +#if DEBUG_PLAN +void dump_plan(struct diveplan *diveplan) +{ + struct divedatapoint *dp; + struct tm tm; + + if (!diveplan) { + printf ("Diveplan NULL\n"); + return; + } + utc_mkdate(diveplan->when, &tm); + + printf("Diveplan @ %04d-%02d-%02d %02d:%02d:%02d (surfpres %dmbar):\n", + tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec, + diveplan->surface_pressure); + dp = diveplan->dp; + while (dp) { + printf("\t%3u:%02u: %dmm gas: %d o2 %d h2\n", FRACTION(dp->time, 60), dp->depth, dp->o2, dp->he); + dp = dp->next; + } + +} +#endif + /* returns the tissue tolerance at the end of this (partial) dive */ double tissue_at_end(struct dive *dive, char **cached_datap) { @@ -508,6 +533,9 @@ void show_planned_dive(void) } dpp = &(*dpp)->next; } +#if DEBUG_PLAN & 1 + dump_plan(&tempplan); +#endif plan(&tempplan, &cache_data, &planned_dive); free_dps(tempplan.dp); } -- cgit v1.2.3-70-g09d2