diff --git a/spec/pab/cloisons.spec.ts b/spec/pab/cloisons.spec.ts index 94ff1554db9e87c2ff60a068c81b0e79706d45a4..419f40263169f4bba17120d56259d43909514d10 100755 --- a/spec/pab/cloisons.spec.ts +++ b/spec/pab/cloisons.spec.ts @@ -88,7 +88,7 @@ describe("Class Cloisons: ", () => { expect(res.vCalc).toBeCloseTo(0.773, 2); expect(res.extraResults.PV).toBeCloseTo(150.1, 1); expect(res.extraResults.ZRMB).toBeCloseTo(76.54, 2); - expect(res.extraResults["ouvrage[0].ZDV"]).toBeCloseTo(76.67, 2); + expect(modelCloisons.structures[0].result.extraResults.ZDV).toBeCloseTo(76.67, 2); }); }); diff --git a/spec/pab/pab.spec.ts b/spec/pab/pab.spec.ts index 4324aeb26b23ce430f8827147a308ef225fc717e..39428bd50abe0953464239564916f5eba4770740 100644 --- a/spec/pab/pab.spec.ts +++ b/spec/pab/pab.spec.ts @@ -230,7 +230,7 @@ describe("Class Pab: ", () => { pab.CalcSerie(); // for ex. Cloisons n°1 expect(pab.children[0].result.resultElements.length).toBe(3); - expect(Object.keys(pab.children[0].result.resultElements[1].realExtraResults).length).toBe(12); + expect(Object.keys(pab.children[0].result.resultElements[1].realExtraResults).length).toBe(8); }); }); diff --git a/spec/structure/functions.ts b/spec/structure/functions.ts index c6a8d35bc169ec3658e4f1056039af54b3ce2e57..0cbe307fe633c38bff5750e24bc1ff7ade233591 100644 --- a/spec/structure/functions.ts +++ b/spec/structure/functions.ts @@ -139,9 +139,8 @@ export function testParallelStructures(o: { ps: ParallelStructure, ld: number[] }); // Tests sur les résultats complémentaires it(`Calc(Q).extraResults[${i}.Q] should return o.ps.structures[${i}].Calc("Q").vCalc`, () => { - expect( - o.ps.Calc("Q").extraResults[`ouvrage[${i}].Q`] - ).toBe( + o.ps.Calc("Q"); + expect(o.ps.structures[i].result.resultElement.extraResults.Q).toBe( o.ps.structures[i].Calc("Q").vCalc ); }); diff --git a/spec/structure/parallel_structure.spec.ts b/spec/structure/parallel_structure.spec.ts index de4b37fd2ad5cbf640f18623ec3876898cb1a641..6f9bd412aa6e6f801ad59bbcd48a537ae47226fd 100644 --- a/spec/structure/parallel_structure.spec.ts +++ b/spec/structure/parallel_structure.spec.ts @@ -61,23 +61,23 @@ function itParallelStructure(structIndex: number, sVarCalc: string, rVcalc: numb if (Q !== undefined) { const pstructLocal = createEnv(); for (let i = 0; i < pstructLocal.structures.length; i++) { - it(`Calc(${JSON.stringify(sVarCalc)}) ExtraResult[ouvrage[${i}].Q] should be ${Q}`, () => { + it(`Calc(${JSON.stringify(sVarCalc)}) ouvrage[${i}].Q should be ${Q}`, () => { const VC2: any = getVarCalc(pstruct, structIndex, sVarCalc); - expect( - pstruct.Calc(VC2).resultElement.extraResults[`ouvrage[${i}].Q`] - ).toBeCloseTo(Q, Math.max(0, precDigits - 1)); + pstruct.Calc(VC2); + const val = pstruct.structures[i].result.resultElement.extraResults.Q; + expect(val).toBeCloseTo(Q, Math.max(0, precDigits - 1)); }); it(`Calc(${JSON.stringify(sVarCalc)}) ExtraResult[ouvrage[${i}].Q_Mode] should be 0`, () => { const VC3 = getVarCalc(pstruct, structIndex, sVarCalc); - expect( - pstruct.Calc(VC3).resultElement.extraResults[`ouvrage[${i}].Q_ENUM_StructureFlowMode`] - ).toEqual(0); + pstruct.Calc(VC3); + const val = pstruct.structures[i].result.resultElement.extraResults.ENUM_StructureFlowMode; + expect(val).toEqual(0); }); it(`Calc(${JSON.stringify(sVarCalc)}) ExtraResult[ouvrage[${i}].Q_Regime] should be 0`, () => { const VC4 = getVarCalc(pstruct, structIndex, sVarCalc); - expect( - pstruct.Calc(VC4).resultElement.extraResults[`ouvrage[${i}].Q_ENUM_StructureFlowRegime`] - ).toEqual(0); + pstruct.Calc(VC4); + const val = pstruct.structures[i].result.resultElement.extraResults.ENUM_StructureFlowRegime; + expect(val).toEqual(0); }); } } diff --git a/spec/util/result_element.spec.ts b/spec/util/result_element.spec.ts deleted file mode 100644 index e8fd05b3339ca46a8e79d4624c4428a278b26cfc..0000000000000000000000000000000000000000 --- a/spec/util/result_element.spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * IMPORTANT ! - * Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine") - * Pour exécuter ce code dans le débugger. - * Faire de même avec le fichier test_func.ts - */ -// import { describe, expect, it, xdescribe, xit } from "../mock_jasmine"; - -/* import { ResultElement } from "../../src/util/resultelement"; - -describe("Class Result: ", () => { - describe("Method AddResulToExtra", () => { - const resEle: ResultElement = new ResultElement(1); - const resEleToAdd: ResultElement = new ResultElement(2); - - const resEleRef: ResultElement = new ResultElement(1); - resEleRef.extraResults = { R: 2 }; - - it("Result should be integrated in extraResult", () => { - resEle.AddResultElementToExtra(resEleToAdd, "R"); - expect(resEle).toEqual(resEleRef); - }); - }); -}); */ diff --git a/src/pab/cloisons.ts b/src/pab/cloisons.ts index 3149b1bda4ad34f22d220baf5fd0f1984c0b4155..b46d0473f51506983c4d423701915593cbebda8c 100644 --- a/src/pab/cloisons.ts +++ b/src/pab/cloisons.ts @@ -73,9 +73,9 @@ export class Cloisons extends ParallelStructure { r.extraResults.ZRAM = this.prms.ZRAM.v; // Ajout de ZDV pour les seuils - for (let i = 0; i < this.structures.length; i++) { - if (this.structures[i].prms.h1.visible) { - r.resultElement.addExtraResult(`ouvrage[${i}].ZDV`, this.prms.Z1.v - this.structures[i].prms.h1.v); + for (const s of this.structures) { + if (s.prms.h1.visible) { + s.result.resultElement.addExtraResult("ZDV", this.prms.Z1.v - s.prms.h1.v); } } diff --git a/src/session.ts b/src/session.ts index f1a2070a5bfd75144c698b47dbc1d6eabd17a551..745bc6c54e7e9a1808d361baa1df2c1be5eb1570 100644 --- a/src/session.ts +++ b/src/session.ts @@ -207,7 +207,7 @@ export class Session { } /** - * Creates a Nub from a JSON representation and adds it tot he current session; returns + * Creates a Nub from a JSON representation and adds it to the current session; returns * a pointer to the Nub and its JSON metadata * @param serialised JSON representation of a single Nub * @param register if false, new Nub will just be returned and won't be registered into the session diff --git a/src/structure/parallel_structure.ts b/src/structure/parallel_structure.ts index 5159c8ff57fcea2ad1271bf36b8014abbf340f49..84c4d41b17c113fd2dfccd6f4718620eea107bd7 100644 --- a/src/structure/parallel_structure.ts +++ b/src/structure/parallel_structure.ts @@ -92,7 +92,7 @@ export class ParallelStructure extends Nub { if (i !== iExcept) { const res: Result = this._children[i].Calc("Q"); // @TODO vérifier que ça marche sans la ligne ci-dessous - calcRes.resultElement.AddResultElementToExtra(res.resultElement, `ouvrage[${i}].Q`); + // calcRes.resultElement.AddResultElementToExtra(res.resultElement, `ouvrage[${i}].Q`); qTot += res.vCalc; } } diff --git a/src/util/resultelement.ts b/src/util/resultelement.ts index 58a1a647529a121548542d52a4cda23a3e29750f..3a515e6fffa15480812a2d88bfd38438883db11b 100644 --- a/src/util/resultelement.ts +++ b/src/util/resultelement.ts @@ -154,27 +154,6 @@ export class ResultElement { public getExtraResult(name: string): any { return this.getValue(name); } - /** - * Add a ResultElement object into extraResult. - * The added ResultElement contains the Value of the ResultElement and the extraResults - * which are added using varCalc as prefix (i.e. [varCalc]_[key]) - * Log messages are also copied to ResultElement - * @param resultElementToAdd Result object to add - * @param varCalc Name of the variable calculated used as key in extraResult - */ - public AddResultElementToExtra(resultElementToAdd: ResultElement, varCalc: string) { - // Add ResultElement into extraResult - this.extraResults[varCalc] = resultElementToAdd.vCalc; - // Add extraResults - for (const extraResKey in resultElementToAdd.realExtraResults) { - if (resultElementToAdd.extraResults.hasOwnProperty(extraResKey)) { - const newExtraKey: string = varCalc + "_" + extraResKey; - this.extraResults[newExtraKey] = resultElementToAdd.extraResults[extraResKey]; - } - } - // Add Logs - this.log.addLog(resultElementToAdd.log); - } // ------------ retrocompat @TODO remove ------------------------ public toString(): string {