From cf59453eadc2caaaebaf1c33cfc03aaa54892944 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Mon, 8 Jul 2019 12:20:57 +0200 Subject: [PATCH] Work on #108 --- src/pab/pab.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/pab/pab.ts b/src/pab/pab.ts index 78537edb..fc509d84 100644 --- a/src/pab/pab.ts +++ b/src/pab/pab.ts @@ -1,4 +1,5 @@ import { CalculatorType } from "../compute-node"; +import { ParamValueMode } from "../index"; import { Nub } from "../nub"; import { ParamCalculability, ParamDefinition } from "../param/param-definition"; import { IParamDefinitionIterator, ParamsEquation, ParamsEquationArrayIterator } from "../param/params-equation"; @@ -253,6 +254,20 @@ export class Pab extends Nub { this.downWall.reinitResult(); } + /** + * Only Q and Z1 are calculable (see #108) + */ + public findFirstCalculableParameter(otherThan?: ParamDefinition) { + for (const p of [ this.prms.Q, this.prms.Z1 ]) { + if (p !== otherThan + && p.valueMode !== ParamValueMode.CALCUL // event LINK might be reset here + ) { + return p; + } + } + throw new Error(`PAB : no calculable parameter found other than ${otherThan ? otherThan.symbol : "undefined"}`); + } + /** * paramétrage de la calculabilité des paramètres */ -- GitLab