UNPKG

jalhyd

Version:

JaLHyd, a Javascript Library for Hydraulics

141 lines 5.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PbCloison = void 0; const internal_modules_1 = require("../internal_modules"); const internal_modules_2 = require("../internal_modules"); const internal_modules_3 = require("../internal_modules"); const internal_modules_4 = require("../internal_modules"); const internal_modules_5 = require("../internal_modules"); class PbCloison extends internal_modules_1.ParallelStructure { constructor(bassinAmont, bassinAval, dbg = false, nullParams = false) { super(new internal_modules_2.ParallelStructureParams(0, 0, 0, nullParams), dbg); // prevent multiple CALC params in session file this.prms.Q.visible = false; this.prms.Z1.visible = false; this.prms.Z2.visible = false; this.setPropValue("upstreamBasin", bassinAmont === undefined ? "" : bassinAmont.uid); this.setPropValue("downstreamBasin", bassinAval === undefined ? "" : bassinAval.uid); this.setCalculatorType(internal_modules_3.CalculatorType.PbCloison); this._intlType = "Cloison"; } /** pointer to parent Nub */ get parent() { return super.parent; } /** Bassin à l'amont de la cloison ou undefined pour condition limite amont */ get bassinAmont() { let basin; const basinUID = this._props.getPropValue("upstreamBasin"); if (basinUID !== undefined && basinUID !== "") { basin = this.parent.findChild(basinUID); if (basin === undefined) { // silent fail } } return basin; } /** sets the upstream basin by setting property "upstreamBasin" to the UID of the given PbBassin */ set bassinAmont(b) { let uid = ""; // empty value if (b !== undefined) { uid = b.uid; } this.setPropValue("upstreamBasin", uid); this.parent.updatePointers(); } /** Bassin à l'aval de la cloison ou undefined pour condition limite aval */ get bassinAval() { let basin; const basinUID = this._props.getPropValue("downstreamBasin"); if (basinUID !== undefined && basinUID !== "") { basin = this.parent.findChild(basinUID); if (basin === undefined) { // silent fail } } return basin; } /** sets the downstream basin by setting property "downstreamBasin" to the UID of the given PbBassin */ set bassinAval(b) { let uid = ""; // empty value if (b !== undefined) { uid = b.uid; } this.setPropValue("downstreamBasin", uid); this.parent.updatePointers(); } get Z1() { if (this.bassinAmont !== undefined) { return this.bassinAmont.Z; } else { return this.parent.prms.Z1.v; } } get Z2() { if (this.bassinAval !== undefined) { return this.bassinAval.Z; } else { return this.parent.prms.Z2.v; } } Calc(sVarCalc, rInit) { this.updateZ1Z2(); const r = super.Calc(sVarCalc, rInit); switch (sVarCalc) { case "Z1": // Upstream water elevation should be at least equal minZDV r.vCalc = Math.max(this.getMinZDV(), r.vCalc); break; case "Q": r.vCalc = Math.max(0, r.vCalc); } return r; } finalCalc() { this.calculatedParam = this.prms.Q; this.Calc("Q"); // add Z1, Z2 & DH extra results for GUI convenience this.result.resultElement.values.Z1 = this.prms.Z1.v; this.result.resultElement.values.Z2 = this.prms.Z2.v; this.result.resultElement.values.DH = this.prms.Z1.v - this.prms.Z2.v; } updateZ1Z2() { this.prms.Z1.v = this.Z1; this.prms.Z2.v = this.Z2; } /** * Give the minimum ZDV on all structures. Undefined if only orifice without ZDV. */ getMinZDV() { let minZDV; for (const s of this.structures) { if (s.prms.ZDV.visible) { if (minZDV === undefined) { minZDV = s.prms.ZDV.v; } else { minZDV = Math.min(minZDV, s.prms.ZDV.v); } } } return minZDV; } getLoisAdmissibles() { return internal_modules_4.loiAdmissiblesOuvrages; // @TODO loiAdmissiblesCloisons plutôt, mais penser à y intégrer Cunge80 } /** * Returns a translatable message for wall description, containing order numbers of * upstream and downstream basin, or "upstream" / "downstream" mention if wall is * directly connected to the river */ get description() { return new internal_modules_5.Message(internal_modules_5.MessageCode.INFO_PB_CLOISON_DESCRIPTION, { ub: this.bassinAmont === undefined ? "MSG_INFO_LIB_AMONT" : "B" + String(this.bassinAmont.order), db: this.bassinAval === undefined ? "MSG_INFO_LIB_AVAL" : "B" + String(this.bassinAval.order), }); } } exports.PbCloison = PbCloison; //# sourceMappingURL=pb_cloison.js.map