From d582af448546a3d94aa2e16aa168862a57ae954b Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Tue, 1 Oct 2019 12:23:47 +0200 Subject: [PATCH] CalcSerie: removed useless sDonnee parameter --- spec/value_ref/value_ref.spec.ts | 28 +++++++++++++++++++--------- src/devalaison/grille.ts | 2 +- src/macrorugo/macrorugo_compound.ts | 4 ++-- src/nub.ts | 16 ++++++---------- src/pab/pab.ts | 4 ++-- src/section/section_parametree.ts | 2 +- src/section/section_type.ts | 4 ++-- 7 files changed, 33 insertions(+), 27 deletions(-) diff --git a/spec/value_ref/value_ref.spec.ts b/spec/value_ref/value_ref.spec.ts index ed59b585..8d5a1d0a 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 3845fee5..6e17a53b 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 81902616..1b617c92 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 afaa5e56..706b0924 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 56af3ef9..708bc42d 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 8436ca95..734fdf81 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 b0b0418c..c5752a1f 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; } -- GitLab