diff --git a/spec/nubtest.ts b/spec/nubtest.ts index 1bc3bc30ae088cac3676d19af7724a8341d84185..0f57426da6a2992e9f084c7f88e01826e88bd02e 100644 --- a/spec/nubtest.ts +++ b/spec/nubtest.ts @@ -1,6 +1,6 @@ import { Result } from "../src/base"; import { Nub } from "../src/nub"; -import { ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability, IParamsEquation } from "../src/param"; +import { ComputeNodeType, ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability, IParamsEquation } from "../src/param"; class NubTestParams implements IParamsEquation { private _A: ParamDefinition; @@ -8,9 +8,9 @@ class NubTestParams implements IParamsEquation { private _C: ParamDefinition; constructor() { - this._A = new ParamDefinition('A', ParamDomainValue.POS_NULL, 1); - this._B = new ParamDefinition('B', ParamDomainValue.POS_NULL, 2); - this._C = new ParamDefinition('C', ParamDomainValue.POS_NULL, 3); + this._A = new ParamDefinition(ComputeNodeType.Test, 'A', ParamDomainValue.POS_NULL, 1); + this._B = new ParamDefinition(ComputeNodeType.Test, 'B', ParamDomainValue.POS_NULL, 2); + this._C = new ParamDefinition(ComputeNodeType.Test, 'C', ParamDomainValue.POS_NULL, 3); } get A() { diff --git a/src/cond_distri.ts b/src/cond_distri.ts index e16ac12952d44410cbc7fd764456b7ad26c5782b..7f187e9b44dc8e65dfd8f94efcf8a304da3485a9 100644 --- a/src/cond_distri.ts +++ b/src/cond_distri.ts @@ -1,5 +1,5 @@ import { Result } from "./base"; -import { ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability, IParamsEquation } from "./param"; +import { ComputeNodeType, ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability, IParamsEquation } from "./param"; import { Nub } from "./nub"; /** @@ -22,11 +22,11 @@ export class ConduiteDistribParams implements IParamsEquation { Nu: ParamDefinition; constructor(rQ: number, rD: number, rJ: number, rLg: number, rNu: number) { - this.Q = new ParamDefinition('Q', ParamDomainValue.POS, rQ); - this.D = new ParamDefinition('D', ParamDomainValue.POS, rD); - this.J = new ParamDefinition('J', ParamDomainValue.POS, rJ); - this.Lg = new ParamDefinition('Lg', ParamDomainValue.POS, rLg); - this.Nu = new ParamDefinition('Nu', ParamDomainValue.POS, rNu); + this.Q = new ParamDefinition(ComputeNodeType.CondDistri, 'Q', ParamDomainValue.POS, rQ); + this.D = new ParamDefinition(ComputeNodeType.CondDistri, 'D', ParamDomainValue.POS, rD); + this.J = new ParamDefinition(ComputeNodeType.CondDistri, 'J', ParamDomainValue.POS, rJ); + this.Lg = new ParamDefinition(ComputeNodeType.CondDistri, 'Lg', ParamDomainValue.POS, rLg); + this.Nu = new ParamDefinition(ComputeNodeType.CondDistri, 'Nu', ParamDomainValue.POS, rNu); } } diff --git a/src/lechaptcalmon.ts b/src/lechaptcalmon.ts index c130e59ae4a6d89fc8ea9b130947d920c92a784f..ceba0fef50aee339b221ba67f21e6d81c4afbed8 100644 --- a/src/lechaptcalmon.ts +++ b/src/lechaptcalmon.ts @@ -1,5 +1,5 @@ import { Result } from "./base"; -import { ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability, IParamsEquation } from "./param"; +import { ComputeNodeType, ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability, IParamsEquation } from "./param"; import { Nub } from "./nub"; /** @@ -28,13 +28,13 @@ export class LechaptCalmonParams implements IParamsEquation { private _N: ParamDefinition; constructor(rQ: number, rD: number, rJ: number, rLg: number, rL: number, rM: number, rN: number) { - this._Q = new ParamDefinition('Q', ParamDomainValue.POS, rQ); - this._D = new ParamDefinition('D', ParamDomainValue.POS, rD); - this._J = new ParamDefinition('J', ParamDomainValue.POS, rJ); - this._Lg = new ParamDefinition('Lg', ParamDomainValue.POS, rLg); - this._L = new ParamDefinition('L', ParamDomainValue.POS, rL); - this._M = new ParamDefinition('M', ParamDomainValue.POS, rM); - this._N = new ParamDefinition('N', ParamDomainValue.POS, rN); + this._Q = new ParamDefinition(ComputeNodeType.LechaptCalmon, 'Q', ParamDomainValue.POS, rQ); + this._D = new ParamDefinition(ComputeNodeType.LechaptCalmon, 'D', ParamDomainValue.POS, rD); + this._J = new ParamDefinition(ComputeNodeType.LechaptCalmon, 'J', ParamDomainValue.POS, rJ); + this._Lg = new ParamDefinition(ComputeNodeType.LechaptCalmon, 'Lg', ParamDomainValue.POS, rLg); + this._L = new ParamDefinition(ComputeNodeType.LechaptCalmon, 'L', ParamDomainValue.POS, rL); + this._M = new ParamDefinition(ComputeNodeType.LechaptCalmon, 'M', ParamDomainValue.POS, rM); + this._N = new ParamDefinition(ComputeNodeType.LechaptCalmon, 'N', ParamDomainValue.POS, rN); } get Q() { diff --git a/src/param.ts b/src/param.ts index 37c028849902d724d84968dc3d7811aa149b9470..670a6ff4961536edb13d274befa75a17644d9a45 100644 --- a/src/param.ts +++ b/src/param.ts @@ -112,6 +112,11 @@ export class ParamDefinition extends DefinedNumber { */ private _symbol: string; + /** + * alias du symbole + */ + // public symbolAlias: string; + /** * calculabilité */ @@ -122,6 +127,11 @@ export class ParamDefinition extends DefinedNumber { */ private _domain: ParamDomain; + /** + * noeud de calcul parent + */ + private _computeNodeType: ComputeNodeType + /** * ancienne valeur du paramètre */ @@ -136,8 +146,9 @@ export class ParamDefinition extends DefinedNumber { // private _id: number; // A VIRER // constructor(s: string, d: ParamDomain, c: ParamCalculability, val: number = undefined) { - constructor(s: string, d: any, val: number = undefined) { + constructor(nt: ComputeNodeType, s: string, d: ParamDomain | ParamDomainValue, val: number = undefined) { super(val); + this._computeNodeType = nt; this._symbol = s; if (d instanceof ParamDomain) @@ -171,6 +182,11 @@ export class ParamDefinition extends DefinedNumber { return this._domain; } + + get computeNodeType(): ComputeNodeType { + return this._computeNodeType; + } + /* * méthodes de calculabilité */ @@ -344,6 +360,16 @@ export interface IParamsEquation { [key: string]: any; } +/** + * type de noeud de calcul + */ +export enum ComputeNodeType { + CondDistri, RegimeUniforme, LechaptCalmon, + SectionParametree, // paramètres communs à toutes les sections paramétrées + SectionTrapeze, SectionRectangle, SectionCercle, SectionPuissance, + Test +} + /** * noeud de calcul */ diff --git a/src/parameters.ts b/src/parameters.ts index 17c23d053db8d88296229505683ad3b9fb76a2f7..37a196a25696b57d47c125e418d72b55bb25e94a 100644 --- a/src/parameters.ts +++ b/src/parameters.ts @@ -1,6 +1,7 @@ -import { IParamsEquation } from "./param"; +import { ComputeNodeType, IParamsEquation } from "./param"; import { ConduiteDistribParams, ConduiteDistrib } from "./cond_distri"; import { LechaptCalmonParams, LechaptCalmon } from "./lechaptcalmon"; +import { ParamsSection, acSection } from "./section/section_type"; import { ParamsSectionTrapez, cSnTrapez } from "./section/section_trapez"; import { ParamsSectionRectang, cSnRectang } from "./section/section_rectang"; import { ParamsSectionCirc, cSnCirc } from "./section/section_circulaire"; @@ -17,44 +18,44 @@ export class ComputeNodeParameters { return ComputeNodeParameters._instance; } - public getComputeNodeParameters(name: string): IParamsEquation { - switch (name) { - case "cond_distri": + public getComputeNodeParameters(type: ComputeNodeType): IParamsEquation { + switch (type) { + case ComputeNodeType.CondDistri: { let cn = new ConduiteDistribParams(undefined, undefined, undefined, undefined, undefined); let n = new ConduiteDistrib(cn); // pour initialiser la calculabilité des paramètres return cn; } - case "lechapt_calmon": + case ComputeNodeType.LechaptCalmon: { let cn = new LechaptCalmonParams(undefined, undefined, undefined, undefined, undefined, undefined, undefined); let n = new LechaptCalmon(cn); // pour initialiser la calculabilité des paramètres return cn; } - case "section_param_trapez": + case ComputeNodeType.SectionTrapeze: { let cn = new ParamsSectionTrapez(undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined); let n = new cSnTrapez(undefined, cn); // pour initialiser la calculabilité des paramètres return cn; } - case "section_param_rect": + case ComputeNodeType.SectionRectangle: { let cn = new ParamsSectionRectang(undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined); let n = new cSnRectang(undefined, cn); // pour initialiser la calculabilité des paramètres return cn; } - case "section_param_circ": + case ComputeNodeType.SectionCercle: { let cn = new ParamsSectionCirc(undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined); let n = new cSnCirc(undefined, cn); // pour initialiser la calculabilité des paramètres return cn; } - case "section_param_para": + case ComputeNodeType.SectionPuissance: { let cn = new ParamsSectionPuiss(undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined); let n = new cSnPuiss(undefined, cn); // pour initialiser la calculabilité des paramètres @@ -62,7 +63,7 @@ export class ComputeNodeParameters { } default: - throw "ComputeNodeParameters.getComputeNodeParameters() : nub '" + name + "' non pris en charge"; + throw "ComputeNodeParameters.getComputeNodeParameters() : noeud de calcul '" + ComputeNodeType[type] + "' non pris en charge"; } } } diff --git a/src/section/section_circulaire.ts b/src/section/section_circulaire.ts index 09931c2a37d2d19f4207b44af74514fe145dbbd3..7fd29262f1c7efdbf9673e9a84be2f0fd27ec959 100644 --- a/src/section/section_circulaire.ts +++ b/src/section/section_circulaire.ts @@ -1,13 +1,14 @@ -import { ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability } from "../param"; +import { ComputeNodeType, ParamDefinition, ParamDomainValue, ParamCalculability } from "../param"; import { acSection, ParamsSection } from "./section_type"; import { cLog } from "./log"; +import { ErrorMessage, ErrorCode } from '../util/error'; export class ParamsSectionCirc extends ParamsSection { private _D: ParamDefinition; // Diamètre du cercle constructor(rD: number, rY: number, rKs: number, rQ: number, rIf: number, rPrec: number, rYB: number, rYCL: number = undefined, rDx: number = undefined, rLong: number = undefined) { super(rY, undefined, rKs, rQ, rIf, rPrec, rYB, rYCL); - this._D = new ParamDefinition('D', ParamDomainValue.POS, rD); + this._D = new ParamDefinition(ComputeNodeType.SectionCercle, 'D', ParamDomainValue.POS, rD); } /** @@ -138,6 +139,11 @@ export class cSnCirc extends acSection { this.debug("circ.Calc_B() : res=" + res); return res; } + + let e: ErrorMessage = new ErrorMessage(ErrorCode.ERROR_PARAMDEF_VALUE_UNDEFINED); + e.extraVar["diameterValue"] = this.prms.D.isDefined ? String(this.prms.D.v) : "undefined"; + e.extraVar["yValue"] = this.prms.Y.isDefined ? String(this.prms.Y.v) : "undefined"; + throw e; } /** diff --git a/src/section/section_puissance.ts b/src/section/section_puissance.ts index b39afc56a4e1ec8eb7521becad1228873661dffe..c11e7fd06dce193bd72039921af106011ef82e79 100644 --- a/src/section/section_puissance.ts +++ b/src/section/section_puissance.ts @@ -1,8 +1,7 @@ -import { ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability } from "../param"; +import { ComputeNodeType, ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability } from "../param"; import { acSection, ParamsSection } from "./section_type"; import { cLog } from "./log"; - /** * Paramètres de la section parabolique ou "puissance" */ @@ -11,7 +10,7 @@ export class ParamsSectionPuiss extends ParamsSection { constructor(rk: number, rY: number, rLargeurBerge: number, rKs: number, rQ: number, rIf: number, rPrec: number, rYB: number, rYCL: number = 0, rDx: number = 0, rLong: number = 0) { super(rY, rLargeurBerge, rKs, rQ, rIf, rPrec, rYB, rYCL); - this._k = new ParamDefinition('k', new ParamDomain(ParamDomainValue.INTERVAL, 0, 1), rk); + this._k = new ParamDefinition(ComputeNodeType.SectionPuissance, 'k', new ParamDomain(ParamDomainValue.INTERVAL, 0, 1), rk); } /** diff --git a/src/section/section_rectang.ts b/src/section/section_rectang.ts index 7f62985f258551ef8f13ca93ef2e78f7ad87e76e..5d93e1ce132fa063eaf9fb04e68f5e82d3bbc103 100644 --- a/src/section/section_rectang.ts +++ b/src/section/section_rectang.ts @@ -1,4 +1,3 @@ -import { ParamDefinition, ParamDomain, ParamCalculability } from "../param"; import { acSection, ParamsSection } from "./section_type"; import { cLog } from "./log"; @@ -7,6 +6,7 @@ export class ParamsSectionRectang extends ParamsSection { super(rY, rLargeurFond, // LargeurBerge=LargeurFond rKs, rQ, rIf, rPrec, rYB, rYCL); + // this.LargeurBerge.symbolAlias = 'LargeurFond'; } } diff --git a/src/section/section_trapez.ts b/src/section/section_trapez.ts index 9ea275eacd534368c851228d22e4782425a6166a..bc9d8f0c67fe01590904f386c80519079d1df765 100644 --- a/src/section/section_trapez.ts +++ b/src/section/section_trapez.ts @@ -1,4 +1,4 @@ -import { ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability } from "../param"; +import { ComputeNodeType, ParamDefinition, ParamDomainValue, ParamCalculability } from "../param"; import { acSection, ParamsSection } from "./section_type"; import { cLog } from "./log"; @@ -9,8 +9,8 @@ export class ParamsSectionTrapez extends ParamsSection { constructor(rLargeurFond: number, rFruit: number, rY: number, rKs: number, rQ: number, rIf: number, rPrec: number, rYB: number, rYCL: number = 0, rDx: number = 0, rLong: number = 0) { super(rY, undefined, rKs, rQ, rIf, rPrec, rYB, rYCL); - this._LargeurFond = new ParamDefinition('LargeurFond', ParamDomainValue.POS_NULL, rLargeurFond); - this._Fruit = new ParamDefinition('Fruit', ParamDomainValue.POS_NULL, rFruit); + this._LargeurFond = new ParamDefinition(ComputeNodeType.SectionTrapeze, 'LargeurFond', ParamDomainValue.POS_NULL, rLargeurFond); + this._Fruit = new ParamDefinition(ComputeNodeType.SectionTrapeze, 'Fruit', ParamDomainValue.POS_NULL, rFruit); } /** diff --git a/src/section/section_type.ts b/src/section/section_type.ts index 7c0ac54be1af9bad231efeccc66932ebf8678075..bb0595d067258d357371e455be35c150b8c3c2fc 100644 --- a/src/section/section_type.ts +++ b/src/section/section_type.ts @@ -1,6 +1,6 @@ import { XOR } from "../base"; import { cLog } from "./log"; -import { ComputeNode, ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability, IParamsEquation } from "../param"; +import { ComputeNodeType, ComputeNode, ParamDefinition, ParamDomainValue, ParamCalculability, IParamsEquation } from "../param"; import { cHautCritique, cHautNormale, cHautCorrespondante, cHautConjuguee } from "./hauteur"; /** @@ -20,18 +20,18 @@ export abstract class cParamsCanal implements IParamsEquation { private _Long: ParamDefinition; // Longueur du bief // public Resolution; /// Méthode de résolution "Euler" ou "RK4" - constructor(rKs: number, rQ: number, rIf: number, rPrec: number, rYB: number, rYCL: number = undefined, rDx: number = undefined, rLong: number = undefined) //, sResolution = '') { + constructor(nodeType: ComputeNodeType, rKs: number, rQ: number, rIf: number, rPrec: number, rYB: number, rYCL: number = undefined, rDx: number = undefined, rLong: number = undefined) //, sResolution = '') { { //this.prms.Resolution = sResolution; - this._Ks = new ParamDefinition('Ks', ParamDomainValue.POS, rKs); - this._Q = new ParamDefinition('Q', ParamDomainValue.POS_NULL, rQ); - this._If = new ParamDefinition('If', ParamDomainValue.ANY, rIf); - this._Prec = new ParamDefinition('Prec', ParamDomainValue.POS, rPrec); - this._iPrec = new ParamDefinition('iPrec', ParamDomainValue.ANY, -Math.log(rPrec) / Math.log(10)); - this._YB = new ParamDefinition('YB', ParamDomainValue.POS, rYB); - this._YCL = new ParamDefinition('YCL', ParamDomainValue.POS_NULL, rYCL); - this._Dx = new ParamDefinition('Dx', ParamDomainValue.NOT_NULL, rDx); - this._Long = new ParamDefinition('Long', ParamDomainValue.POS, rLong); + this._Ks = new ParamDefinition(nodeType, 'Ks', ParamDomainValue.POS, rKs); + this._Q = new ParamDefinition(nodeType, 'Q', ParamDomainValue.POS_NULL, rQ); + this._If = new ParamDefinition(nodeType, 'If', ParamDomainValue.ANY, rIf); + this._Prec = new ParamDefinition(nodeType, 'Prec', ParamDomainValue.POS, rPrec); + this._iPrec = new ParamDefinition(nodeType, 'iPrec', ParamDomainValue.ANY, -Math.log(rPrec) / Math.log(10)); + this._YB = new ParamDefinition(nodeType, 'YB', ParamDomainValue.POS, rYB); + this._YCL = new ParamDefinition(nodeType, 'YCL', ParamDomainValue.POS_NULL, rYCL); + this._Dx = new ParamDefinition(nodeType, 'Dx', ParamDomainValue.NOT_NULL, rDx); + this._Long = new ParamDefinition(nodeType, 'Long', ParamDomainValue.POS, rLong); } /** @@ -104,10 +104,9 @@ export abstract class ParamsSection extends cParamsCanal { private _LargeurBerge: ParamDefinition; // largeur au débordement constructor(rY: number, rLargeurBerge: number, rKs: number, rQ: number, rIf: number, rPrec: number, rYB: number, rYCL: number = undefined, rDx: number = undefined, rLong: number = undefined) { - super(rKs, rQ, rIf, rPrec, rYB, rYCL, rDx, rLong); - - this._Y = new ParamDefinition('Y', ParamDomainValue.POS_NULL, rY); - this._LargeurBerge = new ParamDefinition('LargeurBerge', ParamDomainValue.POS_NULL, rLargeurBerge); + super(ComputeNodeType.SectionParametree, rKs, rQ, rIf, rPrec, rYB, rYCL, rDx, rLong); + this._Y = new ParamDefinition(ComputeNodeType.SectionParametree, 'Y', ParamDomainValue.POS_NULL, rY); + this._LargeurBerge = new ParamDefinition(ComputeNodeType.SectionParametree, 'LargeurBerge', ParamDomainValue.POS_NULL, rLargeurBerge); } /** diff --git a/tsconfig.json b/tsconfig.json index f91d40afc344ef239b8b8d4c7fbebc9f14dd1670..e5b0503469e05cc0e822ab774c1c6588fe2ed880 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,9 @@ "module": "commonjs", "outDir": "./build", "noImplicitAny": true, + "removeComments": true, + "noImplicitReturns": true, + "alwaysStrict": true, "sourceMap": true }, "exclude": [