Newer
Older
import { cLog, CourbeRemousParams, Result, ResultElement, ParamDefinition, ParamDomainValue, Nub } from "jalhyd";
import { CalculatorResults } from "./calculator-results";
import { VarResults } from "./var-results";
import { ServiceFactory } from "../services/service-factory";
import { FormulaireDefinition } from "../formulaire/definition/form-definition";
export class RemousResults extends CalculatorResults {
francois.grand
committed
private _result: Result;
/** pseudo-paramètre varié contenant la liste des abscisses pour lesquelles on a des résultats */
private _xValues: ParamDefinition;
francois.grand
committed
/** pas de discrétisation */
private _Dx: number;
François Grand
committed
/** cote de fond amont */
private _ZF1: number;
/** cote de fond aval */
private _ZF2: number;
/** longueur du bief */
private _Long: number;
/** hauteur de berge */
private _hautBerge: number;
/** pente du fond */
private _penteFond: number;
/** hauteur normale */
private _hautNormale: ResultElement;
/** hauteur critique */
private _hautCritique: ResultElement;
/** présence de données pour la courbe fluviale */
private _hasFlu: boolean;
/** présence de données pour la courbe torrentielle */
private _hasTor: boolean;
/** présence de données pour le paramètre supplémentaire */
private _hasExtra: boolean;
/** résultats variables pour l'affichage d'une table de résultats numériques */
private _varResults: VarResults;
/** le paramètre supplémentaire est affiché dans un graphique séparé */
/** titre de la colonne du paramètre supplémentaire */
private _extraParamSymbol: string;
/** journal de calcul */
private _log: cLog;
/** pointer to form that instantiated this object */
protected _form: FormulaireDefinition;
François Grand
committed
/**
* liste des X,Y (fluvial ou torrentiel)
*/
private _points: any[];
constructor(form?: FormulaireDefinition) {
super();
this.reset();
}
public reset() {
francois.grand
committed
this._result = undefined;
this._log = new cLog();
this._hautBerge = undefined;
this._penteFond = undefined;
this._hautNormale = undefined;
this._hautCritique = undefined;
this._extraParamSymbol = undefined;
this._hasFlu = false;
this._hasTor = false;
this._hasExtra = false;
// série de valeurs de X
this._xValues = new ParamDefinition(
undefined,
"ABSCISSE",
ParamDomainValue.POS_NULL
);
}
public set parameters(p: CourbeRemousParams) {
François Grand
committed
const nub = p.parent as Nub;
// pente du fond
François Grand
committed
this._penteFond = nub.getParameter("If").singleValue;
// hauteur de berge
François Grand
committed
this._hautBerge = nub.getParameter("YB").singleValue;
// longueur du bief
François Grand
committed
this._Long = nub.getParameter("Long").singleValue;
// pas d'espace
François Grand
committed
this._Dx = nub.getParameter("Dx").singleValue;
François Grand
committed
// cote de fond amont
this._ZF1 = nub.getParameter("ZF1").singleValue;
// cote de fond aval
this._ZF2 = nub.getParameter("ZF2").singleValue;
return this._log;
}
public get varResults(): VarResults {
return this._varResults;
francois.grand
committed
}
public get xValues(): ParamDefinition {
return this._xValues;
}
francois.grand
committed
public get result(): Result {
return this._result;
}
public set result(r: Result) {
this._result = r;
// abscisses pour lesquelles on a des résultats
const abscissae = r.resultElements.map((re) => {
return re.getValue("X");
});
this._xValues.setValues(abscissae);
François Grand
committed
this.updatePoints();
}
private updatePoints() {
this._points = this._result.resultElements.map((re) => {
François Grand
committed
const X = re.getValue("X");
// cote de fond
const k = X / this._Long;
const Zf = (this._ZF2 - this._ZF1) * k + this._ZF1;
// cote de l'eau
let Z = re.getValue("flu");
if (Z === undefined)
Z = re.getValue("tor");
// tirant d'eau
const Y = Z - Zf;
return { x: X, y: Y, z: Z };
François Grand
committed
});
francois.grand
committed
François Grand
committed
/*
François Grand
committed
* points pour lesquels on a des résultats
François Grand
committed
*/
François Grand
committed
public get points(): any[] {
return this._points;
François Grand
committed
}
public update() {
francois.grand
committed
this._hasFlu = false;
this._hasTor = false;
this._hasExtra = false;
for (const re of this._result.resultElements) {
if (!this._hasFlu && re.getValue("flu")) {
francois.grand
committed
this._hasFlu = true;
if (!this._hasTor && re.getValue("tor")) {
francois.grand
committed
this._hasTor = true;
if (!this._hasExtra && re.getValue(this.extraParamSymbol)) {
francois.grand
committed
this._hasExtra = true;
if (this._hasFlu && this._hasTor && this._hasExtra )
break; // micro optimisation : pas la peine de continuer à chercher
this._log.addLog(this._result.globalLog);
this._varResults = new VarResults(this._form);
this._varResults.variatedParameters = [ { param: this._xValues, values: this._xValues.paramValues } ];
this._varResults.result = this._result;
keys.push("ZW"); // ligne d'eau
keys.push("Y"); // tirant d'eau
keys.push("flu");
keys.push("tor");
keys.push(this.extraParamSymbol);
mathias.chouet
committed
this._varResults.resultKeys = keys;
this._varResults.helpLinks = this.helpLinks;
}
public get extraParamSymbol(): string {
return this._extraParamSymbol;
}
public set extraParamSymbol(l: string) {
}
public get Dx(): number {
return this._Dx;
}
public get Long(): number {
return this._Long;
}
public get hautBerge() {
return this._hautBerge;
}
public get penteFond() {
return this._penteFond;
}
public get hautNormale() {
return this._hautNormale;
}
public set hauteurNormale(v: ResultElement) {
this._hautNormale = v;
}
public get hautCritique() {
return this._hautCritique;
}
public set hauteurCritique(v: ResultElement) {
this._hautCritique = v;
}
public get hasExtra() {
return this._hasExtra;
}
public get extraChart() {
return this._extraChart;
}
public set extraChart(b: boolean) {
this._extraChart = b;
}
public get hasResults(): boolean {
return this._hautBerge !== undefined ||
this._penteFond !== undefined ||
this._hautNormale !== undefined ||
this._hautCritique !== undefined ||
francois.grand
committed
(this._result && this._result.ok);
/**
* @return true si il existe au moins une données dans la série fluviale
*/
public get hasFluData(): boolean {
return this._hasFlu;
}
/**
* @return true si il existe au moins une données dans la série torrentielle
*/
public get hasTorData(): boolean {
return this._hasTor;