2017-04-27 18:18:03 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2013-04-08 03:20:25 +00:00
|
|
|
#ifndef PLANNER_H
|
|
|
|
#define PLANNER_H
|
|
|
|
|
2019-08-05 18:43:06 +00:00
|
|
|
#include "units.h"
|
|
|
|
#include "divemode.h"
|
2024-05-04 15:55:50 +00:00
|
|
|
#include <string>
|
2024-09-04 05:36:05 +00:00
|
|
|
#include <vector>
|
2019-08-05 18:43:06 +00:00
|
|
|
|
|
|
|
/* this should be converted to use our types */
|
|
|
|
struct divedatapoint {
|
2024-09-07 12:25:48 +00:00
|
|
|
int time = 0;
|
2019-08-05 18:43:06 +00:00
|
|
|
depth_t depth;
|
2024-09-07 12:25:48 +00:00
|
|
|
int cylinderid = 0;
|
2019-08-05 18:43:06 +00:00
|
|
|
pressure_t minimum_gas;
|
2024-09-07 12:25:48 +00:00
|
|
|
int setpoint = 0;
|
|
|
|
bool entered = false;
|
|
|
|
enum divemode_t divemode = OC;
|
|
|
|
|
|
|
|
divedatapoint() = default;
|
|
|
|
divedatapoint(const divedatapoint &) = default;
|
|
|
|
divedatapoint(divedatapoint &&) = default;
|
|
|
|
divedatapoint &operator=(const divedatapoint &) = default;
|
|
|
|
divedatapoint(int time_incr, int depth, int cylinderid, int po2, bool entered);
|
2019-08-05 18:43:06 +00:00
|
|
|
};
|
|
|
|
|
2024-09-07 12:25:48 +00:00
|
|
|
typedef enum {
|
|
|
|
PLAN_OK,
|
|
|
|
PLAN_ERROR_TIMEOUT,
|
|
|
|
PLAN_ERROR_INAPPROPRIATE_GAS,
|
|
|
|
} planner_error_t;
|
|
|
|
|
2019-08-05 18:43:06 +00:00
|
|
|
struct diveplan {
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan();
|
|
|
|
~diveplan();
|
2024-09-10 19:37:00 +00:00
|
|
|
diveplan(const diveplan &) = default;
|
|
|
|
diveplan(diveplan &&) = default;
|
|
|
|
diveplan &operator=(const diveplan &) = default;
|
|
|
|
diveplan &operator=(diveplan &&) = default;
|
2024-09-04 05:36:05 +00:00
|
|
|
|
|
|
|
timestamp_t when = 0;
|
2024-09-09 11:55:37 +00:00
|
|
|
pressure_t surface_pressure;
|
2024-09-04 05:36:05 +00:00
|
|
|
int bottomsac = 0; /* ml/min */
|
|
|
|
int decosac = 0; /* ml/min */
|
|
|
|
int salinity = 0;
|
|
|
|
short gflow = 0;
|
|
|
|
short gfhigh = 0;
|
|
|
|
short vpmb_conservatism = 0;
|
|
|
|
std::vector<divedatapoint> dp;
|
|
|
|
int eff_gflow = 0, eff_gfhigh = 0;
|
|
|
|
int surface_interval = 0;
|
2024-09-07 12:25:48 +00:00
|
|
|
|
|
|
|
bool is_empty() const;
|
|
|
|
void add_plan_to_notes(struct dive &dive, bool show_disclaimer, planner_error_t error);
|
|
|
|
int duration() const;
|
2019-08-05 18:43:06 +00:00
|
|
|
};
|
|
|
|
|
2024-03-07 18:08:22 +00:00
|
|
|
struct deco_state_cache;
|
|
|
|
|
2016-07-06 12:40:28 +00:00
|
|
|
extern int get_cylinderid_at_time(struct dive *dive, struct divecomputer *dc, duration_t time);
|
2019-09-01 15:52:25 +00:00
|
|
|
extern const char *get_planner_disclaimer();
|
2013-04-08 03:20:25 +00:00
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
void plan_add_segment(struct diveplan &diveplan, int duration, int depth, int cylinderid, int po2, bool entered, enum divemode_t divemode);
|
2019-08-05 18:43:06 +00:00
|
|
|
#if DEBUG_PLAN
|
|
|
|
void dump_plan(struct diveplan *diveplan);
|
|
|
|
#endif
|
|
|
|
struct decostop {
|
|
|
|
int depth;
|
|
|
|
int time;
|
|
|
|
};
|
|
|
|
|
2024-03-08 09:44:20 +00:00
|
|
|
extern std::string get_planner_disclaimer_formatted();
|
2024-09-07 13:32:06 +00:00
|
|
|
extern std::vector<decostop> plan(struct deco_state *ds, struct diveplan &diveplan, struct dive *dive, int dcNr, int timestep, deco_state_cache &cache, bool is_planner, bool show_disclaimer);
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // PLANNER_H
|