Commit 8b11619b authored by Dorchies David's avatar Dorchies David
Browse files

Fix #104

Showing with 73 additions and 48 deletions
+73 -48
...@@ -16,50 +16,6 @@ import { Result } from "./util/result"; ...@@ -16,50 +16,6 @@ import { Result } from "./util/result";
*/ */
export abstract class Nub extends ComputeNode implements IObservable { export abstract class Nub extends ComputeNode implements IObservable {
private static progressPercentageAccordedToChainCalculation = 50;
/** paramétrage de la dichotomie */
public dichoStartIntervalMaxSteps: number = 100;
/** pointer to parent Nub */
public parent: Nub;
/** parameter that is to be computed by default - to be overloaded by child classes */
protected _defaultCalculatedParam: ParamDefinition;
/** parameter that is to be computed */
protected _calculatedParam: ParamDefinition;
/** résultat de Calc()/CalcSerie() */
protected _result: Result;
/**
* List of children Nubs; browsed by parameters iterator.
* - for ParallelStructures: contains 0 or more Structures
* - for SectionNub : contains exactly 1 acSection
*/
protected _children: Nub[];
/** properties describing the Nub type */
protected _props: Props = new Props();
/** implémentation par délégation de IObservable */
private _observable: Observable;
/** a rough indication of calculation progress, between 0 and 100 */
private _progress: number = 0;
/** allows notifying of progress every X milliseconds only */
private previousNotificationTimestamp = 0;
public constructor(prms: ParamsEquation, dbg: boolean = false) {
super(prms, dbg);
this._children = [];
this._observable = new Observable();
this._defaultCalculatedParam = this.getFirstAnalyticalParameter();
this.resetDefaultCalculatedParam();
}
public get result(): Result { public get result(): Result {
return this._result; return this._result;
} }
...@@ -75,6 +31,24 @@ export abstract class Nub extends ComputeNode implements IObservable { ...@@ -75,6 +31,24 @@ export abstract class Nub extends ComputeNode implements IObservable {
this._props = props.clone(); this._props = props.clone();
} }
/**
* return ParamsEquation of all children recursively
*/
public get childrenPrms(): ParamsEquation[] {
const prms: ParamsEquation[] = [];
if (this._children.length) { // if called within constructor, default class member value is not set yet
for (const child of this._children) {
prms.push(child.prms);
if (child.getChildren()) {
if (child.getChildren().length) {
Nub.concatPrms(prms, child.childrenPrms);
}
}
}
}
return prms;
}
/** /**
* Returns an iterator over : * Returns an iterator over :
* - own parameters (this._prms) * - own parameters (this._prms)
...@@ -83,10 +57,8 @@ export abstract class Nub extends ComputeNode implements IObservable { ...@@ -83,10 +57,8 @@ export abstract class Nub extends ComputeNode implements IObservable {
public get parameterIterator(): IParamDefinitionIterator { public get parameterIterator(): IParamDefinitionIterator {
const prms: ParamsEquation[] = []; const prms: ParamsEquation[] = [];
prms.push(this._prms); prms.push(this._prms);
if (this._children) { // if called within constructor, default class member value is not set yet if (this._children) {
for (const child of this._children) { Nub.concatPrms(prms, this.childrenPrms);
prms.push(child.prms);
}
} }
return new ParamsEquationArrayIterator(prms); return new ParamsEquationArrayIterator(prms);
} }
...@@ -145,6 +117,58 @@ export abstract class Nub extends ComputeNode implements IObservable { ...@@ -145,6 +117,58 @@ export abstract class Nub extends ComputeNode implements IObservable {
} }
} }
private static progressPercentageAccordedToChainCalculation = 50;
private static concatPrms(p1: ParamsEquation[], p2: ParamsEquation[]): ParamsEquation[] {
const p3: ParamsEquation[] = p1;
for (const p of p2) {
p3.push(p);
}
return p3;
}
/** paramétrage de la dichotomie */
public dichoStartIntervalMaxSteps: number = 100;
/** pointer to parent Nub */
public parent: Nub;
/** parameter that is to be computed by default - to be overloaded by child classes */
protected _defaultCalculatedParam: ParamDefinition;
/** parameter that is to be computed */
protected _calculatedParam: ParamDefinition;
/** résultat de Calc()/CalcSerie() */
protected _result: Result;
/**
* List of children Nubs; browsed by parameters iterator.
* - for ParallelStructures: contains 0 or more Structures
* - for SectionNub : contains exactly 1 acSection
*/
protected _children: Nub[];
/** properties describing the Nub type */
protected _props: Props = new Props();
/** implémentation par délégation de IObservable */
private _observable: Observable;
/** a rough indication of calculation progress, between 0 and 100 */
private _progress: number = 0;
/** allows notifying of progress every X milliseconds only */
private previousNotificationTimestamp = 0;
public constructor(prms: ParamsEquation, dbg: boolean = false) {
super(prms, dbg);
this._children = [];
this._observable = new Observable();
this._defaultCalculatedParam = this.getFirstAnalyticalParameter();
this.resetDefaultCalculatedParam();
}
/** /**
* Finds the previous calculated parameter and sets its mode to SINGLE * Finds the previous calculated parameter and sets its mode to SINGLE
*/ */
...@@ -1207,4 +1231,5 @@ export abstract class Nub extends ComputeNode implements IObservable { ...@@ -1207,4 +1231,5 @@ export abstract class Nub extends ComputeNode implements IObservable {
const rPrec = this._prms.Pr.v; const rPrec = this._prms.Pr.v;
return dicho.Dichotomie(target.v, rPrec, rInit); return dicho.Dichotomie(target.v, rPrec, rInit);
} }
} }
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