From 6a73d97064031cebfed3609787213d32815f9d8b Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 21 Aug 2019 10:43:40 +0200 Subject: [PATCH 1/5] Fix #268 - PAB : interpoler en tenant compte de la longueur des bassins --- .../dialog-edit-pab.component.ts | 2 ++ .../pab-table/pab-table.component.ts | 24 +++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/app/components/dialog-edit-pab/dialog-edit-pab.component.ts b/src/app/components/dialog-edit-pab/dialog-edit-pab.component.ts index ba3986a12..be2ee2315 100644 --- a/src/app/components/dialog-edit-pab/dialog-edit-pab.component.ts +++ b/src/app/components/dialog-edit-pab/dialog-edit-pab.component.ts @@ -130,9 +130,11 @@ export class DialogEditPabComponent { } public get interpolationEnabled() { + const varDetails = this.findVariableDetails(this.variable); return ( this.vertical && (this.selectedItemsAbstract.devices + this.selectedItemsAbstract.wallsDevices) > 1 + && (varDetails.occurrences > 1) ); } diff --git a/src/app/components/pab-table/pab-table.component.ts b/src/app/components/pab-table/pab-table.component.ts index a36aee801..b1c5ca849 100644 --- a/src/app/components/pab-table/pab-table.component.ts +++ b/src/app/components/pab-table/pab-table.component.ts @@ -1283,19 +1283,29 @@ export class PabTableComponent implements AfterViewInit, OnInit { case "interpolate": if (result.variableDetails.occurrences > 1) { const nDigits = this.appSetupService.displayDigits; - // build values list const interpolatedValues: number[] = []; - const step = ( - (result.variableDetails.last - result.variableDetails.first) - / (result.variableDetails.occurrences - 1) - ); + const variableRange = result.variableDetails.last - result.variableDetails.first; + let totalBasinsLengths = 0; + for (const w of walls) { + if (w instanceof Cloisons) { + totalBasinsLengths += w.prms.LB.singleValue; + } + } + console.log(`TOTAL BASINS LENGHTS: ${totalBasinsLengths}, VARIABLE RANGE: ${variableRange}`); + // generate interpolated values list interpolatedValues.push(result.variableDetails.first); let currentValue: number = result.variableDetails.first; - for (let i = 0; i < result.variableDetails.occurrences - 2; i++) { + for (let i = 0; i < result.variableDetails.occurrences - 1; i++) { + // compute step as percentage of total length, related to current basin length + const currentBasingLength = (walls[i] as Cloisons).prms.LB.singleValue; + const currentBasinLengthPercentage = currentBasingLength / totalBasinsLengths; + const step = variableRange * currentBasinLengthPercentage; + console.log(`Wall ${i} : length = ${currentBasingLength} / ${totalBasinsLengths}` + + ` (${currentBasinLengthPercentage}), applying step of ${step}`); currentValue += step; interpolatedValues.push(round(currentValue, nDigits)); } - interpolatedValues.push(result.variableDetails.last); + // interpolatedValues.push(result.variableDetails.last); // apply let idx = 0; for (const s of this.selectedItems) { -- GitLab From 5c7c1b1da388de755c9ed4622c42a2e407775e8b Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Tue, 30 Jul 2019 16:42:51 +0200 Subject: [PATCH 2/5] First attempt of modules diagram --- package-lock.json | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index cf83dd4e2..17c36c845 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2599,8 +2599,7 @@ "ansi-colors": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.4.tgz", - "integrity": "sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==", - "dev": true + "integrity": "sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==" }, "ansi-escapes": { "version": "3.2.0", @@ -2612,7 +2611,6 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz", "integrity": "sha1-KWLPVOyXksSFEKPetSRDaGHvclE=", - "dev": true, "requires": { "ansi-wrap": "0.1.0" } @@ -2653,8 +2651,7 @@ "ansi-wrap": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz", - "integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=", - "dev": true + "integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=" }, "anymatch": { "version": "2.0.0", @@ -4617,8 +4614,7 @@ "color-support": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", - "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", - "dev": true + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==" }, "colors": { "version": "1.3.3", @@ -7663,7 +7659,6 @@ "version": "1.3.3", "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.3.tgz", "integrity": "sha512-k9oEhlyc0FrVh25qYuSELjr8oxsCoc4/LEZfg2iJJrfEk/tZL9bCoJE47gqAvI2m/AUjluCS4+3I0eTx8n3AEw==", - "dev": true, "requires": { "ansi-gray": "^0.1.1", "color-support": "^1.1.3", @@ -12600,6 +12595,14 @@ } } }, + "param-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/param-case/-/param-case-2.1.1.tgz", + "integrity": "sha1-35T9jPZTHs915r75oIWPvHK+Ikc=", + "requires": { + "no-case": "^2.2.0" + } + }, "parse-asn1": { "version": "5.1.4", "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.4.tgz", @@ -12658,8 +12661,7 @@ "parse-node-version": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz", - "integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==", - "dev": true + "integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==" }, "parse-path": { "version": "3.0.4", @@ -15862,8 +15864,7 @@ "time-stamp": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", - "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=", - "dev": true + "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=" }, "timed-out": { "version": "4.0.1", -- GitLab From bfe5b5e8a306c7c6c301bce24c76bf1d435b3f37 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 4 Sep 2019 15:53:25 +0200 Subject: [PATCH 3/5] Fix #277: update PAB table display of ZRAM --- .../dialog-edit-pab.component.ts | 1 + .../pab-profile-graph.component.ts | 5 +- .../pab-results-table.component.ts | 4 +- .../pab-table/pab-table.component.ts | 109 +++++++++++++----- 4 files changed, 90 insertions(+), 29 deletions(-) diff --git a/src/app/components/dialog-edit-pab/dialog-edit-pab.component.ts b/src/app/components/dialog-edit-pab/dialog-edit-pab.component.ts index be2ee2315..4065bed84 100644 --- a/src/app/components/dialog-edit-pab/dialog-edit-pab.component.ts +++ b/src/app/components/dialog-edit-pab/dialog-edit-pab.component.ts @@ -135,6 +135,7 @@ export class DialogEditPabComponent { this.vertical && (this.selectedItemsAbstract.devices + this.selectedItemsAbstract.wallsDevices) > 1 && (varDetails.occurrences > 1) + && ([ "ZRAM", "ZRMB", "ZDV" ].includes(this.variable)) ); } diff --git a/src/app/components/pab-profile-graph/pab-profile-graph.component.ts b/src/app/components/pab-profile-graph/pab-profile-graph.component.ts index 016033443..a4fe27e1d 100644 --- a/src/app/components/pab-profile-graph/pab-profile-graph.component.ts +++ b/src/app/components/pab-profile-graph/pab-profile-graph.component.ts @@ -8,6 +8,8 @@ import { ResultsComponent } from "../fixedvar-results/results.component"; import { PabResults } from "../../results/pab-results"; import { IYSeries } from "../../results/y-series"; +import { CloisonAval } from "jalhyd"; + @Component({ selector: "pab-profile-graph", templateUrl: "./pab-profile-graph.component.html", @@ -242,7 +244,8 @@ export class PabProfileGraphComponent extends ResultsComponent { }); } // downwall - const ZRAMdw = this._results.cloisonAvalResults.resultElement.getValue("ZRAM"); + const dw = (this._results.cloisonAvalResults.sourceNub as CloisonAval); + const ZRAMdw = dw.prms.ZRAM.singleValue; dataF.push({ x: xs[ xs.length - 1 ], y: ZRAMdw.toFixed(nDigits) diff --git a/src/app/components/pab-results/pab-results-table.component.ts b/src/app/components/pab-results/pab-results-table.component.ts index aa44671b5..d685f4500 100644 --- a/src/app/components/pab-results/pab-results-table.component.ts +++ b/src/app/components/pab-results/pab-results-table.component.ts @@ -110,19 +110,19 @@ export class PabResultsTableComponent extends ResultsComponent { } // downstream line + const cloisonAval = (pr.cloisonAvalResults.sourceNub as CloisonAval); if (pr.cloisonAvalResults.resultElements[vi].vCalc) { const rln = pr.cloisonAvalResults.resultElements[vi].values; this._dataSet.push([ this.intlService.localizeText("INFO_LIB_AVAL"), (pr.Z2[vi] !== undefined ? pr.Z2[vi].toFixed(nDigits) : ""), - rln.ZRAM.toFixed(nDigits), + cloisonAval.prms.ZRAM.singleValue.toFixed(nDigits), rln.DH.toFixed(nDigits), rln.Q.toFixed(nDigits), "", "", "", "", this.getJetTypes(pr.cloisonAvalResults, vi) ]); // extra lift gate ? - const cloisonAval = (pr.cloisonAvalResults.sourceNub as CloisonAval); if (cloisonAval && cloisonAval.hasVanneLevante()) { const vanneZDV = cloisonAval.result.resultElements[vi].getValue("ZDV"); if (vanneZDV) { diff --git a/src/app/components/pab-table/pab-table.component.ts b/src/app/components/pab-table/pab-table.component.ts index b1c5ca849..0586b8273 100644 --- a/src/app/components/pab-table/pab-table.component.ts +++ b/src/app/components/pab-table/pab-table.component.ts @@ -535,19 +535,30 @@ export class PabTableComponent implements AfterViewInit, OnInit { for (let i = 0; i < maxNbParams; i++) { // build device params row const deviceParamRow = { selectable: cloison, cells: [] }; - // basin number + // basin number and ZRAM if (i === 0) { + // basin number deviceParamRow.cells.push({ value: childIndex + 1, rowspan: maxNbParams + 1, class: "basin_number", selectable: cloison }); + // 4 empty cells + deviceParamRow.cells.push({ + colspan: 4, + rowspan: maxNbParams , + selectable: cloison + }); + // ZRAM + deviceParamRow.cells.push({ + model: cloison.prms.ZRAM, + title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "ZRAM") + }); } - // 5 empty cells - if (i === 0) { + // 1 empty cell + if (i === 1) { deviceParamRow.cells.push({ - colspan: 5, rowspan: maxNbParams, selectable: cloison }); @@ -632,10 +643,6 @@ export class PabTableComponent implements AfterViewInit, OnInit { { model: cloison.prms.ZRMB, title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "ZRMB") - }, - { - model: cloison.prms.ZRAM, - title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "ZRAM") } ] }; @@ -671,12 +678,22 @@ export class PabTableComponent implements AfterViewInit, OnInit { class: "basin_number", selectable: this.model.downWall }); + // 4 empty cells + deviceParamRowDW.cells.push({ + colspan: 4, + rowspan: maxNbParamsDW , + selectable: this.model.downWall + }); + // ZRAM + deviceParamRowDW.cells.push({ + model: this.model.downWall.prms.ZRAM, + title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "ZRAM") + }); } - // 5 empty cells - if (i === 0) { + if (i === 1) { + // 1 empty cell deviceParamRowDW.cells.push({ - colspan: 5, - rowspan: maxNbParamsDW, + rowspan: maxNbParamsDW - 1, selectable: this.model.downWall }); } @@ -1286,9 +1303,24 @@ export class PabTableComponent implements AfterViewInit, OnInit { const interpolatedValues: number[] = []; const variableRange = result.variableDetails.last - result.variableDetails.first; let totalBasinsLengths = 0; - for (const w of walls) { + for (let wi = 0; wi < walls.length; wi++) { + const w = walls[wi]; if (w instanceof Cloisons) { - totalBasinsLengths += w.prms.LB.singleValue; + if (result.variable === "ZRMB") { + // for ZRMB, exclude 1st basin + if (wi > 0) { + // half the previous basin length, half the current basin length + totalBasinsLengths += ( + (walls[wi - 1] as Cloisons).prms.LB.singleValue / 2 + + w.prms.LB.singleValue / 2 + ); + } + } else { + // for other interpolable elevations, exclude last basin + if (wi < walls.length - 1) { + totalBasinsLengths += w.prms.LB.singleValue; + } + } } } console.log(`TOTAL BASINS LENGHTS: ${totalBasinsLengths}, VARIABLE RANGE: ${variableRange}`); @@ -1296,23 +1328,48 @@ export class PabTableComponent implements AfterViewInit, OnInit { interpolatedValues.push(result.variableDetails.first); let currentValue: number = result.variableDetails.first; for (let i = 0; i < result.variableDetails.occurrences - 1; i++) { - // compute step as percentage of total length, related to current basin length - const currentBasingLength = (walls[i] as Cloisons).prms.LB.singleValue; - const currentBasinLengthPercentage = currentBasingLength / totalBasinsLengths; - const step = variableRange * currentBasinLengthPercentage; - console.log(`Wall ${i} : length = ${currentBasingLength} / ${totalBasinsLengths}` - + ` (${currentBasinLengthPercentage}), applying step of ${step}`); - currentValue += step; - interpolatedValues.push(round(currentValue, nDigits)); + if (result.variable === "ZRMB") { + // for ZRMB, exclude 1st basin + if (i > 0) { + // compute step as percentage of total length, related to sum of + // half the previous basin length and half the current basin length + const currentLength = ( + (walls[i - 1] as Cloisons).prms.LB.singleValue / 2 + + (walls[i] as Cloisons).prms.LB.singleValue / 2 + ); + const currentBasinLengthPercentage = currentLength / totalBasinsLengths; + const step = variableRange * currentBasinLengthPercentage; + console.log(`Wall ${i} : length = ${currentLength} / ${totalBasinsLengths}` + + ` (${currentBasinLengthPercentage}), applying step of ${step}`); + currentValue += step; + interpolatedValues.push(round(currentValue, nDigits)); + } + } else { + // for other interpolable elevations, exclude last basin + if (i < result.variableDetails.occurrences - 2) { + // compute step as percentage of total length, related to current basin length + const currentBasinLength = (walls[i] as Cloisons).prms.LB.singleValue; + const currentBasinLengthPercentage = currentBasinLength / totalBasinsLengths; + const step = variableRange * currentBasinLengthPercentage; + console.log(`Wall ${i} : length = ${currentBasinLength} / ${totalBasinsLengths}` + + ` (${currentBasinLengthPercentage}), applying step of ${step}`); + currentValue += step; + interpolatedValues.push(round(currentValue, nDigits)); + } + } } + console.log("INTERPOPOLATED VALUES", interpolatedValues); // interpolatedValues.push(result.variableDetails.last); // apply let idx = 0; for (const s of this.selectedItems) { - for (const p of s.parameterIterator) { // deep - if (p.symbol === result.variable) { - p.singleValue = interpolatedValues[idx]; - idx ++; + // for ZRMB, interpolatedValues length is shorter by 1 element + if (interpolatedValues[idx] !== undefined) { + for (const p of s.parameterIterator) { // deep + if (p.symbol === result.variable) { + p.singleValue = interpolatedValues[idx]; + idx ++; + } } } } -- GitLab From bdb2ea1f4aedc97ea22217d82264fc99bf4cf37f Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 4 Sep 2019 17:47:58 +0200 Subject: [PATCH 4/5] Fix #268 --- .../pab-table/pab-table.component.ts | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/app/components/pab-table/pab-table.component.ts b/src/app/components/pab-table/pab-table.component.ts index 0586b8273..26e13de15 100644 --- a/src/app/components/pab-table/pab-table.component.ts +++ b/src/app/components/pab-table/pab-table.component.ts @@ -1240,6 +1240,7 @@ export class PabTableComponent implements AfterViewInit, OnInit { } } } + const reallySelectedWalls = [...walls]; // array copy // 2nd pass for (const c of this.selectedItems) { if (c instanceof Structure) { @@ -1249,6 +1250,11 @@ export class PabTableComponent implements AfterViewInit, OnInit { } else { vertical = (vertical && (c.findPositionInParent() === firstDevicePosition)); } + // add parent wall for basin-length based interpolation + const parentWall = (c.parent as ParallelStructure); + if (parentWall && ! walls.includes(parentWall)) { + walls.push(parentWall); + } devices.push(c); } } @@ -1261,7 +1267,7 @@ export class PabTableComponent implements AfterViewInit, OnInit { data: { availableVariables: availableVariables, selectedItemsAbstract: { - walls: walls.length, + walls: reallySelectedWalls.length, wallsDevices: wallsDevices.length, devices: devices.length }, @@ -1323,7 +1329,7 @@ export class PabTableComponent implements AfterViewInit, OnInit { } } } - console.log(`TOTAL BASINS LENGHTS: ${totalBasinsLengths}, VARIABLE RANGE: ${variableRange}`); + // console.log(`TOTAL BASINS LENGHTS: ${totalBasinsLengths}, VARIABLE RANGE: ${variableRange}`); // generate interpolated values list interpolatedValues.push(result.variableDetails.first); let currentValue: number = result.variableDetails.first; @@ -1339,8 +1345,8 @@ export class PabTableComponent implements AfterViewInit, OnInit { ); const currentBasinLengthPercentage = currentLength / totalBasinsLengths; const step = variableRange * currentBasinLengthPercentage; - console.log(`Wall ${i} : length = ${currentLength} / ${totalBasinsLengths}` - + ` (${currentBasinLengthPercentage}), applying step of ${step}`); + /* console.log(`Wall ${i} : length = ${currentLength} / ${totalBasinsLengths}` + + ` (${currentBasinLengthPercentage}), applying step of ${step}`); */ currentValue += step; interpolatedValues.push(round(currentValue, nDigits)); } @@ -1351,14 +1357,14 @@ export class PabTableComponent implements AfterViewInit, OnInit { const currentBasinLength = (walls[i] as Cloisons).prms.LB.singleValue; const currentBasinLengthPercentage = currentBasinLength / totalBasinsLengths; const step = variableRange * currentBasinLengthPercentage; - console.log(`Wall ${i} : length = ${currentBasinLength} / ${totalBasinsLengths}` - + ` (${currentBasinLengthPercentage}), applying step of ${step}`); + /* console.log(`Wall ${i} : length = ${currentBasinLength} / ${totalBasinsLengths}` + + ` (${currentBasinLengthPercentage}), applying step of ${step}`); */ currentValue += step; interpolatedValues.push(round(currentValue, nDigits)); } } } - console.log("INTERPOPOLATED VALUES", interpolatedValues); + // console.log("INTERPOPOLATED VALUES", interpolatedValues); // interpolatedValues.push(result.variableDetails.last); // apply let idx = 0; -- GitLab From 04e0fb7b278a74563ff62edff9945506b501c0a3 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 5 Sep 2019 10:18:44 +0200 Subject: [PATCH 5/5] PAB profile: plot ZRMB in apron line, along with ZRAM --- .../pab-profile-graph.component.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/app/components/pab-profile-graph/pab-profile-graph.component.ts b/src/app/components/pab-profile-graph/pab-profile-graph.component.ts index a4fe27e1d..1fcbeb2d5 100644 --- a/src/app/components/pab-profile-graph/pab-profile-graph.component.ts +++ b/src/app/components/pab-profile-graph/pab-profile-graph.component.ts @@ -8,7 +8,7 @@ import { ResultsComponent } from "../fixedvar-results/results.component"; import { PabResults } from "../../results/pab-results"; import { IYSeries } from "../../results/y-series"; -import { CloisonAval } from "jalhyd"; +import { CloisonAval, Cloisons } from "jalhyd"; @Component({ selector: "pab-profile-graph", @@ -226,22 +226,29 @@ export class PabProfileGraphComponent extends ResultsComponent { const pabLength = Number(xs[xs.length - 1]) - Number(xs[0]); const pabLength5Pct = (pabLength * 5) / 100; - // 1. fond du machin + // 1. radier (cotes amont et mi-bassin) const dataF: { x: string, y: string }[] = []; const nDigits = this.appSetupService.displayDigits; - // extend upstrem + // extend upstream dataF.push({ x: (Number(xs[0]) - pabLength5Pct).toFixed(nDigits), y: this._results.cloisonsResults[0].resultElement.getValue("ZRAM").toFixed(nDigits) }); // regular walls for (let i = 0; i < this._results.cloisonsResults.length; i++) { + const c = (this._results.result.sourceNub.getChildren()[i] as Cloisons); const cr = this._results.cloisonsResults[i]; const ZRAM = cr.resultElement.getValue("ZRAM"); // any ResultElement will do + const ZRMB = cr.resultElement.getValue("ZRMB"); // any ResultElement will do + const halfLB = c.prms.LB.singleValue / 2; dataF.push({ x: xs[i], y: ZRAM.toFixed(nDigits) }); + dataF.push({ + x: (Number(xs[i]) + halfLB).toFixed(nDigits), + y: ZRMB.toFixed(nDigits) + }); } // downwall const dw = (this._results.cloisonAvalResults.sourceNub as CloisonAval); -- GitLab