Skip to content
Snippets Groups Projects
Commit c3dce056 authored by François Grand's avatar François Grand Committed by AUBRY JEAN-PASCAL
Browse files

refactor: add specific form class for MacroRugoRemous

refs #609
parent 4a17005e
No related branches found
No related tags found
2 merge requests!252release: version 4.18.0,!213Resolve "Ajout du module courbe de remous d'une passe à macro-rugosité"
......@@ -13,7 +13,8 @@
"id": "fs_condlim",
"type": "fieldset",
"fields": [
"Z2"
"Z2",
"Q"
]
},
{
......
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;
}
}
......@@ -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();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment