diff --git a/src/pab/cloisons.ts b/src/pab/cloisons.ts index cedb09ffa4679972faaed8ff823b14e98bf5e4af..771514d93850baa592e993efac63095355242b93 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 c403f6564baf8ab9fe9c3146d1cf6d289a2d75b2..ba45893c2a432cc12afb7e76952772aa2ffa238a 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 8734e6a4aaf876751b8f829b579292d9e6cb3990..36f08192ba01dd7740c478f4a5f612b71a81adea 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;