Skip to content
Snippets Groups Projects
Commit 6c47c4f5 authored by David Dorchies's avatar David Dorchies
Browse files

Fix #261 - make QA linkable among PAB Cloisons

parent 5ea96a6e
No related branches found
No related tags found
No related merge requests found
import { ParamValueMode, Session } from "../../src/index";
import { CloisonAval } from "../../src/pab/cloison_aval";
import { CloisonsAvalParams } from "../../src/pab/cloison_aval_params";
import { Cloisons } from "../../src/pab/cloisons";
......@@ -11,6 +10,8 @@ import { StructureVanLevVillemonte } from "../../src/structure/structure_vanlev_
import { StructureWeirSubmergedLarinier } from "../../src/structure/structure_weir_submerged_larinier";
import { StructureWeirVillemonte } from "../../src/structure/structure_weir_villemonte";
import { MessageCode } from "../../src/util/message";
import { ParamValueMode } from "../../src/param/param-value-mode";
import { Session } from "../../src/session";
const dbg: boolean = false;
......@@ -282,4 +283,29 @@ describe("Class Pab: ", () => {
});
});
describe("linking QA", () => {
it("when there are more than 1 Cloison, QA should be linkable to its siblings", () => {
Session.getInstance().clear();
Session.getInstance().registerNub(pab);
const lv = Session.getInstance().getLinkableValues(pab.children[0].prms.QA);
expect(lv.length).toBe(13); // example PAB has 14 walls
});
it("when there are more than 1 Pab, QA should be linkable to other Pab's QAs", () => {
const pab2 = createPabTest();
Session.getInstance().clear();
// keep only one wall
for (let i=0; i < 13; i++) {
pab.deleteChild(13 - i);
pab2.deleteChild(13 - i);
}
expect(pab.children.length).toBe(1);
expect(pab2.children.length).toBe(1);
Session.getInstance().registerNub(pab);
Session.getInstance().registerNub(pab2);
const lv = Session.getInstance().getLinkableValues(pab.children[0].prms.QA);
expect(lv.length).toBe(1); // the only wall of the 2nd PAB
});
});
});
......@@ -789,7 +789,17 @@ export abstract class Nub extends ComputeNode implements IObservable {
}
// 3. children Nubs, except for PAB and MRC and PreBarrage
if (!(this instanceof Pab || this instanceof MacrorugoCompound || this._calcType === CalculatorType.PreBarrage)) {
if (
! (this instanceof MacrorugoCompound)
&& ( // meta-except, if source param in a PAB's Cloison (should only apply to QA)
! (this instanceof Pab)
|| (
src.originNub instanceof Pab
&& src.symbol === "QA"
)
)
&& this._calcType !== CalculatorType.PreBarrage
) {
for (const cn of this.getChildren()) {
res = res.concat(cn.getLinkableValues(src));
}
......
import { CalculatorType } from "../compute-node";
import { Session } from "../index";
import { Session, JalhydObject } from "../index";
import { ParamValueMode } from "../index";
import { Nub } from "../nub";
import { ParamCalculability, ParamDefinition } from "../param/param-definition";
......@@ -76,6 +76,7 @@ export class Pab extends FishPass {
for (let i = 0; i < n; i++) {
const cl: Cloisons =
Session.getInstance().unserialiseSingleNub(serialisedCloisonModel, false).nub as Cloisons;
cl.setUid(JalhydObject.nextUID); // prevent all Cloisons having the same UID
const p = cl.prms;
// Copy calculated param to the new Cloison #130
cl.calculatedParam.singleValue = cloisonModel.calculatedParam.V;
......
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