Skip to content

Commit ccae7e2

Browse files
committed
Removed redundant ProfileMoment
1 parent 27c0521 commit ccae7e2

File tree

10 files changed

+27
-37
lines changed

10 files changed

+27
-37
lines changed

projects/planner/src/app/plan/diveinfo/diveinfo.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from '@fortawesome/free-solid-svg-icons';
88
import { MdbTabsComponent } from 'mdb-angular-ui-kit/tabs/tabs.component';
99

10-
import { Tank, GasToxicity, Time, ProfileMoment } from 'scuba-physics';
10+
import { Tank, GasToxicity, Time } from 'scuba-physics';
1111
import { DiveResults } from '../../shared/diveresults';
1212
import { UnitConversion } from '../../shared/UnitConversion';
1313
import { Streamed } from '../../shared/streamed';
@@ -92,11 +92,11 @@ export class DiveInfoComponent extends Streamed {
9292
}
9393

9494
public get offgasingStartTime(): number {
95-
return Time.toMinutes(this.dive.offgasingStart.runtime);
95+
return Time.toMinutes(this.dive.offgasingStartTime);
9696
}
9797

9898
public get offgasingStartDepth(): number {
99-
return this.dive.offgasingStart.depth;
99+
return this.dive.offgasingStartDepth;
100100
}
101101

102102
public get dive(): DiveResults {

projects/planner/src/app/shared/diveresults.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
Ceiling, EventType, Event, HighestDensity,
3-
OtuCalculator, LoadedTissue, TissueOverPressures, ProfileMoment
3+
OtuCalculator, LoadedTissue, TissueOverPressures
44
} from 'scuba-physics';
55
import { Injectable } from '@angular/core';
66
import { WayPoint } from './wayPoint';
@@ -20,10 +20,8 @@ export class DiveResults {
2020
public emergencyAscentStart = 0;
2121
public averageDepth = 0;
2222
public surfaceGradient = 0;
23-
public offgasingStart: ProfileMoment = {
24-
runtime: 0,
25-
depth: 0
26-
};
23+
public offgasingStartTime = 0;
24+
public offgasingStartDepth = 0;
2725
public otu = 0;
2826
public cns = 0;
2927
public highestDensity = HighestDensity.createDefault();

projects/planner/src/app/shared/planner.service.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ describe('PlannerService', () => {
422422
averageDepth: 0,
423423
events: [],
424424
surfaceGradient: 0,
425-
offgasingStart: { runtime: 0, depth: 0 }
425+
offgasingStartTime: 0,
426+
offgasingStartDepth: 0
426427
}));
427428

428429
expect( () => planner.calculate(1)).not.toThrow();

projects/planner/src/app/shared/planner.service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,8 @@ export class PlannerService extends Streamed {
177177
const events = DtoSerialization.toEvents(diveInfoResult.events);
178178
diveResult.events = this.ignoredIssues.filterIgnored(events.items);
179179
diveResult.surfaceGradient = diveInfoResult.surfaceGradient;
180-
181-
// TODO find depth for the offgasing start runtime
182-
diveResult.offgasingStart = diveInfoResult.offgasingStart;
180+
diveResult.offgasingStartTime = diveInfoResult.offgasingStartTime;
181+
diveResult.offgasingStartDepth = diveInfoResult.offgasingStartDepth;
183182
diveResult.diveInfoFinished();
184183
this.fireFinishedEvents(dive);
185184
}

projects/planner/src/app/shared/serialization.model.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
Tank, Ceiling, EventType,
3-
Salinity, SafetyStop, ProfileMoment,
3+
Salinity, SafetyStop,
44
TissueOverPressures
55
} from 'scuba-physics';
66
import { ViewState } from './views.model';
@@ -93,7 +93,8 @@ export interface DiveInfoResultDto {
9393
averageDepth: number;
9494
events: EventDto[];
9595
surfaceGradient: number;
96-
offgasingStart: ProfileMoment;
96+
offgasingStartTime: number;
97+
offgasingStartDepth: number;
9798
}
9899

99100
export interface DensityDto {

projects/planner/src/app/workers/planning.tasks.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
Consumption, Time, Diver, OtuCalculator, CnsCalculator,
44
DensityAtDepth, EventOptions, AlgorithmParams, BuhlmannAlgorithm,
55
RestingParameters, Segment, PlanFactory, ConsumptionOptions,
6-
ProfileMoment, Tank, ProfileTissues
6+
Tank, ProfileTissues
77
} from 'scuba-physics';
88
import {
99
ProfileRequestDto, ProfileResultDto, ConsumptionRequestDto,
@@ -57,7 +57,7 @@ export class PlanningTasks {
5757

5858
const profileTissues = new ProfileTissues();
5959
const surfaceGradient = profileTissues.surfaceGradient(task.calculatedTissues, depthConverter.surfacePressure);
60-
const offgasingStartRuntime = profileTissues.offgasingStart(task.calculatedOverPressures).runtime;
60+
const offgasingStartRuntime = profileTissues.offgasingStart(task.calculatedOverPressures);
6161
const offgasingStartDepth = Segments.depthAt(originalProfile, offgasingStartRuntime);
6262

6363
return {
@@ -69,10 +69,8 @@ export class PlanningTasks {
6969
averageDepth: averageDepth,
7070
events: eventsDto,
7171
surfaceGradient: surfaceGradient,
72-
offgasingStart: {
73-
runtime: Time.toMinutes(offgasingStartRuntime),
74-
depth: offgasingStartDepth
75-
}
72+
offgasingStartTime: Time.toMinutes(offgasingStartRuntime),
73+
offgasingStartDepth: offgasingStartDepth
7674
};
7775
}
7876

projects/scuba-physics/src/lib/ProfileTissues.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('Profile tissues', () => {
4747
it('Empty saturation returns dive start', () => {
4848
const overPressures: TissueOverPressures[] = [];
4949
const result = sut.offgasingStart(overPressures);
50-
expect(result).toEqual({ runtime: 0, depth: 0 });
50+
expect(result).toEqual(0);
5151
});
5252

5353
it('Wrong number of tissues in any sample throws Error', () => {
@@ -58,25 +58,25 @@ describe('Profile tissues', () => {
5858
it('No submerging saturation returns dive start', () => {
5959
const overPressures = createFilledOverPressures([0, 0, 0, 0, 0]);
6060
const result = sut.offgasingStart(overPressures);
61-
expect(result).toEqual({ runtime: 0, depth: 0 });
61+
expect(result).toEqual(0);
6262
});
6363

6464
it('Simple profile saturation returns 5th sample index', () => {
6565
const overPressures = createFilledOverPressures([0, -0.1, -0.2, -0.1, 0, 0.1, 0.1]);
6666
const result = sut.offgasingStart(overPressures);
67-
expect(result).toEqual({ runtime: 5, depth: 0 });
67+
expect(result).toEqual(5);
6868
});
6969

7070
it('Multi-level profile saturation returns 5th sample index', () => {
7171
const overPressures = createFilledOverPressures([0, -0.1, 0, 0.1, -0.1, 0, 0.1, 0.1]);
7272
const result = sut.offgasingStart(overPressures);
73-
expect(result).toEqual({ runtime: 6, depth: 0 });
73+
expect(result).toEqual(6);
7474
});
7575

7676
it('5th tissues stops offgasing on long deco stop', () => {
7777
const overPressures = createFilledOverPressures([0, -0.1, 0, 0.1, 0, 0.1, 0.1]);
7878
const result = sut.offgasingStart(overPressures);
79-
expect(result).toEqual({ runtime: 3, depth: 0 });
79+
expect(result).toEqual(3);
8080
});
8181

8282
it('5th tissues is not the leading tissue', () => {
@@ -86,7 +86,7 @@ describe('Profile tissues', () => {
8686
overPressures[3][4] = 0.1;
8787

8888
const result = sut.offgasingStart(overPressures);
89-
expect(result).toEqual({ runtime: 3, depth: 0 });
89+
expect(result).toEqual(3);
9090
});
9191
});
9292
});

projects/scuba-physics/src/lib/ProfileTissues.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _ from 'lodash';
2-
import { LoadedTissue, ProfileMoment, TissueOverPressures } from "./Tissues.api";
2+
import { LoadedTissue, TissueOverPressures } from "./Tissues.api";
33
import { Tissues } from "./Tissues";
44

55
export class ProfileTissues {
@@ -22,7 +22,7 @@ export class ProfileTissues {
2222
* The required values are calculated using Tissues.saturationRatio method.
2323
* @returns Index of first overpressure sample, where saturation speed is positive.
2424
**/
25-
public offgasingStart(tissueOverPressures: TissueOverPressures[]): ProfileMoment {
25+
public offgasingStart(tissueOverPressures: TissueOverPressures[]): number {
2626
const tissue5index = 4;
2727

2828
// multilevel dives may switch multiple times between on/offgasing
@@ -38,6 +38,6 @@ export class ProfileTissues {
3838

3939
// Not submerged or never offgased
4040
foundIndex = (foundIndex < 0 || foundIndex >= tissueOverPressures.length - 1) ? 0 : foundIndex;
41-
return { runtime: foundIndex, depth: 0 };
41+
return foundIndex;
4242
}
4343
}

projects/scuba-physics/src/lib/Segments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ export class Segments {
258258
}
259259

260260
/**
261-
* Find depth in bars, at which the diver was at given runtime in seconds for given profile.
261+
* Find depth in meters, at which the diver was at given runtime in seconds for given profile.
262262
**/
263263
public static depthAt(profile: Segment[], runtime: number): number {
264264
// TODO implement method Segments.depthAt

projects/scuba-physics/src/lib/Tissues.api.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,3 @@ export interface LoadedTissue {
2626
*/
2727
pHe: number;
2828
}
29-
30-
export interface ProfileMoment {
31-
/** In seconds from start of the dive */
32-
runtime: number;
33-
/** In meters */
34-
depth: number;
35-
}

0 commit comments

Comments
 (0)