diff --git a/spec/math/spp.spec.ts b/spec/math/spp.spec.ts index 21c75314a6c821810004c2bc217809a0a808abd8..30264ce6dd61b71fe65f885e273b82c02ae40527 100644 --- a/spec/math/spp.spec.ts +++ b/spec/math/spp.spec.ts @@ -83,12 +83,12 @@ describe("Class SPP: ", () => { // SPP.Y should be linkable to all ParallelStructures params const lpY = Session.getInstance().getLinkableValues(spp.prms.Y); - expect(lpY.length).toBe(7); + expect(lpY.length).toBe(8); // all 3 YAXN.X should be linkable to all ParallelStructures params for (const c of spp.getChildren()) { const lp = Session.getInstance().getLinkableValues((c as YAXN).prms.X); - expect(lp.length).toBe(13); // 7, plus siblings params + expect(lp.length).toBe(14); // 8, plus siblings params } // each ParallelStructures param should be linkable to SPP.Y and all 3 YAXN.X diff --git a/spec/math/trigo.spec.ts b/spec/math/trigo.spec.ts index a12b4b19c3046dcdb6d5dc18337fc75ea81c1b2d..4d0afb314eadfddc1a49213fcfe7caeeb6400aee 100644 --- a/spec/math/trigo.spec.ts +++ b/spec/math/trigo.spec.ts @@ -157,8 +157,8 @@ describe("Class Trigo: ", () => { Session.getInstance().registerNubs([ trig, lo ]); // each Trigo param should be linkable to all ParallelStructures params - expect(Session.getInstance().getLinkableValues(trig.prms.Y).length).toBe(7); - expect(Session.getInstance().getLinkableValues(trig.prms.X).length).toBe(7); + expect(Session.getInstance().getLinkableValues(trig.prms.Y).length).toBe(8); + expect(Session.getInstance().getLinkableValues(trig.prms.X).length).toBe(8); // each ParallelStructures param should be linkable to all Trigo params for (const p of lo.parameterIterator) { diff --git a/spec/math/yaxb.spec.ts b/spec/math/yaxb.spec.ts index f9d964728a5314c3c679bfe0d2fb206f2c1c16c3..737b266d9a340649c9d3ad3b3db26b473a873ce5 100644 --- a/spec/math/yaxb.spec.ts +++ b/spec/math/yaxb.spec.ts @@ -70,10 +70,10 @@ describe("Class YAXB: ", () => { Session.getInstance().registerNubs([ yaxb, lo ]); // each YAXB param should be linkable to all ParallelStructures params - expect(Session.getInstance().getLinkableValues(yaxb.prms.Y).length).toBe(7); - expect(Session.getInstance().getLinkableValues(yaxb.prms.A).length).toBe(7); - expect(Session.getInstance().getLinkableValues(yaxb.prms.X).length).toBe(7); - expect(Session.getInstance().getLinkableValues(yaxb.prms.B).length).toBe(7); + expect(Session.getInstance().getLinkableValues(yaxb.prms.Y).length).toBe(8); + expect(Session.getInstance().getLinkableValues(yaxb.prms.A).length).toBe(8); + expect(Session.getInstance().getLinkableValues(yaxb.prms.X).length).toBe(8); + expect(Session.getInstance().getLinkableValues(yaxb.prms.B).length).toBe(8); // each ParallelStructures param should be linkable to all YAXB params for (const p of lo.parameterIterator) { diff --git a/spec/value_ref/value_ref_Dever_Structures.spec.ts b/spec/value_ref/value_ref_Dever_Structures.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..020a6c1d92f20951cf744bcbb74706328cc3aa82 --- /dev/null +++ b/spec/value_ref/value_ref_Dever_Structures.spec.ts @@ -0,0 +1,28 @@ +import { Session } from "../../src/session"; +import { DeverParams } from "../../src/structure/dever_params"; +import { LoiDebit } from "../../src/structure/structure_props"; +import { Dever } from "../../src/structure/dever"; +import { CreateStructure } from "../../src/structure/factory_structure"; +import { YAXBParams } from "../../src/math/yaxb_params"; +import { YAXB } from "../../src/math/yaxb"; + +describe("Dever and Structures", () => { + + it("Dever results with family undefined, and Structure flow Q, should be linkable to param with family ANY", () => { + const dever = new Dever(new DeverParams(0.5, 102, 10, 99)); + const s1 = CreateStructure(LoiDebit.RectangularOrificeFree, dever); + dever.addChild(s1); + const affine = new YAXB(new YAXBParams(0, 1, 2, 3)); + Session.getInstance().clear(); + Session.getInstance().registerNubs([ dever, affine ]); + + const axlp = Session.getInstance().getLinkableValues(affine.prms.X); + expect(axlp.length).toBe(12); // Q, Z1, BR, ZR (params) + V, Ec, Cv (results) + ZDV, W, L CdGR (structure params) + Q (structure result) + expect(axlp.map((p) => p.symbol)).toEqual([ "Q", "Z1", "BR", "ZR", "V", "Ec", "Cv", "ZDV", "W", "L", "CdGR", "Q" ]); + }); + + xit("Structure flow Q in PreBarrage should (not ?) be linkable", () => { + // @TODO + }); + +}); diff --git a/src/nub.ts b/src/nub.ts index ee08e1b0a8bc61a9d22dbd924e0a79f3fca10438..80ac04a64a9856edb616cad1b28f91008c149b82 100644 --- a/src/nub.ts +++ b/src/nub.ts @@ -716,9 +716,11 @@ export abstract class Nub extends ComputeNode implements IObservable { const erFamily = this._resultsFamilies[erSymbol]; // if family is identical or ANY, and variability doesn't cause any problem if ( - erFamily !== undefined - && ( - erFamily === src.family + ( + ( // both families cannot be undefined + erFamily === src.family + && erFamily !== undefined + ) || erFamily === ParamFamily.ANY || src.family === ParamFamily.ANY ) diff --git a/src/param/param-definition.ts b/src/param/param-definition.ts index b05038ca6dbfd4d03905bc308bbeab9d4e548f49..6269080574681153280bb0674689a395f4f7f97b 100644 --- a/src/param/param-definition.ts +++ b/src/param/param-definition.ts @@ -766,8 +766,14 @@ export class ParamDefinition implements INamedIterableValues, IObservable { // 1. extra result ? // - start here to avoid extra results being presented as // parameters by the iterator internally used by nub.getParameter() - // - extra results with no family are not linkable - if (Object.keys(nub.resultsFamilies).includes(symbol) && nub.resultsFamilies[symbol] !== undefined) { + // - extra results with no family are linkable only if linking parameter family is ANY + if ( + Object.keys(nub.resultsFamilies).includes(symbol) + && ( + nub.resultsFamilies[symbol] !== undefined + || this._family === ParamFamily.ANY + ) + ) { this._referencedValue = new LinkedValue(nub, undefined, symbol); } else { // 2. is it a parameter (possibly in CALC mode) ? diff --git a/src/structure/structure.ts b/src/structure/structure.ts index d1c9351bec4d93e59a56c4d0edc0a37f6c87234e..ad090a6e2c9b59fb9ebcdeeb1d8b999f78c09882 100644 --- a/src/structure/structure.ts +++ b/src/structure/structure.ts @@ -1,6 +1,6 @@ import { ChildNub } from "../child_nub"; import { CalculatorType } from "../compute-node"; -import { ParamCalculability, ParamDefinition } from "../param/param-definition"; +import { ParamCalculability, ParamDefinition, ParamFamily } from "../param/param-definition"; import { Props } from "../props"; import { Message, MessageCode } from "../util/message"; import { Result } from "../util/result"; @@ -330,4 +330,10 @@ export abstract class Structure extends ChildNub { } } + protected exposeResults() { + this._resultsFamilies = { + Q: ParamFamily.FLOWS + }; + } + }