From 4b9ccea31b85eace1350af9df1c15ef32ace825b Mon Sep 17 00:00:00 2001
From: "francois.grand" <francois.grand@irstea.fr>
Date: Thu, 12 Apr 2018 17:01:24 +0200
Subject: [PATCH] =?UTF-8?q?=20#77=20suite=20=C3=A0=20la=20cr=C3=A9ation=20?=
 =?UTF-8?q?de=20la=20classe=20SessionNub=20dans=20la=20lib,=20FormCompute.?=
 =?UTF-8?q?getCurrentNub()=20transform=C3=A9e=20en=20getCurrentSessionNub(?=
 =?UTF-8?q?)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../definition/form-compute-cond-distri.ts    |  9 ++--
 .../definition/form-compute-courbe-remous.ts  | 15 +++---
 .../definition/form-compute-fixedvar.ts       |  2 +-
 .../definition/form-compute-lechapt-calmon.ts |  9 ++--
 .../definition/form-compute-pab-bassin-dim.ts |  9 ++--
 .../form-compute-pab-bassin-puissance.ts      |  9 ++--
 .../form-compute-parallel-structures.ts       | 52 ++-----------------
 .../form-compute-regime-uniforme.ts           | 16 +++---
 .../form-compute-section-parametree.ts        | 13 +++--
 src/app/formulaire/definition/form-compute.ts |  4 +-
 10 files changed, 54 insertions(+), 84 deletions(-)

diff --git a/src/app/formulaire/definition/form-compute-cond-distri.ts b/src/app/formulaire/definition/form-compute-cond-distri.ts
index 44481cab8..26ca00a13 100644
--- a/src/app/formulaire/definition/form-compute-cond-distri.ts
+++ b/src/app/formulaire/definition/form-compute-cond-distri.ts
@@ -1,4 +1,4 @@
-import { ComputeNode, ParamsEquation, ConduiteDistribParams, ConduiteDistrib, ComputeNodeType } from "jalhyd";
+import { ComputeNode, ParamsEquation, ConduiteDistribParams, ConduiteDistrib, ComputeNodeType, CalculatorType } from "jalhyd";
 
 import { FormComputeFixedVar } from "./form-compute-fixedvar";
 import { FormulaireDefinition } from "./form-definition";
@@ -9,7 +9,10 @@ export class FormComputeConduiteDistributrice extends FormComputeFixedVar {
         super(formBase, formResult);
     }
 
-    protected getCurrentNub() {
-        return this._formBase.getNub(ComputeNodeType.None);
+    protected getCurrentSessionNub() {
+        return this._formBase.getSessionNub({
+            "calcType": CalculatorType.ConduiteDistributrice,
+            "nodeType": ComputeNodeType.None
+        });
     }
 }
diff --git a/src/app/formulaire/definition/form-compute-courbe-remous.ts b/src/app/formulaire/definition/form-compute-courbe-remous.ts
index fcabe29f5..929cd0446 100644
--- a/src/app/formulaire/definition/form-compute-courbe-remous.ts
+++ b/src/app/formulaire/definition/form-compute-courbe-remous.ts
@@ -1,4 +1,4 @@
-import { SectionParametree, acSection, ParamsEquation, ComputeNode, Result, MethodeResolution, CourbeRemousParams, CourbeRemous, ResultElement, ParamValues } from "jalhyd";
+import { SectionParametree, acSection, ParamsEquation, ComputeNode, Result, MethodeResolution, CourbeRemousParams, CourbeRemous, ResultElement, ParamValues, CalculatorType } from "jalhyd";
 
 import { SelectField } from "../select-field";
 import { RemousResults } from "../../results/remous-results";
@@ -12,12 +12,11 @@ export class FormComputeCourbeRemous extends FormCompute {
         super(formBase, formResult);
     }
 
-    // protected getNubAndParameters(): [ComputeNode, ParamsEquation] {
-    //     return this._formSection.getSectionNubAndParameters(false);
-    // }
-
-    protected getCurrentNub() {
-        return this._formBase.getNub(this._formSection.sectionNodeType);
+    protected getCurrentSessionNub() {
+        return this._formBase.getSessionNub({
+            "calcType": CalculatorType.SectionParametree,
+            "nodeType": this._formSection.sectionNodeType
+        });
     }
 
     private get remousResults(): RemousResults {
@@ -26,7 +25,7 @@ export class FormComputeCourbeRemous extends FormCompute {
     }
 
     protected compute() {
-        const cr: CourbeRemous = this.getCurrentNub() as CourbeRemous;
+        const cr: CourbeRemous = this.getCurrentSessionNub().nub as CourbeRemous;
         const prmCR: CourbeRemousParams = cr.parameters as CourbeRemousParams;
         const sect: acSection = prmCR.Sn;
 
diff --git a/src/app/formulaire/definition/form-compute-fixedvar.ts b/src/app/formulaire/definition/form-compute-fixedvar.ts
index d5ae4c50b..14506bd85 100644
--- a/src/app/formulaire/definition/form-compute-fixedvar.ts
+++ b/src/app/formulaire/definition/form-compute-fixedvar.ts
@@ -41,7 +41,7 @@ export abstract class FormComputeFixedVar extends FormCompute {
     }
 
     protected compute() {
-        const nub: Nub = this.getCurrentNub();
+        const nub: Nub = this.getCurrentSessionNub().nub;
 
         if (this._formBase.hasParameter("Pr"))
             var computePrec: number = this._formBase.getParameterValue("Pr"); // précision de calcul
diff --git a/src/app/formulaire/definition/form-compute-lechapt-calmon.ts b/src/app/formulaire/definition/form-compute-lechapt-calmon.ts
index 7af295988..766c4f593 100644
--- a/src/app/formulaire/definition/form-compute-lechapt-calmon.ts
+++ b/src/app/formulaire/definition/form-compute-lechapt-calmon.ts
@@ -1,4 +1,4 @@
-import { ComputeNode, ComputeNodeType, ParamsEquation, LechaptCalmonParams, LechaptCalmon } from "jalhyd";
+import { ComputeNode, ComputeNodeType, ParamsEquation, LechaptCalmonParams, LechaptCalmon, CalculatorType } from "jalhyd";
 
 import { FormComputeFixedVar } from "./form-compute-fixedvar";
 import { FormulaireDefinition } from "./form-definition";
@@ -9,7 +9,10 @@ export class FormComputeLechaptCalmon extends FormComputeFixedVar {
         super(formBase, formResult);
     }
 
-    protected getCurrentNub() {
-        return this._formBase.getNub(ComputeNodeType.None);
+    protected getCurrentSessionNub() {
+        return this._formBase.getSessionNub({
+            "calcType": CalculatorType.LechaptCalmon,
+            "nodeType": ComputeNodeType.None
+        });
     }
 }
diff --git a/src/app/formulaire/definition/form-compute-pab-bassin-dim.ts b/src/app/formulaire/definition/form-compute-pab-bassin-dim.ts
index 312748d43..cd984bfad 100644
--- a/src/app/formulaire/definition/form-compute-pab-bassin-dim.ts
+++ b/src/app/formulaire/definition/form-compute-pab-bassin-dim.ts
@@ -1,4 +1,4 @@
-import { ComputeNode, ParamsEquation, PabDimensionParams, PabDimension, ComputeNodeType } from "jalhyd";
+import { ComputeNode, ParamsEquation, PabDimensionParams, PabDimension, ComputeNodeType, CalculatorType } from "jalhyd";
 
 import { FormComputeFixedVar } from "./form-compute-fixedvar";
 import { FormulaireDefinition } from "./form-definition";
@@ -9,7 +9,10 @@ export class FormComputePasseBassinDimensions extends FormComputeFixedVar {
         super(formBase, formResult);
     }
 
-    protected getCurrentNub() {
-        return this._formBase.getNub(ComputeNodeType.None);
+    protected getCurrentSessionNub() {
+        return this._formBase.getSessionNub({
+            "calcType": CalculatorType.PabDimensions,
+            "nodeType": ComputeNodeType.None
+        });
     }
 }
\ No newline at end of file
diff --git a/src/app/formulaire/definition/form-compute-pab-bassin-puissance.ts b/src/app/formulaire/definition/form-compute-pab-bassin-puissance.ts
index e7d689de3..b5b961618 100644
--- a/src/app/formulaire/definition/form-compute-pab-bassin-puissance.ts
+++ b/src/app/formulaire/definition/form-compute-pab-bassin-puissance.ts
@@ -1,4 +1,4 @@
-import { ComputeNode, ParamsEquation, PabPuissanceParams, PabPuissance, ComputeNodeType } from "jalhyd";
+import { ComputeNode, ParamsEquation, PabPuissanceParams, PabPuissance, ComputeNodeType, CalculatorType } from "jalhyd";
 
 import { FormComputeFixedVar } from "./form-compute-fixedvar";
 import { FormulaireDefinition } from "./form-definition";
@@ -9,7 +9,10 @@ export class FormComputePasseBassinPuissance extends FormComputeFixedVar {
         super(formBase, formResult);
     }
 
-    protected getCurrentNub() {
-        return this._formBase.getNub(ComputeNodeType.None);
+    protected getCurrentSessionNub() {
+        return this._formBase.getSessionNub({
+            "calcType": CalculatorType.PabPuissance,
+            "nodeType": ComputeNodeType.None
+        });
     }
 }
\ No newline at end of file
diff --git a/src/app/formulaire/definition/form-compute-parallel-structures.ts b/src/app/formulaire/definition/form-compute-parallel-structures.ts
index 3509249bd..ce8ff3a10 100644
--- a/src/app/formulaire/definition/form-compute-parallel-structures.ts
+++ b/src/app/formulaire/definition/form-compute-parallel-structures.ts
@@ -63,52 +63,10 @@ export class FormComputeParallelStructures extends FormComputeFixedVar {
         }
     }
 
-    public getNubAndParameters(): [ComputeNode, ParamsEquation] {
-        // paramètres communs
-
-        const Q: number = this._formBase.getParameterValue("Q"); // Débit 
-        const Z1: number = this._formBase.getParameterValue("Z1"); // Cote de l'eau amont (m)
-        const Z2: number = this._formBase.getParameterValue("Z2"); // Cote de l'eau aval (m)
-        const prms = new ParallelStructureParams(Q, Z1, Z2);
-
-        const nub: ParallelStructure = new ParallelStructure(prms);
-
-        // ouvrages
-
-        for (const fs of this._formBase.allFieldsets)
-            if (fs.calculatorType == CalculatorType.Structure) {
-                const ts: StructureType = this._formParallelStruct.getStructureType(fs);
-                const ld: LoiDebit = this._formParallelStruct.getLoiDebit(fs);
-
-                // cote de radier
-                const ZDV = fs.getNodeParameterValue("ZDV");
-
-                // ouverture de vanne
-                try {
-                    var W = fs.getNodeParameterValue("W");
-                } catch (e) {
-                }
-
-                // création de l'ouvrage
-                const ouvr = CreateStructure(ts, ld);
-
-                // affectation des valeurs (en prenant garde de ne pas écraser les valeurs par défaut dans le cas d'un paramètre à calculer)
-                if (Z1 != undefined)
-                    ouvr.prms.Z1.v = Z1;
-                if (Z2 != undefined)
-                    ouvr.prms.Z2.v = Z2;
-                if (ZDV != undefined)
-                    ouvr.prms.ZDV.v = ZDV;
-                if (W != undefined)
-                    ouvr.prms.W.v = W;
-
-                nub.addStructure(ouvr);
-            }
-
-        return [nub, prms];
-    }
-
-    protected getCurrentNub() {
-        return undefined;
+    protected getCurrentSessionNub() {
+        return this._formBase.getSessionNub({
+            "calcType": CalculatorType.ParallelStructure,
+            "nodeType": ComputeNodeType.None
+        });
     }
 }
diff --git a/src/app/formulaire/definition/form-compute-regime-uniforme.ts b/src/app/formulaire/definition/form-compute-regime-uniforme.ts
index b01615cdf..cf2bdcf1b 100644
--- a/src/app/formulaire/definition/form-compute-regime-uniforme.ts
+++ b/src/app/formulaire/definition/form-compute-regime-uniforme.ts
@@ -1,4 +1,4 @@
-import { ComputeNode, ParamsEquation, RegimeUniforme, acSection } from "jalhyd";
+import { ComputeNode, ParamsEquation, RegimeUniforme, acSection, CalculatorType } from "jalhyd";
 
 import { FormComputeFixedVar } from "./form-compute-fixedvar";
 import { FormulaireDefinition } from "./form-definition";
@@ -10,12 +10,10 @@ export class FormComputeRegimeUniforme extends FormComputeFixedVar {
         super(formBase, formResult);
     }
 
-    // protected getNubAndParameters(): [ComputeNode, ParamsEquation] {
-    //     const snp: [acSection, ParamsEquation] = this._formSection.getSectionNubAndParameters();
-    //     return [new RegimeUniforme(snp[0]), snp[1]];
-    // }
-
-    protected getCurrentNub() {
-        return this._formBase.getNub(this._formSection.sectionNodeType);
+    protected getCurrentSessionNub() {
+        return this._formBase.getSessionNub({
+            "calcType": CalculatorType.RegimeUniforme,
+            "nodeType": this._formSection.sectionNodeType
+        });
     }
-}
\ No newline at end of file
+}
diff --git a/src/app/formulaire/definition/form-compute-section-parametree.ts b/src/app/formulaire/definition/form-compute-section-parametree.ts
index 3b695217c..c4fe1f453 100644
--- a/src/app/formulaire/definition/form-compute-section-parametree.ts
+++ b/src/app/formulaire/definition/form-compute-section-parametree.ts
@@ -1,4 +1,4 @@
-import { SectionParametree, acSection, ParamsEquation, ComputeNode, Result, ParamValueMode, Nub, ParamsSection } from "jalhyd";
+import { SectionParametree, acSection, ParamsEquation, ComputeNode, Result, ParamValueMode, Nub, ParamsSection, CalculatorType, SessionNub } from "jalhyd";
 
 import { FormCompute } from "./form-compute";
 import { NgParameter } from "../ngparam";
@@ -38,8 +38,11 @@ export class FormComputeSectionParametree extends FormCompute {
         return this._formSectionResult.sectionResults;
     }
 
-    protected getCurrentNub(): Nub {
-        return this._formBase.getNub(this._formSection.sectionNodeType);
+    protected getCurrentSessionNub(): SessionNub {
+        return this._formBase.getSessionNub({
+            "calcType": CalculatorType.SectionParametree,
+            "nodeType": this._formSection.sectionNodeType
+        });
     }
 
     /**
@@ -55,7 +58,7 @@ export class FormComputeSectionParametree extends FormCompute {
         // paramètre à calculer en fonction du paramètre à varier
         let computedParamInfo = this._formSection.getSectionComputedParam();
 
-        const sectNub: SectionParametree = this.getCurrentNub() as SectionParametree;
+        const sectNub: SectionParametree = this.getCurrentSessionNub().nub as SectionParametree;
         const sect: acSection = sectNub.section;
         const prms = sectNub.parameters;
 
@@ -96,7 +99,7 @@ export class FormComputeSectionParametree extends FormCompute {
             return;
         }
 
-        const sectNub: SectionParametree = this.getCurrentNub() as SectionParametree;
+        const sectNub: SectionParametree = this.getCurrentSessionNub().nub as SectionParametree;
 
         const sect: acSection = sectNub.section;
         this._sectionResults.section = sect;
diff --git a/src/app/formulaire/definition/form-compute.ts b/src/app/formulaire/definition/form-compute.ts
index f364ee0b1..1fff53c84 100644
--- a/src/app/formulaire/definition/form-compute.ts
+++ b/src/app/formulaire/definition/form-compute.ts
@@ -1,4 +1,4 @@
-import { ParamValueMode, Nub, Result, ParamDomainValue, ParamDomain } from "jalhyd";
+import { ParamValueMode, Nub, Result, ParamDomainValue, ParamDomain, SessionNub } from "jalhyd";
 
 import { FormResult } from "./form-result";
 import { FormulaireDefinition } from "./form-definition";
@@ -8,7 +8,7 @@ export abstract class FormCompute {
     constructor(protected _formBase: FormulaireDefinition, protected _formResult: FormResult) {
     }
 
-    protected abstract getCurrentNub(): Nub;
+    protected abstract getCurrentSessionNub(): SessionNub;
 
     protected abstract compute();
 
-- 
GitLab