form-compute-section-parametree.ts 4.41 KiB
import { SectionParametree, acSection, Result, ParamDomain, ParamDefinition, ParamDomainValue } from "jalhyd";
import { FormCompute } from "./form-compute";
import { NgParameter } from "../ngparam";
import { FormResult } from "./form-result";
import { FormDefSection } from "./form-def-section";
import { FormResultSection } from "./form-result-section";
import { VarResults } from "../../results/var-results";
import { SectionResults } from "../../results/section-results";
import { FormulaireDefinition } from "./form-definition";
import { FormulaireNode } from "../formulaire-node";
export class FormComputeSectionParametree extends FormCompute {
    constructor(formBase: FormulaireDefinition, private _formSection: FormDefSection, formResult: FormResult) {
        super(formBase, formResult);
    private get _formSectionResult(): FormResultSection {
        return this._formResult as FormResultSection;
    private get _varResults(): VarResults {
        return this._formSectionResult.varResults;
    private get _sectionResults(): SectionResults {
        return this._formSectionResult.sectionResults;
    /**
     * calcul de la section paramétrée dans le cas d'un paramètre à varier
     * @param varParam paramètre à varier
    private doComputeSectionVar(varParam: NgParameter) {
        this._formSectionResult.addSectionFixedParameters(false);
        // paramètre à calculer en fonction du paramètre à varier
        const computedParamInfo = this._formSection.getSectionComputedParam();
        const sectNub: SectionParametree = this._formBase.currentNub as SectionParametree;
        const sect: acSection = sectNub.section;
        this._sectionResults.section = sect;
        this._varResults.variatedParameter = varParam;
        const computedParam: NgParameter = this.createParameter(computedParamInfo.symbol, this._formBase);
        this._varResults.calculatedParameter = computedParam;
        this._varResults.result = this.runNubCalc(sectNub, computedParam);
        this._varResults.update(false);
    protected compute() {
        const varParam = this._formSection.getSectionVariatedParameter();
        if (varParam !== undefined) {
            this.doComputeSectionVar(varParam);
            return;
        const sectNub: SectionParametree = this._formBase.currentNub as SectionParametree;
        const sect: acSection = sectNub.section;
        this._sectionResults.section = sect;
        const tmpResult: Result = sectNub.CalcSerie(
            undefined, // valeur initiale, non utilisée dans ce cas
            undefined // variable à calculer, non utilisée
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
); // résultats de section (avec le graphique de section) this._sectionResults.result = tmpResult; // résultats complémentaires des paramètres fixés this._formSectionResult.addSectionFixedParameters(false); this._formSectionResult.fixedResults.result = tmpResult; } /** * * @param calcType crée un NgParameter n'appartenant pas à un ComputeNode * @param symbol symbole du paramètre à créer */ private createParameter(symbol: string, parent: FormulaireNode): NgParameter { let p: NgParameter; const dom = new ParamDomain(ParamDomainValue.POS_NULL); p = new NgParameter(new ParamDefinition(null, symbol, dom), parent); p.confId = symbol; switch (symbol) { case "Hs": case "Hsc": case "B": case "P": case "R": case "Yc": case "Yn": case "Yf": case "Yt": case "Yco": case "J": p.unit = "m"; break; case "S": p.unit = "m2"; break; case "V": p.unit = "m/s"; break; case "I-J": p.unit = "m/m"; break; case "Fr": p.unit = ""; break; case "Imp": p.unit = "N"; break; case "Tau0": p.unit = "Pa"; break; case "Pr": break; default: throw new Error(`ParamService.createParameter() : symbole ${symbol} non pris en charge`); } p.updateLocalisation(this._formBase.specificLocalisation); return p; }
141142
}