From e860b55be1689adfe35f8f78ffed31e7c2ba8761 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 29 Aug 2019 10:51:11 +0200 Subject: [PATCH] MacroRugoCompound: manage varying parameters and iteration selector --- ...rorugo-compound-results-table.component.ts | 59 ++++++++++++------- .../macrorugo-compound-results.component.ts | 1 - .../variable-results-selector.component.ts | 22 ++++--- src/locale/messages.en.json | 3 +- src/locale/messages.fr.json | 1 + 5 files changed, 57 insertions(+), 29 deletions(-) diff --git a/src/app/components/macrorugo-compound-results/macrorugo-compound-results-table.component.ts b/src/app/components/macrorugo-compound-results/macrorugo-compound-results-table.component.ts index 9102984c0..8352c1fa5 100644 --- a/src/app/components/macrorugo-compound-results/macrorugo-compound-results-table.component.ts +++ b/src/app/components/macrorugo-compound-results/macrorugo-compound-results-table.component.ts @@ -58,27 +58,46 @@ export class MacrorugoCompoundResultsTableComponent extends ResultsComponent { // lines 1 - n-1 for (let i = 0; i < pr.childrenResults.length; i++) { - if ( - pr.childrenResults[i].resultElements[vi].vCalc - ) { - const res = pr.childrenResults[i].resultElements[vi].values; - const nub = (pr.childrenResults[i].sourceNub as MacroRugo); - this._dataSet.push([ - i + 1, // n° radier - nub.prms.ZF1.singleValue.toFixed(nDigits), // @TODO what if ZF1 or B varies ? - nub.prms.B.singleValue.toFixed(nDigits), - res.Q.toFixed(nDigits), - res.ZF2.toFixed(nDigits), - res.Vdeb.toFixed(nDigits), - res.Fr.toFixed(nDigits), - res.Vmax.toFixed(nDigits), - res.PV.toFixed(nDigits), - this.intlService.localizeText("INFO_ENUM_MACRORUGOFLOWTYPE_" + res.ENUM_MacroRugoFlowType), - res.Q_GuideTech.toFixed(nDigits), - (res.V_GuideTech !== undefined ? res.V_GuideTech.toFixed(nDigits) : "-"), - res.xCenter.toFixed(nDigits) - ]); + // @TODO protect loop contents with if(vCalc) ? Will hide erroneous apron results.. + const res = pr.childrenResults[i].resultElements[vi].values; + const nub = (pr.childrenResults[i].sourceNub as MacroRugo); + // does ZF1 or B vary ? + let zf1: number; + try { + if (nub.prms.ZF1.hasMultipleValues) { + zf1 = nub.prms.ZF1.getInferredValuesList()[vi]; + } else { + zf1 = nub.prms.ZF1.singleValue; + } + } catch (e) { + // silent fail } + let b: number; + try { + if (nub.prms.B.hasMultipleValues) { + b = nub.prms.B.getInferredValuesList()[vi]; + } else { + b = nub.prms.B.singleValue; + } + } catch (e) { + // silent fail + } + + this._dataSet.push([ + i + 1, // n° radier + (zf1 !== undefined ? zf1.toFixed(nDigits) : "-"), + (b !== undefined ? b.toFixed(nDigits) : "-"), + res.Q.toFixed(nDigits), + res.ZF2.toFixed(nDigits), + res.Vdeb.toFixed(nDigits), + res.Fr.toFixed(nDigits), + res.Vmax.toFixed(nDigits), + res.PV.toFixed(nDigits), + this.intlService.localizeText("INFO_ENUM_MACRORUGOFLOWTYPE_" + res.ENUM_MacroRugoFlowType), + res.Q_GuideTech.toFixed(nDigits), + (res.V_GuideTech !== undefined ? res.V_GuideTech.toFixed(nDigits) : "-"), + res.xCenter.toFixed(nDigits) + ]); } } } diff --git a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts index db564243e..20b521280 100644 --- a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts +++ b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts @@ -252,7 +252,6 @@ export class MacrorugoCompoundResultsComponent implements DoCheck { this.generalLogComponent.log = this.globalLog; } - console.log("update ====>", this._mrcResults); if (this.hasResults) { mrcUpdated = this.mrcResultsTableComponent !== undefined; if (mrcUpdated) { diff --git a/src/app/components/variable-results-selector/variable-results-selector.component.ts b/src/app/components/variable-results-selector/variable-results-selector.component.ts index 901c77ebb..0ac86ebd1 100644 --- a/src/app/components/variable-results-selector/variable-results-selector.component.ts +++ b/src/app/components/variable-results-selector/variable-results-selector.component.ts @@ -79,14 +79,22 @@ export class VariableResultsSelectorComponent { } protected entryLabel(index: number): string { - let i = 0; - return this.varValues.map((vv) => { + const kv = []; + for (let i = 0; i < this.varValues.length; i++) { + const vv = this.varValues[i]; const vp = this._results.variatedParameters[i]; - i++; - let value = "0"; - value = vv[index]; - return `${vp.symbol} = ${value}`; - }).join(", "); + let symbol = vp.symbol; + // is vp a parameter of a child Nub ? + if ( + vp.paramDefinition.parentNub + && vp.paramDefinition.parentNub !== vp.paramDefinition.originNub + ) { + const pos = vp.paramDefinition.parentNub.findPositionInParent() + 1; + symbol = this.intlService.localizeText("INFO_LIB_RADIER_N_COURT") + pos + "_" + symbol; + } + kv.push(`${symbol} = ${vv[index]}`); + } + return kv.join(", "); } public get selectedValue(): number { diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index adcc569ba..5953d1ee7 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -215,9 +215,10 @@ "INFO_LIB_Q": "Discharge", "INFO_LIB_QA": "Attraction flow", "INFO_LIB_R": "Hydraulic radius", - "INFO_LIB_S": "Orifice area", "INFO_LIB_RADIER": "Basin bottom", "INFO_LIB_RADIER_N": "Apron #", + "INFO_LIB_RADIER_N_COURT": "A#", + "INFO_LIB_S": "Orifice area", "INFO_LIB_SELECT_LOIDEBIT": "Stage-discharge law", "INFO_LIB_SELECT_LOIDEBIT1_KIVI": "Kindsvater-Carter and Villemonte", "INFO_LIB_SELECT_LOIDEBIT1": "Stage-discharge law", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index e5c5de4bf..ba9202669 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -216,6 +216,7 @@ "INFO_LIB_R": "Rayon hydraulique", "INFO_LIB_RADIER": "Radier", "INFO_LIB_RADIER_N": "Radier n°", + "INFO_LIB_RADIER_N_COURT": "R", "INFO_LIB_S": "Surface de l'orifice", "INFO_LIB_SELECT_LOIDEBIT": "Loi de débit", "INFO_LIB_SELECT_LOIDEBIT1_KIVI": "Kindsvater-Carter et Villemonte", -- GitLab