diff --git a/spec/value_ref/value_ref.spec.ts b/spec/value_ref/value_ref.spec.ts index ed59b5856e060731e924c4fcbcf5387737c5a5d4..8d5a1d0af010fc09a90b45c6da70a03b4ff63db0 100644 --- a/spec/value_ref/value_ref.spec.ts +++ b/spec/value_ref/value_ref.spec.ts @@ -119,13 +119,21 @@ describe("référence d'un paramètre à un autre : ", () => { prm2.B.singleValue = 0; // valeur esclave (doit être masquée par la valeur maître) prm2.B.defineReference(nub1, "B"); - expect(nub1.CalcSerie(undefined, "A").vCalc).toBeCloseTo(0, precDigits); - expect(nub1.CalcSerie(undefined, "B").vCalc).toBeCloseTo(2, precDigits); - expect(nub1.CalcSerie(undefined, "C").vCalc).toBeCloseTo(4, precDigits); - - expect(nub2.CalcSerie(undefined, "A").vCalc).toBeCloseTo(0, precDigits); - expect(nub2.CalcSerie(undefined, "B").vCalc).toBeCloseTo(2, precDigits); - expect(nub2.CalcSerie(undefined, "C").vCalc).toBeCloseTo(4, precDigits); + nub1.calculatedParam = nub1.prms.A; + expect(nub1.CalcSerie().vCalc).toBeCloseTo(0, precDigits); + nub1.calculatedParam = nub1.prms.B; + expect(nub1.CalcSerie().vCalc).toBeCloseTo(2, precDigits); + nub1.calculatedParam = nub1.prms.C; + expect(nub1.CalcSerie().vCalc).toBeCloseTo(4, precDigits); + + nub2.calculatedParam = nub2.prms.A; + expect(nub2.CalcSerie().vCalc).toBeCloseTo(0, precDigits); + nub2.calculatedParam = nub2.prms.C; + expect(nub2.CalcSerie().vCalc).toBeCloseTo(4, precDigits); + // définir B en calcul fait sauter le lien, donc on calcule C + // avant, pour ne pas avoir à redéfinir le lien + nub2.calculatedParam = nub2.prms.B; + expect(nub2.CalcSerie().vCalc).toBeCloseTo(2, precDigits); }); @@ -184,7 +192,8 @@ describe("référence d'un paramètre à un autre : ", () => { prm2.A.singleValue = 0; prm2.A.defineReference(nub1, "C"); - expect(nub2.CalcSerie(undefined, "C").vCalc).toBeCloseTo(5, precDigits); + nub2.calculatedParam = nub2.prms.C; + expect(nub2.CalcSerie().vCalc).toBeCloseTo(5, precDigits); }); it("test 3", () => { @@ -229,7 +238,8 @@ describe("référence d'un paramètre à un autre : ", () => { prm2.A.defineReference(nub1, "A"); SessionSettings.precision = 0.001; - const r: Result = nub2.CalcSerie(0.1, "C"); + nub2.calculatedParam = nub2.prms.C; + const r: Result = nub2.CalcSerie(0.1); let n = 0; for (const re of r.resultElements) { diff --git a/src/devalaison/grille.ts b/src/devalaison/grille.ts index 3845fee58daa9143917dc12234315f8124f49d91..6e17a53bdc6edd85bdaab45742bdfedc2c689812 100644 --- a/src/devalaison/grille.ts +++ b/src/devalaison/grille.ts @@ -245,7 +245,7 @@ export class Grille extends Nub { } // no calculated param - protected findCalculatedParameter(sDonnee: any): any { + protected findCalculatedParameter(): any { return undefined; } diff --git a/src/macrorugo/macrorugo_compound.ts b/src/macrorugo/macrorugo_compound.ts index 819026161133a1360af2040d917dea24cfd714bc..1b617c926e0360fa87f70ead5b0b56ed237c06c7 100644 --- a/src/macrorugo/macrorugo_compound.ts +++ b/src/macrorugo/macrorugo_compound.ts @@ -28,12 +28,12 @@ export class MacrorugoCompound extends MacroRugo implements Observer { this._childrenType = "MacroRugo"; } - public CalcSerie(rInit?: number, sDonnee?: any): Result { + public CalcSerie(rInit?: number): Result { if (this.properties.getPropValue("inclinedApron")) { // important to regenerate it here, at every iteration of CalcSerie() this.generateInclinedFishway(); } - return super.CalcSerie(rInit, sDonnee); + return super.CalcSerie(rInit); } /** diff --git a/src/nub.ts b/src/nub.ts index afaa5e56ab016fd168e11c08e79cb833c67bc417..706b0924d698b926f99fd3569aa231bdaef6eb87 100644 --- a/src/nub.ts +++ b/src/nub.ts @@ -377,7 +377,7 @@ export abstract class Nub extends ComputeNode implements IObservable { * @param rInit solution approximative du paramètre * @param sDonnee éventuel symbole / paire symbole-uid du paramètre à calculer */ - public CalcSerie(rInit?: number, sDonnee?: any): Result { + public CalcSerie(rInit?: number): Result { // variated parameters caracteristics const variated: Array<{ param: ParamDefinition, values: ParamValues }> = []; @@ -407,7 +407,7 @@ export abstract class Nub extends ComputeNode implements IObservable { } // find calculated parameter - const computedSymbol = this.findCalculatedParameter(sDonnee); + const computedSymbol = this.findCalculatedParameter(); if (rInit === undefined && this.calculatedParam) { rInit = this.calculatedParam.v; @@ -1295,16 +1295,12 @@ export abstract class Nub extends ComputeNode implements IObservable { return size; } - protected findCalculatedParameter(sDonnee: any): any { + protected findCalculatedParameter(): any { let computedSymbol: any; - if (sDonnee) { - computedSymbol = sDonnee; - } else { - if (this.calculatedParam === undefined) { - throw new Error(`CalcSerie() : aucun paramètre à calculer`); - } - computedSymbol = this.calculatedParamDescriptor; + if (this.calculatedParam === undefined) { + throw new Error(`CalcSerie() : aucun paramètre à calculer`); } + computedSymbol = this.calculatedParamDescriptor; return computedSymbol; } diff --git a/src/pab/pab.ts b/src/pab/pab.ts index 56af3ef99288431be2977691ce22c62baae8c247..708bc42d8362da532d8d1918cd873a4685550387 100644 --- a/src/pab/pab.ts +++ b/src/pab/pab.ts @@ -103,13 +103,13 @@ export class Pab extends Nub { } } - public CalcSerie(rInit?: number, sDonnee?: any): Result { + public CalcSerie(rInit?: number): Result { if (!this.downWall.checkVanneLevante()) { this._result = new Result(undefined, this); this._result.globalLog.insert(new Message(MessageCode.ERROR_CLOISON_AVAL_UN_OUVRAGE_REGULE)); return this._result; } - return super.CalcSerie(rInit, sDonnee); + return super.CalcSerie(rInit); } /** diff --git a/src/section/section_parametree.ts b/src/section/section_parametree.ts index 8436ca9586903710a47a20cb5f919ce7f2818d56..734fdf812830a3741ebb930b42400b42d82ef313 100644 --- a/src/section/section_parametree.ts +++ b/src/section/section_parametree.ts @@ -135,7 +135,7 @@ export class SectionParametree extends SectionNub { } // calculated param is always "Y" - protected findCalculatedParameter(sDonnee: any): any { + protected findCalculatedParameter(): any { return undefined; } diff --git a/src/section/section_type.ts b/src/section/section_type.ts index b0b0418cc3f0f6a206e96d1d25431cb7bc1d1a25..c5752a1f73187c9e9e142e71a9e2615696f077dc 100644 --- a/src/section/section_type.ts +++ b/src/section/section_type.ts @@ -164,8 +164,8 @@ export abstract class acSection extends Nub { * result, to facilitate values reading by targetting modules * (used by triggerChainCalculation) */ - public CalcSerie(rInit?: number, sDonnee?: any): Result { - this.currentResult = this.parent.CalcSerie(rInit, sDonnee); + public CalcSerie(rInit?: number): Result { + this.currentResult = this.parent.CalcSerie(rInit); return this.result; }