Skip to content
Snippets Groups Projects
Commit 8b11619b authored by David Dorchies's avatar David Dorchies
Browse files

Fix #104

parent 4dfa0ec2
No related branches found
No related tags found
No related merge requests found
......@@ -16,50 +16,6 @@ import { Result } from "./util/result";
*/
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 {
return this._result;
}
......@@ -75,6 +31,24 @@ export abstract class Nub extends ComputeNode implements IObservable {
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 :
* - own parameters (this._prms)
......@@ -83,10 +57,8 @@ export abstract class Nub extends ComputeNode implements IObservable {
public get parameterIterator(): IParamDefinitionIterator {
const prms: ParamsEquation[] = [];
prms.push(this._prms);
if (this._children) { // if called within constructor, default class member value is not set yet
for (const child of this._children) {
prms.push(child.prms);
}
if (this._children) {
Nub.concatPrms(prms, this.childrenPrms);
}
return new ParamsEquationArrayIterator(prms);
}
......@@ -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
*/
......@@ -1207,4 +1231,5 @@ export abstract class Nub extends ComputeNode implements IObservable {
const rPrec = this._prms.Pr.v;
return dicho.Dichotomie(target.v, rPrec, rInit);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment