diff --git a/src/app/calculators/cond_distri/cond_distri.config.json b/src/app/calculators/cond_distri/cond_distri.config.json index 696906531e32d119b56c715fcd9e372797afa788..06ef5a56c9a85540e1a3100e6a190345c4358f72 100644 --- a/src/app/calculators/cond_distri/cond_distri.config.json +++ b/src/app/calculators/cond_distri/cond_distri.config.json @@ -49,7 +49,6 @@ }, { "type": "options", - "idCal": "J", - "nodeType": "CondDistri" + "idCal": "J" } ] \ No newline at end of file diff --git a/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json b/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json index 08c41005db198d60e6c008dfc68ac52e255acc2d..1cc7e88615c807c55c24f05fbf35b38d4fe95fbc 100644 --- a/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json +++ b/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json @@ -239,7 +239,6 @@ }, { "type": "options", - "idCal": "J", - "nodeType": "LechaptCalmon" + "idCal": "J" } ] \ No newline at end of file diff --git a/src/app/calculators/pab-dimensions/pab-dimensions.config.json b/src/app/calculators/pab-dimensions/pab-dimensions.config.json index 0084011a0d9d9b031939fdc56546bd47fbe387c7..8ef2539adcf667ed17296a7b106feaa13acc78e6 100644 --- a/src/app/calculators/pab-dimensions/pab-dimensions.config.json +++ b/src/app/calculators/pab-dimensions/pab-dimensions.config.json @@ -32,7 +32,6 @@ }, { "type": "options", - "idCal": "V", - "nodeType": "PabDimensions" + "idCal": "V" } ] \ No newline at end of file diff --git a/src/app/calculators/pab-puissance/pab-puissance.config.json b/src/app/calculators/pab-puissance/pab-puissance.config.json index 9aeb0415d6ef7e0339b591650881811951c64dd2..0a9d8cc4b28217e8cd2682673f54ced64172bbc6 100644 --- a/src/app/calculators/pab-puissance/pab-puissance.config.json +++ b/src/app/calculators/pab-puissance/pab-puissance.config.json @@ -43,7 +43,6 @@ }, { "type": "options", - "idCal": "Pv", - "nodeType": "PabPuissance" + "idCal": "Pv" } ] \ No newline at end of file diff --git a/src/app/calculators/parallel-structures/parallel-structures.config.json b/src/app/calculators/parallel-structures/parallel-structures.config.json new file mode 100644 index 0000000000000000000000000000000000000000..840ccc54408b107250fb9d1083d2a18fac2c7c3d --- /dev/null +++ b/src/app/calculators/parallel-structures/parallel-structures.config.json @@ -0,0 +1,244 @@ +[ + { + "id": "fs_ouvrage", + "type": "fieldset", + "fields": [ + { + "id": "select_ouvrage", + "type": "select", + "select": [ + { + "id": "select_ouvrage_vanne_rect" + }, + { + "id": "select_ouvrage_vanne_circ" + }, + { + "id": "select_ouvrage_seuil_rect" + }, + { + "id": "select_ouvrage_seuil_trap" + }, + { + "id": "select_ouvrage_vanne_trap" + } + ] + }, + { + "id": "select_loidebit1", + "type": "select", + "dep_exist": [ + { + "refid": "select_ouvrage_vanne", + "refvalue": "select_ouvrage_vanne_rect" + }, + { + "refid": "select_ouvrage_vanne", + "refvalue": "select_ouvrage_vanne_circ" + }, + { + "refid": "select_ouvrage_vanne", + "refvalue": "select_ouvrage_seuil_rect" + } + ], + "select": [ + { + "id": "select_loidebit1_cemagref88" + }, + { + "id": "select_loidebit1_vannedenoye" + }, + { + "id": "select_loidebit1_vannenoye" + } + ] + }, + { + "id": "select_loidebit2", + "type": "select", + "dep_exist": [ + { + "refid": "select_ouvrage_vanne", + "refvalue": "select_ouvrage_seuil_trap" + }, + { + "refid": "select_ouvrage_vanne", + "refvalue": "select_ouvrage_vanne_trap" + } + ], + "select": [ + { + "id": "select_loidebit4_cemagref88" + } + ] + } + ] + }, + { + "id": "fs_caract_1", + "type": "fieldset", + "dep_exist": [ + { + "refid": "select_ouvrage_vanne", + "refvalue": "select_ouvrage_vanne_rect" + }, + { + "refid": "select_ouvrage_vanne", + "refvalue": "select_ouvrage_vanne_circ" + } + ], + "fields": [ + { + "type": "input", + "id": "larg", + "unit": "m", + "value": 2 + }, + { + "type": "input", + "id": "ouv", + "unit": "m", + "value": 0.5 + }, + { + "type": "input", + "id": "kq", + "unit": "", + "value": 0.4 + } + ] + }, + { + "id": "fs_caract_2", + "type": "fieldset", + "dep_exist": [ + { + "refid": "select_ouvrage_vanne", + "refvalue": "select_ouvrage_seuil_rect" + } + ], + "fields": [ + { + "type": "input", + "id": "larg", + "unit": "m", + "value": 2 + }, + { + "type": "input", + "id": "kq", + "unit": "", + "value": 0.4 + } + ] + }, + { + "id": "fs_caract_3", + "type": "fieldset", + "dep_exist": [ + { + "refid": "select_ouvrage_vanne", + "refvalue": "select_ouvrage_seuil_trap" + }, + { + "refid": "select_ouvrage_vanne", + "refvalue": "select_ouvrage_vanne_trap" + } + ], + "fields": [ + { + "type": "input", + "id": "largf", + "unit": "m", + "value": 2 + }, + { + "type": "input", + "id": "kqr", + "unit": "", + "value": 0.4 + }, + { + "type": "input", + "id": "kqt", + "unit": "", + "value": 0.5 + }, + { + "type": "input", + "id": "fruit", + "unit": "m/m", + "value": 0.56 + } + ] + }, + { + "id": "fs_surverse", + "type": "fieldset", + "dep_exist": [ + { + "id": "select_ouvrage_vanne_rect" + }, + { + "id": "select_ouvrage_vanne_circ" + }, + { + "id": "select_ouvrage_vanne_trap" + } + ], + "fields": [ + { + "type": "bool", + "id": "surverse", + "value": false + } + ] + }, + { + "id": "fs_hydraulique", + "type": "fieldset", + "name": "Caractéristiques globales", + "option": "cal", + "fields": [ + { + "type": "input", + "id": "Q", + "unit": "m³/s", + "value": 3 + }, + { + "type": "input", + "id": "D", + "unit": "m", + "value": 1.2 + }, + { + "type": "input", + "id": "J", + "unit": "m", + "value": 0.6 + }, + { + "type": "input", + "id": "Lg", + "unit": "m", + "value": 100 + } + ] + }, + { + "id": "fs_param_calc", + "type": "fieldset", + "option": "fix", + "fields": [ + { + "type": "input", + "id": "Pr" + } + ] + }, + { + "type": "options", + "idCal": "J" + } +] \ No newline at end of file diff --git a/src/app/calculators/parallel-structures/parallel-structures.fr.json b/src/app/calculators/parallel-structures/parallel-structures.fr.json new file mode 100644 index 0000000000000000000000000000000000000000..ce4d974c577834aaba2dc09d4d62ba6d1b098f7c --- /dev/null +++ b/src/app/calculators/parallel-structures/parallel-structures.fr.json @@ -0,0 +1,32 @@ +{ + "fs_ouvrage": "Type d'ouvrage", + "select_ouvrage": "Ouvrage", + "select_ouvrage_vanne_rect": "Vanne rectangulaire", + "select_loidebit1": "Loi de débit", + "select_loidebit1_cemagref88": "Déversoir/Orifice Cemagref 88", + "select_loidebit1_vannedenoye": "Vanne dénoyé", + "select_loidebit1_vannenoye": "Vanne noyé", + "select_loidebit2": "Loi de débit", + "select_loidebit2_cemagref88": "Déversoir/Orifice Cemagref 88", + "select_ouvrage_circ": "Vanne circulaire", + "select_ouvrage_seuil_rect": "Seuil rectangulaire", + "select_ouvrage_seuil_trap": "Seuil trapézoïdal", + "select_ouvrage_vanne_trap": "Vanne trapézoïdale", + "fs_caract_1": "Caractéristiques de l'ouvrage", + "larg": "Largeur", + "ouv": "Ouverture", + "kq": "Coefficient de débit", + "fs_caract_2": "Caractéristiques de l'ouvrage", + "fs_caract_3": "Caractéristiques de l'ouvrage", + "largf": "Largeur au fond", + "kqr": "Coefficient de débit partie rectangulaire", + "kqt": "Coefficient de débit partie triangulaire", + "fruit": "Fruit", + "fs_surverse": "Surverse", + "fs_hydraulique": "Caractéristiques globales", + "Q": "Débit", + "Y_A": "Cote de l'eau à l'amont", + "Y_a": "Cote de l'eau à l'aval", + "fs_param_calc": "Paramètres de calcul", + "Pr": "Précision de calcul" +} \ No newline at end of file diff --git a/src/app/calculators/regime-uniforme/regime-uniforme.config.json b/src/app/calculators/regime-uniforme/regime-uniforme.config.json index 228b17e7f1c1eea6dee4bdb4e10a8ae65ec6b21a..29ba446e2abcd91ced3777d73c9babf0933ea356 100644 --- a/src/app/calculators/regime-uniforme/regime-uniforme.config.json +++ b/src/app/calculators/regime-uniforme/regime-uniforme.config.json @@ -26,7 +26,7 @@ { "id": "fs_section_trapez", "type": "fieldset", - "nodeType": "RegimeUniformeTrapeze", + "nodeType": "SectionTrapeze", "option": "cal", "dep_exist": [ { @@ -52,7 +52,7 @@ { "id": "fs_section_rect", "type": "fieldset", - "nodeType": "RegimeUniformeRectangle", + "nodeType": "SectionRectangle", "option": "cal", "dep_exist": [ { @@ -72,7 +72,7 @@ { "id": "fs_section_circ", "type": "fieldset", - "nodeType": "RegimeUniformeCercle", + "nodeType": "SectionCercle", "option": "cal", "dep_exist": [ { @@ -92,7 +92,7 @@ { "id": "fs_section_puiss", "type": "fieldset", - "nodeType": "RegimeUniformePuissance", + "nodeType": "SectionPuissance", "option": "cal", "dep_exist": [ { @@ -173,7 +173,6 @@ { "type": "options", "idCal": "Q", - "nodeType": "RegimeUniforme", "sectionSelectId": "select_section" } ] \ No newline at end of file diff --git a/src/app/calculators/remous/remous.config.json b/src/app/calculators/remous/remous.config.json index 6dbe78356dcfa5ad4a3852162a7c196e154ec527..61afbc02d7169ac14410ad57926c2b96a6d1d4ff 100644 --- a/src/app/calculators/remous/remous.config.json +++ b/src/app/calculators/remous/remous.config.json @@ -26,7 +26,7 @@ { "id": "fs_section_trapez", "type": "fieldset", - "nodeType": "CourbeRemousTrapeze", + "nodeType": "SectionTrapeze", "option": "fix", "dep_exist": [ { @@ -52,7 +52,7 @@ { "id": "fs_section_rect", "type": "fieldset", - "nodeType": "CourbeRemousRectangle", + "nodeType": "SectionRectangle", "option": "fix", "dep_exist": [ { @@ -72,7 +72,7 @@ { "id": "fs_section_circ", "type": "fieldset", - "nodeType": "CourbeRemousCercle", + "nodeType": "SectionCercle", "option": "fix", "dep_exist": [ { @@ -92,7 +92,7 @@ { "id": "fs_section_puiss", "type": "fieldset", - "nodeType": "CourbeRemousPuissance", + "nodeType": "SectionPuissance", "option": "fix", "dep_exist": [ { @@ -265,7 +265,6 @@ }, { "type": "options", - "nodeType": "CourbeRemous", "sectionSelectId": "select_section" } ] \ No newline at end of file diff --git a/src/app/calculators/section-param/section-param.config.json b/src/app/calculators/section-param/section-param.config.json index b59a813cdf406b38a9a780a7176e315ab8d8ff74..a082a2db933175586f7dc2615e9290072d91b1cc 100644 --- a/src/app/calculators/section-param/section-param.config.json +++ b/src/app/calculators/section-param/section-param.config.json @@ -277,7 +277,6 @@ }, { "type": "options", - "nodeType": "SectionParametree", "sectionSelectId": "select_section" } ] \ No newline at end of file diff --git a/src/app/components/calculator-list/calculator-list.component.ts b/src/app/components/calculator-list/calculator-list.component.ts index 9ce84d292495902ff634fef4cbfbdd05d42ad049..9a10529fa5401dabae61b9381f2ee826068e46e4 100644 --- a/src/app/components/calculator-list/calculator-list.component.ts +++ b/src/app/components/calculator-list/calculator-list.component.ts @@ -1,9 +1,9 @@ import { Component, OnInit } from "@angular/core"; import { Router } from '@angular/router'; -import { EnumEx } from "jalhyd"; +import { CalculatorType, EnumEx } from "jalhyd"; -import { CalculatorType, FormulaireDefinition } from "../../formulaire/formulaire-definition"; +import { FormulaireDefinition } from "../../formulaire/formulaire-definition"; import { FormulaireService } from "../../services/formulaire/formulaire.service"; import { InternationalisationService } from '../../services/internationalisation/internationalisation.service'; diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts index 2228bf7bbc6d32c674534b5c51d49bb9c667dc11..6656f0c8c9ac609e4a74d89d9b5cc520d5f0401b 100644 --- a/src/app/components/generic-calculator/calculator.component.ts +++ b/src/app/components/generic-calculator/calculator.component.ts @@ -5,7 +5,6 @@ import { FormulaireService } from "../../services/formulaire/formulaire.service" import { InternationalisationService } from "../../services/internationalisation/internationalisation.service"; import { FieldSet } from "../../formulaire/fieldset"; import { FormulaireDefinition } from "../../formulaire/formulaire-definition"; -import { CalculatorType } from "../../formulaire/formulaire-definition"; import { CalculatorResultsComponent } from "../../components/calculator-results/calculator-results.component"; import { Observer } from "../../services/observer"; import { Subscription } from "rxjs/Subscription"; diff --git a/src/app/formulaire/formulaire-definition.ts b/src/app/formulaire/formulaire-definition.ts index 312a54436a644634a86969fcb806dfac97b2894d..61d5a65fd3f16d464170d00a308f2ba106c2f1b1 100644 --- a/src/app/formulaire/formulaire-definition.ts +++ b/src/app/formulaire/formulaire-definition.ts @@ -1,4 +1,5 @@ -import { ComputeNodeType, ParamsEquation, Nub, acSection, RegimeUniforme, MethodeResolution, CourbeRemousParams, CourbeRemous, ParamDomainValue, Result, ResultElement } from "jalhyd"; +import { CalculatorType, ComputeNodeType, ParamsEquation, Nub, acSection, RegimeUniforme, MethodeResolution } from "jalhyd"; +import { CourbeRemous, CourbeRemousParams, ParamDomainValue, Result, ResultElement } from "jalhyd"; import { ParamsSectionRectang, cSnRectang, ParamsSectionCirc, cSnCirc, ParamsSectionPuiss, cSnPuiss } from "jalhyd"; import { ConduiteDistrib, ConduiteDistribParams, LechaptCalmon, LechaptCalmonParams, ParamsSectionTrapez, cSnTrapez } from "jalhyd"; import { PabDimension, PabDimensionParams, PabPuissance, PabPuissanceParams } from "jalhyd"; @@ -26,13 +27,6 @@ import { StringMap } from "../stringmap"; import { Observable } from "../services/observer"; -export enum CalculatorType { - ConduiteDistributrice, LechaptCalmon, SectionParametree, RegimeUniforme, CourbeRemous, - PabDimensions, // passe à bassin rectangulaire - PabPuissance, // passe à bassin : puissance dissipée -} - - export class FormulaireDefinition extends Observable { /** * objet JSON chargé depuis le fichier de configuration de la calculette @@ -53,15 +47,10 @@ export class FormulaireDefinition extends Observable { */ private _sectionSelectFieldId: string; - /** - * type de noeud de calcul par défaut - */ - private _defaultNodeType: ComputeNodeType; - /** * type de noeud de calcul actuel (utilisé pour les sections) */ - private _nodeType: ComputeNodeType; + private _nodeType: ComputeNodeType = ComputeNodeType.None; /** * résultats fixes/variables @@ -137,7 +126,7 @@ export class FormulaireDefinition extends Observable { let res: FieldSet[] = []; for (let fs of this._fieldSets) - if (fs.computeNodeType == this._nodeType || fs.computeNodeType == this._defaultNodeType) + if (fs.computeNodeType == this._nodeType || fs.computeNodeType == ComputeNodeType.None) res.push(fs); return res; @@ -197,79 +186,37 @@ export class FormulaireDefinition extends Observable { } public updateNodeType() { - this._nodeType = this.getNodeTypeFromSelectField(this._calcType); + this._nodeType = this.getNodeTypeFromSelectField(); } - private getNodeTypeFromSelectField(calcType: CalculatorType): ComputeNodeType { + private getNodeTypeFromSelectField(): ComputeNodeType { if (this._sectionSelectFieldId != undefined) { let ssf: SelectField = <SelectField>this.getFormulaireElementById(this._sectionSelectFieldId); let val = ssf.getValue(); let type: string = this.removePrefix(val, this._sectionSelectFieldId + "_"); if (type != undefined) - return this.getComputeNodeTypeFromSection(type, calcType); + return this.getComputeNodeTypeFromSection(type); } return undefined; } - private getComputeNodeTypeFromSection(sect: string, calc: CalculatorType): ComputeNodeType { - switch (calc) { - case CalculatorType.SectionParametree: - switch (sect) { - case "trapez": - return ComputeNodeType.SectionTrapeze; - - case "rect": - return ComputeNodeType.SectionRectangle; - - case "circ": - return ComputeNodeType.SectionCercle; - - case "puiss": - return ComputeNodeType.SectionPuissance; - - default: - throw "getComputeNodeTypeFromSection() : section " + sect + " / type de calculette " + CalculatorType[calc] + " non pris en charge" - } - - case CalculatorType.RegimeUniforme: - switch (sect) { - case "trapez": - return ComputeNodeType.RegimeUniformeTrapeze; - - case "rect": - return ComputeNodeType.RegimeUniformeRectangle; - - case "circ": - return ComputeNodeType.RegimeUniformeCercle; - - case "puiss": - return ComputeNodeType.RegimeUniformePuissance; - - default: - throw "getComputeNodeTypeFromSection() : section " + sect + " / type de calculette " + CalculatorType[calc] + " non pris en charge" - } - - case CalculatorType.CourbeRemous: - switch (sect) { - case "trapez": - return ComputeNodeType.CourbeRemousTrapeze; - - case "rect": - return ComputeNodeType.CourbeRemousRectangle; + private getComputeNodeTypeFromSection(sect: string): ComputeNodeType { + switch (sect) { + case "trapez": + return ComputeNodeType.SectionTrapeze; - case "circ": - return ComputeNodeType.CourbeRemousCercle; + case "rect": + return ComputeNodeType.SectionRectangle; - case "puiss": - return ComputeNodeType.CourbeRemousPuissance; + case "circ": + return ComputeNodeType.SectionCercle; - default: - throw "getComputeNodeTypeFromSection() : section " + sect + " / type de calculette " + CalculatorType[calc] + " non pris en charge" - } + case "puiss": + return ComputeNodeType.SectionPuissance; default: - throw "getComputeNodeTypeFromSection() : section " + sect + " / type de calculette " + CalculatorType[calc] + " non pris en charge" + throw new Error(`getComputeNodeTypeFromSection() : section ${sect} non pris en charge`); } } @@ -408,14 +355,14 @@ export class FormulaireDefinition extends Observable { } } - if (nodeType != this._defaultNodeType) - return this.getNodeParameterValue(this._defaultNodeType, symbol); + if (nodeType != ComputeNodeType.None) + return this.getNodeParameterValue(ComputeNodeType.None, symbol); throw "Formulaire.getNodeParameterValue() : pas de paramètre " + symbol + " trouvé pour le noeud " + ComputeNodeType[nodeType] + "(" + nodeType + ")"; } private getParameterValue(symbol: string): number { - return this.getNodeParameterValue(this._defaultNodeType, symbol); + return this.getNodeParameterValue(ComputeNodeType.None, symbol); } private getSectionComputedParam(): { symbol: string, label: string } { @@ -535,9 +482,9 @@ export class FormulaireDefinition extends Observable { private parse_input(node_type: ComputeNodeType, fieldset: {}, field: {}): NgParameter { let input_id: string = field["id"]; - let res: NgParameter = this.paramService.createParameter(node_type, input_id, this._uid); + let res: NgParameter = this.paramService.createParameter(this._calcType, node_type, input_id, this._uid); if (res == undefined) - throw "pas de paramètre '" + input_id + "' trouvé dans le noeud " + ComputeNodeType[node_type] + "(" + node_type + ") ou " + ComputeNodeType[this._defaultNodeType] + "(" + this._defaultNodeType + ")"; + throw new Error(`pas de paramètre '${input_id}' trouvé dans le noeud ${ComputeNodeType[node_type]} (${node_type}) ou ComputeNodeType.None`); res.unit = field["unit"]; if (input_id == "Pr") @@ -558,8 +505,7 @@ export class FormulaireDefinition extends Observable { private parse_fieldset(fieldset: {}) { const fs_id: string = fieldset["id"]; const nt: string = fieldset["nodeType"]; - let node_type: ComputeNodeType; - node_type = nt == undefined ? this._defaultNodeType : ComputeNodeType[nt]; + let node_type: ComputeNodeType = nt == undefined ? ComputeNodeType.None : ComputeNodeType[nt]; const res: FieldSet = new FieldSet(node_type, fs_id, this._uid); this._fieldSets.push(res); @@ -593,19 +539,11 @@ export class FormulaireDefinition extends Observable { return undefined; } - private parseDefaultNodeType() { - let nt: string = this.getOption("nodeType"); - if (nt == undefined) - throw new Error("l'option obligatoire 'nodeType' est absente du fichier de définition de formulaire"); - this._defaultNodeType = ComputeNodeType[nt]; - } - public parseConfig(config: {}) { this._config = config; this._dependencies = []; this._defaultCalculatedParam = undefined; - this.parseDefaultNodeType(); for (let conf_index in this._config) { const conf = this._config[conf_index]; @@ -699,7 +637,7 @@ export class FormulaireDefinition extends Observable { if (strict) return res; - return res || nodeType == ComputeNodeType.SectionParametree + return res || this._calcType == CalculatorType.SectionParametree } private addFixedResults(displaySymbol: boolean) { @@ -736,7 +674,7 @@ export class FormulaireDefinition extends Observable { this._fixVarResults.setVariableParamHeaderFromParameter(varParam, false); this._fixVarResults.setVariableResultHeader(computedParam["label"]); - let nodeType: ComputeNodeType = this.getNodeTypeFromSelectField(CalculatorType.SectionParametree); + let nodeType: ComputeNodeType = this.getNodeTypeFromSelectField(); var np: [acSection, ParamsEquation] = this.getSectionNubAndParameters(nodeType); let sect: acSection = np[0]; @@ -770,7 +708,7 @@ export class FormulaireDefinition extends Observable { return; } - let nodeType: ComputeNodeType = this.getNodeTypeFromSelectField(CalculatorType.SectionParametree); + let nodeType: ComputeNodeType = this.getNodeTypeFromSelectField(); var np: [acSection, ParamsEquation] = this.getSectionNubAndParameters(nodeType); let sect: acSection = np[0]; @@ -778,7 +716,7 @@ export class FormulaireDefinition extends Observable { this._sectionResults.section = sect; - let computePrec: number = this.getNodeParameterValue(ComputeNodeType.SectionParametree, "Pr"); // précision de calcul + let computePrec: number = this.getNodeParameterValue(ComputeNodeType.None, "Pr"); // précision de calcul let nDigits = -Math.log10(computePrec); let Y = prms.map.Y.v; // tirant d'eau original (doit être fourni à acSection.Calc() sous peine d'être modifié par les appels successifs car c'est en même temps un paramètre et une variable temporaire) @@ -853,18 +791,18 @@ export class FormulaireDefinition extends Observable { } private doComputeRemous() { - let nodeType: ComputeNodeType = this.getNodeTypeFromSelectField(CalculatorType.CourbeRemous); + let nodeType: ComputeNodeType = this.getNodeTypeFromSelectField(); var np: [acSection, ParamsEquation] = this.getSectionNubAndParameters(nodeType, false); let sect: acSection = np[0]; let prmSect: ParamsEquation = np[1]; - let Yamont: number = this.getNodeParameterValue(ComputeNodeType.CourbeRemous, "Yamont"); // tirant amont - let Yaval: number = this.getNodeParameterValue(ComputeNodeType.CourbeRemous, "Yaval"); // tirant aval - let Dx: number = this.getNodeParameterValue(ComputeNodeType.CourbeRemous, "Dx"); // pas de discrétisation - let Long: number = this.getNodeParameterValue(ComputeNodeType.CourbeRemous, "Long"); // longueur du bief - let If: number = this.getNodeParameterValue(ComputeNodeType.CourbeRemous, "If"); // pente du fond - let YB: number = this.getNodeParameterValue(ComputeNodeType.CourbeRemous, "YB"); // hauteur de berge + let Yamont: number = this.getNodeParameterValue(nodeType, "Yamont"); // tirant amont + let Yaval: number = this.getNodeParameterValue(nodeType, "Yaval"); // tirant aval + let Dx: number = this.getNodeParameterValue(nodeType, "Dx"); // pas de discrétisation + let Long: number = this.getNodeParameterValue(nodeType, "Long"); // longueur du bief + let If: number = this.getNodeParameterValue(nodeType, "If"); // pente du fond + let YB: number = this.getNodeParameterValue(nodeType, "YB"); // hauteur de berge let Yn: Result = sect.Calc("Yn"); // hauteur normale let Yc: Result = sect.Calc("Yc"); // hauteur critique @@ -997,8 +935,6 @@ export class FormulaireDefinition extends Observable { switch (nt) { case ComputeNodeType.SectionTrapeze: - case ComputeNodeType.RegimeUniformeTrapeze: - case ComputeNodeType.CourbeRemousTrapeze: { let LargeurFond = this.getNodeParameterValue(nt, "LargeurFond"); // Largeur au fond let Fruit = this.getNodeParameterValue(nt, "Fruit"); // Fruit des berges @@ -1009,8 +945,6 @@ export class FormulaireDefinition extends Observable { } case ComputeNodeType.SectionRectangle: - case ComputeNodeType.RegimeUniformeRectangle: - case ComputeNodeType.CourbeRemousRectangle: { let LargeurFond = this.getNodeParameterValue(nt, "LargeurBerge"); // Largeur au fond let prms = new ParamsSectionRectang(Y, LargeurFond, Ks, Q, If, Prec, YB); @@ -1020,8 +954,6 @@ export class FormulaireDefinition extends Observable { } case ComputeNodeType.SectionCercle: - case ComputeNodeType.RegimeUniformeCercle: - case ComputeNodeType.CourbeRemousCercle: { let D = this.getNodeParameterValue(nt, "D"); // Largeur au fond let prms = new ParamsSectionCirc(D, Y, Ks, Q, If, Prec, YB); @@ -1031,8 +963,6 @@ export class FormulaireDefinition extends Observable { } case ComputeNodeType.SectionPuissance: - case ComputeNodeType.RegimeUniformePuissance: - case ComputeNodeType.CourbeRemousPuissance: { let k = this.getNodeParameterValue(nt, "k"); // coefficient let LargeurBerge = this.getNodeParameterValue(nt, "LargeurBerge"); // Largeur au niveau des berges diff --git a/src/app/services/formulaire/formulaire.service.ts b/src/app/services/formulaire/formulaire.service.ts index 5c313c89931a990fb48be6395c9543a0caf2cd6c..03038d8136ec47cda1c3849bdfeea01ad0de4816 100644 --- a/src/app/services/formulaire/formulaire.service.ts +++ b/src/app/services/formulaire/formulaire.service.ts @@ -3,13 +3,13 @@ import { Response } from "@angular/http"; import { Observable as rxObservable } from "rxjs/Observable"; import "rxjs/add/operator/toPromise"; -import { EnumEx } from "jalhyd"; +import { CalculatorType, EnumEx } from "jalhyd"; import { ParamService } from "../param/param.service"; import { HttpService } from "../../services/http/http.service"; import { InternationalisationService } from "../../services/internationalisation/internationalisation.service"; import { ApplicationSetupService } from "../../services/app-setup/app-setup.service"; -import { FormulaireDefinition, CalculatorType } from "../../formulaire/formulaire-definition"; +import { FormulaireDefinition } from "../../formulaire/formulaire-definition"; import { FormulaireElement } from "../../formulaire/formulaire-element"; import { InputField } from "../../formulaire/input-field"; import { SelectField } from "../../formulaire/select-field"; @@ -210,6 +210,12 @@ export class FormulaireService extends Observable { case CalculatorType.PabPuissance: return "app/calculators/pab-puissance/pab-puissance."; + case CalculatorType.Structure: + return "app/calculators/ouvrages/ouvrages."; + + case CalculatorType.ParallelStructure: + return "app/calculators/parallel-structures/parallel-structures."; + default: throw "FormulaireService.getConfigPathPrefix() : valeur de CalculatorType " + ct + " non implémentée" } diff --git a/src/app/services/param/param.service.ts b/src/app/services/param/param.service.ts index a56076a61b4902525e01c3c5f374ac83cece20e3..91591c06e862cc4ea44043a25cb0549b0f07a78d 100644 --- a/src/app/services/param/param.service.ts +++ b/src/app/services/param/param.service.ts @@ -1,112 +1,24 @@ -import { ParamDomain, ComputeNodeType, ComputeNodeParameters, ParamsEquation, ParamDefinition, ParamDomainValue, ParamCalculability } from "jalhyd"; +import { ParamDomain, ComputeNodeType, ComputeNodeParameters, ParamsEquation, ParamDefinition, ParamDomainValue, ParamCalculability, CalculatorType } from "jalhyd"; import { NgParameter } from "../../formulaire/ngparam"; import { logObject } from "../../util"; export class ParamService { - private _params: ParamDefinition[]; - - constructor() { - this._params = []; - - this.addParameters(ComputeNodeType.CondDistri); - this.addParameters(ComputeNodeType.LechaptCalmon); - this.addParameters(ComputeNodeType.SectionTrapeze); - this.addParameters(ComputeNodeType.SectionRectangle); - this.addParameters(ComputeNodeType.SectionCercle); - this.addParameters(ComputeNodeType.SectionPuissance); - this.addParameters(ComputeNodeType.RegimeUniformeTrapeze); - this.addParameters(ComputeNodeType.RegimeUniformeRectangle); - this.addParameters(ComputeNodeType.RegimeUniformeCercle); - this.addParameters(ComputeNodeType.RegimeUniformePuissance); - this.addParameters(ComputeNodeType.CourbeRemousCercle); - this.addParameters(ComputeNodeType.CourbeRemousPuissance); - this.addParameters(ComputeNodeType.CourbeRemousRectangle); - this.addParameters(ComputeNodeType.CourbeRemousTrapeze); - this.addParameters(ComputeNodeType.PabDimensions); - this.addParameters(ComputeNodeType.PabPuissance); - - // précision de calcul - - let d = new ParamDomain(ParamDomainValue.INTERVAL, 1e-10, 100); - let p = new ParamDefinition(ComputeNodeType.LechaptCalmon, 'Pr', d); - p.calculability = ParamCalculability.FREE; - this.addParameter(p); - - p = new ParamDefinition(ComputeNodeType.CondDistri, 'Pr', d); - p.calculability = ParamCalculability.FREE; - this.addParameter(p); - - p = new ParamDefinition(ComputeNodeType.SectionParametree, 'Pr', d); - p.calculability = ParamCalculability.FREE; - this.addParameter(p); - - p = new ParamDefinition(ComputeNodeType.RegimeUniforme, 'Pr', d); - p.calculability = ParamCalculability.FREE; - this.addParameter(p); - - p = new ParamDefinition(ComputeNodeType.CourbeRemous, 'Pr', d); + private createAccuracyParameter(calcType: CalculatorType): ParamDefinition { + const d = new ParamDomain(ParamDomainValue.INTERVAL, 1e-10, 100); + const p = new ParamDefinition(calcType, 'Pr', d); p.calculability = ParamCalculability.FREE; - this.addParameter(p); - - p = new ParamDefinition(ComputeNodeType.PabPuissance, 'Pr', d); - p.calculability = ParamCalculability.FREE; - this.addParameter(p); - - // logObject(this._params); - } - - private addParameter(p: ParamDefinition) { - if (!this.hasParameter(p.computeNodeType, p.symbol)) - this._params.push(p); - } - - private addParameters(nodeType: ComputeNodeType) { - let cdp: ParamsEquation = ComputeNodeParameters.getInstance().getComputeNodeParameters(nodeType); - for (let pi in cdp.map) { - let p: ParamDefinition = cdp.map[pi]; - this.addParameter(p); - } + return p; } - /** - * vérifie si un noeud possède un paramètre donné - * @param nodeType type de noeud - * @param symbol symbole à vérifier - */ - private hasParameter(nodeType: ComputeNodeType, symbol: string): ParamDefinition { - for (let p of this._params) - if (p.computeNodeType == nodeType && p.symbol == symbol) - return p; - - switch (nodeType) { - case ComputeNodeType.SectionCercle: - case ComputeNodeType.SectionPuissance: - case ComputeNodeType.SectionRectangle: - case ComputeNodeType.SectionTrapeze: - return this.hasParameter(ComputeNodeType.SectionParametree, symbol); - - case ComputeNodeType.RegimeUniformeCercle: - case ComputeNodeType.RegimeUniformePuissance: - case ComputeNodeType.RegimeUniformeRectangle: - case ComputeNodeType.RegimeUniformeTrapeze: - return this.hasParameter(ComputeNodeType.RegimeUniforme, symbol); - - case ComputeNodeType.CourbeRemousCercle: - case ComputeNodeType.CourbeRemousPuissance: - case ComputeNodeType.CourbeRemousRectangle: - case ComputeNodeType.CourbeRemousTrapeze: - return this.hasParameter(ComputeNodeType.CourbeRemous, symbol); - - default: - return undefined; - } - } + public createParameter(calcType: CalculatorType, nodeType: ComputeNodeType, symbol: string, formId: number): NgParameter { + if (symbol === "Pr") + var prmDef: ParamDefinition = this.createAccuracyParameter(calcType); + else + prmDef = ComputeNodeParameters.getInstance().getComputeNodeParameter(calcType, nodeType, symbol); - public createParameter(nodeType: ComputeNodeType, symbol: string, formId: number): NgParameter { - let prmDef: ParamDefinition = this.hasParameter(nodeType, symbol); if (prmDef == undefined) - throw "ParamService.createParameter() : pas de paramètre '" + symbol + "' pour le type de noeud " + ComputeNodeType[nodeType]; + throw new Error(`ParamService.createParameter() : pas de paramètre '${symbol}' pour la calculette ${CalculatorType[calcType]}/type de noeud ${ComputeNodeType[nodeType]}`); return new NgParameter(prmDef.clone(), formId); }