Skip to content

Commit

Permalink
Merge pull request #3 from KG32/feat/max-end-gf-true
Browse files Browse the repository at this point in the history
feat: end dive GF calculated on resurface instead of end of log
  • Loading branch information
KG32 authored May 13, 2024
2 parents 3d235cc + 259ae83 commit 2c5d2d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 10 additions & 7 deletions src/dive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{common::{Depth, Seconds}, parser::DiveElem, stats::GasMixesData};
pub struct DiveMeta {
gradient_factors: GradientFactorsSetting,
current_mix: Gas,
last_depth: Depth,
}

#[derive(Debug)]
Expand All @@ -34,6 +35,7 @@ impl Dive {
let dive_meta = DiveMeta {
gradient_factors: config.gradient_factors,
current_mix: init_gas,
last_depth: 0.,
};

Dive {
Expand Down Expand Up @@ -64,10 +66,6 @@ impl Dive {
// update last waypoint time
last_waypoint_time = data_point.dive_time;
}

// end dive GF
let (gf_end, ..) = model.gfs_current();
self.gf_end = gf_end;
}

fn process_data_point(
Expand Down Expand Up @@ -108,7 +106,7 @@ impl Dive {

// GFs
let gfs = model.gfs_current();
self.register_gfs(gfs, &step_time);
self.register_gfs(gfs, &step_time, &data_point.depth);

// deco time
if model.ceiling() > 0. {
Expand All @@ -131,9 +129,8 @@ impl Dive {
}
}

fn register_gfs(&mut self, gfs: (Pressure, Pressure), time: &Seconds) {
fn register_gfs(&mut self, gfs: (Pressure, Pressure), time: &Seconds, depth: &Depth) {
let (gf_99, gf_surf) = gfs;
self.gf_end = gf_99;
// GF surf
if gf_surf > self.gf_surf_max {
self.gf_surf_max = gf_surf;
Expand All @@ -142,6 +139,12 @@ impl Dive {
if gf_99 > self.gf_99_max {
self.gf_99_max = gf_99;
}
// GF end
if *depth == 0. && self.meta.last_depth != 0. {
self.gf_end = gf_99;
}
// register last depth for end dive GF99 check
self.meta.last_depth = *depth;
}

fn update_time_in_deco(&mut self, time: Seconds) {
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ impl Config {
args.next();
let path = match args.next() {
Some(arg) => arg,
// None => return Err("Path missing"),
None => "/Users/kubagroblewski/Documents/dive-reporter-uddf/kg-ss/165-167.uddf".to_string()
None => return Err("Path missing"),
};
Ok(Config {
path,
Expand Down

0 comments on commit 2c5d2d8

Please sign in to comment.