diff --git a/src/app/calculators/bief/bief.config.json b/src/app/calculators/bief/bief.config.json new file mode 100644 index 0000000000000000000000000000000000000000..58561811fb3b2cede61ea70cd6690707f478e113 --- /dev/null +++ b/src/app/calculators/bief/bief.config.json @@ -0,0 +1,70 @@ +[ + { + "id": "fs_water_line", + "type": "fieldset", + "fields": [ + { + "id": "select_regime", + "type": "select", + "source": "bief_regime" + } + ] + }, + { + "id": "fs_section", + "type": "fieldset", + "fields": [ + { + "id": "select_section", + "type": "select", + "help": { + "SectionRectangle": "hsl/types_sections.html#section-rectangulaire", + "SectionCercle": "hsl/types_sections.html#section-circulaire", + "SectionTrapeze": "hsl/types_sections.html#section-trapezoidale", + "SectionPuissance": "hsl/types_sections.html#section-parabolique" + }, + "source": "acsection_section" + }, + "LargeurFond", + "Fruit", + "LargeurBerge", + "D", + "k" + ] + }, + { + "id": "fs_bief", + "type": "fieldset", + "fields": [ + "Ks", + "Long", + "YB", + "ZF1", + "ZF2" + ] + }, + { + "id": "fs_condlim", + "type": "fieldset", + "fields": [ + "Q", + "Z1", + "Z2" + ] + }, + { + "id": "fs_param_calc", + "type": "fieldset", + "fields": [ + "Dx" + ] + }, + { + "type": "options", + "defaultNodeType": "SectionRectangle", + "defaultRegime": "Fluvial", + "sectionSourceId": "select_section", + "regimeSelectId": "select_regime", + "help": "hsl/bief.html" + } +] \ No newline at end of file diff --git a/src/app/calculators/bief/bief.en.json b/src/app/calculators/bief/bief.en.json new file mode 100644 index 0000000000000000000000000000000000000000..056d2873002dba19ea3ab322a185f7c413259a4c --- /dev/null +++ b/src/app/calculators/bief/bief.en.json @@ -0,0 +1,35 @@ +{ + "fs_water_line": "Type of water line", + "select_regime": "Regime", + + "select_regime_0": "Fluvial", + "select_regime_1": "Torrential", + + "fs_section": "Type of section", + "select_section": "Choice of section type", + + "select_section_SectionTrapeze": "Trapezoidal", + "select_section_SectionRectangle": "Rectangular", + "select_section_SectionCercle": "Circular", + "select_section_SectionPuissance": "Parabolic", + + "LargeurFond": "Width at bottom", + "Fruit": "Bank slope", + "D": "Diameter", + "k": "Coefficient", + "LargeurBerge": "Width at embankment level", + "fs_bief": "Reach features", + "Ks": "Strickler coefficient", + "Hs": "Head", + "Long": "Length of reach", + "YB": "Embankment elevation", + "fs_condlim": "Boundary conditions", + "Q": "Upstream flow", + "S": "Wet surface", + "fs_param_calc": "Calculation parameters", + "Dx": "Discretisation step", + "Z1": "Upstream water elevation", + "Z2": "Downstream water elevation", + "ZF1": "Upstream bottom elevation", + "ZF2": "Downstream bottom elevation" +} \ No newline at end of file diff --git a/src/app/calculators/bief/bief.fr.json b/src/app/calculators/bief/bief.fr.json new file mode 100644 index 0000000000000000000000000000000000000000..f22d1f0240caff2b34f64ce0d5b458624d6c6e5c --- /dev/null +++ b/src/app/calculators/bief/bief.fr.json @@ -0,0 +1,35 @@ +{ + "fs_water_line": "Type de ligne d'eau", + "select_regime": "Régime", + + "select_regime_0": "Fluvial", + "select_regime_1": "Torrentiel", + + "fs_section": "Type de section", + "select_section": "Choix du type de section", + + "select_section_SectionTrapeze": "Trapézoïdale", + "select_section_SectionRectangle": "Rectangulaire", + "select_section_SectionCercle": "Circulaire", + "select_section_SectionPuissance": "Parabolique", + + "LargeurFond": "Largeur au fond", + "Fruit": "Fruit des berges", + "D": "Diamètre", + "k": "Coefficient", + "LargeurBerge": "Largeur de berge", + "fs_bief": "Caractéristiques du bief", + "Ks": "Coefficient de Strickler", + "Hs": "Charge", + "Long": "Longueur du bief", + "YB": "Hauteur de berge", + "fs_condlim": "Conditions aux limites", + "Q": "Débit amont", + "S": "Surface mouillée", + "Dx": "Pas de discrétisation", + "fs_param_calc": "Paramètres de calcul", + "Z1": "Cote de l'eau à l'amont", + "Z2": "Cote de l'eau à l'aval", + "ZF1": "Cote du fond à l'amont", + "ZF2": "Cote du fond à l'aval" +} \ No newline at end of file diff --git a/src/app/config.json b/src/app/config.json index d7fa138742d5c05aa522aa79330249d6c204c733..1b2da220febf7661f5a2d1fed5cf860609dbca72 100644 --- a/src/app/config.json +++ b/src/app/config.json @@ -38,7 +38,7 @@ "path": "surface-libre.jpg", "credits": "David Dorchies / Irstea" }, - "calculators": [ 2, 3, 4, 20 ] + "calculators": [ 2, 3, 4, 20, 21 ] }, { "name": "HYDRAULIQUE_EN_CHARGE", diff --git a/src/app/formulaire/definition/concrete/form-bief.ts b/src/app/formulaire/definition/concrete/form-bief.ts new file mode 100644 index 0000000000000000000000000000000000000000..7aa4a69506db16b5d6e5741d066d181502d7621d --- /dev/null +++ b/src/app/formulaire/definition/concrete/form-bief.ts @@ -0,0 +1,71 @@ +import { IObservable, SectionNub, Session, BiefRegime } from "jalhyd"; + +import { FormDefSection } from "../form-def-section"; +import { FieldSet } from "../../fieldset"; +import { FormulaireBase } from "./form-base"; + +export class FormulaireBief extends FormulaireBase { + + private _formSection: FormDefSection; + + /** id du select configurant le régime */ + private _regimeSelectId: string; + + constructor() { + super(); + this._formSection = new FormDefSection(this); + // default properties + this._props["regime"] = BiefRegime.Fluvial; + } + + protected parseOptions(json: {}) { + super.parseOptions(json); + this._formSection.parseOptions(json); + + // id du select configurant la méthode de résolution + this._regimeSelectId = this.getOption(json, "regimeSelectId"); + } + + public afterParseFieldset(fs: FieldSet) { + this._formSection.afterParseFieldset(fs); + + // si le FieldSet contient le select de méthode de résolution + if (this._regimeSelectId) { + const sel = fs.getFormulaireNodeById(this._regimeSelectId); + if (sel) { + // on abonne le formulaire aux propriétés du FieldSet + fs.properties.addObserver(this); + } + } + } + + // interface Observer + + update(sender: IObservable, data: any) { + + super.update(sender, data); + + if (sender instanceof FieldSet && data.action === "propertyChange") { + switch (sender.id) { + case "fs_section": + // replace underlying section without replacing whole Nub + const newSect = Session.getInstance().createSection(data.value); + (this._currentNub as SectionNub).setSection(newSect); + // reflect changes in GUI + for (const fs of this.allFieldsets) { + // show / hide dependent fields + fs.updateFields(); + } + this.reset(); + break; + + case "fs_water_line": + console.log("reset water line"); + this.reset(); + // Either Z1 or Z2 is calculable, depending on Regime + this.getFieldsetById("fs_condlim").updateFields(); + break; + } + } + } +} diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 494e64140121f81b1ac62b9bf0e6f90aefa3e021..b5d4978c5be82673ce8d59cccf9b0b20c41c9266 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -1,6 +1,5 @@ import { CalculatorType, - ComputeNodeType, ParamDefinition, LCMaterial, LoiDebit, @@ -10,6 +9,7 @@ import { MethodeResolution, GrilleType, GrilleProfile, + BiefRegime, } from "jalhyd"; import { FormulaireElement } from "./formulaire-element"; @@ -254,6 +254,10 @@ export class FieldSet extends FormulaireElement implements Observer { case "fs_grille": // Grille this.setSelectValueFromProperty("select_grid_profile", "gridProfile"); break; + + case "fs_water_line": // Bief + this.setSelectValueFromProperty("select_regime", "regime"); + break; } } @@ -315,6 +319,7 @@ export class FieldSet extends FormulaireElement implements Observer { this.setPropertyValueFromConfig(json, "defaultMaterial", "material", LCMaterial); this.setPropertyValueFromConfig(json, "defaultGridProfile", "gridProfile", GrilleProfile); this.setPropertyValueFromConfig(json, "defaultGridType", "gridType", GrilleType); + this.setPropertyValueFromConfig(json, "defaultRegime", "regime", BiefRegime); this.setPropertyValueFromConfig(json, "varCalc", "varCalc"); this.updateFields(); @@ -404,6 +409,9 @@ export class FieldSet extends FormulaireElement implements Observer { case "select_grid_profile": // Grille this.setPropValue("gridProfile", data.value.value); break; + case "select_regime": // Bief + this.setPropValue("regime", data.value.value); + break; } break; } diff --git a/src/app/formulaire/select-field.ts b/src/app/formulaire/select-field.ts index ee83f1ae853c34319ac27a88b04a88ffe06d1dbe..308b319b08bab11b65ededa940cc947143cb7e7c 100644 --- a/src/app/formulaire/select-field.ts +++ b/src/app/formulaire/select-field.ts @@ -1,4 +1,15 @@ -import { LechaptCalmon, acSection, CourbeRemous, Nub, ParallelStructure, StructureType, LoiDebit, GrilleType, GrilleProfile } from "jalhyd"; +import { + BiefRegime, + LechaptCalmon, + acSection, + CourbeRemous, + Nub, + ParallelStructure, + StructureType, + LoiDebit, + GrilleType, + GrilleProfile + } from "jalhyd"; import { Field } from "./field"; import { SelectEntry } from "./select-entry"; @@ -172,6 +183,11 @@ export class SelectField extends Field { this.addEntry(new SelectEntry(this._entriesBaseId + GrilleProfile.Rectangular, GrilleProfile.Rectangular)); this.addEntry(new SelectEntry(this._entriesBaseId + GrilleProfile.Hydrodynamic, GrilleProfile.Hydrodynamic)); break; + + case "bief_regime": // Bief: type de régime + this.addEntry(new SelectEntry(this._entriesBaseId + BiefRegime.Fluvial, BiefRegime.Fluvial)); + this.addEntry(new SelectEntry(this._entriesBaseId + BiefRegime.Torrentiel, BiefRegime.Torrentiel)); + break; } } } diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts index 8741f40e1865a7ccc90b525d059a1adddfac36a8..65a60d25bc8ea319c99c4b369e0ce228ff0ba21a 100644 --- a/src/app/services/formulaire.service.ts +++ b/src/app/services/formulaire.service.ts @@ -38,6 +38,7 @@ import { FormulairePab } from "../formulaire/definition/concrete/form-pab"; import { FormulaireMacrorugoCompound } from "../formulaire/definition/concrete/form-macrorugo-compound"; import { FormulaireLechaptCalmon } from "../formulaire/definition/concrete/form-lechapt-calmon"; import { FormulaireGrille } from "../formulaire/definition/concrete/form-grille"; +import { FormulaireBief } from "../formulaire/definition/concrete/form-bief"; @Injectable() export class FormulaireService extends Observable { @@ -82,6 +83,7 @@ export class FormulaireService extends Observable { this.calculatorPaths[CalculatorType.Jet] = "jet"; this.calculatorPaths[CalculatorType.Grille] = "grille"; this.calculatorPaths[CalculatorType.Pente] = "pente"; + this.calculatorPaths[CalculatorType.Bief] = "bief"; } private get _intlService(): I18nService { @@ -323,6 +325,10 @@ export class FormulaireService extends Observable { f = new FormulaireGrille(); break; + case CalculatorType.Bief: + f = new FormulaireBief(); + break; + default: f = new FormulaireBase(); } diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index e8cbdf1d3a141377537f4acc845dc41418d5d792..4e2f733dafb988480c30b766a0e5cd951ed32a54 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -62,6 +62,8 @@ "INFO_CALCULATOR_SAVE": "Save", "INFO_CALCULATOR_USED_BY": "Used by", "INFO_CALCULATOR_VALEURS": "Values", + "INFO_BIEF_TITRE_COURT": "Reach", + "INFO_BIEF_TITRE": "Up/downstream elevations of a reach", "INFO_CLOISONS_TITRE_COURT": "Cross walls", "INFO_CLOISONS_TITRE": "Fish ladder: Cross walls", "INFO_CLOSE_DIALOGUE_DEPENDING_MODULES": "The following modules depend on the one you are closing:", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index f2199ec48ec6217d359dedb84a5a225299f8cd82..39603c3860ac8580f3843f0abe9b3712e047f2e8 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -62,6 +62,8 @@ "INFO_CALCULATOR_SAVE": "Enregistrer", "INFO_CALCULATOR_USED_BY": "Utilisé par", "INFO_CALCULATOR_VALEURS": "Valeurs", + "INFO_BIEF_TITRE_COURT": "Bief", + "INFO_BIEF_TITRE": "Cotes amont/aval d'un bief", "INFO_CLOISONS_TITRE_COURT": "Cloisons", "INFO_CLOISONS_TITRE": "Passe à bassins : Cloisons", "INFO_CLOSE_DIALOGUE_DEPENDING_MODULES": "Les modules suivants dépendent de celui que vous êtes en train de fermer :",