diff --git a/src/jalhyd_object.ts b/src/jalhyd_object.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c01127da53dbaca98d49d2fa9dfe7982bfeb47b --- /dev/null +++ b/src/jalhyd_object.ts @@ -0,0 +1,25 @@ +export abstract class JalhydObject { + /** + * id numérique unique + */ + private _uid: number; + + /** + * générateur d'id + */ + private static _uidSequence: number = 0; + + constructor() { + this._uid = JalhydObject.nextUID; + } + + public get uid(): number { + return this._uid; + } + + public static get nextUID(): number { + let res = this._uidSequence; + this._uidSequence++; + return res; + } +} diff --git a/src/param.ts b/src/param.ts index 98268a09649d38ae4bfb59e2cc0bf683e2caa212..ed9b00ad9757e8e0802c2d630b33854b06e97587 100644 --- a/src/param.ts +++ b/src/param.ts @@ -3,6 +3,7 @@ import { DefinedNumber } from "./util/definedvalue"; import { Interval } from "./util/interval"; import { Message, MessageCode } from "./util/message"; import { MapIterator } from "./util/iterator"; +import { JalhydObject } from "./jalhyd_object"; /** * domaine de définition du paramètre @@ -168,7 +169,7 @@ export enum ParamCalculability { * paramètre avec symbole et domaine de définition */ // tslint:disable-next-line:max-classes-per-file -export class BaseParam extends DefinedNumber { +export class BaseParam extends JalhydObject { /** * symbole */ @@ -179,9 +180,15 @@ export class BaseParam extends DefinedNumber { */ private _domain: ParamDomain; + /** + * valeur numérique (éventuellement non définie) + */ + private _value: DefinedNumber; + constructor(symb: string, d: ParamDomain | ParamDomainValue, val?: number) { - super(val); + super(); this._symbol = symb; + this._value = new DefinedNumber(val); if (d instanceof ParamDomain) { this._domain = d; @@ -208,23 +215,31 @@ export class BaseParam extends DefinedNumber { * gestion de la valeur */ + public get isDefined(): boolean { + return this._value.isDefined; + } + public getValue(): number { - if (!this.isDefined) { + if (!this._value.isDefined) { const e = new Message(MessageCode.ERROR_PARAMDEF_VALUE_UNDEFINED); e.extraVar.symbol = this.symbol; throw e; } - return super.getValue(); + return this._value.value; } public setValue(val: number) { this.checkValue(val); - super.setValue(val); + this._value.value = val; // console.log("setting param " + this._symbol + " id=" + this._id + " to " + val); // A VIRER } + public get uncheckedValue(): number { + return this._value.uncheckedValue; + } + public checkValue(v: number) { const sDomain = ParamDomainValue[this._domain.domain]; @@ -281,7 +296,7 @@ export class BaseParam extends DefinedNumber { } /** - * définition d'un paramètre d'un neud de calcul + * définition d'un paramètre d'un noeud de calcul */ // tslint:disable-next-line:max-classes-per-file export class ParamDefinition extends BaseParam { diff --git a/src/section/section_type.ts b/src/section/section_type.ts index 99f98b1fd19ac21575eaa666f479907723f8a313..7cc0467dee1aeff35225310065fb6cb0f7903e4b 100644 --- a/src/section/section_type.ts +++ b/src/section/section_type.ts @@ -262,7 +262,7 @@ export abstract class acSection extends ComputeNode { this.debug("in calcFromY(" + sDonnee + ", rY=" + rY + ") old " + sDonnee + "=" + this.arCalc[sDonnee]); this.debug("this.Y=" + this.prms.Y.toString()); - if (rY != undefined && (!this.prms.Y.isDefined || rY != this.prms.Y.v)) { + if (rY != undefined && (!this.prms.Y.isDefined || (this.prms.Y.isDefined && rY != this.prms.Y.v))) { this.prms.Y.v = rY; // On efface toutes les données dépendantes de Y pour forcer le calcul this.Reset(false);