diff --git a/src/pab/pab.ts b/src/pab/pab.ts index 78537edb08f4ba23cdb17917d52c1d26a50250f2..fc509d84c0363bc19f2ae0f48c2597cf34fa0ea5 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 */