From ed781f7ecd9a94ce2b42c699b4e369debc3334ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr>
Date: Wed, 7 Dec 2022 09:23:04 +0100
Subject: [PATCH] refactor: rename Nub.currentResult setter to
 Nub.currentResultElement

refs #330
---
 src/devalaison/grille.ts                           |  2 +-
 src/devalaison/jet.ts                              |  2 +-
 src/macrorugo/macrorugo_compound.ts                |  2 +-
 src/math/spp.ts                                    |  2 +-
 src/nub.ts                                         | 10 +++++-----
 src/open-channel/regime_uniforme.ts                |  2 +-
 src/open-channel/section/section_type.ts           |  2 +-
 src/pab/cloison_aval.ts                            |  6 +++---
 src/pab/pab.ts                                     |  2 +-
 src/par/par.ts                                     |  2 +-
 src/par/par_simulation.ts                          |  2 +-
 src/solveur/solveur.ts                             |  2 +-
 src/structure/parallel_structure.ts                |  2 +-
 src/structure/structure.ts                         | 14 +++++++-------
 src/structure/structure_orifice_free.ts            |  2 +-
 .../structure_rectangular_orifice_free.ts          |  2 +-
 src/structure/structure_weir_free.ts               |  2 +-
 src/structure/structure_weir_submerged.ts          |  2 +-
 src/structure/structure_weir_submerged_larinier.ts |  2 +-
 src/structure/structure_weir_villemonte.ts         |  2 +-
 src/verification/verificateur.ts                   |  2 +-
 21 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/src/devalaison/grille.ts b/src/devalaison/grille.ts
index b54f0757..1170c087 100644
--- a/src/devalaison/grille.ts
+++ b/src/devalaison/grille.ts
@@ -97,7 +97,7 @@ export class Grille extends Nub implements Observer {
     }
 
     public Calc(): Result {
-        this.currentResult = this.Equation();
+        this.currentResultElement = this.Equation();
         return this.result;
     }
 
diff --git a/src/devalaison/jet.ts b/src/devalaison/jet.ts
index c00f1944..d61b0f4a 100644
--- a/src/devalaison/jet.ts
+++ b/src/devalaison/jet.ts
@@ -24,7 +24,7 @@ export class Jet extends Nub {
     }
 
     public Calc(sVarCalc: string, rInit?: number): Result {
-        this.currentResult = super.Calc(sVarCalc, rInit);
+        this.currentResultElement = super.Calc(sVarCalc, rInit);
         // omit extra results if calculation failed
         if (this.result.vCalc !== undefined) {
             // H: chute
diff --git a/src/macrorugo/macrorugo_compound.ts b/src/macrorugo/macrorugo_compound.ts
index 4d4b748e..0a16b571 100644
--- a/src/macrorugo/macrorugo_compound.ts
+++ b/src/macrorugo/macrorugo_compound.ts
@@ -91,7 +91,7 @@ export class MacrorugoCompound extends MacroRugo implements Observer {
             throw new Error("MacrorugoCompound.Calc() : invalid parameter " + sVarCalc);
         }
         this.copyPrmsToChildren();
-        this.currentResult = this.Equation(sVarCalc);
+        this.currentResultElement = this.Equation(sVarCalc);
 
         // lateral inclination for inclined aprons
         if (this.properties.getPropValue("inclinedApron") === MRCInclination.INCLINED) {
diff --git a/src/math/spp.ts b/src/math/spp.ts
index b7436633..b59c5bc0 100644
--- a/src/math/spp.ts
+++ b/src/math/spp.ts
@@ -50,7 +50,7 @@ export class SPP extends Nub {
         }
         switch (sVarCalc) {
             case "Y":
-                this.currentResult = super.Calc(sVarCalc, rInit);
+                this.currentResultElement = super.Calc(sVarCalc, rInit);
                 if (this.result.ok) {
                     this.getParameter(sVarCalc).v = this.result.resultElement.vCalc;
                 }
diff --git a/src/nub.ts b/src/nub.ts
index 91c1c242..b5fff7fd 100644
--- a/src/nub.ts
+++ b/src/nub.ts
@@ -114,11 +114,11 @@ export abstract class Nub extends ComputeNode implements IObservable {
     }
 
     /**
-     * Local setter to set results of Equation() / Solve() / …  as current
+     * Local setter to set result element of Equation() / Solve() / …  as current
      * ResultElement, instead of overwriting the whole Result object
      * (used by CalcSerie with varying parameters)
      */
-    protected set currentResult(r: Result) {
+    protected set currentResultElement(r: Result) {
         if (! this._result) {
             this.initNewResultElement();
         }
@@ -450,14 +450,14 @@ export abstract class Nub extends ComputeNode implements IObservable {
             rInit = computedVar.initValue;
         }
         if (computedVar.isAnalytical()) {
-            this.currentResult = this.Equation(sVarCalc);
+            this.currentResultElement = this.Equation(sVarCalc);
             this._result.symbol = sVarCalc;
             return this._result;
         }
 
         const resSolve: Result = this.Solve(sVarCalc, rInit);
         if (!resSolve.ok) {
-            this.currentResult = resSolve;
+            this.currentResultElement = resSolve;
             this._result.symbol = sVarCalc;
             return this._result;
         }
@@ -466,7 +466,7 @@ export abstract class Nub extends ComputeNode implements IObservable {
         const res: Result = this.Equation(sAnalyticalPrm);
         res.vCalc = resSolve.vCalc;
 
-        this.currentResult = res;
+        this.currentResultElement = res;
         this._result.symbol = sVarCalc;
 
         this.notifyResultUpdated();
diff --git a/src/open-channel/regime_uniforme.ts b/src/open-channel/regime_uniforme.ts
index e8424499..4666bb50 100644
--- a/src/open-channel/regime_uniforme.ts
+++ b/src/open-channel/regime_uniforme.ts
@@ -72,7 +72,7 @@ export class RegimeUniforme extends SectionNub {
             && this.section.prms.YB.v >= this.section.prms.D.v
             && isGreaterThan(this.section.prms.Y.v, this.section.prms.D.v, 1e-3)
         ) {
-            this.currentResult = new Result(new Message(MessageCode.ERROR_RU_CIRC_LEVEL_TOO_HIGH));
+            this.currentResultElement = new Result(new Message(MessageCode.ERROR_RU_CIRC_LEVEL_TOO_HIGH));
             return this.result;
         }
 
diff --git a/src/open-channel/section/section_type.ts b/src/open-channel/section/section_type.ts
index be114310..dc7c5976 100644
--- a/src/open-channel/section/section_type.ts
+++ b/src/open-channel/section/section_type.ts
@@ -166,7 +166,7 @@ export abstract class acSection extends Nub {
      * (used by triggerChainCalculation)
      */
     public CalcSerie(rInit?: number): Result {
-        this.currentResult = this.parent.CalcSerie(rInit);
+        this.currentResultElement = this.parent.CalcSerie(rInit);
         return this.result;
     }
 
diff --git a/src/pab/cloison_aval.ts b/src/pab/cloison_aval.ts
index 31d96158..f3b2ee10 100644
--- a/src/pab/cloison_aval.ts
+++ b/src/pab/cloison_aval.ts
@@ -52,14 +52,14 @@ export class CloisonAval extends ParallelStructure {
             throw new Error("CloisonAval sVarCalc should be Z1");
         }
         if (!this.checkVanneLevante()) {
-            this.currentResult.addMessage(new Message(MessageCode.ERROR_CLOISON_AVAL_UN_OUVRAGE_REGULE));
+            this.currentResultElement.addMessage(new Message(MessageCode.ERROR_CLOISON_AVAL_UN_OUVRAGE_REGULE));
             return this.result;
         }
         let m: Message;
         if (this.hasVanneLevante()) {
             const s = this.structures[this.indexVanneLevante] as StructureVanLevVillemonte | StructureVanLevLarinier;
             this.prms.Z1.v = this.prms.Z2.v + s.getParameter("DH").v;
-            this.currentResult = this.CalcStructPrm(this.indexVanneLevante, "ZDV");
+            this.currentResultElement = this.CalcStructPrm(this.indexVanneLevante, "ZDV");
             if (this.result.ok) {
                 s.prms.ZDV.v = this.result.vCalc;
             }
@@ -74,7 +74,7 @@ export class CloisonAval extends ParallelStructure {
         }
         if (!this.hasVanneLevante() || this.result.ok) {
             // Calculation of Z1 with the new ZDV in case of existing vanne levante
-            this.currentResult = super.Calc("Z1", rInit);
+            this.currentResultElement = super.Calc("Z1", rInit);
             if (this.result.ok) {
                 this.getParameter(sVarCalc).v = this.result.vCalc;
                 // Recalcul du débit total pour récupérer les résultats des ouvrages dans les résultats complémentaires
diff --git a/src/pab/pab.ts b/src/pab/pab.ts
index 811081b4..fe4d7647 100644
--- a/src/pab/pab.ts
+++ b/src/pab/pab.ts
@@ -147,7 +147,7 @@ export class Pab extends FishPass {
             }
         }
         if (r.hasErrorMessages()) {
-            this.currentResult = r;
+            this.currentResultElement = r;
             return this.result;
         }
         return super.Calc(sVarCalc, rInit);
diff --git a/src/par/par.ts b/src/par/par.ts
index b89e4380..bf84a1a3 100644
--- a/src/par/par.ts
+++ b/src/par/par.ts
@@ -97,7 +97,7 @@ export class Par extends FishPass implements Observer {
 
         // if any fatal error occurred
         if (hasError) {
-            this.currentResult = r;
+            this.currentResultElement = r;
             return this.result;
         }
 
diff --git a/src/par/par_simulation.ts b/src/par/par_simulation.ts
index ce67c64a..a6d7ad83 100644
--- a/src/par/par_simulation.ts
+++ b/src/par/par_simulation.ts
@@ -112,7 +112,7 @@ export class ParSimulation extends Par implements Observer {
 
         // if any fatal error occurred
         if (hasError) {
-            this.currentResult = r;
+            this.currentResultElement = r;
             return this.result;
         }
 
diff --git a/src/solveur/solveur.ts b/src/solveur/solveur.ts
index 68bdd598..6db56950 100644
--- a/src/solveur/solveur.ts
+++ b/src/solveur/solveur.ts
@@ -136,7 +136,7 @@ export class Solveur extends Nub implements Observer {
         const r: Result = new Result(new ResultElement());
         if (this.nubToCalculate.resultHasMultipleValues()) {
             r.resultElement.addMessage(new Message(MessageCode.ERROR_SOLVEUR_NO_VARIATED_PARAMS_ALLOWED));
-            this.currentResult = r;
+            this.currentResultElement = r;
             return this.result;
         }
         return super.Calc(sVarCalc, rInit);
diff --git a/src/structure/parallel_structure.ts b/src/structure/parallel_structure.ts
index e8037fc9..2d85e9b5 100644
--- a/src/structure/parallel_structure.ts
+++ b/src/structure/parallel_structure.ts
@@ -130,7 +130,7 @@ export class ParallelStructure extends Nub {
             case "Z1":
             case "Z2":
             case "Q":
-                this.currentResult = super.Calc(sVarCalc, rInit);
+                this.currentResultElement = super.Calc(sVarCalc, rInit);
                 if (this.result.ok) {
                     this.getParameter(sVarCalc).v = this.result.resultElement.vCalc;
                 }
diff --git a/src/structure/structure.ts b/src/structure/structure.ts
index 0d97bd2f..52dc8ed7 100644
--- a/src/structure/structure.ts
+++ b/src/structure/structure.ts
@@ -204,26 +204,26 @@ export abstract class Structure extends ChildNub {
         };
         if (sVarCalc === "Q") {
             if (this.prms.h1.v <= 1E-20 || Math.abs(this.prms.h1.v - this.prms.h2.v) < 1E-20 || this.W <= 1E-20) {
-                this.currentResult = new Result(0, this, flagsNull);
+                this.currentResultElement = new Result(0, this, flagsNull);
                 return this._result;
             }
         } else if (this.prms.Q.v === 0) {
             // Débit nul <=> tirant d'eau amont = tirant d'eau aval ou tout autre paramètre nul
             switch (sVarCalc) {
                 case "Z1":
-                    this.currentResult = new Result(this.prms.Z2.v, this, flagsNull);
+                    this.currentResultElement = new Result(this.prms.Z2.v, this, flagsNull);
                     return this._result;
                 case "Z2":
-                    this.currentResult = new Result(this.prms.Z1.v, this, flagsNull);
+                    this.currentResultElement = new Result(this.prms.Z1.v, this, flagsNull);
                     return this._result;
                 default:
                     // Est-ce toujours vrai ? Nécessitera peut-être d'étendre la méthode
-                this.currentResult = new Result(0, this, flagsNull);
+                this.currentResultElement = new Result(0, this, flagsNull);
                 return this._result;
             }
         } else if (this.W === 0 && sVarCalc === "Z1") {
             // Si la vanne est fermée la cote amont est infinie
-            this.currentResult = new Result(Infinity, this, flagsNull);
+            this.currentResultElement = new Result(Infinity, this, flagsNull);
             return this._result;
         }
 
@@ -249,7 +249,7 @@ export abstract class Structure extends ChildNub {
                     res = new Result(new Message(MessageCode.ERROR_STRUCTURE_Q_TROP_ELEVE), this, flagsNull);
                 }
                 res.vCalc = rPrm;
-                this.currentResult = res;
+                this.currentResultElement = res;
 
                 // "Les cotes et le débit ne sont pas cohérents => fermeture de l'ouvrage
                 return res;
@@ -261,7 +261,7 @@ export abstract class Structure extends ChildNub {
             [this.prms.Z1.v, this.prms.Z2.v] = [this.prms.Z2.v, this.prms.Z1.v]; // Swap ES6 fashion
             const res: Result = super.Calc(sVarCalc, rInit);
             [this.prms.Z1.v, this.prms.Z2.v] = [this.prms.Z2.v, this.prms.Z1.v]; // Swap ES6 fashion
-            this.currentResult = res;
+            this.currentResultElement = res;
             return res;
         }
 
diff --git a/src/structure/structure_orifice_free.ts b/src/structure/structure_orifice_free.ts
index ce1cdfb4..2e73f509 100644
--- a/src/structure/structure_orifice_free.ts
+++ b/src/structure/structure_orifice_free.ts
@@ -24,7 +24,7 @@ export class StructureOrificeFree extends Structure {
     }
 
     public Calc(sVarCalc: string, rInit?: number): Result {
-        this.currentResult = super.Calc(sVarCalc, rInit);
+        this.currentResultElement = super.Calc(sVarCalc, rInit);
         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_rectangular_orifice_free.ts b/src/structure/structure_rectangular_orifice_free.ts
index b5082d17..fd66175e 100644
--- a/src/structure/structure_rectangular_orifice_free.ts
+++ b/src/structure/structure_rectangular_orifice_free.ts
@@ -19,7 +19,7 @@ export class StructureRectangularOrificeFree extends RectangularStructure {
     }
 
     public Calc(sVarCalc: string, rInit?: number): Result {
-        this.currentResult = super.Calc(sVarCalc, rInit);
+        this.currentResultElement = super.Calc(sVarCalc, rInit);
         if (this.prms.h2.v > 0) {
             this._result.resultElement.addMessage(new Message(
                 MessageCode.WARNING_DOWNSTREAM_ELEVATION_POSSIBLE_SUBMERSION,
diff --git a/src/structure/structure_weir_free.ts b/src/structure/structure_weir_free.ts
index 4bc0607f..6e588384 100644
--- a/src/structure/structure_weir_free.ts
+++ b/src/structure/structure_weir_free.ts
@@ -17,7 +17,7 @@ export class StructureWeirFree extends RectangularStructure {
     }
 
     public Calc(sVarCalc: string, rInit?: number): Result {
-        this.currentResult = super.Calc(sVarCalc, rInit);
+        this.currentResultElement = super.Calc(sVarCalc, rInit);
         // do not check h2 for derived classes (ex: StructureWeirVillemonte)
         if (this.loiDebit === LoiDebit.WeirFree && this.prms.h2.v > 0) {
             this._result.resultElement.addMessage(new Message(
diff --git a/src/structure/structure_weir_submerged.ts b/src/structure/structure_weir_submerged.ts
index 76925f3f..76f7969b 100644
--- a/src/structure/structure_weir_submerged.ts
+++ b/src/structure/structure_weir_submerged.ts
@@ -20,7 +20,7 @@ export class StructureWeirSubmerged extends RectangularStructure {
     }
 
     public Calc(sVarCalc: string, rInit?: number): Result {
-        this.currentResult = super.Calc(sVarCalc, rInit);
+        this.currentResultElement = super.Calc(sVarCalc, rInit);
         const h2h1ratio = this.prms.h2.v / this.prms.h1.v;
         if (h2h1ratio < 0.8) {
             this._result.resultElement.addMessage(new Message(
diff --git a/src/structure/structure_weir_submerged_larinier.ts b/src/structure/structure_weir_submerged_larinier.ts
index 63df6fd3..72f0c5e6 100644
--- a/src/structure/structure_weir_submerged_larinier.ts
+++ b/src/structure/structure_weir_submerged_larinier.ts
@@ -26,7 +26,7 @@ export class StructureWeirSubmergedLarinier extends RectangularStructure {
     }
 
     public Calc(sVarCalc: string, rInit?: number): Result {
-        this.currentResult = super.Calc(sVarCalc, rInit);
+        this.currentResultElement = super.Calc(sVarCalc, rInit);
         const h2h1ratio = this.prms.h2.v / this.prms.h1.v;
         if (h2h1ratio < 0.7 || h2h1ratio > 0.9) {
             this._result.resultElement.addMessage(new Message(
diff --git a/src/structure/structure_weir_villemonte.ts b/src/structure/structure_weir_villemonte.ts
index e701fd24..0599551f 100644
--- a/src/structure/structure_weir_villemonte.ts
+++ b/src/structure/structure_weir_villemonte.ts
@@ -14,7 +14,7 @@ export class StructureWeirVillemonte extends StructureWeirFree {
     }
 
     public Calc(sVarCalc: string, rInit?: number): Result {
-        this.currentResult = super.Calc(sVarCalc, rInit);
+        this.currentResultElement = super.Calc(sVarCalc, rInit);
         if ((this.prms.h2.v / this.prms.h1.v) > 0.7) {
             this._result.resultElement.addMessage(new Message(
                 MessageCode.WARNING_NOTCH_SUBMERGENCE_GREATER_THAN_07,
diff --git a/src/verification/verificateur.ts b/src/verification/verificateur.ts
index 4ceb194c..69a7df26 100644
--- a/src/verification/verificateur.ts
+++ b/src/verification/verificateur.ts
@@ -181,7 +181,7 @@ export class Verificateur extends Nub {
     }
 
     public Calc(): Result {
-        this.currentResult = this.Equation();
+        this.currentResultElement = this.Equation();
         return this.result;
     }
 
-- 
GitLab