Skip to content

Commit

Permalink
Added over pressures comparison test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkapok committed Jan 1, 2025
1 parent 5a54e29 commit 8368fd5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ export class ProfileDifferenceChartComponent extends Streamed implements OnInit

const chartPlotterFactory = new ChartPlotterFactory(resampling, units);
const profileATraces = chartPlotterFactory.withNamePrefix('Profile A ')
.create(() => this.profileA);
.create(() => this.profileComparatorService.profileAResults);
const profileBTraces = chartPlotterFactory
.withNamePrefix('Profile B ')
.wthAverageDepthColor('rgb(188,191,192)')
.wthDepthColor(ChartPlotterFactory.depthLineColorB)
.wthCeilingColor(ChartPlotterFactory.depthLineColorB)
.wthEventFillColor(ChartPlotterFactory.depthLineColorB)
.wthEventLineColor('rgb(118,119,120)')
.create(() => this.profileB);
.create(() => this.profileComparatorService.profileBResults);

this.plotter = new ChartPlotter('diveplotdiff', chartPlotterFactory, profileBTraces, profileATraces);
this.heatMapPlotterA = new HeatMapPlotter('heatmapPlotA');
Expand Down Expand Up @@ -75,14 +75,6 @@ export class ProfileDifferenceChartComponent extends Streamed implements OnInit
return this.profileComparatorService.profilesCalculated;
}

private get profileA(): DiveResults {
return this.profileComparatorService.profileAResults;
}

private get profileB(): DiveResults {
return this.profileComparatorService.profileBResults;
}

public ngOnInit(): void {
if (this.profilesCalculated) {
this.plotCharts();
Expand Down Expand Up @@ -115,12 +107,9 @@ export class ProfileDifferenceChartComponent extends Streamed implements OnInit
this.plotter.plotCharts(this.profileComparatorService.totalDuration);

if(this.heatMapEnabled) {
// TODO rescale different profile duration to the same max. duration (add surface tissues offgasing to shorter dive)
const overPressuresA = this.profileA.tissueOverPressures;
this.heatMapPlotterA.plotHeatMap(overPressuresA);

const overPressuresB = this.profileB.tissueOverPressures;
this.heatMapPlotterB.plotHeatMap(overPressuresB);
var overPressures = this.profileComparatorService.overPressures;
this.heatMapPlotterA.plotHeatMap(overPressures.profileAOverPressures);
this.heatMapPlotterB.plotHeatMap(overPressures.profileBOverPressures);
}
}

Expand Down
14 changes: 14 additions & 0 deletions projects/planner/src/app/shared/diff/profileComparatorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import { ReloadDispatcher } from '../reloadDispatcher';
import { Streamed } from '../streamed';
import { WayPoint } from '../wayPoint';

export interface SaturationComparison {
profileAOverPressures: number[][];
profileBOverPressures: number[][];
}

@Injectable()
export class ProfileComparatorService extends Streamed {
private _profileAIndex = 0;
Expand Down Expand Up @@ -108,6 +113,15 @@ export class ProfileComparatorService extends Streamed {
return this.profileAResults.showResults && this.profileBResults.showResults;
}

public get overPressures(): SaturationComparison {
// TODO rescale different profile duration to the same max. duration (add surface tissues offgasing to shorter dive)
const aLonger = this.profileAResults.planDuration > this.profileBResults.planDuration;
return {
profileAOverPressures: this.profileAResults.tissueOverPressures,
profileBOverPressures: this.profileBResults.tissueOverPressures
};
}

private get wayPointsA(): WayPoint[]{
return this.profileAResults.wayPoints;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { ReloadDispatcher } from '../reloadDispatcher';
import { UnitConversion } from '../UnitConversion';
import { ConsumptionByMix, IConsumedMix, Segment, StandardGases, Tank } from 'scuba-physics';
import { WayPoint } from '../wayPoint';
import { PlannerService } from '../planner.service';
import { ViewSwitchService } from "../viewSwitchService";
import { ApplicationSettingsService } from "../ApplicationSettings";
import { WorkersFactoryCommon } from "../serial.workers.factory";

describe('ProfileComparison service', () => {
let sut: ProfileComparatorService;
Expand All @@ -17,6 +21,8 @@ describe('ProfileComparison service', () => {
providers: [
ProfileComparatorService, UnitConversion,
ReloadDispatcher, DiveSchedules,
PlannerService, ViewSwitchService,
ApplicationSettingsService, WorkersFactoryCommon
]
}).compileComponents();
});
Expand Down Expand Up @@ -161,4 +167,19 @@ describe('ProfileComparison service', () => {
expect(sut.profileBIndex).toEqual(0);
});
});

xit('Tissue saturation Both have the same amount of samples', () => {
schedules.add();
schedules.dives[1].depths.planDuration = 14;
sut.selectProfile(1);
const planner = TestBed.inject(PlannerService);
// needed to get the finale over pressures
planner.calculate(1);
planner.calculate(2);

const overPressures = sut.overPressures;
const lengthB = overPressures.profileAOverPressures.length;
const lengthA = overPressures.profileBOverPressures.length;
expect(lengthA).toEqual(lengthB);
});
});

0 comments on commit 8368fd5

Please sign in to comment.