From 751d5a8d843c271c6c3e67b11c4e46307bc7f91b Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Mon, 1 Jul 2019 15:40:18 +0200 Subject: [PATCH] Fix nghyd#226 --- src/pab/cloisons.ts | 17 +---------------- src/pab/pab.ts | 13 ++++++++++++- src/structure/parallel_structure.ts | 21 ++++++++++++++++++++- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/pab/cloisons.ts b/src/pab/cloisons.ts index cedb09ff..771514d9 100644 --- a/src/pab/cloisons.ts +++ b/src/pab/cloisons.ts @@ -2,7 +2,6 @@ import { CalculatorType } from "../compute-node"; import { Nub } from "../index"; import { ParamCalculability } from "../param/param-definition"; import { ParallelStructure } from "../structure/parallel_structure"; -import { StructureParams } from "../structure/structure"; import { StructureKiviParams } from "../structure/structure_kivi"; import { loiAdmissiblesCloisons, LoiDebit } from "../structure/structure_props"; import { Result } from "../util/result"; @@ -23,13 +22,6 @@ export class Cloisons extends ParallelStructure { return this._prms as CloisonsParams; } - /** - * Is the cloison used in a PAB? - */ - get isInPAB(): boolean { - return (this.parent !== undefined); - } - public getLoisAdmissibles(): { [key: string]: LoiDebit[]; } { return loiAdmissiblesCloisons; } @@ -84,14 +76,7 @@ export class Cloisons extends ParallelStructure { } public adjustChildParameters(child: Nub) { - const prms = child.prms as StructureParams; - if (!this.isInPAB && prms.ZDV.visible) { - // Dans le contexte hors PAB - // Pour les seuils (i.e. Structures avec cote de radier de seuil) - // on remplace ZDV par h1 la charge sur le seuil - prms.h1.visible = true; - prms.ZDV.visible = false; - } + super.adjustChildParameters(child); if (child.prms instanceof StructureKiviParams) { // hide ZRAM for KIVI, in Cloisons and PAB context only child.prms.ZRAM.visible = false; diff --git a/src/pab/pab.ts b/src/pab/pab.ts index c403f656..ba45893c 100644 --- a/src/pab/pab.ts +++ b/src/pab/pab.ts @@ -54,7 +54,7 @@ export class Pab extends Nub { /** * Last wall at downstream */ - public downWall: ParallelStructure; + private _downWall: ParallelStructure; constructor(prms: PabParams, downWall: ParallelStructure, dbg: boolean = false) { super(prms, dbg); @@ -62,6 +62,17 @@ export class Pab extends Nub { this._calcType = CalculatorType.Pab; } + public get downWall() { + return this._downWall; + } + + public set downWall(dw: ParallelStructure) { + this._downWall = dw; + if (dw) { // might be undefined + dw.parent = this; // important + } + } + /** * Add Cloisons to the PAB from a cloison model * @param cloisonModel Cloison model parametrised as first upstream basin diff --git a/src/structure/parallel_structure.ts b/src/structure/parallel_structure.ts index 8734e6a4..36f08192 100644 --- a/src/structure/parallel_structure.ts +++ b/src/structure/parallel_structure.ts @@ -1,11 +1,12 @@ import { CalculatorType } from "../compute-node"; import { Nub } from "../nub"; +import { Pab } from "../pab/pab"; import { ParamCalculability } from "../param/param-definition"; import { ParamsEquation } from "../param/params-equation"; import { Session } from "../session"; import { Result } from "../util/result"; import { ParallelStructureParams } from "./parallel_structure_params"; -import { Structure } from "./structure"; +import { Structure, StructureParams } from "./structure"; import { loiAdmissiblesOuvrages, LoiDebit } from "./structure_props"; export { ParallelStructureParams }; @@ -38,6 +39,24 @@ export class ParallelStructure extends Nub { return this._prms as ParallelStructureParams; } + /** + * Is the Nub used in a PAB? + */ + get isInPAB(): boolean { + return (this.parent !== undefined && this.parent instanceof Pab); + } + + public adjustChildParameters(child: Nub) { + const prms = child.prms as StructureParams; + if (!this.isInPAB && prms.ZDV.visible) { + // Dans le contexte hors PAB + // Pour les seuils (i.e. Structures avec cote de radier de seuil) + // on remplace ZDV par h1 la charge sur le seuil + prms.h1.visible = true; + prms.ZDV.visible = false; + } + } + /** Returns admissible LoiDebit grouped by StructureType */ public getLoisAdmissibles(): { [key: string]: LoiDebit[]; } { return loiAdmissiblesOuvrages; -- GitLab