From 6f00232d13e26a2aa7acc5615d84bce32c7501e5 Mon Sep 17 00:00:00 2001
From: "francois.grand" <francois.grand@irstea.fr>
Date: Thu, 5 Apr 2018 15:37:20 +0200
Subject: [PATCH] =?UTF-8?q?=20#77=20adaptation=20des=20courbes=20de=20remo?=
 =?UTF-8?q?us=20=C3=A0=20la=20factory=20de=20Nub?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/app/calculators/remous/remous.config.json | 52 +++++++------------
 .../remous-results.component.ts               |  4 +-
 .../definition/concrete/form-courbe-remous.ts |  6 ++-
 .../definition/form-compute-courbe-remous.ts  | 37 ++++---------
 src/app/results/remous-results.ts             | 34 +++++++-----
 5 files changed, 56 insertions(+), 77 deletions(-)

diff --git a/src/app/calculators/remous/remous.config.json b/src/app/calculators/remous/remous.config.json
index 61afbc02d..2110d94c0 100644
--- a/src/app/calculators/remous/remous.config.json
+++ b/src/app/calculators/remous/remous.config.json
@@ -26,7 +26,6 @@
     {
         "id": "fs_section_trapez",
         "type": "fieldset",
-        "nodeType": "SectionTrapeze",
         "option": "fix",
         "dep_exist": [
             {
@@ -38,21 +37,20 @@
             {
                 "type": "input",
                 "id": "LargeurFond",
-                "unit": "m",
-                "value": 2.5
+                "nodeType": "SectionTrapeze",
+                "unit": "m"
             },
             {
                 "type": "input",
                 "id": "Fruit",
-                "unit": "m/m",
-                "value": 0.56
+                "nodeType": "SectionTrapeze",
+                "unit": "m/m"
             }
         ]
     },
     {
         "id": "fs_section_rect",
         "type": "fieldset",
-        "nodeType": "SectionRectangle",
         "option": "fix",
         "dep_exist": [
             {
@@ -64,15 +62,14 @@
             {
                 "type": "input",
                 "id": "LargeurBerge",
-                "unit": "m",
-                "value": 2.5
+                "nodeType": "SectionRectangle",
+                "unit": "m"
             }
         ]
     },
     {
         "id": "fs_section_circ",
         "type": "fieldset",
-        "nodeType": "SectionCercle",
         "option": "fix",
         "dep_exist": [
             {
@@ -84,15 +81,14 @@
             {
                 "type": "input",
                 "id": "D",
-                "unit": "m",
-                "value": 2
+                "nodeType": "SectionCercle",
+                "unit": "m"
             }
         ]
     },
     {
         "id": "fs_section_puiss",
         "type": "fieldset",
-        "nodeType": "SectionPuissance",
         "option": "fix",
         "dep_exist": [
             {
@@ -104,14 +100,14 @@
             {
                 "type": "input",
                 "id": "k",
-                "unit": "",
-                "value": 0.5
+                "nodeType": "SectionPuissance",
+                "unit": ""
             },
             {
                 "type": "input",
                 "id": "LargeurBerge",
-                "unit": "m",
-                "value": 2
+                "nodeType": "SectionPuissance",
+                "unit": "m"
             }
         ]
     },
@@ -123,26 +119,22 @@
             {
                 "type": "input",
                 "id": "Ks",
-                "unit": "m1/3s-1",
-                "value": 40
+                "unit": "m1/3s-1"
             },
             {
                 "type": "input",
                 "id": "Long",
-                "unit": "m",
-                "value": 100
+                "unit": "m"
             },
             {
                 "type": "input",
                 "id": "If",
-                "unit": "m/m",
-                "value": 0.001
+                "unit": "m/m"
             },
             {
                 "type": "input",
                 "id": "YB",
-                "unit": "m",
-                "value": 1
+                "unit": "m"
             }
         ]
     },
@@ -154,20 +146,17 @@
             {
                 "type": "input",
                 "id": "Q",
-                "unit": "m³/s",
-                "value": 2
+                "unit": "m³/s"
             },
             {
                 "type": "input",
                 "id": "Yaval",
-                "unit": "m",
-                "value": 0.4
+                "unit": "m"
             },
             {
                 "type": "input",
                 "id": "Yamont",
-                "unit": "m",
-                "value": 0.15
+                "unit": "m"
             }
         ]
     },
@@ -179,8 +168,7 @@
             {
                 "type": "input",
                 "id": "Dx",
-                "unit": "m",
-                "value": 5
+                "unit": "m"
             },
             {
                 "type": "input",
diff --git a/src/app/components/remous-results/remous-results.component.ts b/src/app/components/remous-results/remous-results.component.ts
index c553ecc73..9b8bccc04 100644
--- a/src/app/components/remous-results/remous-results.component.ts
+++ b/src/app/components/remous-results/remous-results.component.ts
@@ -244,8 +244,8 @@ export class RemousResultsComponent {
         gr1.drawLine(0, 0, 3, "#753F00", this.uitextFond, "#753F00");
 
         // ligne de berge
-        if (this._remousResults.hautBerge != undefined && this._remousResults.hautBerge.ok)
-            gr1.drawLine(this._remousResults.hautBerge.vCalc, this._remousResults.hautBerge.vCalc, 4, "#C58F50", this.uitextBerge);
+        if (this._remousResults.hautBerge)
+            gr1.drawLine(this._remousResults.hautBerge, this._remousResults.hautBerge, 4, "#C58F50", this.uitextBerge);
 
         // hauteur normale
         if (this._remousResults.hautNormale != undefined && this._remousResults.hautNormale.ok)
diff --git a/src/app/formulaire/definition/concrete/form-courbe-remous.ts b/src/app/formulaire/definition/concrete/form-courbe-remous.ts
index 2ee614614..af674161b 100644
--- a/src/app/formulaire/definition/concrete/form-courbe-remous.ts
+++ b/src/app/formulaire/definition/concrete/form-courbe-remous.ts
@@ -1,4 +1,4 @@
-import { CalculatorType } from "jalhyd";
+import { CalculatorType, ComputeNodeType } from "jalhyd";
 
 import { ParamService } from "../../../services/param/param.service";
 import { ApplicationSetupService } from "../../../services/app-setup/app-setup.service";
@@ -23,6 +23,10 @@ export class FormulaireCourbeRemous extends FormulaireDefinition {
     }
 
     protected createNubs() {
+        this._nubs.set(ComputeNodeType.SectionCercle, this.paramService.createNub(this.calculatorType, ComputeNodeType.SectionCercle));
+        this._nubs.set(ComputeNodeType.SectionPuissance, this.paramService.createNub(this.calculatorType, ComputeNodeType.SectionPuissance));
+        this._nubs.set(ComputeNodeType.SectionRectangle, this.paramService.createNub(this.calculatorType, ComputeNodeType.SectionRectangle));
+        this._nubs.set(ComputeNodeType.SectionTrapeze, this.paramService.createNub(this.calculatorType, ComputeNodeType.SectionTrapeze));
     }
 
     protected initParse() {
diff --git a/src/app/formulaire/definition/form-compute-courbe-remous.ts b/src/app/formulaire/definition/form-compute-courbe-remous.ts
index eb0f82842..fcabe29f5 100644
--- a/src/app/formulaire/definition/form-compute-courbe-remous.ts
+++ b/src/app/formulaire/definition/form-compute-courbe-remous.ts
@@ -26,23 +26,14 @@ export class FormComputeCourbeRemous extends FormCompute {
     }
 
     protected compute() {
-        // var np: [ComputeNode, ParamsEquation] = this.getNubAndParameters();
-        // let sect: acSection = np[0] as acSection;
-        // let prmSect: ParamsEquation = np[1];
-
-        const sectNub: SectionParametree = this.getCurrentNub() as SectionParametree;
-        const sect: acSection = sectNub.section;
-
-        let Yamont: number = this._formBase.getParameterValue("Yamont"); // tirant amont
-        let Yaval: number = this._formBase.getParameterValue("Yaval"); // tirant aval
-        let Dx: number = this._formBase.getParameterValue("Dx"); // pas de discrétisation
-        let Long: number = this._formBase.getParameterValue("Long"); // longueur du bief
-        let If: number = this._formBase.getParameterValue("If"); // pente du fond
-        let YB: number = this._formBase.getParameterValue("YB"); // hauteur de berge
+        const cr: CourbeRemous = this.getCurrentNub() as CourbeRemous;
+        const prmCR: CourbeRemousParams = cr.parameters as CourbeRemousParams;
+        const sect: acSection = prmCR.Sn;
+
         let Yn: Result = sect.Calc("Yn"); // hauteur normale
         let Yc: Result = sect.Calc("Yc"); // hauteur critique
 
-        this.remousResults.penteFond = If;
+        this.remousResults.parameters = prmCR;
 
         // méthode de résolution
 
@@ -56,21 +47,18 @@ export class FormComputeCourbeRemous extends FormCompute {
         else if (smeth == "select_resolution_euler")
             methRes = MethodeResolution.EulerExplicite;
         else
-            throw "GenericCalculatorComponent.doComputeRemous() : type de méthode de résolution '" + smeth + "' inconnu";
+            throw "FormComputeCourbeRemous.compute() : type de méthode de résolution '" + smeth + "' inconnu";
 
-        // paramètre supplémentaire à calculer
+        // variable supplémentaire à calculer
 
         const extraSymbol: string = this._formBase.getSelectedValue("select_target");
 
         // calcul
 
-        let prmCR: CourbeRemousParams = new CourbeRemousParams(sect, Yamont, Yaval, Long, Dx, methRes);
-        let cr = new CourbeRemous(prmCR);
-        let res: Result = cr.calculRemous(extraSymbol == "none" ? undefined : extraSymbol);
+        this.remousResults.result = cr.calculRemous(extraSymbol == "none" ? undefined : extraSymbol);
 
-        // affichage du graphe
+        // données du graphe
 
-        this.remousResults.hauteurBerge = new ResultElement(YB);
         this.remousResults.hauteurNormale = Yn.resultElement;
         this.remousResults.hauteurCritique = Yc.resultElement;
         if (extraSymbol != "none") {
@@ -79,12 +67,5 @@ export class FormComputeCourbeRemous extends FormCompute {
         }
         else
             this.remousResults.extraGraph = false;
-
-        // résultats numériques
-
-        this.remousResults.result = res;
-        const xValues = new ParamValues();
-        xValues.setValues(0, Long, Dx);
-        this.remousResults.xValues = xValues;
     }
 }
diff --git a/src/app/results/remous-results.ts b/src/app/results/remous-results.ts
index 1ef254c4c..c450fe10b 100644
--- a/src/app/results/remous-results.ts
+++ b/src/app/results/remous-results.ts
@@ -1,4 +1,4 @@
-import { cLog, Result, ResultElement, ParamValues } from "jalhyd";
+import { cLog, Result, ResultElement, ParamValues, CourbeRemousParams } from "jalhyd";
 
 import { CalculatorResults } from "./calculator-results";
 
@@ -10,7 +10,7 @@ export class RemousResults extends CalculatorResults {
     /**
      * hauteur de berge
      */
-    private _hautBerge: ResultElement;
+    private _hautBerge: number;
 
     /**
      * pente du fond
@@ -75,6 +75,24 @@ export class RemousResults extends CalculatorResults {
         this._extraGraph = false;
     }
 
+    public set parameters(p: CourbeRemousParams) {
+        // pente du fond
+        this._penteFond = p.map.If.v;
+
+        // hauteur de berge
+        this._hautBerge = p.map.YB.v;
+
+        // longueur du bief
+        const Long = p.map.Long.v;
+
+        // pas d'espace
+        const Dx = p.map.Dx.v;
+
+        // série de valeurs de X
+        this._xValues = new ParamValues();
+        this._xValues.setValues(0, Long, Dx);
+    }
+
     public get log() {
         return this._log;
     }
@@ -83,10 +101,6 @@ export class RemousResults extends CalculatorResults {
         return this._xValues;
     }
 
-    public set xValues(p: ParamValues) {
-        this._xValues = p;
-    }
-
     public get result(): Result {
         return this._result;
     }
@@ -122,18 +136,10 @@ export class RemousResults extends CalculatorResults {
         return this._hautBerge;
     }
 
-    public set hauteurBerge(v: ResultElement) {
-        this._hautBerge = v;
-    }
-
     public get penteFond() {
         return this._penteFond;
     }
 
-    public set penteFond(v: number) {
-        this._penteFond = v;
-    }
-
     public get hautNormale() {
         return this._hautNormale;
     }
-- 
GitLab