mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
2d8e343221
This has become a bit of a catch-all overhaul of a large portion of the planner - I started out wanting to improve the CCR mode, but then as I started pulling all the other threads that needed addressing started to come with it. Improve how the gas selection is handled when planning dives in CCR mode, by making the type (OC / CCR) of segments dependent on the gas use type that was set for the selected gas. Add a preference to allow the user to chose to use OC gases as diluent, in a similar fashion to the original implementation. Hide gases that cannot be used in the currently selected dive mode in all drop downs. Include usage type in gas names if this is needed. Hide columns and disable elements in the 'Dive planner points' table if they can they can not be edited in the curently selected dive mode. Visually identify gases and usage types that are not appropriate for the currently selected dive mode. Move the 'Dive mode' selection to the top of the planner view, to accommodate the fact that this is a property of the dive and not a planner setting. Show a warning instead of the dive plan if the plan contains gases that are not usable in the selected dive mode. Fix the data entry for the setpoint in the 'Dive planner points' table. Fix problems with enabling / disabling planner settings when switching between dive modes. Refactor some names to make them more appropriate for their current usage. One point that is still open is to hide gas usage graphs in the planner profile if the gas isn't used for OC, as there is no way to meaningfully interpolate such usage. Signed-off-by: Michael Keller <github@ike.ch>
75 lines
3.1 KiB
C++
75 lines
3.1 KiB
C++
// SPDX-License-Identifier: GPL-2.0
|
|
#ifndef DIVECOMPUTER_H
|
|
#define DIVECOMPUTER_H
|
|
|
|
#include "divemode.h"
|
|
#include "units.h"
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
struct extra_data;
|
|
struct event;
|
|
struct sample;
|
|
|
|
/* Is this header the correct place? */
|
|
#define SURFACE_THRESHOLD 750 /* somewhat arbitrary: only below 75cm is it really diving */
|
|
|
|
/*
|
|
* NOTE! The deviceid and diveid are model-specific *hashes* of
|
|
* whatever device identification that model may have. Different
|
|
* dive computers will have different identifying data, it could
|
|
* be a firmware number or a serial ID (in either string or in
|
|
* numeric format), and we do not care.
|
|
*
|
|
* The only thing we care about is that subsurface will hash
|
|
* that information the same way. So then you can check the ID
|
|
* of a dive computer by comparing the hashes for equality.
|
|
*
|
|
* A deviceid or diveid of zero is assumed to be "no ID".
|
|
*/
|
|
struct divecomputer {
|
|
timestamp_t when = 0;
|
|
duration_t duration, surfacetime, last_manual_time;
|
|
depth_t maxdepth, meandepth;
|
|
temperature_t airtemp, watertemp;
|
|
pressure_t surface_pressure;
|
|
enum divemode_t divemode = OC; // dive computer type: OC(default) or CCR
|
|
uint8_t no_o2sensors = 0; // rebreathers: number of O2 sensors used
|
|
int salinity = 0; // kg per 10000 l
|
|
std::string model, serial, fw_version;
|
|
uint32_t deviceid = 0, diveid = 0;
|
|
// Note: ve store samples, events and extra_data in std::vector<>s.
|
|
// This means that pointers to these items are *not* stable.
|
|
std::vector<struct sample> samples;
|
|
std::vector<struct event> events;
|
|
std::vector<struct extra_data> extra_data;
|
|
|
|
divecomputer();
|
|
~divecomputer();
|
|
divecomputer(const divecomputer &);
|
|
divecomputer(divecomputer &&);
|
|
divecomputer &operator=(const divecomputer &);
|
|
};
|
|
|
|
extern void fake_dc(struct divecomputer *dc);
|
|
extern void free_dc_contents(struct divecomputer *dc);
|
|
extern int get_depth_at_time(const struct divecomputer *dc, unsigned int time);
|
|
extern struct sample *prepare_sample(struct divecomputer *dc);
|
|
extern void append_sample(const struct sample &sample, struct divecomputer *dc);
|
|
extern void fixup_dc_duration(struct divecomputer &dc);
|
|
extern int add_event_to_dc(struct divecomputer *dc, struct event ev); // event structure is consumed, returns index of inserted event
|
|
extern struct event *add_event(struct divecomputer *dc, unsigned int time, int type, int flags, int value, const std::string &name);
|
|
extern struct event remove_event_from_dc(struct divecomputer *dc, int idx);
|
|
struct event *get_event(struct divecomputer *dc, int idx);
|
|
extern void add_extra_data(struct divecomputer *dc, const std::string &key, const std::string &value);
|
|
extern uint32_t calculate_string_hash(const char *str);
|
|
extern bool is_dc_planner(const struct divecomputer *dc);
|
|
extern void make_planner_dc(struct divecomputer *dc);
|
|
extern const char *manual_dc_name;
|
|
extern bool is_dc_manually_added_dive(const struct divecomputer *dc);
|
|
extern void make_manually_added_dive_dc(struct divecomputer *dc);
|
|
|
|
/* Check if two dive computer entries are the exact same dive (-1=no/0=maybe/1=yes) */
|
|
extern int match_one_dc(const struct divecomputer &a, const struct divecomputer &b);
|
|
|
|
#endif
|