mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: add notion of gas-type to core/gas.c
Create a gastype enum, which describes the type of a gas. For now: air, nitrox, normoxic, trimix and oxygen. This probably should be made configurable. The gas types will be used to bin gasses in the statistics module. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
1d93926700
commit
1270d94701
2 changed files with 42 additions and 0 deletions
30
core/gas.c
30
core/gas.c
|
@ -1,6 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "gas.h"
|
||||
#include "pref.h"
|
||||
#include "gettext.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -139,3 +140,32 @@ void fill_pressures(struct gas_pressures *pressures, const double amb_pressure,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum gastype gasmix_to_type(struct gasmix mix)
|
||||
{
|
||||
if (gasmix_is_air(mix))
|
||||
return GASTYPE_AIR;
|
||||
if (mix.o2.permille >= 980)
|
||||
return GASTYPE_OXYGEN;
|
||||
if (mix.he.permille == 0)
|
||||
return mix.o2.permille >= 230 ? GASTYPE_NITROX : GASTYPE_AIR;
|
||||
if (mix.o2.permille <= 180)
|
||||
return GASTYPE_HYPOXIC_TRIMIX;
|
||||
return mix.o2.permille <= 230 ? GASTYPE_NORMOXIC_TRIMIX : GASTYPE_HYPEROXIC_TRIMIX;
|
||||
}
|
||||
|
||||
static const char *gastype_names[] = {
|
||||
QT_TRANSLATE_NOOP("gettextFromC", "Air"),
|
||||
QT_TRANSLATE_NOOP("gettextFromC", "Nitrox"),
|
||||
QT_TRANSLATE_NOOP("gettextFromC", "Hypoxic Trimix"),
|
||||
QT_TRANSLATE_NOOP("gettextFromC", "Normoxic Trimix"),
|
||||
QT_TRANSLATE_NOOP("gettextFromC", "Hyperoxic Trimix"),
|
||||
QT_TRANSLATE_NOOP("gettextFromC", "Oxygen")
|
||||
};
|
||||
|
||||
const char *gastype_name(enum gastype type)
|
||||
{
|
||||
if (type < 0 || type >= GASTYPE_COUNT)
|
||||
return "";
|
||||
return translate("gettextFromC", gastype_names[type]);
|
||||
}
|
||||
|
|
12
core/gas.h
12
core/gas.h
|
@ -22,6 +22,16 @@ struct gasmix {
|
|||
static const struct gasmix gasmix_invalid = { { -1 }, { -1 } };
|
||||
static const struct gasmix gasmix_air = { { 0 }, { 0 } };
|
||||
|
||||
enum gastype {
|
||||
GASTYPE_AIR,
|
||||
GASTYPE_NITROX,
|
||||
GASTYPE_HYPOXIC_TRIMIX,
|
||||
GASTYPE_NORMOXIC_TRIMIX,
|
||||
GASTYPE_HYPEROXIC_TRIMIX,
|
||||
GASTYPE_OXYGEN,
|
||||
GASTYPE_COUNT
|
||||
};
|
||||
|
||||
struct icd_data { // This structure provides communication between function isobaric_counterdiffusion() and the calling software.
|
||||
int dN2; // The change in fraction (permille) of nitrogen during the change
|
||||
int dHe; // The change in fraction (permille) of helium during the change
|
||||
|
@ -59,6 +69,8 @@ extern fraction_t get_gas_component_fraction(struct gasmix mix, enum gas_compone
|
|||
extern void fill_pressures(struct gas_pressures *pressures, double amb_pressure, struct gasmix mix, double po2, enum divemode_t dctype);
|
||||
|
||||
extern bool gasmix_is_air(struct gasmix gasmix);
|
||||
extern enum gastype gasmix_to_type(struct gasmix mix);
|
||||
extern const char *gastype_name(enum gastype type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue