diff --git a/src/app/calculators/regime-uniforme/regime-uniforme.config.json b/src/app/calculators/regime-uniforme/regime-uniforme.config.json index 5710ce3e1b1c62bce4c8402e11a398c034d1274c..7286a71d854c26253d79f644a1ee23f176901b13 100644 --- a/src/app/calculators/regime-uniforme/regime-uniforme.config.json +++ b/src/app/calculators/regime-uniforme/regime-uniforme.config.json @@ -2,7 +2,6 @@ { "id": "fs_section", "type": "fieldset", - "defaultNodeType": "SectionTrapeze", "option": "cal", "fields": [ { @@ -104,7 +103,6 @@ { "id": "fs_bief", "type": "fieldset", - "defaultNodeType": "SectionTrapeze", "option": "cal", "fields": [ { @@ -127,7 +125,6 @@ { "id": "fs_hydraulique", "type": "fieldset", - "defaultNodeType": "SectionTrapeze", "option": "cal", "fields": [ { @@ -145,7 +142,6 @@ { "id": "fs_param_calc", "type": "fieldset", - "defaultNodeType": "SectionTrapeze", "option": "fix", "fields": [ { diff --git a/src/app/calculators/remous/remous.config.json b/src/app/calculators/remous/remous.config.json index f530722a3210a51e2f269a6a41748b85e3314ebf..289a274e1025d7b6fcda32c5556734efe79fba3c 100644 --- a/src/app/calculators/remous/remous.config.json +++ b/src/app/calculators/remous/remous.config.json @@ -2,7 +2,6 @@ { "id": "fs_section", "type": "fieldset", - "defaultNodeType": "SectionTrapeze", "option": "fix", "fields": [ { @@ -104,7 +103,6 @@ { "id": "fs_bief", "type": "fieldset", - "defaultNodeType": "SectionTrapeze", "option": "fix", "fields": [ { @@ -132,7 +130,6 @@ { "id": "fs_condlim", "type": "fieldset", - "defaultNodeType": "SectionTrapeze", "option": "fix", "fields": [ { @@ -155,7 +152,6 @@ { "id": "fs_param_calc", "type": "fieldset", - "defaultNodeType": "SectionTrapeze", "option": "fix", "fields": [ { diff --git a/src/app/calculators/section-param/section-param.config.json b/src/app/calculators/section-param/section-param.config.json index 88aac4d949f05449c57ae25044a5931fe9b8565f..56ea1dd3cb265ab2e03c10c0fa9cd8689157168e 100644 --- a/src/app/calculators/section-param/section-param.config.json +++ b/src/app/calculators/section-param/section-param.config.json @@ -2,7 +2,6 @@ { "id": "fs_section", "type": "fieldset", - "defaultNodeType": "SectionTrapeze", "option": "var", "fields": [ { @@ -104,7 +103,6 @@ { "id": "fs_bief", "type": "fieldset", - "defaultNodeType": "SectionTrapeze", "option": "var", "fields": [ { @@ -127,7 +125,6 @@ { "id": "fs_hydraulique", "type": "fieldset", - "defaultNodeType": "SectionTrapeze", "option": "var", "fields": [ { @@ -145,7 +142,6 @@ { "id": "fs_param_calc", "type": "fieldset", - "defaultNodeType": "SectionTrapeze", "option": "fix", "fields": [ { diff --git a/src/app/formulaire/definition/concrete/form-cond-distri.ts b/src/app/formulaire/definition/concrete/form-cond-distri.ts index b79c5d50c422c29eb3ed00096c9e2bee525c0774..c9e70be83fe041ed100de2532b4b64ff14f2303e 100644 --- a/src/app/formulaire/definition/concrete/form-cond-distri.ts +++ b/src/app/formulaire/definition/concrete/form-cond-distri.ts @@ -16,13 +16,17 @@ export class FormulaireConduiteDistributrice extends FormulaireDefinition { private _formResult: FormResultFixedVar; constructor() { - super(CalculatorType.ConduiteDistributrice); + super(); this._formFixedVar = new FormDefFixedVar(this); this._formParamCalc = new FormDefParamToCalculate(this); this._formResult = new FormResultFixedVar(this, false); this._formCompute = new FormComputeFixedVar(this, this._formResult); } + protected get defaultProperties(): {} { + return { "calcType": CalculatorType.ConduiteDistributrice, "nodeType": ComputeNodeType.None }; + } + protected initParse() { this._formParamCalc.initParse(); } diff --git a/src/app/formulaire/definition/concrete/form-courbe-remous.ts b/src/app/formulaire/definition/concrete/form-courbe-remous.ts index 0f60d8a59e1c38e7ff3b7aedc5a99d803e67a7a9..d67e9bf24054149d46a542a767382dd6d4ede2ab 100644 --- a/src/app/formulaire/definition/concrete/form-courbe-remous.ts +++ b/src/app/formulaire/definition/concrete/form-courbe-remous.ts @@ -21,12 +21,16 @@ export class FormulaireCourbeRemous extends FormulaireDefinition { private _resolveMethSelectId: string; constructor() { - super(CalculatorType.CourbeRemous) + super(); this._formSection = new FormDefSection(this); this._formResult = new FormResultRemous(this); this._formCompute = new FormComputeCourbeRemous(this, this._formSection, this._formResult); } + protected get defaultProperties(): {} { + return { "calcType": CalculatorType.CourbeRemous, "nodeType": ComputeNodeType.SectionPuissance }; + } + protected parseOptions(json: {}) { this._formSection.parseOptions(json); diff --git a/src/app/formulaire/definition/concrete/form-lechapt-calmon.ts b/src/app/formulaire/definition/concrete/form-lechapt-calmon.ts index baf385278a86ef377612817a839b6e59f92f5ffb..96d6fad59683bc4d6cc15cd03e1ce2d7eeac1c0d 100644 --- a/src/app/formulaire/definition/concrete/form-lechapt-calmon.ts +++ b/src/app/formulaire/definition/concrete/form-lechapt-calmon.ts @@ -18,13 +18,17 @@ export class FormulaireLechaptCalmon extends FormulaireDefinition implements Obs private _formResult: FormResultFixedVar; constructor() { - super(CalculatorType.LechaptCalmon) + super(); this._formFixedVar = new FormDefFixedVar(this); this._formParamCalc = new FormDefParamToCalculate(this); this._formResult = new FormResultFixedVar(this, false); this._formCompute = new FormComputeFixedVar(this, this._formResult); } + protected get defaultProperties(): {} { + return { "calcType": CalculatorType.LechaptCalmon, "nodeType": ComputeNodeType.None }; + } + protected initParse() { this._formParamCalc.initParse(); } diff --git a/src/app/formulaire/definition/concrete/form-parallel-structures.ts b/src/app/formulaire/definition/concrete/form-parallel-structures.ts index 66838edba6c3e52e30279889cec8c0936ebf6fe4..d06971f41d48d3d6bd4a5a63fbc8d3521e3f4b9c 100644 --- a/src/app/formulaire/definition/concrete/form-parallel-structures.ts +++ b/src/app/formulaire/definition/concrete/form-parallel-structures.ts @@ -1,4 +1,4 @@ -import { CalculatorType, ComputeNodeType, Structure, ParallelStructure, SessionNub } from "jalhyd"; +import { CalculatorType, ComputeNodeType, Structure, ParallelStructure, SessionNub, StructureType, LoiDebit } from "jalhyd"; import { FormulaireDefinition } from "../form-definition"; import { CalculatorResults } from "../../../results/calculator-results"; @@ -33,7 +33,7 @@ export class FormulaireParallelStructure extends FormulaireDefinition { private __ouvrageSelectId: string; constructor() { - super(CalculatorType.ParallelStructure) + super(); this._formFixedVar = new FormDefFixedVar(this); this._formParamCalc = new FormDefParamToCalculate(this); this._formResult = new FormResultFixedVar(this, false); @@ -41,6 +41,13 @@ export class FormulaireParallelStructure extends FormulaireDefinition { this._formCompute = new FormComputeParallelStructures(this, this._formParallelStruct, this._formResult); } + protected get defaultProperties(): {} { + return { + "calcType": CalculatorType.ParallelStructure, "nodeType": ComputeNodeType.None, + "structureType": StructureType.SeuilRectangulaire, "loiDebit": LoiDebit.Cem88v + }; + } + private createStructNub(templ: FieldsetTemplate): SessionNub { const paramService: ParamService = ServiceFactory.instance.paramService; diff --git a/src/app/formulaire/definition/concrete/form-passe-bassin-dim.ts b/src/app/formulaire/definition/concrete/form-passe-bassin-dim.ts index bc8d202d131162619850b424d6227acc8e3c5b70..64a5141cdb1703b8f874265783afcd5b9dfff25c 100644 --- a/src/app/formulaire/definition/concrete/form-passe-bassin-dim.ts +++ b/src/app/formulaire/definition/concrete/form-passe-bassin-dim.ts @@ -17,13 +17,17 @@ export class FormulairePasseBassinDimensions extends FormulaireDefinition { private _formResult: FormResultFixedVar; constructor() { - super(CalculatorType.PabDimensions); + super(); this._formFixedVar = new FormDefFixedVar(this); this._formParamCalc = new FormDefParamToCalculate(this); this._formResult = new FormResultFixedVar(this, false); this._formCompute = new FormComputeFixedVar(this, this._formResult); } + protected get defaultProperties(): {} { + return { "calcType": CalculatorType.PabDimensions, "nodeType": ComputeNodeType.None }; + } + protected initParse() { this._formParamCalc.initParse(); } diff --git a/src/app/formulaire/definition/concrete/form-passe-bassin-puissance.ts b/src/app/formulaire/definition/concrete/form-passe-bassin-puissance.ts index 02ed7376af7c340c8337b49a367c75bf8f8e13e3..31d2a86390c4ffa51a2822bfbabee50653ad66d5 100644 --- a/src/app/formulaire/definition/concrete/form-passe-bassin-puissance.ts +++ b/src/app/formulaire/definition/concrete/form-passe-bassin-puissance.ts @@ -17,13 +17,17 @@ export class FormulairePasseBassinPuissance extends FormulaireDefinition { private _formResult: FormResultFixedVar; constructor() { - super(CalculatorType.PabPuissance); + super(); this._formFixedVar = new FormDefFixedVar(this); this._formParamCalc = new FormDefParamToCalculate(this); this._formResult = new FormResultFixedVar(this, false); this._formCompute = new FormComputeFixedVar(this, this._formResult); } + protected get defaultProperties(): {} { + return { "calcType": CalculatorType.PabPuissance, "nodeType": ComputeNodeType.None }; + } + protected initParse() { this._formParamCalc.initParse(); } diff --git a/src/app/formulaire/definition/concrete/form-regime-uniforme.ts b/src/app/formulaire/definition/concrete/form-regime-uniforme.ts index b4f322431ebc8cb74cd06e96855f68aa19b11555..50e7aeff7b5e5cc3f8f0eca81db18a7c88969f78 100644 --- a/src/app/formulaire/definition/concrete/form-regime-uniforme.ts +++ b/src/app/formulaire/definition/concrete/form-regime-uniforme.ts @@ -20,7 +20,7 @@ export class FormulaireRegimeUniforme extends FormulaireDefinition implements Ob private _formResult: FormResultFixedVar; constructor() { - super(CalculatorType.RegimeUniforme) + super(); this._formFixedVar = new FormDefFixedVar(this); this._formParamCalc = new FormDefParamToCalculate(this); this._formSection = new FormDefSection(this); @@ -28,6 +28,10 @@ export class FormulaireRegimeUniforme extends FormulaireDefinition implements Ob this._formCompute = new FormComputeFixedVar(this, this._formResult); } + protected get defaultProperties(): {} { + return { "calcType": CalculatorType.RegimeUniforme, "nodeType": ComputeNodeType.SectionCercle }; + } + protected initParse() { this._formParamCalc.initParse(); } diff --git a/src/app/formulaire/definition/concrete/form-section-parametree.ts b/src/app/formulaire/definition/concrete/form-section-parametree.ts index 63f636138d3f22505f32dbfd08574c8b8e252ddc..1f14c0f662e254bc5e3d81823e5e943f4362827d 100644 --- a/src/app/formulaire/definition/concrete/form-section-parametree.ts +++ b/src/app/formulaire/definition/concrete/form-section-parametree.ts @@ -22,13 +22,17 @@ export class FormulaireSectionParametree extends FormulaireDefinition { private _formSectionResult: FormResultSection; constructor() { - super(CalculatorType.SectionParametree); + super(); this._formFixedVar = new FormDefFixedVar(this); this._formSection = new FormDefSection(this); this._formSectionResult = new FormResultSection(this, this._formSection); this._formCompute = new FormComputeSectionParametree(this, this._formSection, this._formSectionResult); } + protected get defaultProperties(): {} { + return { "calcType": CalculatorType.SectionParametree, "nodeType": ComputeNodeType.SectionCercle }; + } + protected parseOptions(json: {}) { this._formSection.parseOptions(json); } diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index c596e5f4e13d5293800eed56d6171bdfdd2a8c47..7d577b03da01de75cecd1d97d0c94ea3f3085d23 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -20,11 +20,6 @@ import { FieldsetTemplate } from "../fieldset-template"; * classe de base pour tous les formulaires */ export abstract class FormulaireDefinition extends FormulaireNode implements Observer { - /** - * type de calculette - */ - private _calcType: CalculatorType; - /** * nom de la calculette */ @@ -47,15 +42,19 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs protected _paramService: ParamService; - constructor(calcType: CalculatorType) { + constructor() { super(undefined); - this._calcType = calcType; this._paramService = ServiceFactory.instance.paramService; - this.initSessionNub(); } public get calculatorType(): CalculatorType { - return this._calcType; + const props = this._currentSessionNub === undefined ? this.defaultProperties : this._currentSessionNub.properties.props; + return props["calcType"]; + } + + public get nodeType(): ComputeNodeType { + const props = this._currentSessionNub === undefined ? this.defaultProperties : this._currentSessionNub.properties.props; + return props["nodeType"]; } public get calculatorName() { @@ -70,15 +69,17 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs return this._jsonConfig; } - protected initSessionNub() { - this._currentSessionNub = this.createSessionNub({ "calcType": this._calcType, "nodeType": ComputeNodeType.None }); + protected abstract get defaultProperties(): {}; + + public initSessionNub(props?: {}) { + this._currentSessionNub = this.createSessionNub(props === undefined ? this.defaultProperties : props); } public get currentSessionNub(): SessionNub { return this._currentSessionNub; } - protected findNub(params: Props | {}) { + private findNub(params: Props | {}) { return this._paramService.findSessionNub(params); } diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 967d8388bbd88e66227e535ef036c67fc5bbd1b7..1a35a58bb3ad365632496e7018754207dd437e80 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -112,7 +112,7 @@ export class FieldSet extends FormulaireElement implements Observer { return this._props; } - public getPropValue(key: string): any { + private getPropValue(key: string): any { return this._props.getPropValue(key); } @@ -296,18 +296,9 @@ export class FieldSet extends FormulaireElement implements Observer { const calc_type: CalculatorType = ct == undefined ? this.parentForm.calculatorType : CalculatorType[ct]; this.setPropValue("calcType", calc_type); - const nt: string = json["nodeType"]; - const node_type: ComputeNodeType = nt == undefined ? ComputeNodeType.None : ComputeNodeType[nt]; - const dnt: string = json["defaultNodeType"]; - const default_node_type: ComputeNodeType = dnt == undefined ? ComputeNodeType.None : ComputeNodeType[dnt]; - - if (nt !== undefined && dnt !== undefined) - throw new Error("les champs 'nodeType' et 'defaultNodeType' ne doivent pas être définis en même temps") - - const ntype = dnt !== undefined ? default_node_type : node_type; - - this.setPropValue("nodeType", ntype); + const node_type: ComputeNodeType = dnt == undefined ? this.parentForm.nodeType : ComputeNodeType[dnt]; + this.setPropValue("nodeType", node_type); const st: string = json["defaultStructType"]; if (st)