From 5871e7745b10932deb2ab574e9206fdb973ed2df Mon Sep 17 00:00:00 2001 From: David Dorchies <david.dorchies@irstea.fr> Date: Tue, 25 Jun 2019 11:10:40 +0200 Subject: [PATCH] #33 Delete all reference to PabCloisons --- spec/pab/pab.spec.ts | 1 - src/compute-node.ts | 3 +- src/index.ts | 1 - src/nub.ts | 2 +- src/pab/pab.ts | 10 +-- src/pab/pab_cloisons.ts | 151 ---------------------------------------- src/session.ts | 13 +--- 7 files changed, 9 insertions(+), 172 deletions(-) delete mode 100644 src/pab/pab_cloisons.ts diff --git a/spec/pab/pab.spec.ts b/spec/pab/pab.spec.ts index ff7bd1d4..3e0185b1 100644 --- a/spec/pab/pab.spec.ts +++ b/spec/pab/pab.spec.ts @@ -8,7 +8,6 @@ import { Cloisons, CloisonsParams } from "../../src/pab/cloisons"; import { Pab, PabParams } from "../../src/pab/pab"; -import { PabCloisons } from "../../src/pab/pab_cloisons"; import { ParallelStructure, ParallelStructureParams } from "../../src/structure/parallel_structure"; import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params"; import { StructureKivi, StructureKiviParams } from "../../src/structure/structure_kivi"; diff --git a/src/compute-node.ts b/src/compute-node.ts index a49820c6..448bfc41 100644 --- a/src/compute-node.ts +++ b/src/compute-node.ts @@ -22,8 +22,7 @@ export enum CalculatorType { PabChute, PabNombre, Section, - Pab, // Passe à bassins; - PabCloisons // modèle de cloisons + débit d'attrait, pour Passe à bassins + Pab // Passe à bassins; } /** diff --git a/src/index.ts b/src/index.ts index c970bb50..3098fb10 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,4 +37,3 @@ export * from "./jalhyd_object"; export * from "./date_revision"; export * from "./section/section_nub"; export * from "./pab/pab"; -export * from "./pab/pab_cloisons"; diff --git a/src/nub.ts b/src/nub.ts index 409de6aa..e387b0ca 100644 --- a/src/nub.ts +++ b/src/nub.ts @@ -872,7 +872,7 @@ export abstract class Nub extends ComputeNode implements IObservable { } } // define calculated param at Nub level - // @TODO except if we are a Section / Structure / PabCloisons ? + // @TODO except if we are a Section / Structure / Cloisons ? if (ret.p) { this.calculatedParam = ret.p; } diff --git a/src/pab/pab.ts b/src/pab/pab.ts index 6f9a96c8..bd17ddb0 100644 --- a/src/pab/pab.ts +++ b/src/pab/pab.ts @@ -40,7 +40,7 @@ export class Pab extends Nub { /** * Add Cloisons to the PAB from a cloison model * @param cloisonModel Cloison model parametrised as first upstream basin - * @param n Number of walls of the PAB (Number of basin = n - 1) + * @param n Number of walls (or falls) of the PAB (Number of basin = n - 1) */ public addCloisonsFromModel(cloisonModel: Cloisons , n: number) { // Fix some parameters of the upstream cloison (= Wall + basin) @@ -154,6 +154,7 @@ export class Pab extends Nub { * Finds the ParallelStructure targetted by modelUid and defines it as the current downWall */ public setDownWall(modelUid: string) { + // TODO: check if this is still necessary this.properties.setPropValue("modeleCloisonAval", modelUid); const dw = (Session.getInstance().findNubByUid(modelUid) as ParallelStructure); if (dw) { @@ -164,17 +165,18 @@ export class Pab extends Nub { } /** - * Once session is loaded, run a second pass on all PabCloisons to + * Once session is loaded, run a second pass on all PAB's Cloisons to * reinit their target if needed */ public fixPAB(obj: any) { + // TODO: check if this is still necessary if (obj.children && Array.isArray(obj.children)) { // Cloisons models for (const c of obj.children) { - if (c.props.calcType === CalculatorType.PabCloisons) { // who knows ? + if (c.props.calcType === CalculatorType.Cloisons) { // who knows ? const childUid = c.uid; const targetCloisonsUid = c.props.modeleCloisons; - // find child PabCloisons to relink + // find child Cloisons to relink const cloisons = (this.getChild(childUid) as Cloisons); if (cloisons) { // cloisons.setModel(targetCloisonsUid); diff --git a/src/pab/pab_cloisons.ts b/src/pab/pab_cloisons.ts deleted file mode 100644 index 0784c44e..00000000 --- a/src/pab/pab_cloisons.ts +++ /dev/null @@ -1,151 +0,0 @@ -import { ParamCalculability, ParamDefinition, ParamFamily} from "../param/param-definition"; -import { ParamDomainValue } from "../param/param-domain"; -import { Result } from "../util/result"; - -import { CalculatorType, Session } from "../index"; -import { Cloisons, CloisonsParams } from "./cloisons"; -import { Pab } from "./pab"; - -class PabCloisonsParams extends CloisonsParams { - - /** Débit d'attrait d'un bassin (m3/s) */ - public _QA: ParamDefinition; - - /** Model of cloison on which this pabCloison is based */ - private _modelCloisonsParams: CloisonsParams; - - /** - * Paramètres communs à toutes les équations de structure - * @param rQ Débit total (m3/s) - * @param rZ1 Cote de l'eau amont (m) - * @param rLB Longueur des bassins (m) - * @param rBB Largeur des bassins (m) - * @param rPB Profondeur moyenne (m) - * @param rDH Hauteur de chute (m) - */ - constructor(modelCloisonsParams?: CloisonsParams, rQA: number = 0) { - super(1, 1, 1, 1, 1, 1); // overwritten by init() below - this.modelCloisonsParams = modelCloisonsParams; - - // Débit d'attrait - this._QA = new ParamDefinition(this, "QA", ParamDomainValue.POS_NULL, rQA, ParamFamily.FLOWS); - this.addParamDefinition(this._QA); - } - - public get QA() { - return this._QA; - } - - /** - * Record pointer to the cloison model for future updating of local parameters - */ - set modelCloisonsParams(modelCloisonsParams: CloisonsParams) { - this._modelCloisonsParams = modelCloisonsParams; - } - - /** - * Update Current values and sandobx values of parameter from cloison model - */ - public setCurrentValuesFromModel() { - if (this._modelCloisonsParams !== undefined) { - for (const p of this._modelCloisonsParams) { - this._paramMap[p.symbol].singleValue = p.currentValue; - this._paramMap[p.symbol].v = p.currentValue; - } - } - } - -} - -// tslint:disable-next-line:max-classes-per-file -export class PabCloisons extends Cloisons { - - /** - * paramètres castés au bon type - */ - get prms(): PabCloisonsParams { - return this._prms as PabCloisonsParams; - } - - /** - * Calculation of upstream water depth - */ - get Yam(): number { - // TODO: ajouter l'option radier horizontal - return this.prms.PB.currentValue + this.prms.DH.currentValue / 2; - } - - public parent: Pab; - - constructor(modelCloisons: Cloisons, rQA: number = 0, dbg: boolean = false) { - super(new PabCloisonsParams(), dbg); // model is set below - this.initModelCloisons(modelCloisons); - this._calcType = CalculatorType.PabCloisons; - } - - public Calc(sVarCalc: string, rInit?: number): Result { - const r: Result = super.Calc(sVarCalc, rInit); - const p = this.getParamValuesAfterCalc(sVarCalc, r); - r.extraResults.ZRAM = p.Z1 - p.PB; - return r; - } - - /** - * Update crest elevations from upstream apron elevation - */ - public updateZDV(rZR: number) { - for (const st of this.structures) { - if (st.prms.ZDV.calculability !== ParamCalculability.NONE) { - st.prms.ZDV.v = st.prms.ZDV.currentValue + rZR - (this.prms.Z1.currentValue - this.Yam); - } - } - } - - /** - * Sets modelCloisons as the current model (set pointers to parameters and structure array) - */ - public initModelCloisons(modelCloisons: Cloisons) { - this.prms.modelCloisonsParams = modelCloisons ? modelCloisons.prms : undefined; - this._children = modelCloisons ? modelCloisons.structures : []; - } - - /** - * Finds the Cloisons targetted by modelUid and defines it as the current model - */ - public setModel(modelUid: string) { - this.properties.setPropValue("modeleCloisons", modelUid); - const cloisons = (Session.getInstance().findNubByUid(modelUid) as Cloisons); - if (cloisons) { - this.initModelCloisons(cloisons); - } /* else { - console.error("PabCloisons.setModel : cannot find target Cloisons"); - } */ - } - - /** - * Returns an object representation of the Nub's current state - */ - public objectRepresentation() { - const ret: any = { - uid: this.uid, - props: this.properties.props, - parameters: [] - }; - - // ! do not iterate over local parameters (would copy the parameters of the Cloisons used as model), - // just serialise QA - ret.parameters.push(this.prms.QA.objectRepresentation()); - - // ! do not iterate over children Nubs (would copy the children of the Cloisons used as model) - - return ret; - } - - /** - * paramétrage de la calculabilité des paramètres - */ - protected setParametersCalculability() { - super.setParametersCalculability(); - this.prms._QA.calculability = ParamCalculability.FREE; - } -} diff --git a/src/session.ts b/src/session.ts index ff547732..d8909d00 100644 --- a/src/session.ts +++ b/src/session.ts @@ -28,7 +28,6 @@ import { acSection } from "./section/section_type"; import { Cloisons } from "./pab/cloisons"; import { CloisonsParams } from "./pab/cloisons_params"; import { Pab, PabParams } from "./pab/pab"; -import { PabCloisons } from "./pab/pab_cloisons"; import { ParamDefinition } from "./param/param-definition"; import { Dever, DeverParams } from "./structure/dever"; import { CreateStructure } from "./structure/factory_structure"; @@ -401,17 +400,6 @@ export class Session { ); break; - case CalculatorType.PabCloisons: - const modeleCloisons: string = params.getPropValue("modeleCloisons"); - if (modeleCloisons) { - const cloisons = (Session.getInstance().findNubByUid(modeleCloisons) as Cloisons); - // si le module Cloisons ciblé n'existe pas, Session.fixPAB() est censé s'en occuper - nub = new PabCloisons(cloisons); - } else { - nub = new PabCloisons(undefined); // don't forget to init with a Cloisons model afterwards ! - } - break; - default: { throw new Error( @@ -632,6 +620,7 @@ export class Session { * Asks all loaded PAB Nubs to reinit any PabCloisons from their model */ private fixPAB(serialised: string, uids?: string[]) { + // TODO: check if this is still necessary const data = JSON.parse(serialised); if (data.session && Array.isArray(data.session)) { // find each PAB in the session -- GitLab