Skip to content

Commit

Permalink
Added feature flag to enable saturation
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkapok committed Dec 6, 2024
1 parent f0602f9 commit 4ea7a94
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
7 changes: 7 additions & 0 deletions projects/scuba-physics/src/lib/AlgorithmContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Options } from './Options';
import { DepthConverter } from './depth-converter';
import { Time } from './Time';
import { StandardGases } from './StandardGases';
import { FeatureFlags } from './featureFlags';

export interface ContextMemento {
tissues: Tissue[];
Expand Down Expand Up @@ -67,6 +68,7 @@ export class AlgorithmContext {
return this.speeds.ascent(this.currentDepth);
}

/** Gets depth at end of last segment */
public get currentDepth(): number {
return this.segments.currentDepth;
}
Expand Down Expand Up @@ -135,6 +137,11 @@ export class AlgorithmContext {
}

public addSaturation(): void {
if (!FeatureFlags.Instance.collectSaturation) {
return;
}

// TODO Fix current depth at the moment, not the currentDepth at end of last segment
const ambientPressure = this.depthConverter.toBar(this.currentDepth);
const currentOverPressures = this.tissues.saturationRatio(ambientPressure, this.depthConverter.surfacePressure, 1);
this.saturationRatios.push(currentOverPressures);
Expand Down
2 changes: 1 addition & 1 deletion projects/scuba-physics/src/lib/Tissues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export class Tissues {
// TODO do we need adjust m-value against user gradient factors and surface pressure?
// We need use Gradient here, since we want to show the saturation aligned with profile and ceilings.
// Or should the heat map change when changing gradient factors?
return [];
// return [];
return _(this._compartments).map(t => {
if (t.pTotal < ambientPressure) {
return t.pTotal / ambientPressure - 1;
Expand Down
14 changes: 14 additions & 0 deletions projects/scuba-physics/src/lib/featureFlags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export class FeatureFlags
{
private static _instance: FeatureFlags;

public collectSaturation = false;

private constructor() {
}

public static get Instance()
{
return FeatureFlags._instance || (FeatureFlags._instance = new FeatureFlags());
}
}
1 change: 1 addition & 0 deletions projects/scuba-physics/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from './lib/DefaultValues';
export * from './lib/depth-converter';
export * from './lib/DepthLevels';
export * from './lib/Diver';
export * from './lib/featureFlags';
export * from './lib/GasMixtures';
export * from './lib/Gases';
export * from './lib/gasBlender';
Expand Down

0 comments on commit 4ea7a94

Please sign in to comment.