diff --git a/spec/pab/pab.spec.ts b/spec/pab/pab.spec.ts index e31c5783b4108e644e874aa21ec3b05a37e0553f..c32052ee021f9a024b921fa56ef7fe0ca23b5495 100644 --- a/spec/pab/pab.spec.ts +++ b/spec/pab/pab.spec.ts @@ -12,7 +12,7 @@ import { Cloisons, CloisonsParams } from "../../src/structure/cloisons"; import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params"; import { StructureWeirSubmergedLarinier } from "../../src/structure/structure_weir_submerged_larinier"; -const dbg: boolean = true; +const dbg: boolean = false; /** * Exemple formation Cassiopée 2018-09 @@ -41,7 +41,7 @@ const rectStructPrms = new RectangularStructureParams( ); // Ajout d'ouvrage dans la cloison -modelCloisons.addStructure(new StructureWeirSubmergedLarinier(rectStructPrms, dbg)); +modelCloisons.addChild(new StructureWeirSubmergedLarinier(rectStructPrms, dbg)); // Création de la passe diff --git a/src/pab/pab.ts b/src/pab/pab.ts index 3b58e19efe118b32de4801d7be56123427dd91e3..1bef4aeb00315368ebaf5931c963817e92ea8e5c 100644 --- a/src/pab/pab.ts +++ b/src/pab/pab.ts @@ -15,8 +15,12 @@ export class Pab extends Nub { return this._prms as PabParams; } - /** Tableau des cloisons en série */ - protected _pabCloisons: PabCloisons[] = []; + /** + * enfants castés au bon type + */ + get children(): PabCloisons[] { + return this._children as PabCloisons[]; + } /** * Calcul analytique @@ -25,7 +29,7 @@ export class Pab extends Nub { public Equation(sVarCalc: string): Result { const r: Result = new Result(0, this); let Z: number = this.prms.Z2.v; - for (const cloison of this._pabCloisons) { + for (const cloison of this.children) { cloison.prms.Z2.v = Z; cloison.Calc("Z1"); Z = cloison.prms.Z1.v; @@ -34,23 +38,6 @@ export class Pab extends Nub { return r; } - /** - * Ajout d'une cloison en série - * @param structure La structure à rajouter - * @param after position après laquelle insérer la cloison, à la fin sinon - */ - public addChild(pabCloisons: PabCloisons, after?: number) { - if (after !== undefined) { - this._pabCloisons.splice(after + 1, 0, pabCloisons); - } else { - this._pabCloisons.push(pabCloisons); - } - // add reference to parent collection (this) - pabCloisons.parent = this; - // propagate precision - pabCloisons.prms.Pr.setValue(this.prms.Pr.v); // does not write to .v to bypass calculability control - } - /** * paramétrage de la calculabilité des paramètres */ diff --git a/src/pab/pab_cloisons.ts b/src/pab/pab_cloisons.ts index 631fdd64b324711d7814187e67297ce1ae75b869..a80edbb84c9df923b3494f654e6f476ac78165bd 100644 --- a/src/pab/pab_cloisons.ts +++ b/src/pab/pab_cloisons.ts @@ -6,7 +6,7 @@ import { Pab } from "./pab"; class PabCloisonsParams extends CloisonsParams { - /** Débit entrant à l'amont de la passe (m3/s) */ + /** Débit d'attrait d'un bassin (m3/s) */ public QA: ParamDefinition; /** @@ -27,6 +27,16 @@ class PabCloisonsParams extends CloisonsParams { modelCloisonsParams.PB.v, modelCloisonsParams.DH.v ); + this.init(modelCloisonsParams); + + // On garde Pr en propre sur cet objet (Pointage impossible car en lecture seule) + this.addParamDefinition(this.Pr, true); + + this.QA = new ParamDefinition(this, "QA", ParamDomainValue.ANY, rQA, ParamFamily.FLOWS); + this.addParamDefinition(this.QA); + } + + public init(modelCloisonsParams: CloisonsParams) { this.Q = modelCloisonsParams.Q; this.Z1 = modelCloisonsParams.Z1; this.LB = modelCloisonsParams.LB; @@ -35,11 +45,6 @@ class PabCloisonsParams extends CloisonsParams { this.DH = modelCloisonsParams.DH; // Force la MAJ de la map avec les propriétés pointant vers celles de CloisonsParam this.addParamDefinitions(modelCloisonsParams); - // On garde Pr en propre sur cet objet (Pointage impossible car en lecture seule) - this.addParamDefinition(this.Pr, true); - - this.QA = new ParamDefinition(this, "QA", ParamDomainValue.ANY, rQA, ParamFamily.FLOWS); - this.addParamDefinition(this.QA); } } @@ -51,7 +56,7 @@ export class PabCloisons extends Cloisons { constructor(modelCloisons: Cloisons, rQA: number = 0, dbg: boolean = false) { super(new PabCloisonsParams(modelCloisons.prms, rQA), dbg); - this._structures = modelCloisons.structures; + this._children = modelCloisons.structures; } /** diff --git a/src/structure/cloisons.ts b/src/structure/cloisons.ts index 19eb0a079999674b73fc400421c9b2a43d7b3a4e..056bf4f212b78a3a7e1d18229d2ae17f712f75ef 100644 --- a/src/structure/cloisons.ts +++ b/src/structure/cloisons.ts @@ -7,6 +7,7 @@ import { ParallelStructure } from "./parallel_structure"; import { StructureKiviParams } from "./structure_kivi"; import { loiAdmissiblesCloisons, LoiDebit } from "./structure_props"; +export { CloisonsParams }; export class Cloisons extends ParallelStructure { constructor(prms: CloisonsParams, dbg: boolean = false) { super(prms, dbg);