diff --git a/boilerplate/js/boilerplate.js b/boilerplate/js/boilerplate.js index 499ce350c1d9a3c3728093c2a10ff88ebbd86ebf..803f4039b192f17a5006dd7a798d90122fd1d5d3 100644 --- a/boilerplate/js/boilerplate.js +++ b/boilerplate/js/boilerplate.js @@ -2,12 +2,65 @@ * JaLHyd must be compiled with "es2016" target and "commonjs" modules * @see `npm run build-node` and `src/tsconfig.app.node.json` */ -const { PabChute, PabChuteParams, formattedValue } = require("jalhyd"); +const { + CalculatorType, + formattedValue, + LoiDebit, + Props, + Session +} = require("jalhyd"); +// ---- example of modules setup and calculation : fish ladder ---- -// ---- example of simple modules setup and calculation ---- - -const pabChute = new PabChute(new PabChuteParams(29.99, 26.81, 0)); +const pabChute = Session.getInstance().createSessionNub( + new Props({ calcType: CalculatorType.PabChute }) +); +pabChute.prms.Z1.singleValue = 29.99; +pabChute.prms.Z2.singleValue = 26.81; pabChute.calculatedParam = pabChute.prms.DH; -const res = pabChute.CalcSerie(); -console.log("RESULT :", formattedValue(res.vCalc, 3)); + +const pabNombre = Session.getInstance().createSessionNub( + new Props({ calcType: CalculatorType.PabNombre }) +); +pabNombre.prms.N.singleValue = 14; +pabNombre.calculatedParam = pabNombre.prms.DH; +pabNombre.prms.DHT.defineReference(pabChute, "DH"); + +const pabPuissance = Session.getInstance().createSessionNub( + new Props({ calcType: CalculatorType.PabPuissance }) +); +pabPuissance.prms.Q.singleValue = 1.8; +pabPuissance.prms.PV.singleValue = 140; +pabPuissance.calculatedParam = pabPuissance.prms.V; +pabPuissance.prms.DH.defineReference(pabNombre, "DH"); + +const pabDimension = Session.getInstance().createSessionNub( + new Props({ calcType: CalculatorType.PabDimensions }) +); +pabDimension.prms.L.singleValue = 5; +pabDimension.prms.W.singleValue = 3.6; +pabDimension.calculatedParam = pabDimension.prms.Y; +pabDimension.prms.V.defineReference(pabPuissance, "V"); + +const resDim = pabDimension.CalcSerie(); +console.log("Water level in PAB:Dimension :", formattedValue(resDim.vCalc, 3)); + +const cloisons = Session.getInstance().createSessionNub( + new Props({ calcType: CalculatorType.Cloisons }) +); +const struct = Session.getInstance().createNub( + new Props({ calcType: CalculatorType.Structure, loiDebit: LoiDebit.WeirSubmergedLarinier }) +); +struct.prms.L.singleValue = 0.5; +struct.prms.CdWSL.singleValue = 0.83; +cloisons.addChild(struct); +cloisons.calculatedParam = cloisons.structures[0].prms.h1; +cloisons.prms.Z1.singleValue = 30.14; +cloisons.prms.LB.singleValue = 4.5; +cloisons.prms.PB.singleValue = 2.5; +cloisons.prms.Q.defineReference(pabPuissance, "Q"); +cloisons.prms.BB.defineReference(pabDimension, "W"); +cloisons.prms.DH.defineReference(pabNombre, "DH"); + +const resC = cloisons.CalcSerie(); +console.log("Head in Cloisons :", formattedValue(resC.vCalc, 3));