mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 14:10:19 +00:00
Bugfix: Fix planner debug code.
Fix the debug code in `core/planner.cpp`. Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
parent
91d8bfef55
commit
1560272673
1 changed files with 12 additions and 14 deletions
|
@ -27,6 +27,8 @@
|
|||
#include "qthelper.h"
|
||||
#include "version.h"
|
||||
|
||||
#define DEBUG_PLAN 255
|
||||
|
||||
static constexpr int base_timestep = 2; // seconds
|
||||
|
||||
static int decostoplevels_metric[] = { 0, 3000, 6000, 9000, 12000, 15000, 18000, 21000, 24000, 27000,
|
||||
|
@ -45,23 +47,19 @@ static int decostoplevels_imperial[] = { 0, 3048, 6096, 9144, 12192, 15240, 1828
|
|||
#if DEBUG_PLAN
|
||||
void dump_plan(struct diveplan *diveplan)
|
||||
{
|
||||
struct divedatapoint *dp;
|
||||
struct tm tm;
|
||||
|
||||
if (!diveplan) {
|
||||
printf("Diveplan NULL\n");
|
||||
return;
|
||||
}
|
||||
struct tm tm;
|
||||
utc_mkdate(diveplan->when, &tm);
|
||||
|
||||
printf("\nDiveplan @ %04d-%02d-%02d %02d:%02d:%02d (surfpres %dmbar):\n",
|
||||
tm.tm_year, tm.tm_mon + 1, tm.tm_mday,
|
||||
tm.tm_hour, tm.tm_min, tm.tm_sec,
|
||||
diveplan->surface_pressure.mbar);
|
||||
dp = diveplan->dp;
|
||||
while (dp) {
|
||||
printf("\t%3u:%02u: %6dmm cylid: %2d setpoint: %d\n", FRACTION_TUPLE(dp->time, 60), dp->depth, dp->cylinderid, dp->setpoint);
|
||||
dp = dp->next;
|
||||
for (auto &dp: diveplan->dp) {
|
||||
printf("\t%3u:%02u: %6dmm cylid: %2d setpoint: %d\n", FRACTION_TUPLE(dp.time, 60), dp.depth.mm, dp.cylinderid, dp.setpoint);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -209,7 +207,7 @@ static void create_dive_from_plan(struct diveplan &diveplan, struct dive *dive,
|
|||
return;
|
||||
#if DEBUG_PLAN & 4
|
||||
printf("in create_dive_from_plan\n");
|
||||
dump_plan(diveplan);
|
||||
dump_plan(&diveplan);
|
||||
#endif
|
||||
dive->salinity = diveplan.salinity;
|
||||
// reset the cylinders and clear out the samples and events of the
|
||||
|
@ -296,7 +294,7 @@ static void create_dive_from_plan(struct diveplan &diveplan, struct dive *dive,
|
|||
dc->last_manual_time.seconds = last_manual_point;
|
||||
|
||||
#if DEBUG_PLAN & 32
|
||||
save_dive(stdout, *dive);
|
||||
save_dive(stdout, *dive, false);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -392,8 +390,8 @@ static std::vector<gaschanges> analyze_gaslist(const struct diveplan &diveplan,
|
|||
#if DEBUG_PLAN & 16
|
||||
for (size_t nr = 0; nr < gaschanges.size(); nr++) {
|
||||
int idx = gaschanges[nr].gasidx;
|
||||
printf("gaschange nr %d: @ %5.2lfm gasidx %d (%s)\n", nr, gaschanges[nr].depth / 1000.0,
|
||||
idx, dive.get_cylinder(idx)->gasmix.name().c_str());
|
||||
printf("gaschange nr %zu: @ %5.2lfm gasidx %d (%s)\n", nr, gaschanges[nr].depth / 1000.0,
|
||||
idx, dive->get_cylinder(idx)->gasmix.name().c_str());
|
||||
}
|
||||
#endif
|
||||
return gaschanges;
|
||||
|
@ -789,7 +787,7 @@ std::vector<decostop> plan(struct deco_state *ds, struct diveplan &diveplan, str
|
|||
|
||||
#if DEBUG_PLAN & 16
|
||||
printf("switch to gas %d (%d/%d) @ %5.2lfm\n", best_first_ascend_cylinder,
|
||||
(get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[best_first_ascend_cylinder].depth / 1000.0);
|
||||
(get_o2(gas) + 5) / 10, (get_he(gas) + 5) / 10, gaschanges[best_first_ascend_cylinder].depth / 1000.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -902,7 +900,7 @@ std::vector<decostop> plan(struct deco_state *ds, struct diveplan &diveplan, str
|
|||
#if DEBUG_PLAN & 16
|
||||
gas = dive->get_cylinder(current_cylinder)->gasmix;
|
||||
printf("switch to gas %d (%d/%d) @ %5.2lfm\n", gaschanges[gi].gasidx,
|
||||
(get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[gi].depth / 1000.0);
|
||||
(get_o2(gas) + 5) / 10, (get_he(gas) + 5) / 10, gaschanges[gi].depth / 1000.0);
|
||||
#endif
|
||||
/* Stop for the minimum duration to switch gas unless we switch to o2 */
|
||||
if (!last_segment_min_switch && get_o2(dive->get_cylinder(current_cylinder)->gasmix) != 1000) {
|
||||
|
@ -956,7 +954,7 @@ std::vector<decostop> plan(struct deco_state *ds, struct diveplan &diveplan, str
|
|||
#if DEBUG_PLAN & 16
|
||||
gas = dive->get_cylinder(current_cylinder)->gasmix;
|
||||
printf("switch to gas %d (%d/%d) @ %5.2lfm\n", gaschanges[gi + 1].gasidx,
|
||||
(get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[gi + 1].depth / 1000.0);
|
||||
(get_o2(gas) + 5) / 10, (get_he(gas) + 5) / 10, gaschanges[gi + 1].depth / 1000.0);
|
||||
#endif
|
||||
/* Stop for the minimum duration to switch gas unless we switch to o2 */
|
||||
if (!last_segment_min_switch && get_o2(dive->get_cylinder(current_cylinder)->gasmix) != 1000) {
|
||||
|
|
Loading…
Reference in a new issue