Commit 505ec559 authored by Dorchies David's avatar Dorchies David
Browse files

#33 PAB: Break dependencies between param mode of cloison model and pabCloisons

Showing with 33 additions and 19 deletions
+33 -19
...@@ -36,8 +36,17 @@ export class Pab extends Nub { ...@@ -36,8 +36,17 @@ export class Pab extends Nub {
return this._children as PabCloisons[]; return this._children as PabCloisons[];
} }
public Calc(sVarCalc?: string, rInit?: number): Result {
// Update array of PabCloisons with last Models current values
for (const cl of this.children) {
cl.prms.setCurrentValuesFromModel();
}
return super.Calc(sVarCalc, rInit);
}
/** /**
* Calcul analytique * Calcul analytique
* @warning Should be called by this.Calc only for parameter initialisations
* @param sVarCalc Variable à calculer (Z1 uniquement) * @param sVarCalc Variable à calculer (Z1 uniquement)
*/ */
public Equation(sVarCalc: string): Result { public Equation(sVarCalc: string): Result {
......
...@@ -7,8 +7,11 @@ import { Pab } from "./pab"; ...@@ -7,8 +7,11 @@ import { Pab } from "./pab";
class PabCloisonsParams extends CloisonsParams { class PabCloisonsParams extends CloisonsParams {
/** Débit d'attrait d'un bassin (m3/s) */ /** Débit d'attrait d'un bassin (m3/s) */
public _QA: ParamDefinition; public _QA: ParamDefinition;
/** Model of cloison on which this pabCloison is based */
private _modelCloisonsParams: CloisonsParams;
/** /**
* Paramètres communs à toutes les équations de structure * Paramètres communs à toutes les équations de structure
...@@ -21,10 +24,7 @@ class PabCloisonsParams extends CloisonsParams { ...@@ -21,10 +24,7 @@ class PabCloisonsParams extends CloisonsParams {
*/ */
constructor(modelCloisonsParams?: CloisonsParams, rQA: number = 0) { constructor(modelCloisonsParams?: CloisonsParams, rQA: number = 0) {
super(1, 1, 1, 1, 1, 1); // overwritten by init() below super(1, 1, 1, 1, 1, 1); // overwritten by init() below
this.init(modelCloisonsParams); this.modelCloisonsParams = modelCloisonsParams;
// On garde Pr en propre sur cet objet (Pointage impossible car en lecture seule)
this.addParamDefinition(this.Pr, true);
// Débit d'attrait // Débit d'attrait
this._QA = new ParamDefinition(this, "QA", ParamDomainValue.POS_NULL, rQA, ParamFamily.FLOWS); this._QA = new ParamDefinition(this, "QA", ParamDomainValue.POS_NULL, rQA, ParamFamily.FLOWS);
...@@ -35,17 +35,22 @@ class PabCloisonsParams extends CloisonsParams { ...@@ -35,17 +35,22 @@ class PabCloisonsParams extends CloisonsParams {
return this._QA; return this._QA;
} }
public init(modelCloisonsParams: CloisonsParams) { /**
// might be undefined when created by a Session * Record pointer to the cloison model for future updating of local parameters
if (modelCloisonsParams) { */
this.Q = modelCloisonsParams.Q; set modelCloisonsParams(modelCloisonsParams: CloisonsParams) {
this.Z1 = modelCloisonsParams.Z1; this._modelCloisonsParams = modelCloisonsParams;
this.LB = modelCloisonsParams.LB; }
this.BB = modelCloisonsParams.BB;
this.PB = modelCloisonsParams.PB; /**
this.DH = modelCloisonsParams.DH; * Update Current values and sandobx values of parameter from cloison model
// Force la MAJ de la map avec les propriétés pointant vers celles de CloisonsParam */
this.addParamDefinitions(modelCloisonsParams); public setCurrentValuesFromModel() {
if (this._modelCloisonsParams !== undefined) {
for (const p of this._modelCloisonsParams) {
this._paramMap[p.symbol].currentValue = p.currentValue;
this._paramMap[p.symbol].v = p.currentValue;
}
} }
} }
...@@ -89,10 +94,10 @@ export class PabCloisons extends Cloisons { ...@@ -89,10 +94,10 @@ export class PabCloisons extends Cloisons {
} }
/** /**
* Sets modelCloisons as the current model, initializing the parameters with it * Sets modelCloisons as the current model (set pointers to parameters and structure array)
*/ */
public initModelCloisons(modelCloisons: Cloisons) { public initModelCloisons(modelCloisons: Cloisons) {
this.prms.init(modelCloisons ? modelCloisons.prms : undefined); this.prms.modelCloisonsParams = modelCloisons ? modelCloisons.prms : undefined;
this._children = modelCloisons ? modelCloisons.structures : []; this._children = modelCloisons ? modelCloisons.structures : [];
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment