Commit 0d5fc5fb authored by Grand Francois's avatar Grand Francois
Browse files

introduction de la classe JalhydObject destinée à être la base des paramètres, résultats, ...

Showing with 47 additions and 7 deletions
+47 -7
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;
}
}
......@@ -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 {
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment