From 0fa4704d27ee8d0d2603ef96c273804b9e45c742 Mon Sep 17 00:00:00 2001 From: Jiri Pokorny Date: Thu, 15 Aug 2024 01:34:43 +0200 Subject: [PATCH] Implemented usage of max. gas density --- .../src/app/app-settings/app-settings.component.spec.ts | 1 + .../app/depths-complex/depths-complex.component.spec.ts | 2 ++ .../planner/src/app/shared/PlanUrlSerialization.spec.ts | 2 +- projects/planner/src/app/shared/planner.service.spec.ts | 3 ++- projects/planner/src/app/shared/planner.service.ts | 9 +++++---- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/projects/planner/src/app/app-settings/app-settings.component.spec.ts b/projects/planner/src/app/app-settings/app-settings.component.spec.ts index d4f5edb7..a3695791 100644 --- a/projects/planner/src/app/app-settings/app-settings.component.spec.ts +++ b/projects/planner/src/app/app-settings/app-settings.component.spec.ts @@ -109,3 +109,4 @@ describe('App settings component', () => { // * What are the values to test? // * Scheduler: Change of maxDensity triggers schedule calculation // * Diver.component.ts: Add tests for rmv and stressRmv save and load +// * PlannerService: MaxGasDensity is used when calling task diff --git a/projects/planner/src/app/depths-complex/depths-complex.component.spec.ts b/projects/planner/src/app/depths-complex/depths-complex.component.spec.ts index 127ea7c4..6a39d912 100644 --- a/projects/planner/src/app/depths-complex/depths-complex.component.spec.ts +++ b/projects/planner/src/app/depths-complex/depths-complex.component.spec.ts @@ -18,6 +18,7 @@ import { Preferences } from '../shared/preferences'; import { DiveResults } from '../shared/diveresults'; import { ReloadDispatcher } from '../shared/reloadDispatcher'; import { DiveSchedules } from '../shared/dive.schedules'; +import { ApplicationSettingsService } from '../shared/ApplicationSettings'; export class ComplexDepthsPage { constructor(private fixture: ComponentFixture) { } @@ -71,6 +72,7 @@ describe('Depths Complex Component', () => { SubViewStorage, ViewStates, DiveSchedules, PreferencesStore, Preferences, DiveResults, ReloadDispatcher, + ApplicationSettingsService, ] }) .compileComponents(); diff --git a/projects/planner/src/app/shared/PlanUrlSerialization.spec.ts b/projects/planner/src/app/shared/PlanUrlSerialization.spec.ts index 7eecfdc2..2afcbf34 100644 --- a/projects/planner/src/app/shared/PlanUrlSerialization.spec.ts +++ b/projects/planner/src/app/shared/PlanUrlSerialization.spec.ts @@ -46,8 +46,8 @@ describe('Url Serialization', () => { units.imperialUnits = imperial; const schedules = new DiveSchedules(units, dispatcher); const viewSwitch = new ViewSwitchService(schedules); - const planner = new PlannerService(schedules, dispatcher, viewSwitch, irrelevantFactory, units); const appSettings = new ApplicationSettingsService(units); + const planner = new PlannerService(schedules, dispatcher, viewSwitch, appSettings, irrelevantFactory, units); const preferences = new Preferences(viewSwitch, units, schedules, appSettings, new ViewStates()); const normalization = new SettingsNormalizationService(units, schedules); const urlSerialization = new PlanUrlSerialization(viewSwitch, units, normalization, diff --git a/projects/planner/src/app/shared/planner.service.spec.ts b/projects/planner/src/app/shared/planner.service.spec.ts index 98da4c71..f8f09666 100644 --- a/projects/planner/src/app/shared/planner.service.spec.ts +++ b/projects/planner/src/app/shared/planner.service.spec.ts @@ -22,6 +22,7 @@ import { DiveResults } from './diveresults'; import { ReloadDispatcher } from './reloadDispatcher'; import { DiveSchedules } from './dive.schedules'; import { ViewSwitchService } from './viewSwitchService'; +import { ApplicationSettingsService } from './ApplicationSettings'; describe('PlannerService', () => { let planner: PlannerService; @@ -39,7 +40,7 @@ describe('PlannerService', () => { PlannerService, UnitConversion, DiveSchedules, ReloadDispatcher, SettingsNormalizationService, ViewStates, - ViewSwitchService + ViewSwitchService, ApplicationSettingsService ], imports: [] }).compileComponents(); diff --git a/projects/planner/src/app/shared/planner.service.ts b/projects/planner/src/app/shared/planner.service.ts index 67c42453..31bc0e53 100644 --- a/projects/planner/src/app/shared/planner.service.ts +++ b/projects/planner/src/app/shared/planner.service.ts @@ -4,8 +4,8 @@ import { DiveResults } from './diveresults'; import { WayPointsService } from './waypoints.service'; import { WorkersFactoryCommon } from './serial.workers.factory'; import { - GasDensity, CalculatedProfile, - Precision, Segments, LoadedTissue + CalculatedProfile, Precision, + Segments, LoadedTissue } from 'scuba-physics'; import { ConsumptionResultDto, ConsumptionRequestDto, EventOptionsDto, @@ -20,6 +20,7 @@ import { ReloadDispatcher } from './reloadDispatcher'; import { Logger } from './Logger'; import { ViewSwitchService } from './viewSwitchService'; import { WayPoint } from './wayPoint'; +import { ApplicationSettingsService } from './ApplicationSettings'; @Injectable() @@ -33,6 +34,7 @@ export class PlannerService extends Streamed { private schedules: DiveSchedules, private dispatcher: ReloadDispatcher, private viewSwitch: ViewSwitchService, + private appSettings: ApplicationSettingsService, workerFactory: WorkersFactoryCommon, units: UnitConversion) { super(); @@ -201,8 +203,7 @@ export class PlannerService extends Streamed { private createEventOptions(): EventOptionsDto { return { - // TODO make maxDensity configurable - maxDensity: GasDensity.recommendedMaximum + maxDensity: this.appSettings.settings.maxGasDensity }; }