From 090ef9e01201adf5d1aa8c7abf5702da76f12fa5 Mon Sep 17 00:00:00 2001
From: David Dorchies <david.dorchies@irstea.fr>
Date: Tue, 2 Oct 2018 14:29:42 +0200
Subject: [PATCH] nghyd#44 gestion propre des ENUM dans les extraResult

---
 spec/macrorugo/macrorugo.spec.ts               |  9 +++++----
 spec/structure/functions.ts                    |  4 ++--
 spec/structure/parallel_structure.spec.ts      |  4 ++--
 spec/structure/structure.spec.ts               |  2 +-
 ...tructure_triangular_trunc_weir_free.spec.ts |  6 +++---
 spec/value_ref/value_ref_structure.spec.ts     | 18 +++++++++---------
 src/macrorugo/macrorugo.ts                     |  8 ++++----
 src/structure/structure.ts                     |  6 +++---
 src/structure/structure_cem88d.ts              |  6 +++---
 src/structure/structure_cem88v.ts              | 10 +++++-----
 src/structure/structure_cunge80.ts             |  6 +++---
 src/structure/structure_kivi.ts                |  2 +-
 src/structure/villemonte.ts                    |  2 +-
 13 files changed, 42 insertions(+), 41 deletions(-)

diff --git a/spec/macrorugo/macrorugo.spec.ts b/spec/macrorugo/macrorugo.spec.ts
index 0eb635f1..fe481961 100644
--- a/spec/macrorugo/macrorugo.spec.ts
+++ b/spec/macrorugo/macrorugo.spec.ts
@@ -85,19 +85,20 @@ describe("Class MacroRugo: ", () => {
         });
 
         it(`Calc("Q", 0.1).extraResults.P should be around 759.240352`, () => {
-            checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.P, 759.240352, 0.03);
+            checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.PV, 759.240352, 0.03);
         });
 
         it(`Calc("Q", 0.1).extraResults.FlowType should be MacroRugoFlowType.EMERGENT`, () => {
-            expect(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.FlowType).toBe(MacroRugoFlowType.EMERGENT);
+            expect(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.ENUM_MacroRugoFlowType)
+                .toBe(MacroRugoFlowType.EMERGENT);
         });
 
         it(`Calc("Q", 0.1).extraResults.Q2 should be around 0.868672`, () => {
-            checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.Q2, 0.868672, 0.03);
+            checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.Q_GuideTech, 0.868672, 0.03);
         });
 
         it(`Calc("Q", 0.1).extraResults.V2 should be around 1.991299`, () => {
-            checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.V2, 1.991299, 0.03);
+            checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.V_GuideTech, 1.991299, 0.03);
         });
 
         const nub = macroRugoInstanceEmergent();
diff --git a/spec/structure/functions.ts b/spec/structure/functions.ts
index 800641dc..6d8e1e1e 100644
--- a/spec/structure/functions.ts
+++ b/spec/structure/functions.ts
@@ -33,12 +33,12 @@ export function itCalcQ(
     });
     if (mode !== undefined) {
         it("Q(Z1=" + Z1 + ",W=" + W + ") Mode should be " + mode, () => {
-            expect(res.extraResults.Mode).toBe(mode);
+            expect(res.extraResults.ENUM_StructureFlowMode).toBe(mode);
         });
     }
     if (regime !== undefined) {
         it("Q(Z1=" + Z1 + ",W=" + W + ") Regime should be " + regime, () => {
-            expect(res.extraResults.Regime).toBe(regime);
+            expect(res.extraResults.ENUM_StructureFlowRegime).toBe(regime);
         });
     }
 }
diff --git a/spec/structure/parallel_structure.spec.ts b/spec/structure/parallel_structure.spec.ts
index fcccae3e..6ec41d51 100644
--- a/spec/structure/parallel_structure.spec.ts
+++ b/spec/structure/parallel_structure.spec.ts
@@ -67,12 +67,12 @@ function itParallelStructure(sVarCalc: string, rVcalc: number, Q?: number) {
             });
             it(`ExtraResult[ouvrage[${i}].Q_Mode] should be 0`, () => {
                 expect(
-                    pstruct.Calc(sVarCalc).resultElement.extraResults[`ouvrage[${i}].Q_Mode`]
+                    pstruct.Calc(sVarCalc).resultElement.extraResults[`ouvrage[${i}].Q_ENUM_StructureFlowMode`]
                 ).toEqual(0);
             });
             it(`ExtraResult[ouvrage[${i}].Q_Regime] should be 0`, () => {
                 expect(
-                    pstruct.Calc(sVarCalc).resultElement.extraResults[`ouvrage[${i}].Q_Regime`]
+                    pstruct.Calc(sVarCalc).resultElement.extraResults[`ouvrage[${i}].Q_ENUM_StructureFlowRegime`]
                 ).toEqual(0);
             });
         }
diff --git a/spec/structure/structure.spec.ts b/spec/structure/structure.spec.ts
index 4a4c22b8..62abfb70 100644
--- a/spec/structure/structure.spec.ts
+++ b/spec/structure/structure.spec.ts
@@ -46,7 +46,7 @@ describe("Class Structure: ", () => {
     });
 
     describe("Calc()", () => {
-        const flagsNull = { Mode: StructureFlowMode.NULL, Regime: StructureFlowRegime.NULL };
+        const flagsNull = { ENUM_StructureFlowMode: StructureFlowMode.NULL, ENUM_StructureFlowRegime: StructureFlowRegime.NULL };
         it("Z1=Z2 => Q=0", () => {
             structTest.prms.Z2.v = structTest.prms.Z1.v;
             checkResult(structTest.Calc("Q"), 0);
diff --git a/spec/structure/structure_triangular_trunc_weir_free.spec.ts b/spec/structure/structure_triangular_trunc_weir_free.spec.ts
index f0e771dc..c80ce74c 100644
--- a/spec/structure/structure_triangular_trunc_weir_free.spec.ts
+++ b/spec/structure/structure_triangular_trunc_weir_free.spec.ts
@@ -17,15 +17,15 @@ const structTest: StructureTriangularTruncWeirFree = new StructureTriangularTrun
 
 describe("Class StructureTriangularTruncWeirFree: ", () => {
     describe("Calcul Q a surface libre avec h1 croissant: ", () => {
-        const h1: number[] =
+        const Z1: number[] =
             [100.1, 100.2, 100.3, 100.4, 100.5, 100.6, 100.7, 100.8, 100.9, 101, 101.1, 101.5, 101.8, 102];
         const Q: number[] =
             [0., 0.004, 0.024, 0.067, 0.138, 0.240, 0.379, 0.558, 0.778, 1.045, 1.356, 2.914, 4.346, 5.407];
         const mode: StructureFlowMode = StructureFlowMode.WEIR;
         const regime: StructureFlowRegime = StructureFlowRegime.FREE;
-        itCalcQ(structTest, h1[0], Infinity, Q[0], StructureFlowMode.NULL, StructureFlowRegime.NULL);
+        itCalcQ(structTest, Z1[0], Infinity, Q[0], StructureFlowMode.NULL, StructureFlowRegime.NULL);
         for (let i = 1; i < Q.length; i++) {
-            itCalcQ(structTest, h1[i], Infinity, Q[i], mode, regime);
+            itCalcQ(structTest, Z1[i], Infinity, Q[i], mode, regime);
         }
     });
 });
diff --git a/spec/value_ref/value_ref_structure.spec.ts b/spec/value_ref/value_ref_structure.spec.ts
index f49eb0a6..b24a97e5 100644
--- a/spec/value_ref/value_ref_structure.spec.ts
+++ b/spec/value_ref/value_ref_structure.spec.ts
@@ -49,20 +49,20 @@ describe("référence d'un paramètre à un autre : ", () => {
 
             createEnv();
 
-            prm4.Q.defineReference(nub1, "ouvrage[0].Q_Mode");
+            prm4.Q.defineReference(nub1, "ouvrage[0].Q_ENUM_StructureFlowMode");
 
             nub1.CalcSerie(0.001, 0.1, "Q");
             nub2.CalcSerie(0.001, 0.1, "Q");
             /*
             nub1.result.resultElements[0].extraResults = {
             "ouvrage[0].Q" : 6.264183905346331
-            "ouvrage[0].Q_Mode" : 0
-            "ouvrage[0].Q_Regime" : 0
+            "ouvrage[0].Q_ENUM_StructureFlowMode" : 0
+            "ouvrage[0].Q_ENUM_StructureFlowRegime" : 0
             }
             nub2.result.resultElements[0].extraResults = {
             "ouvrage[0].Q" : 2.4110855093366834
-            "ouvrage[0].Q_Mode" : 0
-            "ouvrage[0].Q_Regime" : 0
+            "ouvrage[0].Q_ENUM_StructureFlowMode" : 0
+            "ouvrage[0].Q_ENUM_StructureFlowRegime" : 0
             }
             */
 
@@ -83,13 +83,13 @@ describe("référence d'un paramètre à un autre : ", () => {
             /*
             nub1.result.resultElements[0].extraResults = {
             "ouvrage[0].Q" : 6.264183905346331
-            "ouvrage[0].Q_Mode" : 0
-            "ouvrage[0].Q_Regime" : 0
+            "ouvrage[0].Q_ENUM_StructureFlowMode" : 0
+            "ouvrage[0].Q_ENUM_StructureFlowRegime" : 0
             }
             nub2.result.resultElements[0].extraResults = {
             "ouvrage[0].Q" : 2.4110855093366834
-            "ouvrage[0].Q_Mode" : 0
-            "ouvrage[0].Q_Regime" : 0
+            "ouvrage[0].Q_ENUM_StructureFlowMode" : 0
+            "ouvrage[0].Q_ENUM_StructureFlowRegime" : 0
             }
             */
 
diff --git a/src/macrorugo/macrorugo.ts b/src/macrorugo/macrorugo.ts
index 001b446a..b69ba0d5 100644
--- a/src/macrorugo/macrorugo.ts
+++ b/src/macrorugo/macrorugo.ts
@@ -1,8 +1,8 @@
 import { Nub } from "../nub";
 import { ParamCalculability } from "../param/param-definition";
+import { ParamValueMode } from "../param/param-value-mode";
 import { Result } from "../util/result";
 import { MacrorugoParams } from "./macrorugo_params";
-import { ParamValueMode } from "../param/param-value-mode";
 
 export { MacrorugoParams };
 
@@ -75,11 +75,11 @@ export class MacroRugo extends Nub {
         r.extraResults.PV = 1000 * MacroRugo.g * this.V(this.prms.Q) / this.prms.B.v * this.prms.If.v;
         // Type d'écoulement
         if (this.prms.Y.v / this.prms.PBH.v < 1) {
-            r.extraResults.FlowType = MacroRugoFlowType.EMERGENT;
+            r.extraResults.ENUM_MacroRugoFlowType = MacroRugoFlowType.EMERGENT;
         } else if (this.prms.Y.v / this.prms.PBH.v < MacroRugo.limitSubmerg) {
-            r.extraResults.FlowType = MacroRugoFlowType.QUASI_EMERGENT;
+            r.extraResults.ENUM_MacroRugoFlowType = MacroRugoFlowType.QUASI_EMERGENT;
         } else {
-            r.extraResults.FlowType = MacroRugoFlowType.IMMERGE;
+            r.extraResults.ENUM_MacroRugoFlowType = MacroRugoFlowType.IMMERGE;
         }
         // Vitesse et débit du guide technique
         let cQ: [number, number, number, number];
diff --git a/src/structure/structure.ts b/src/structure/structure.ts
index c3dfca92..0494b4e1 100644
--- a/src/structure/structure.ts
+++ b/src/structure/structure.ts
@@ -110,7 +110,7 @@ export abstract class Structure extends Nub {
         this.prms.update_h1h2();
 
         // Gestion du débit nul
-        const flagsNull = { Mode: StructureFlowMode.NULL, Regime: StructureFlowRegime.NULL };
+        const flagsNull = { ENUM_StructureFlowMode: StructureFlowMode.NULL, ENUM_StructureFlowRegime: StructureFlowRegime.NULL };
         if (sVarCalc === "Q") {
             if (this.prms.h1.v <= 0 || this.prms.Z1.v === this.prms.Z2.v || this.prms.W.v <= 0) {
                 return new Result(0, flagsNull);
@@ -166,8 +166,8 @@ export abstract class Structure extends Nub {
 
     protected getResultData() {
         return {
-            Mode: this.getFlowMode(),
-            Regime: this.getFlowRegime(),
+            ENUM_StructureFlowMode: this.getFlowMode(),
+            ENUM_StructureFlowRegime: this.getFlowRegime(),
         };
     }
 
diff --git a/src/structure/structure_cem88d.ts b/src/structure/structure_cem88d.ts
index 0ddac7bd..2040e13e 100644
--- a/src/structure/structure_cem88d.ts
+++ b/src/structure/structure_cem88d.ts
@@ -31,9 +31,9 @@ export class StructureCem88d extends RectangularStructure {
         const b2: number = Math.sqrt(this.prms.h1.v - this.prms.h2.v);
         const cd1: number = cd * 2.5981; // cd * 3*sqrt(3)/2
         this.debug("StructureCem88d.Equation b1=" + b1 + " b2=" + b2 + " cd1=" + cd1);
-        switch (data.Mode) {
+        switch (data.ENUM_StructureFlowMode) {
             case StructureFlowMode.WEIR:
-                switch (data.Regime) {
+                switch (data.ENUM_StructureFlowRegime) {
                     case StructureFlowRegime.FREE:
                         v = cd * this.prms.h1.v * b1;
                         break;
@@ -45,7 +45,7 @@ export class StructureCem88d extends RectangularStructure {
                 break;
             case StructureFlowMode.ORIFICE:
                 const b3: number = Math.pow(this.prms.h1.v - this.prms.W.v, 1.5);
-                switch (data.Regime) {
+                switch (data.ENUM_StructureFlowRegime) {
                     case StructureFlowRegime.FREE:
                         v = cd * (this.prms.h1.v * b1 - b3);
                         break;
diff --git a/src/structure/structure_cem88v.ts b/src/structure/structure_cem88v.ts
index c0dc94ca..a7876538 100644
--- a/src/structure/structure_cem88v.ts
+++ b/src/structure/structure_cem88v.ts
@@ -21,13 +21,13 @@ export class StructureCem88v extends RectangularStructure {
         let v: number;
         const mu0: number = 2 / 3 * this.prms.Cd.v;
         let KF: number;
-        if (data.Regime !== StructureFlowRegime.FREE) {
+        if (data.ENUM_StructureFlowRegime !== StructureFlowRegime.FREE) {
             KF = this.getKF(Math.sqrt(1 - this.prms.h2.v / this.prms.h1.v), this.getAlfa(this.prms.h2.v));
         }
-        switch (data.Mode) {
+        switch (data.ENUM_StructureFlowMode) {
             case StructureFlowMode.WEIR:
                 const muf: number = mu0 - 0.08;
-                switch (data.Regime) {
+                switch (data.ENUM_StructureFlowRegime) {
                     case StructureFlowRegime.FREE:
                         v = muf * this.prms.L.v * Structure.R2G * Math.pow(this.prms.h1.v, 1.5);
                         break;
@@ -40,12 +40,12 @@ export class StructureCem88v extends RectangularStructure {
             case StructureFlowMode.ORIFICE:
                 const mu: number = mu0 - 0.08 / (this.prms.h1.v / this.prms.W.v);
                 const mu1: number = mu0 - 0.08 / (this.prms.h1.v / this.prms.W.v - 1);
-                if (data.Regime === StructureFlowRegime.FREE) {
+                if (data.ENUM_StructureFlowRegime === StructureFlowRegime.FREE) {
                     v = this.prms.L.v * Structure.R2G
                         * (mu * Math.pow(this.prms.h1.v, 1.5)
                             - mu1 * Math.pow(this.prms.h1.v - this.prms.W.v, 1.5));
                 } else {
-                    if (data.Regime === StructureFlowRegime.PARTIAL) {
+                    if (data.ENUM_StructureFlowRegime === StructureFlowRegime.PARTIAL) {
                         v = this.prms.L.v * Structure.R2G * (
                             KF * mu * Math.pow(this.prms.h1.v, 1.5)
                             - mu1 * Math.pow(this.prms.h1.v - this.prms.W.v, 1.5)
diff --git a/src/structure/structure_cunge80.ts b/src/structure/structure_cunge80.ts
index b278eadc..eee8b87e 100644
--- a/src/structure/structure_cunge80.ts
+++ b/src/structure/structure_cunge80.ts
@@ -26,9 +26,9 @@ export class StructureCunge80 extends RectangularStructure {
         const data = this.getResultData();
         let v: number;
 
-        switch (data.Regime) {
+        switch (data.ENUM_StructureFlowRegime) {
             case StructureFlowRegime.FREE:
-                if (data.Mode === StructureFlowMode.WEIR) {
+                if (data.ENUM_StructureFlowMode === StructureFlowMode.WEIR) {
                     const R32: number = 3 * Math.sqrt(3) / 2;
                     v = this.prms.Cd.v * this.prms.L.v * Structure.R2G / R32 * Math.pow(this.prms.h1.v, 1.5);
                     this.debug("StructureCunge80.Equation WEIR FREE Q=" + v);
@@ -39,7 +39,7 @@ export class StructureCunge80 extends RectangularStructure {
                 }
                 break;
             case StructureFlowRegime.SUBMERGED:
-                if (data.Mode === StructureFlowMode.WEIR) {
+                if (data.ENUM_StructureFlowMode === StructureFlowMode.WEIR) {
                     v = this.prms.Cd.v * this.prms.L.v * Structure.R2G * this.prms.h2.v
                         * Math.sqrt(this.prms.h1.v - this.prms.h2.v);
                     this.debug("StructureCunge80.Equation WEIR SUBMERGED Q=" + v);
diff --git a/src/structure/structure_kivi.ts b/src/structure/structure_kivi.ts
index 082bdf61..797f184f 100644
--- a/src/structure/structure_kivi.ts
+++ b/src/structure/structure_kivi.ts
@@ -45,7 +45,7 @@ export class StructureKivi extends Structure {
 
         let Q = cd * this.prms.L.v * Structure.R2G * Math.pow(this.prms.h1.v, 1.5);
 
-        if (res.extraResults.Regime === StructureFlowRegime.SUBMERGED) {
+        if (res.extraResults.ENUM_StructureFlowRegime === StructureFlowRegime.SUBMERGED) {
             Q = Villemonte(this.prms.h1.v, this.prms.h2.v, 1.5) * Q;
         }
 
diff --git a/src/structure/villemonte.ts b/src/structure/villemonte.ts
index c2fdf090..c78a2829 100644
--- a/src/structure/villemonte.ts
+++ b/src/structure/villemonte.ts
@@ -2,7 +2,7 @@
  *
  * @param h1 hauteur d'eau amont au dessus de la crête du seuil
  * @param h2 hauteur d'eau aval au dessus de la crête du seuil
- * @param n n est l’exposant dans les relations d’écoulement dénoyé :
+ * @param n n est l'exposant dans les relations d'écoulement dénoyé :
  *          déversoir proportionnel : n=1 déversoir rectangulaire : n=1,5
  *          déversoir parabolique : n=2 déversoir triangulaire : n=2,5
  */
-- 
GitLab