diff --git a/src/structure/structure.ts b/src/structure/structure.ts index 6425e6ae08c3fde51e2e2934a17e6ce00711b33e..b9d3a0c99d481f95b6c9bbf90465df85f1bcb1f4 100644 --- a/src/structure/structure.ts +++ b/src/structure/structure.ts @@ -82,7 +82,7 @@ export abstract class Structure extends ChildNub { /** Peut-on calculer ZDV ? */ protected _isZDVcalculable: boolean; - protected _loiDebit: LoiDebit; + private _loiDebit: LoiDebit; constructor(prms: StructureParams, dbg: boolean = false) { super(prms, dbg); @@ -97,13 +97,6 @@ export abstract class Structure extends ChildNub { /** Returns Props object (observable set of key-values) associated to this Nub */ public get properties(): Props { - // completes props with calcType, structureType and loiDebit if not already set - if (this._props.getPropValue("loiDebit") === undefined) { - this._props.setPropValue("loiDebit", this._loiDebit); - } - if (this._props.getPropValue("structureType") === undefined) { - this._props.setPropValue("structureType", StructureProperties.findCompatibleStructure(this._props.getPropValue("loiDebit"), this.parent as ParallelStructure)); - } return this._props; } @@ -142,6 +135,13 @@ export abstract class Structure extends ChildNub { return this._loiDebit; } + protected setLoiDebit(ld: LoiDebit) { + // completes props with structureType and loiDebit + this._loiDebit = ld; + this._props.setPropValue("loiDebit", this._loiDebit); + this._props.setPropValue("structureType", StructureProperties.findCompatibleStructure(this._loiDebit, this.parent as ParallelStructure)); + } + /** * Returns the nth visible parameter (used in nghyd/PabTable) */ diff --git a/src/structure/structure_gate_cem88d.ts b/src/structure/structure_gate_cem88d.ts index 0cbd201999a83588b9b5a2bf80da6a53a9593dca..6e5ee8a0af82ebeac1ee7a292e6a6d9a09522a58 100644 --- a/src/structure/structure_gate_cem88d.ts +++ b/src/structure/structure_gate_cem88d.ts @@ -12,7 +12,7 @@ export class StructureGateCem88d extends RectangularStructure { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.GateCem88d; + this.setLoiDebit(LoiDebit.GateCem88d); this._isZDVcalculable = false; this.prms.W.visible = true; this.prms.CdWR.visible = true; diff --git a/src/structure/structure_gate_cem88v.ts b/src/structure/structure_gate_cem88v.ts index eea96f17f0aabde2e3618f90131deb17d7f40c17..8cd007c63cea461b22e8199b28bf0aaa0de92a06 100644 --- a/src/structure/structure_gate_cem88v.ts +++ b/src/structure/structure_gate_cem88v.ts @@ -12,7 +12,7 @@ export class StructureGateCem88v extends RectangularStructure { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.GateCem88v; + this.setLoiDebit(LoiDebit.GateCem88v); this.prms.W.visible = true; this.prms.CdGR.visible = true; } diff --git a/src/structure/structure_gate_cunge80.ts b/src/structure/structure_gate_cunge80.ts index 698bd507f1bc45cad1c62a65cc8713b24287ea0a..b2a71ead139c3dbec020799e619bf62a7bdf7114 100644 --- a/src/structure/structure_gate_cunge80.ts +++ b/src/structure/structure_gate_cunge80.ts @@ -16,7 +16,7 @@ export class StructureGateCunge80 extends RectangularStructure { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.GateCunge80; + this.setLoiDebit(LoiDebit.GateCunge80); if (prms.W.v !== Infinity) { this._isZDVcalculable = false; } diff --git a/src/structure/structure_kivi.ts b/src/structure/structure_kivi.ts index 77c7cb1986161dda7555ee9781194aaede72a589..a84bd2d268fe769bd46728b1c26f50a6adbdbcb2 100644 --- a/src/structure/structure_kivi.ts +++ b/src/structure/structure_kivi.ts @@ -10,7 +10,7 @@ export class StructureKivi extends Structure { constructor(prms: StructureKiviParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.KIVI; + this.setLoiDebit(LoiDebit.KIVI); } /** diff --git a/src/structure/structure_orifice_free.ts b/src/structure/structure_orifice_free.ts index afa7181113d867f15d42638ca95306a29d357f3b..ce1cdfb4e147bffd199d89e2863a209e3fd66d6a 100644 --- a/src/structure/structure_orifice_free.ts +++ b/src/structure/structure_orifice_free.ts @@ -12,7 +12,7 @@ export class StructureOrificeFree extends Structure { constructor(prms: StructureOrificeFreeParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.OrificeFree; + this.setLoiDebit(LoiDebit.OrificeFree); this._isZDVcalculable = false; } @@ -25,7 +25,7 @@ export class StructureOrificeFree extends Structure { public Calc(sVarCalc: string, rInit?: number): Result { this.currentResult = super.Calc(sVarCalc, rInit); - if (this._loiDebit === LoiDebit.OrificeFree && this.prms.Z2.v > this.prms.Zco.v) { + if (this.loiDebit === LoiDebit.OrificeFree && this.prms.Z2.v > this.prms.Zco.v) { this._result.resultElement.addMessage(new Message( MessageCode.WARNING_ORIFICE_FREE_DOWNSTREAM_ELEVATION_POSSIBLE_SUBMERSION, { diff --git a/src/structure/structure_orifice_submerged.ts b/src/structure/structure_orifice_submerged.ts index df3878b2141c6d0fc8f33de905e5649b8d8b5a64..bf72df9ef711a3b6a5e7d371f16c937694cf5630 100644 --- a/src/structure/structure_orifice_submerged.ts +++ b/src/structure/structure_orifice_submerged.ts @@ -11,7 +11,7 @@ export class StructureOrificeSubmerged extends Structure { constructor(prms: StructureOrificeSubmergedParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.OrificeSubmerged; + this.setLoiDebit(LoiDebit.OrificeSubmerged); this._isZDVcalculable = false; } diff --git a/src/structure/structure_props.ts b/src/structure/structure_props.ts index a6fc2b01c5c8d94f45bc465f546713cd36bc6d9b..0ec013415ce5e1068fd7e4c1eedf4cb43ea179bc 100644 --- a/src/structure/structure_props.ts +++ b/src/structure/structure_props.ts @@ -140,7 +140,7 @@ export class StructureProperties { * du module de calcul parentNub @TODO la 1ère ? normalement il n'y en a qu'une ! */ public static findCompatibleStructure(loi: LoiDebit, parentNub: ParallelStructure): StructureType { - const loisAdmissibles = parentNub.getLoisAdmissibles(); + const loisAdmissibles = parentNub?.getLoisAdmissibles(); for (const st in loisAdmissibles) { if (loisAdmissibles.hasOwnProperty(st)) { const lds: LoiDebit[] = loisAdmissibles[st]; diff --git a/src/structure/structure_rectangular_orifice_free.ts b/src/structure/structure_rectangular_orifice_free.ts index 0a91a37d10a93831aa02452366be597e07fce465..b5082d172b19e4b41bf1239f51cbf7f9f7cd5c21 100644 --- a/src/structure/structure_rectangular_orifice_free.ts +++ b/src/structure/structure_rectangular_orifice_free.ts @@ -13,7 +13,7 @@ export class StructureRectangularOrificeFree extends RectangularStructure { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.RectangularOrificeFree; + this.setLoiDebit(LoiDebit.RectangularOrificeFree); this.prms.W.visible = true; this.prms.CdGR.visible = true; } diff --git a/src/structure/structure_rectangular_orifice_submerged.ts b/src/structure/structure_rectangular_orifice_submerged.ts index 9182c6156ef6365f78dc7a4591f07e7c0134fe00..d1715d168ea2bafb0026c99bdcf340f6a65c5d7d 100644 --- a/src/structure/structure_rectangular_orifice_submerged.ts +++ b/src/structure/structure_rectangular_orifice_submerged.ts @@ -12,7 +12,7 @@ export class StructureRectangularOrificeSubmerged extends RectangularStructure { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.RectangularOrificeSubmerged; + this.setLoiDebit(LoiDebit.RectangularOrificeSubmerged); if (prms.W.v !== Infinity) { this._isZDVcalculable = false; } diff --git a/src/structure/structure_triangular_trunc_weir.ts b/src/structure/structure_triangular_trunc_weir.ts index 7b72b299bbce63fa6a888f996e8e8772f3f92b8b..5ef3cb3ea606c5865250358d2ca57857a12acff9 100644 --- a/src/structure/structure_triangular_trunc_weir.ts +++ b/src/structure/structure_triangular_trunc_weir.ts @@ -12,7 +12,7 @@ export class StructureTriangularTruncWeirFree extends Structure { constructor(prms: TriangularTruncStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.TriangularTruncWeirFree; + this.setLoiDebit(LoiDebit.TriangularTruncWeirFree); } /** diff --git a/src/structure/structure_triangular_weir.ts b/src/structure/structure_triangular_weir.ts index 02798fbb8b2723a0057659359c91399129d77cb2..e4c445fbc60f0667eefbcbd2de6d2ba4d2457d4e 100644 --- a/src/structure/structure_triangular_weir.ts +++ b/src/structure/structure_triangular_weir.ts @@ -13,7 +13,7 @@ export class StructureTriangularWeir extends StructureTriangularWeirFree { constructor(prms: TriangularStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.TriangularWeirFree; // First name of the law for backward compatibility + this.setLoiDebit(LoiDebit.TriangularWeirFree); // First name of the law for backward compatibility } /** diff --git a/src/structure/structure_triangular_weir_broad.ts b/src/structure/structure_triangular_weir_broad.ts index 46581dcffbd8dea739fff5a69a74d42e77ae1265..4f4e11012322659100f78c626172bd4ddb3c6cbc 100644 --- a/src/structure/structure_triangular_weir_broad.ts +++ b/src/structure/structure_triangular_weir_broad.ts @@ -13,7 +13,7 @@ export class StructureTriangularWeirBroad extends StructureTriangularWeirFree { constructor(prms: TriangularStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.TriangularWeirBroad; // First name of the law for backward compatibility + this.setLoiDebit(LoiDebit.TriangularWeirBroad); // First name of the law for backward compatibility } /** diff --git a/src/structure/structure_vanlev_larinier.ts b/src/structure/structure_vanlev_larinier.ts index 33342264b54ab73f42d874491f825bdeda8ff3b3..9fb690d91bb1865962f87e87015bf68c96311a9b 100644 --- a/src/structure/structure_vanlev_larinier.ts +++ b/src/structure/structure_vanlev_larinier.ts @@ -6,7 +6,7 @@ export class StructureVanLevLarinier extends StructureWeirSubmergedLarinier { constructor(prms: StructureVanLevParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.VanLevLarinier; + this.setLoiDebit(LoiDebit.VanLevLarinier); } /** diff --git a/src/structure/structure_vanlev_villemonte.ts b/src/structure/structure_vanlev_villemonte.ts index 07e186e7faad776c91f1f361a96bf5eeef8ee0f1..ca803315edffb96077e3187656d5e11201c59897 100644 --- a/src/structure/structure_vanlev_villemonte.ts +++ b/src/structure/structure_vanlev_villemonte.ts @@ -6,7 +6,7 @@ export class StructureVanLevVillemonte extends StructureWeirVillemonte { constructor(prms: StructureVanLevParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.VanLevVillemonte; + this.setLoiDebit(LoiDebit.VanLevVillemonte); } /** diff --git a/src/structure/structure_weir_cem88d.ts b/src/structure/structure_weir_cem88d.ts index 4ca6ff9889b2798fcad1a850057bb3716f49f4d8..a35c7c87b08a0d54e69d5d6309172726cd457fe8 100644 --- a/src/structure/structure_weir_cem88d.ts +++ b/src/structure/structure_weir_cem88d.ts @@ -7,7 +7,7 @@ export class StructureWeirCem88d extends StructureGateCem88d { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.WeirCem88d; + this.setLoiDebit(LoiDebit.WeirCem88d); this._isZDVcalculable = true; // Gestion de l'affichage l'ouverture de vanne this.prms.W.visible = false; diff --git a/src/structure/structure_weir_cem88v.ts b/src/structure/structure_weir_cem88v.ts index f4c44d3319cb49ae12ee67f71599e4b6f7985ffa..aa29d7f06ab9a706268deec2c77d90cff4e9a0d2 100644 --- a/src/structure/structure_weir_cem88v.ts +++ b/src/structure/structure_weir_cem88v.ts @@ -7,7 +7,7 @@ export class StructureWeirCem88v extends StructureGateCem88v { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.WeirCem88v; + this.setLoiDebit(LoiDebit.WeirCem88v); this.prms.W.visible = false; } diff --git a/src/structure/structure_weir_cunge80.ts b/src/structure/structure_weir_cunge80.ts index c46ffb635ccc40c96e2d61c44f21bdbaeff48adf..c2fc2e4c5dbb376e9080f89064998b9edcd6d065 100644 --- a/src/structure/structure_weir_cunge80.ts +++ b/src/structure/structure_weir_cunge80.ts @@ -7,7 +7,7 @@ export class StructureWeirCunge80 extends StructureGateCunge80 { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.WeirCunge80; + this.setLoiDebit(LoiDebit.WeirCunge80); this.prms.W.visible = false; } diff --git a/src/structure/structure_weir_free.ts b/src/structure/structure_weir_free.ts index 3ac77c7a453228dd00e546097ceb011c7f932076..4bc0607fb4b83bdb0bf2ac0e1be03afbe4617a32 100644 --- a/src/structure/structure_weir_free.ts +++ b/src/structure/structure_weir_free.ts @@ -12,14 +12,14 @@ export class StructureWeirFree extends RectangularStructure { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.WeirFree; + this.setLoiDebit(LoiDebit.WeirFree); this.prms.CdWR.visible = true; } public Calc(sVarCalc: string, rInit?: number): Result { this.currentResult = super.Calc(sVarCalc, rInit); // do not check h2 for derived classes (ex: StructureWeirVillemonte) - if (this._loiDebit === LoiDebit.WeirFree && this.prms.h2.v > 0) { + if (this.loiDebit === LoiDebit.WeirFree && this.prms.h2.v > 0) { this._result.resultElement.addMessage(new Message( MessageCode.WARNING_DOWNSTREAM_ELEVATION_POSSIBLE_SUBMERSION, { diff --git a/src/structure/structure_weir_submerged.ts b/src/structure/structure_weir_submerged.ts index 6fbd5e3c1f26f4be0acf9ad9141d763dc208c88c..76925f3fd2553475a7cfdea6f252e3d7621cd19d 100644 --- a/src/structure/structure_weir_submerged.ts +++ b/src/structure/structure_weir_submerged.ts @@ -15,7 +15,7 @@ export class StructureWeirSubmerged extends RectangularStructure { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.WeirSubmerged; + this.setLoiDebit(LoiDebit.WeirSubmerged); this.prms.CdWS.visible = true; } diff --git a/src/structure/structure_weir_submerged_larinier.ts b/src/structure/structure_weir_submerged_larinier.ts index c865175927b752ab8fb4800c070a0cdca84b9d5f..63df6fd3001d0dc15e4e4a18482c44f882055fa8 100644 --- a/src/structure/structure_weir_submerged_larinier.ts +++ b/src/structure/structure_weir_submerged_larinier.ts @@ -14,7 +14,7 @@ export class StructureWeirSubmergedLarinier extends RectangularStructure { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.WeirSubmergedLarinier; + this.setLoiDebit(LoiDebit.WeirSubmergedLarinier); this.prms.CdWSL.visible = true; } diff --git a/src/structure/structure_weir_villemonte.ts b/src/structure/structure_weir_villemonte.ts index 8df8423584701d6d6d8c20b91199d5cb9d5a91d2..e701fd2421560376084e65fd1d50deb9c74cc48f 100644 --- a/src/structure/structure_weir_villemonte.ts +++ b/src/structure/structure_weir_villemonte.ts @@ -10,7 +10,7 @@ export class StructureWeirVillemonte extends StructureWeirFree { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); - this._loiDebit = LoiDebit.WeirVillemonte; + this.setLoiDebit(LoiDebit.WeirVillemonte); } public Calc(sVarCalc: string, rInit?: number): Result {