From 0ac038d67b66cd299f33b46d4f260ca819d80819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Thu, 8 Sep 2022 15:14:35 +0200 Subject: [PATCH] refactor: nub: move children type from parent nub to itself refs #320 --- src/macrorugo/macrorugo.ts | 1 + src/macrorugo/macrorugo_compound.ts | 1 - src/math/spp.ts | 1 - src/math/yaxn.ts | 1 + src/nub.ts | 13 +++++++++---- src/pab/cloison_aval.ts | 1 + src/pab/cloisons.ts | 1 + src/pab/pab.ts | 1 - src/prebarrage/pb_bassin.ts | 1 + src/prebarrage/pb_cloison.ts | 1 + src/prebarrage/pre_barrage.ts | 2 +- src/solveur/solveur.ts | 1 - src/structure/parallel_structure.ts | 1 - src/structure/structure.ts | 1 + 14 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/macrorugo/macrorugo.ts b/src/macrorugo/macrorugo.ts index cb6f50e6..cdd32605 100644 --- a/src/macrorugo/macrorugo.ts +++ b/src/macrorugo/macrorugo.ts @@ -59,6 +59,7 @@ export class MacroRugo extends FishPass { this._cache = {}; this._calcType = CalculatorType.MacroRugo; this._defaultCalculatedParam = this.prms.Q; + this._intlType = "MacroRugo"; this.resetDefaultCalculatedParam(); } diff --git a/src/macrorugo/macrorugo_compound.ts b/src/macrorugo/macrorugo_compound.ts index 0d96cef5..021e1eb2 100644 --- a/src/macrorugo/macrorugo_compound.ts +++ b/src/macrorugo/macrorugo_compound.ts @@ -27,7 +27,6 @@ export class MacrorugoCompound extends MacroRugo implements Observer { this._calcType = CalculatorType.MacroRugoCompound; this._props.addObserver(this); this.inclinedApron = MRCInclination.NOT_INCLINED; - this._childrenType = "MacroRugo"; } public get inclinedApron(): MRCInclination { diff --git a/src/math/spp.ts b/src/math/spp.ts index 3f8b5070..aaffa178 100644 --- a/src/math/spp.ts +++ b/src/math/spp.ts @@ -21,7 +21,6 @@ export class SPP extends Nub { super(prms, dbg); this._calcType = CalculatorType.SPP; this._defaultCalculatedParam = prms.Y; - this._childrenType = "Puissance"; this.resetDefaultCalculatedParam(); this.operation = SPPOperation.SUM; } diff --git a/src/math/yaxn.ts b/src/math/yaxn.ts index fba559ff..0c05407e 100644 --- a/src/math/yaxn.ts +++ b/src/math/yaxn.ts @@ -14,6 +14,7 @@ export class YAXN extends ChildNub { super(prms, dbg); this._calcType = CalculatorType.YAXN; this._defaultCalculatedParam = prms.Y; + this._intlType = "Puissance"; this.resetDefaultCalculatedParam(); } diff --git a/src/nub.ts b/src/nub.ts index 11689aff..d3b2be68 100644 --- a/src/nub.ts +++ b/src/nub.ts @@ -78,11 +78,16 @@ export abstract class Nub extends ComputeNode implements IObservable { /** pointer to parent Nub */ public parent: Nub; - /** type of children elements, used by GUI for translation */ - protected _childrenType: string = ""; + /** + * Used by GUI for translation of the nub type in ngHyd (snackbar, ...). + * Formely childrenType, this was indicating type of children nubs. + * Now the child nub itself declares its type. + * Related to CalculatorType and INFO_CHILD_TYPE_* messages. + */ + protected _intlType: string; - public get childrenType(): string { - return this._childrenType; + public get intlType(): string { + return this._intlType; } public get result(): Result { diff --git a/src/pab/cloison_aval.ts b/src/pab/cloison_aval.ts index 4f440d4b..5b5eb3ac 100644 --- a/src/pab/cloison_aval.ts +++ b/src/pab/cloison_aval.ts @@ -13,6 +13,7 @@ export class CloisonAval extends ParallelStructure { constructor(prms: CloisonsAvalParams, dbg: boolean = false) { super(prms, dbg); this._calcType = CalculatorType.CloisonAval; + this._intlType = "Cloison"; } /** diff --git a/src/pab/cloisons.ts b/src/pab/cloisons.ts index aeea6a63..64288537 100644 --- a/src/pab/cloisons.ts +++ b/src/pab/cloisons.ts @@ -13,6 +13,7 @@ export class Cloisons extends ParallelStructure { constructor(prms: CloisonsParams, dbg: boolean = false) { super(prms, dbg); this._calcType = CalculatorType.Cloisons; + this._intlType = "Cloison"; } /** diff --git a/src/pab/pab.ts b/src/pab/pab.ts index 5e4f27a5..f54f632a 100644 --- a/src/pab/pab.ts +++ b/src/pab/pab.ts @@ -56,7 +56,6 @@ export class Pab extends FishPass { super(prms, dbg); this.downWall = downWall; this._calcType = CalculatorType.Pab; - this._childrenType = "Cloison"; } public get downWall() { diff --git a/src/prebarrage/pb_bassin.ts b/src/prebarrage/pb_bassin.ts index 6b4e86ab..ba68be6a 100644 --- a/src/prebarrage/pb_bassin.ts +++ b/src/prebarrage/pb_bassin.ts @@ -33,6 +33,7 @@ export class PbBassin extends Nub { this._calcType = CalculatorType.PbBassin; this.cloisonsAmont = []; this.cloisonsAval = []; + this._intlType = "Bassin"; } /** diff --git a/src/prebarrage/pb_cloison.ts b/src/prebarrage/pb_cloison.ts index 694f968a..a8044fac 100644 --- a/src/prebarrage/pb_cloison.ts +++ b/src/prebarrage/pb_cloison.ts @@ -21,6 +21,7 @@ export class PbCloison extends ParallelStructure { this.properties.setPropValue("upstreamBasin", bassinAmont === undefined ? "" : bassinAmont.uid); this.properties.setPropValue("downstreamBasin", bassinAval === undefined ? "" : bassinAval.uid); this._calcType = CalculatorType.PbCloison; + this._intlType = "Cloison"; } /** Bassin à l'amont de la cloison ou undefined pour condition limite amont */ diff --git a/src/prebarrage/pre_barrage.ts b/src/prebarrage/pre_barrage.ts index bd472755..30bf43f8 100644 --- a/src/prebarrage/pre_barrage.ts +++ b/src/prebarrage/pre_barrage.ts @@ -32,7 +32,7 @@ export class PreBarrage extends Nub { this.cloisonsAmont = []; this._bassins = []; this.maxIterations = SessionSettings.maxIterations; - this._childrenType = "Cloison"; + //this._intlType = "Cloison"; } /** diff --git a/src/solveur/solveur.ts b/src/solveur/solveur.ts index 2f83fc85..8fd138a8 100644 --- a/src/solveur/solveur.ts +++ b/src/solveur/solveur.ts @@ -39,7 +39,6 @@ export class Solveur extends Nub implements Observer { constructor(prms: SolveurParams, dbg: boolean = false) { super(prms, dbg); this._calcType = CalculatorType.Solveur; - this._childrenType = "Espece" this._props.addObserver(this); this.prms.addObserver(this); // UID of Session Nub to calculate, the result of the which must be this.prms.Ytarget.singleValue diff --git a/src/structure/parallel_structure.ts b/src/structure/parallel_structure.ts index 446bc1e0..057e012d 100644 --- a/src/structure/parallel_structure.ts +++ b/src/structure/parallel_structure.ts @@ -19,7 +19,6 @@ export class ParallelStructure extends Nub { constructor(prms: ParamsEquation, dbg: boolean = false) { super(prms, dbg); this._calcType = CalculatorType.ParallelStructure; - this._childrenType = "Ouvrage"; } /** children casting */ diff --git a/src/structure/structure.ts b/src/structure/structure.ts index 3c070c55..d11552de 100644 --- a/src/structure/structure.ts +++ b/src/structure/structure.ts @@ -85,6 +85,7 @@ export abstract class Structure extends ChildNub { // of a Structure to CALC mode makes it the calculated variable of the // *parent* ParallelStructures this.calculatedParam = this.prms.Q; + this._intlType = "Ouvrage"; } /** Returns Props object (observable set of key-values) associated to this Nub */ -- GitLab