diff --git a/src/app/calculators/macrorugoremous/config.json b/src/app/calculators/macrorugoremous/config.json index d9d1769085444f6a55e6a8aefed1a54be96b7fe5..5eb0dfb7b58d8703f82bef9017215d496068b2f6 100644 --- a/src/app/calculators/macrorugoremous/config.json +++ b/src/app/calculators/macrorugoremous/config.json @@ -13,7 +13,8 @@ "id": "fs_condlim", "type": "fieldset", "fields": [ - "Z2" + "Z2", + "Q" ] }, { diff --git a/src/app/formulaire/definition/form-macrorugo-remous.ts b/src/app/formulaire/definition/form-macrorugo-remous.ts new file mode 100644 index 0000000000000000000000000000000000000000..fffac2f9a50a30843c8497659a0d569a4d126df0 --- /dev/null +++ b/src/app/formulaire/definition/form-macrorugo-remous.ts @@ -0,0 +1,86 @@ +import { RemousResults } from "app/results/remous-results"; +import { acSection, CourbeRemous, CourbeRemousParams, MacroRugo, MacroRugoRemous, Props, Result, Session } from "jalhyd"; +import { MacroRugoRemousParams } from "jalhyd/build/internal_modules"; +import { FormulaireFixedVar } from "./form-fixedvar"; + +export class FormulaireMacroRugoRemous extends FormulaireFixedVar { + public initNub(props?: Props) { + // scan session, find first PAM + let pam: MacroRugo; + for (const n of Session.getInstance().getAllNubs()) { + if (n instanceof MacroRugo) { + pam = n; + break; + } + } + if (pam !== undefined) { + props.setPropValue(MacroRugoRemous.NubMacroRugoProp, pam.uid); + } + return super.initNub(props); + } + + + /** résultats de courbes de remous */ + private _remousResults: RemousResults; + + private resultYn: Result; + + private resultYc: Result; + + constructor() { + super(); + this._remousResults = new RemousResults(this); + this.updateCalcResults(); + this._props["varCalc"] = ""; // important + } + + protected compute() { + this.reaffectResultComponents(); + } + + protected reaffectResultComponents() { + const mrr = this.currentNub as MacroRugoRemous; + + // variable supplémentaire à calculer + this._remousResults.extraParamSymbol = mrr.getPropValue("varCalc"); + + // calcul + this._remousResults.result = mrr.CalcSerie(); + + const prmMRR = mrr.prms as MacroRugoRemousParams; + this._remousResults.parameters = prmMRR; + + const sect: acSection = mrr.Sn; + this.resultYn = sect.CalcSection("Yn"); // hauteur normale + this.resultYc = sect.CalcSection("Yc"); // hauteur critique + + // données du graphique + this._remousResults.hauteurNormale = this.resultYn.resultElement; + this._remousResults.hauteurCritique = this.resultYc.resultElement; + if (this._remousResults.extraParamSymbol) { + this._remousResults.extraChart = !["Hs", "Hsc", "Ycor", "Ycon"].includes(this._remousResults.extraParamSymbol); + } else { + this._remousResults.extraChart = false; + } + this.updateCalcResults(); + } + + protected updateCalcResults() { + this._calcResults = []; + if (this._remousResults) { + // ensure help links are propagated + this._remousResults.helpLinks = this.helpLinks; + this._calcResults.push(this._remousResults); + } + } + + public resetFormResults() { + this._remousResults.reset(); + this.updateCalcResults(); + } + + public get hasResults(): boolean { + return this._remousResults.hasResults; + } + +} diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts index a32a1aec446448eb849d26fcddc3c5d77b81497f..019244c56de7af8e5543b6f5ebedfb88a744bd47 100644 --- a/src/app/services/formulaire.service.ts +++ b/src/app/services/formulaire.service.ts @@ -59,6 +59,7 @@ import { FormulairePrebarrage } from "../formulaire/definition/form-prebarrage"; import { ServiceFactory } from "./service-factory"; import { FormulairePressureLoss } from "app/formulaire/definition/form-pressureloss"; import { getNubResultUnit } from "jalhyd"; +import { FormulaireMacroRugoRemous } from "app/formulaire/definition/form-macrorugo-remous"; @Injectable() export class FormulaireService extends Observable { @@ -344,6 +345,10 @@ export class FormulaireService extends Observable { f = new FormulairePressureLoss(); break; + case CalculatorType.MacroRugoRemous: + f = new FormulaireMacroRugoRemous(); + break; + default: f = new FormulaireFixedVar(); }