Skip to content
Snippets Groups Projects
Commit ccd82ce7 authored by francois.grand's avatar francois.grand
Browse files

#77 sections paramétrées : utilisation de SectionParametree.CalcSerie() (de...

 #77 sections paramétrées : utilisation de SectionParametree.CalcSerie() (de jalhyd) pour le cas "aucun paramètre à varier"
parent 0b1b82d4
No related branches found
No related tags found
1 merge request!15Resolve "faire les modifications nécessaires prendre en compte le ticket cassiopee/jalhyd#46 (Gestion de la session dans la lib)"
......@@ -9,13 +9,10 @@
<!-- tableau de valeurs -->
<div class="row">
<div class="col mx-auto">
<table style="width: 100%">
<tr *ngFor="let r of sectionResults; let i=index" [class]="getResultClass(i)">
<td class="result_label">{{r.label}}</td>
<td horizontal-result-element [result-element]=r.value class="result_value">
</td>
<table style="width: 100%" cellpadding="15">
<tr vertical-result-element [result-element]=resultElement>
</tr>
</table>
</div>
</div>
</div>
\ No newline at end of file
</div>
import { Component, ViewChild, DoCheck } from '@angular/core';
import { acSection, Result } from 'jalhyd';
import { acSection, Result, ResultElement } from 'jalhyd';
import { SectionCanvasComponent } from '../section-canvas/section-canvas.component';
import { SectionResults } from '../../results/section-results';
import { ApplicationSetupService } from '../../services/app-setup/app-setup.service';
import { CalculatorResults } from '../../results/calculator-results';
import { InternationalisationService } from '../../services/internationalisation/internationalisation.service';
@Component({
selector: 'section-results',
......@@ -37,7 +38,12 @@ export class SectionResultsComponent implements DoCheck {
*/
private _results: SectionResults;
constructor(private appSetupService: ApplicationSetupService) { }
/**
* ResultElement mis en forme (symboles des variables traduits)
*/
private _resultElement: ResultElement;
constructor(private appSetupService: ApplicationSetupService, private intlService: InternationalisationService) { }
private static labelColors: { [key: string]: any; } = {
"Hs": { r: 255, g: 0, b: 0 },
......@@ -55,6 +61,8 @@ export class SectionResultsComponent implements DoCheck {
private _sectionCanvas: SectionCanvasComponent;
public set results(rs: CalculatorResults[]) {
this._resultElement = undefined;
this._results = undefined;
if (rs != undefined)
for (const r of rs) {
......@@ -82,18 +90,30 @@ export class SectionResultsComponent implements DoCheck {
this._doUpdate = !this.updateResults();
}
private isSectionLevel(s: string) {
for (const k in SectionResultsComponent.labelColors)
if (k === s)
return true;
return false;
}
private updateResults() {
if (this._results != undefined && this._sectionCanvas != undefined) {
if (this._results && this._sectionCanvas) {
const nDigits = this.appSetupService.displayDigits;
for (let r of this._results.results) {
const v: Result = r["value"];
const l = r["label"];
this._resultElement = new ResultElement();
const drawLabel = r["drawLabel"];
if (drawLabel != undefined && v.vCalc != undefined)
this._sectionCanvas.addLevel(v.vCalc, drawLabel + " = " + v.vCalc.toFixed(nDigits), SectionResultsComponent.labelColors[drawLabel]);
// traduction des symboles des variables calculées
for (const k in this._results.result.extraResults) {
const k2 = "INFO_GRANDEUR_" + k.toUpperCase();
const lbl = this.intlService.localizeText(k2);
const er = this._results.result.getExtraResult(k);
this._resultElement.addExtraResult(lbl, er);
if (this.isSectionLevel(k))
this._sectionCanvas.addLevel(er, k + " = " + er.toFixed(nDigits), SectionResultsComponent.labelColors[k]);
}
this._sectionCanvas.section = this._results.section;
return true;
}
......@@ -104,8 +124,8 @@ export class SectionResultsComponent implements DoCheck {
return this._results != undefined && this._results.hasResults;
}
private get sectionResults() {
return this._results.results;
private get resultElement() {
return this._resultElement;
}
private getResultClass(i: number) {
......
......@@ -96,84 +96,15 @@ export class FormComputeSectionParametree extends FormCompute {
return;
}
var np: [ComputeNode, ParamsEquation] = this.getNubAndParameters();
let sect: acSection = np[0] as acSection;
let prms: ParamsEquation = np[1];
const sectNub: SectionParametree = this.getCurrentNub() as SectionParametree;
const sect: acSection = sectNub.section;
this._sectionResults.section = sect;
let computePrec: number = this._formBase.getParameterValue("Pr"); // précision de calcul
let nDigits = -Math.log10(computePrec);
let Y = prms.map.Y.v; // tirant d'eau original (doit être fourni à acSection.Calc() sous peine d'être modifié par les appels successifs car c'est en même temps un paramètre et une variable temporaire)
// charge spécifique
let Hs = sect.Calc("Hs", Y);
this._formSectionResult.addSectionFixedResult(Hs.resultElement, this.intlService.localizeText("INFO_GRANDEUR_HS"), "Hs");
// charge critique
let Hsc = sect.Calc("Hsc", Y);
this._formSectionResult.addSectionFixedResult(Hsc.resultElement, this.intlService.localizeText("INFO_GRANDEUR_HSC"), "Hsc");
// largeur au miroir
let B = sect.Calc("B", Y);
this._formSectionResult.addSectionFixedResult(B.resultElement, this.intlService.localizeText("INFO_GRANDEUR_B"));
// périmètre hydraulique
let P = sect.Calc("P", Y);
this._formSectionResult.addSectionFixedResult(P.resultElement, this.intlService.localizeText("INFO_GRANDEUR_P"));
// surface hydraulique
let S = sect.Calc("S", Y);
this._formSectionResult.addSectionFixedResult(S.resultElement, this.intlService.localizeText("INFO_GRANDEUR_S"));
// rayon hydraulique
let R = sect.Calc("R", Y);
this._formSectionResult.addSectionFixedResult(R.resultElement, this.intlService.localizeText("INFO_GRANDEUR_R"));
// vitesse moyenne
let V = sect.Calc("V", Y);
this._formSectionResult.addSectionFixedResult(V.resultElement, this.intlService.localizeText("INFO_GRANDEUR_V"));
// nombre de Froude
let Fr = sect.Calc("Fr", Y);
this._formSectionResult.addSectionFixedResult(Fr.resultElement, this.intlService.localizeText("INFO_GRANDEUR_FR"), );
// tirant d'eau critique
let Yc = sect.Calc("Yc", Y);
this._formSectionResult.addSectionFixedResult(Yc.resultElement, this.intlService.localizeText("INFO_GRANDEUR_YC"), "Yc");
// tirant d'eau normal
let Yn = sect.Calc("Yn", Y);
this._formSectionResult.addSectionFixedResult(Yn.resultElement, this.intlService.localizeText("INFO_GRANDEUR_YN"), "Yn");
// tirant d'eau fluvial
let Yf = sect.Calc("Yf", Y);
this._formSectionResult.addSectionFixedResult(Yf.resultElement, this.intlService.localizeText("INFO_GRANDEUR_YF"), "Yf");
// tirant d'eau torrentiel
let Yt = sect.Calc("Yt", Y);
this._formSectionResult.addSectionFixedResult(Yt.resultElement, this.intlService.localizeText("INFO_GRANDEUR_YT"), "Yt");
// tirant d'eau conjugué
let Yco = sect.Calc("Yco", Y);
this._formSectionResult.addSectionFixedResult(Yco.resultElement, this.intlService.localizeText("INFO_GRANDEUR_YCO"), "Yco");
// perte de charge
let J = sect.Calc("J", Y);
this._formSectionResult.addSectionFixedResult(J.resultElement, this.intlService.localizeText("INFO_GRANDEUR_J"));
// Variation linéaire de l'énergie spécifique
let IJ = sect.Calc("I-J", Y);
this._formSectionResult.addSectionFixedResult(IJ.resultElement, this.intlService.localizeText("INFO_GRANDEUR_I-J"));
// impulsion hydraulique
let Imp = sect.Calc("Imp", Y);
this._formSectionResult.addSectionFixedResult(Imp.resultElement, this.intlService.localizeText("INFO_GRANDEUR_IMP"));
// contrainte de cisaillement
let Tau0 = sect.Calc("Tau0", Y);
this._formSectionResult.addSectionFixedResult(Tau0.resultElement, this.intlService.localizeText("INFO_GRANDEUR_TAU0"));
const computePrec: number = this._formBase.getParameterValue("Pr"); // précision de calcul
this._sectionResults.result = sectNub.CalcSerie(computePrec,
undefined, // valeur initiale, non utilisée dans ce cas
undefined // variable à calculer, non utilisée
);
}
}
......@@ -51,10 +51,6 @@ export class FormResultSection extends FormResult {
this._sectionResults.reset();
}
public addSectionFixedResult(val: ResultElement, label: string, drawLabel: string = undefined) {
this._sectionResults.addResult(val, label, drawLabel);
}
public addSectionFixedParameters(displaySymbol: boolean) {
for (let p of this._formBase.getDisplayedParamListFromState(ParamRadioConfig.FIX))
if (p.symbol !== "Pr")
......
......@@ -4,7 +4,7 @@ import { CalculatorResults } from "./calculator-results";
import { NgParameter } from "../formulaire/ngparam";
export class SectionResults extends CalculatorResults {
private _results: Object[];
private _result: Result;
private _section: acSection;
......@@ -15,19 +15,15 @@ export class SectionResults extends CalculatorResults {
public reset() {
this._section = undefined;
this._results = [];
this._result = undefined;
}
public addResult(v: ResultElement, l: string, drawLabel: string) {
this._results.push({
"label": l,
"value": v,
"drawLabel": drawLabel
});
public get result(): Result {
return this._result;
}
public get results() {
return this._results;
public set result(r: Result) {
this._result = r;
}
public get section() {
......@@ -39,6 +35,6 @@ export class SectionResults extends CalculatorResults {
}
public get hasResults(): boolean {
return this._section != undefined && this._results.length > 0;
return this._section != undefined && this._result != undefined;
}
}
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