Skip to content

Commit

Permalink
Removed tank property form planner
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkapok committed Dec 24, 2023
1 parent e89c33b commit 2869c35
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions projects/planner/src/app/shared/planner.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ export class PlannerService extends Streamed {
.subscribe(() => this.profileFailed());
}

private get tanks(): TanksService {
return this.schedules.selected.tanksService;
}

private get depths(): DepthsService {
return this.schedules.selected.depths;
}
Expand Down Expand Up @@ -122,7 +118,7 @@ export class PlannerService extends Streamed {
}

private continueCalculation(result: ProfileResultDto): void {
const tankData = this.tanks.tankData;
const tankData = this.diveBy(result.diveId).tanksService.tankData;
const calculatedProfile = DtoSerialization.toProfile(result.profile, tankData);
const events = DtoSerialization.toEvents(result.events);
const dive = this.diveResult(result.diveId);
Expand Down Expand Up @@ -157,7 +153,7 @@ export class PlannerService extends Streamed {
}

private createProfileRequest(previousDivetissues: LoadedTissue[], diveId: number): ProfileRequestDto {
const serializableTanks = this.tanks.tanks as ITankBound[];
const serializableTanks = this.diveBy(diveId).tanksService.tanks as ITankBound[];
return {
diveId: diveId,
tanks: DtoSerialization.fromTanks(serializableTanks),
Expand Down Expand Up @@ -204,17 +200,18 @@ export class PlannerService extends Streamed {

// TODO add testcase: dive is removed before its info is calculated
private finishCalculation(result: ConsumptionResultDto): void {
this.tanks.copyTanksConsumption(result.tanks);
const tanks = this.diveBy(result.diveId).tanksService;
tanks.copyTanksConsumption(result.tanks);
const dive = this.diveResult(result.diveId);
dive.maxTime = result.maxTime;
dive.timeToSurface = result.timeToSurface;

dive.emergencyAscentStart = this.depths.startAscentTime;
dive.turnPressure = this.tanks.calculateTurnPressure();
dive.turnPressure = tanks.calculateTurnPressure();
dive.turnTime = Precision.floor(this.depths.planDuration / 2);
// this needs to be moved to each gas or do we have other option?
dive.needsReturn = this.depths.needsReturn && this.tanks.singleTank;
dive.notEnoughGas = !this.tanks.enoughGas;
dive.needsReturn = this.depths.needsReturn && tanks.singleTank;
dive.notEnoughGas = !tanks.enoughGas;

// TODO still there is an option, that some calculation is still running.
dive.calculated = true;
Expand Down

0 comments on commit 2869c35

Please sign in to comment.