diff --git a/e2e/tested_calctypes.ts b/e2e/tested_calctypes.ts index cdd1fc76623d3d0408d0232848ed10438a92395a..59041631826270cba7d5410fae53de50b9be7a9e 100644 --- a/e2e/tested_calctypes.ts +++ b/e2e/tested_calctypes.ts @@ -1,7 +1,9 @@ // cannot import JaLHyd here :/ // @WARNING keep in sync if CalculatorType enum order changes in JaLHyd export const testedCalcTypes = [ - 0, 1, 2, 3, 4, 5, 6, + 0, + // omit 1 - LechaptCalmon + 2, 3, 4, 5, 6, // omit 7 - Structure 8, 9, 10, 11, 12, 13, // omit 14 -Section diff --git a/jalhyd_branch b/jalhyd_branch index d64531f1305e091791eac674c3a36d86b9e17ddd..0bd0de8433c44aa322701f9bf4b87ff6d54b525c 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1 @@ -devel +334-restructurer-lechapt-et-calmon-pour-de-nouvelles-lois-de-pertes-de-charge diff --git a/src/app/calculators/lechaptcalmon/config.json b/src/app/calculators/pressureloss/config.json similarity index 57% rename from src/app/calculators/lechaptcalmon/config.json rename to src/app/calculators/pressureloss/config.json index 1633e8d94288652e6573960f5e2a937b57b40050..e74c60cd9129266e00927d7bedecfef2509cc91a 100644 --- a/src/app/calculators/lechaptcalmon/config.json +++ b/src/app/calculators/pressureloss/config.json @@ -1,8 +1,17 @@ [ { - "id": "fs_materiau", + "id": "fs_pressureloss_law", "type": "fieldset", "fields": [ + { + "id": "select_pressurelosstype", + "type": "select", + "property": "pressureLossType", + "default": "LechaptCalmon", + "help": { + "0": "hyd_en_charge/lechapt-calmon.html" + } + }, { "id": "select_material", "type": "select", @@ -22,11 +31,7 @@ "D", "J", "Lg", - "Ks" + "Kloc" ] - }, - { - "type": "options", - "help": "hyd_en_charge/lechapt-calmon.html" } ] diff --git a/src/app/calculators/lechaptcalmon/en.json b/src/app/calculators/pressureloss/en.json similarity index 84% rename from src/app/calculators/lechaptcalmon/en.json rename to src/app/calculators/pressureloss/en.json index 729994b0eefa9009092b821d43e3410b05358419..3ed24c3c74772516a9672ca3d85717fce126b768 100644 --- a/src/app/calculators/lechaptcalmon/en.json +++ b/src/app/calculators/pressureloss/en.json @@ -1,4 +1,8 @@ { + "fs_pressureloss_law": "Pressure loss", + "select_pressurelosstype": "Pressure loss law", + "PRESSURELOSSTYPE_0": "Lechapt-Calmon", + "fs_materiau": "Type of material", "select_material": "Choice of material", "MATERIAL_0": "Unlined cast iron - Coarse concrete (corrosive water)", @@ -16,7 +20,7 @@ "fs_hydraulique": "Hydraulic features", "D": "Pipe diameter", "J": "Total head loss", - "Ks": "Singular head loss coefficient", + "Kloc": "Singular head loss coefficient", "Lg": "Pipe length", "fs_param_calc": "Calculation parameters", "Jl": "Linear head loss", @@ -25,4 +29,4 @@ "UNIT_JL": "m", "UNIT_V": "m/s" -} \ No newline at end of file +} diff --git a/src/app/calculators/lechaptcalmon/fr.json b/src/app/calculators/pressureloss/fr.json similarity index 84% rename from src/app/calculators/lechaptcalmon/fr.json rename to src/app/calculators/pressureloss/fr.json index 89884cabd4634f566ed4d86d2a419de79000447f..9028496a312b980acc1064598ffa1db2b8e20f2a 100644 --- a/src/app/calculators/lechaptcalmon/fr.json +++ b/src/app/calculators/pressureloss/fr.json @@ -1,4 +1,8 @@ { + "fs_pressureloss_law": "Perte de charge", + "select_pressurelosstype": "Loi de perte de charge", + "PRESSURELOSSTYPE_0": "Lechapt-Calmon", + "fs_materiau": "Type du matériau", "select_material": "Choix du matériau", "MATERIAL_0": "Fonte ou acier non revêtus - Béton grossier (eau corrosive)", @@ -16,7 +20,7 @@ "fs_hydraulique": "Caractéristiques hydrauliques", "D": "Diamètre du tuyau", "J": "Perte de charge totale", - "Ks": "Coefficient de perte de charge singulière", + "Kloc": "Coefficient de perte de charge singulière", "Lg": "Longueur du tuyau", "fs_param_calc": "Paramètres de calcul", "Jl": "Perte de charge linéaire", @@ -25,4 +29,4 @@ "UNIT_JL": "m", "UNIT_V": "m/s" -} \ 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 ec0ec059a9df1cea2998e70ecbdbe9f0112580fa..b62c4f2e4cdbd58b89ee75fb1feebcc144edfe27 100644 --- a/src/app/components/calculator-list/calculator-list.component.ts +++ b/src/app/components/calculator-list/calculator-list.component.ts @@ -120,7 +120,8 @@ export class CalculatorListComponent implements OnInit { CalculatorType.CloisonAval, CalculatorType.YAXN, CalculatorType.PbBassin, - CalculatorType.PbCloison + CalculatorType.PbCloison, + CalculatorType.LechaptCalmon ].includes(t) ) { unusedTheme.calculators.push({ diff --git a/src/app/config.json b/src/app/config.json index 97f3c60d6743c80c47231016f0666d26fb40e77d..1bc4882309f296358e3b051647ffbb6b8867896d 100644 --- a/src/app/config.json +++ b/src/app/config.json @@ -63,7 +63,7 @@ "path": "en-charge.jpg", "credits": "Catherine Tailleux / Inrae" }, - "calculators": [ 1, 0 ] + "calculators": [ 35, 0 ] }, { "name": "LOIS_D_OUVRAGES", diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index 475c630c86e8664ce74bdfcef850275bd4f32a67..f2141323a49d79f1ff4fee955ce54213479efdf7 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -25,6 +25,7 @@ import { ServiceFactory } from "../../services/service-factory"; import { SelectEntry } from "../elements/select/select-entry"; import { SelectField } from "../elements/select/select-field"; import { DeepSelectFieldIterator } from "../form-iterator/deep-selectfield-iterator"; +import { ConfigParser } from "./config-parser"; /** * classe de base pour tous les formulaires @@ -146,6 +147,24 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs Session.getInstance().deleteNub(sn); } + /** + * parse calculator JSON configuration for select default value + * @param selectId select id, ie. "id" field value + * @return select "default" field value + */ + protected parseSelectDefaultValue(json: {}, selectId: string): string { + const jp = new ConfigParser(json); + for (const fs of jp.forAll("fieldset")) { + const fsp = new ConfigParser(fs["fields"]); + for (const sel of fsp.forAll("select")) { + if (sel["id"] === selectId) { + return sel["default"]; + } + } + } + return undefined; + } + /** * prepare options parsing */ diff --git a/src/app/formulaire/definition/form-pressureloss.ts b/src/app/formulaire/definition/form-pressureloss.ts new file mode 100644 index 0000000000000000000000000000000000000000..60c98da99b692a86de8de20bc0025ff96d6327c6 --- /dev/null +++ b/src/app/formulaire/definition/form-pressureloss.ts @@ -0,0 +1,24 @@ +import { PressureLoss, Props, PressureLossType } from "jalhyd"; +import { FormulaireFixedVar } from "./form-fixedvar"; + +/** + * Formulaire pour la perte de charge + */ +export class FormulairePressureLoss extends FormulaireFixedVar { + public preparseConfig(json: {}) { + super.preparseConfig(json); + + // get pressure loss law select default value + const dft: string = this.parseSelectDefaultValue(json, "select_pressurelosstype"); + this.defaultProperties["pressureLossType"] = PressureLossType[dft]; + } + + public initNub(props?: Props) { + if (props === undefined) { + props = new Props(); + } + props.setPropValue("calcType", this.calculatorType); + props.setPropValue("pressureLossType", this.defaultProperties["pressureLossType"]); + super.initNub(props); + } +} diff --git a/src/app/formulaire/definition/form-section.ts b/src/app/formulaire/definition/form-section.ts index 7ef1534e104c6b2a3193dfcdca657222c03f016e..8f8be0af96d577110333fe270c861ec7297c621f 100644 --- a/src/app/formulaire/definition/form-section.ts +++ b/src/app/formulaire/definition/form-section.ts @@ -3,7 +3,6 @@ import { FieldSet } from "../elements/fieldset"; import { ServiceFactory } from "../../services/service-factory"; import { IObservable, Session, SectionNub, Props, CalculatorType, Prop_NullParameters, acSection } from "jalhyd"; -import { ConfigParser } from "./config-parser"; import { SectionType } from "jalhyd"; export class FormulaireSection extends FormulaireFixedVar { @@ -16,17 +15,8 @@ export class FormulaireSection extends FormulaireFixedVar { */ private parseDefaultSectionType() { if (this._defaultSectionType === undefined) { - const jp = new ConfigParser(this._jsonConfig); - for (const fs of jp.forAll("fieldset")) { - const fsp = new ConfigParser(fs["fields"]); - for (const sel of fsp.forAll("select")) { - if (sel["id"] === "select_section") { - const st = sel["default"]; - this._defaultSectionType = SectionType[st]; - return; - } - } - } + const def = this.parseSelectDefaultValue(this._jsonConfig, "select_section"); + this._defaultSectionType = SectionType[def]; } } diff --git a/src/app/formulaire/elements/select/select-field-factory.ts b/src/app/formulaire/elements/select/select-field-factory.ts index 49fed0c91265f84c008fff570c024693adf85591..afb4246e01c12c991552a742e86f31ca9495954c 100644 --- a/src/app/formulaire/elements/select/select-field-factory.ts +++ b/src/app/formulaire/elements/select/select-field-factory.ts @@ -69,10 +69,11 @@ export class SelectFieldFactory { case "select_section": case "select_sppoperation": case "select_unit": + case "select_pressurelosstype": return new SelectFieldNubProperty(parent); default: - throw new Error("unknown select id ${id}"); + throw new Error(`unknown select id ${json["id"]}`); } } } diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts index 5c29f442d1a79d93e9f4b143b76a2491492d7b70..e54805c7d5ed9279f1cbed3150cdfe8f6ec5d65c 100644 --- a/src/app/services/formulaire.service.ts +++ b/src/app/services/formulaire.service.ts @@ -57,6 +57,7 @@ import { FormulaireVerificateur } from "../formulaire/definition/form-verificate import { FormulaireEspece } from "../formulaire/definition/form-espece"; import { FormulairePrebarrage } from "../formulaire/definition/form-prebarrage"; import { ServiceFactory } from "./service-factory"; +import { FormulairePressureLoss } from "app/formulaire/definition/form-pressureloss"; @Injectable() export class FormulaireService extends Observable { @@ -346,6 +347,10 @@ export class FormulaireService extends Observable { f = new FormulairePrebarrage(); break; + case CalculatorType.PressureLoss: + f = new FormulairePressureLoss(); + break; + default: f = new FormulaireFixedVar(); } diff --git a/src/app/services/internationalisation.service.ts b/src/app/services/internationalisation.service.ts index af0f2d42e05abe4ee0c9d29a5c8fe528a7822baa..ba7e4cf84633d4bdf079f7bde4ca5b3bd6eb8023 100644 --- a/src/app/services/internationalisation.service.ts +++ b/src/app/services/internationalisation.service.ts @@ -62,7 +62,8 @@ export class I18nService extends Observable implements Observer { public async setLanguage(code: string) { /** excluded calculators */ const childCalculatorType: CalculatorType[] = [ - CalculatorType.Section, CalculatorType.Structure, CalculatorType.CloisonAval, CalculatorType.YAXN + CalculatorType.Section, CalculatorType.Structure, CalculatorType.CloisonAval, CalculatorType.YAXN, + CalculatorType.LechaptCalmon ]; // ensure 2-letter language code diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 6ac8ce559ee4a307c510e6ebdab1ed70a5fb7068..5130406b10e0cdde1994abc35bd303f2fbe46ceb 100755 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -233,6 +233,7 @@ "INFO_CHILD_TYPE_SECTION": "section", "INFO_CHILD_TYPE_SECTION_PLUR": "sections", "INFO_CHILD_TYPE_SECTION_SHORT": "S", + "INFO_CHILD_TYPE_LECHAPTCALMON": "Lechapt-Calmon", "INFO_DIALOG_PARSIM_DESC": "Choose a combination of values to generate the simulation", "INFO_FIELDSET_ADD": "Add", "INFO_FIELDSET_COPY": "Copy", @@ -261,6 +262,9 @@ "INFO_LECHAPTCALMON_DESCRIPTION": "pipe flow circular headloss", "INFO_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.", "INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon", + "INFO_PRESSURELOSS_TITRE_DESCRIPTION": "Headloss in a pipe flow", + "INFO_PRESSURELOSS_TITRE_COURT": "Press. loss", + "INFO_PRESSURELOSS_TITRE": "Pressure loss", "INFO_LIB_ABSCISSE": "Abscissa (m)", "INFO_LIB_ALTITUDE": "Altitude (m)", "INFO_LIB_LENGTHS": "Every length", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 24135323659bf1aafcebc9ba8881f9ffe3e84e60..f487a29c09e7be331d0a10127319874b86a20b55 100755 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -233,6 +233,7 @@ "INFO_CHILD_TYPE_SECTION": "section", "INFO_CHILD_TYPE_SECTION_PLUR": "sections", "INFO_CHILD_TYPE_SECTION_SHORT": "S", + "INFO_CHILD_TYPE_LECHAPTCALMON": "Lechapt-Calmon", "INFO_DIALOG_PARSIM_DESC": "Choisir une combinaison de valeurs pour générer la simulation", "INFO_FIELDSET_ADD": "Ajouter", "INFO_FIELDSET_COPY": "Copier", @@ -261,6 +262,9 @@ "INFO_LECHAPTCALMON_DESCRIPTION": "Hydraulique en charge conduite colebrook", "INFO_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.", "INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon", + "INFO_PRESSURELOSS_TITRE_DESCRIPTION": "Pertes dans une conduite en charge", + "INFO_PRESSURELOSS_TITRE_COURT": "Perte de ch.", + "INFO_PRESSURELOSS_TITRE": "Perte de charge", "INFO_LIB_ABSCISSE": "Abscisse (m)", "INFO_LIB_ALTITUDE": "Altitude (m)", "INFO_LIB_LENGTHS": "Toutes les longueurs",