diff options
author | Tim Segers <tsegers@pm.me> | 2022-10-12 16:04:51 +0200 |
---|---|---|
committer | Tim Segers <tsegers@pm.me> | 2022-10-12 16:05:56 +0200 |
commit | 879de8903e617d9e172a36045dc1b7b7ca4250c1 (patch) | |
tree | 82340b12e10ea7abb65d4c1eccf89b259f17a47a | |
parent | 378ee4dbffb8c99ffe8a74bcce70e96851a3624a (diff) | |
download | opendeco-879de8903e617d9e172a36045dc1b7b7ca4250c1.tar.gz |
Add option to perform last deco stop at 6m instead of 3m
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | src/deco.c | 9 | ||||
-rw-r--r-- | src/deco.h | 4 | ||||
-rw-r--r-- | src/opendeco.c | 15 |
4 files changed, 24 insertions, 6 deletions
@@ -27,6 +27,8 @@ Implementation of Buhlmann ZH-L16 with Gradient Factors: -s Only switch gas at deco stops + -6 Perform last deco stop at 6m + Informational options: -?, --help Give this help list @@ -15,6 +15,8 @@ double P_WV = P_WV_DEFAULT; double PO2_MAX = PO2_MAX_DEFAULT; double END_MAX = END_MAX_DEFAULT; +int LAST_STOP_AT_SIX = LAST_STOP_AT_SIX_DEFAULT; + typedef struct zhl_n2_t { double t; double a[3]; @@ -213,7 +215,12 @@ double round_ceiling(const decostate_t *ds, const double c) { assert(ds->ceil_multiple != 0); - return abs_depth(ds->ceil_multiple * ceil(RND(gauge_depth(c) / ds->ceil_multiple))); + int numbered_stop = ceil(RND(gauge_depth(c) / ds->ceil_multiple)); + + if (numbered_stop == 1 && LAST_STOP_AT_SIX) + numbered_stop = 2; + + return abs_depth(ds->ceil_multiple * numbered_stop); } double ceiling(const decostate_t *ds, double gf) @@ -20,6 +20,8 @@ #define PO2_MAX_DEFAULT 1.6 #define END_MAX_DEFAULT 4.01325 +#define LAST_STOP_AT_SIX_DEFAULT 0 + #define MOD_AUTO 0 /* types */ @@ -54,6 +56,8 @@ extern double P_WV; extern double PO2_MAX; extern double END_MAX; +extern int LAST_STOP_AT_SIX; + /* functions */ double bar_to_msw(const double bar); double msw_to_bar(const double msw); diff --git a/src/opendeco.c b/src/opendeco.c index 9329383..ae95f58 100644 --- a/src/opendeco.c +++ b/src/opendeco.c @@ -38,6 +38,7 @@ static struct argp_option options[] = { {"gfhigh", 'h', "NUMBER", 0, "Set the gradient factor at the surface, defaults to 75", 5}, {"decogasses", 'G', "LIST", 0, "Set the gasses available for deco", 6}, {0, 's', 0, OPTION_ARG_OPTIONAL, "Only switch gas at deco stops", 7}, + {0, '6', 0, OPTION_ARG_OPTIONAL, "Perform last deco stop at 6m", 8}, {0, 0, 0, 0, "Informational options:", 0}, {0, 0, 0, 0, 0, 0} }; @@ -51,6 +52,7 @@ struct arguments { char *decogasses; double SURFACE_PRESSURE; int SWITCH_INTERMEDIATE; + int LAST_STOP_AT_SIX; }; static error_t parse_opt(int key, char *arg, struct argp_state *state) @@ -73,6 +75,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) case 's': arguments->SWITCH_INTERMEDIATE = 0; break; + case '6': + arguments->LAST_STOP_AT_SIX = 1; + break; case 'G': arguments->decogasses = arg; break; @@ -174,17 +179,17 @@ int main(int argc, char *argv[]) .gflow = 30, .gfhigh = 75, .decogasses = "", - .SURFACE_PRESSURE = 0, - .SWITCH_INTERMEDIATE = 1, + .SURFACE_PRESSURE = SURFACE_PRESSURE_DEFAULT, + .SWITCH_INTERMEDIATE = SWITCH_INTERMEDIATE_DEFAULT, + .LAST_STOP_AT_SIX = LAST_STOP_AT_SIX_DEFAULT, }; argp_parse(&argp, argc, argv, 0, 0, &arguments); /* apply global options */ - if (arguments.SURFACE_PRESSURE > 0) - SURFACE_PRESSURE = arguments.SURFACE_PRESSURE; - + SURFACE_PRESSURE = arguments.SURFACE_PRESSURE; SWITCH_INTERMEDIATE = arguments.SWITCH_INTERMEDIATE; + LAST_STOP_AT_SIX = arguments.LAST_STOP_AT_SIX; /* setup */ decostate_t ds; |