diff --git a/src/app/calculators/pab-nombre/pab-nombre.config.json b/src/app/calculators/pab-nombre/pab-nombre.config.json new file mode 100644 index 0000000000000000000000000000000000000000..1534195af9979fafe13fdfe8a99a2671789725d6 --- /dev/null +++ b/src/app/calculators/pab-nombre/pab-nombre.config.json @@ -0,0 +1,29 @@ +[ + { + "id": "fs_nombre", + "type": "fieldset", + "option": "cal", + "fields": [ + { + "type": "input", + "id": "DHT", + "unit": "m" + }, + { + "type": "input", + "id": "N", + "unit": "" + }, + { + "type": "input", + "id": "DH", + "unit": "m" + } + ] + }, + { + "type": "options", + "idCal": "N", + "help": "pab/nombre" + } +] \ No newline at end of file diff --git a/src/app/calculators/pab-nombre/pab-nombre.en.json b/src/app/calculators/pab-nombre/pab-nombre.en.json new file mode 100644 index 0000000000000000000000000000000000000000..2af024c560bccc7b711bd84ada8854f53e938867 --- /dev/null +++ b/src/app/calculators/pab-nombre/pab-nombre.en.json @@ -0,0 +1,6 @@ +{ + "fs_nombre": "Basin dimensions", + "DHT": "Total fall", + "N": "Number of basins", + "DH": "Fall between basins" +} \ No newline at end of file diff --git a/src/app/calculators/pab-nombre/pab-nombre.fr.json b/src/app/calculators/pab-nombre/pab-nombre.fr.json new file mode 100644 index 0000000000000000000000000000000000000000..bee20ccb84366afee990d43757713a739f11a66c --- /dev/null +++ b/src/app/calculators/pab-nombre/pab-nombre.fr.json @@ -0,0 +1,6 @@ +{ + "fs_nombre": "Dimensions du bassin", + "DHT": "Chute totale", + "N": "Nombre de bassins", + "DH": "Chute entre bassins" +} \ No newline at end of file diff --git a/src/app/config.json b/src/app/config.json index cb7754e64b271455f1e1d128346868fd88441224..bfa33ed9d12f9001a25bb0d4846a6d905104e43a 100644 --- a/src/app/config.json +++ b/src/app/config.json @@ -13,7 +13,7 @@ "title": "Passe à poisson sur le Lez, entre Bollène et Suze", "credits": "Hervé Capra / Irstea" }, - "calculators": [ 5, 6, 10, 9 ] + "calculators": [ 5, 6, 10, 9, 12, 13 ] }, { "name": "PASSE_NATURELLE", diff --git a/src/app/services/formulaire/formulaire.service.ts b/src/app/services/formulaire/formulaire.service.ts index d8a6e6830ba27a7debd123a1fdcf5ae519a99adc..1f80b90b46ed17270145e8b54df6e20683806601 100644 --- a/src/app/services/formulaire/formulaire.service.ts +++ b/src/app/services/formulaire/formulaire.service.ts @@ -25,6 +25,9 @@ import { NotificationsService } from "../notifications/notifications.service"; @Injectable() export class FormulaireService extends Observable { + + private calculatorPaths = {}; + /** list of known forms */ private _formulaires: FormulaireDefinition[]; @@ -32,7 +35,6 @@ export class FormulaireService extends Observable { /** to avoid loading language files multiple times */ private languageCache = {}; - constructor( private i18nService: I18nService, private appSetupService: ApplicationSetupService, @@ -42,6 +44,22 @@ export class FormulaireService extends Observable { ) { super(); this._formulaires = []; + + // register calculator config paths here + this.calculatorPaths[CalculatorType.ConduiteDistributrice] = "cond_distri"; + this.calculatorPaths[CalculatorType.LechaptCalmon] = "lechapt-calmon"; + this.calculatorPaths[CalculatorType.SectionParametree] = "section-param"; + this.calculatorPaths[CalculatorType.RegimeUniforme] = "regime-uniforme"; + this.calculatorPaths[CalculatorType.CourbeRemous] = "remous"; + this.calculatorPaths[CalculatorType.PabChute] = "pab-chute"; + this.calculatorPaths[CalculatorType.PabDimensions] = "pab-dimensions"; + this.calculatorPaths[CalculatorType.PabNombre] = "pab-nombre"; + this.calculatorPaths[CalculatorType.PabPuissance] = "pab-puissance"; + this.calculatorPaths[CalculatorType.Structure] = "ouvrages"; + this.calculatorPaths[CalculatorType.ParallelStructure] = "parallel-structures"; + this.calculatorPaths[CalculatorType.Dever] = "dever"; + this.calculatorPaths[CalculatorType.Cloisons] = "cloisons"; + this.calculatorPaths[CalculatorType.MacroRugo] = "macrorugo"; } private get _intlService(): I18nService { @@ -172,13 +190,6 @@ export class FormulaireService extends Observable { private newFormulaire(ct: CalculatorType, jsonState?: {}): FormulaireDefinition { let f: FormulaireDefinition; switch (ct) { - case CalculatorType.ConduiteDistributrice: - case CalculatorType.PabChute: - case CalculatorType.PabDimensions: - case CalculatorType.PabPuissance: - case CalculatorType.MacroRugo: - f = new FormulaireBase(); - break; case CalculatorType.LechaptCalmon: f = new FormulaireLechaptCalmon(); @@ -203,7 +214,7 @@ export class FormulaireService extends Observable { break; default: - throw new Error(`FormulaireService.newFormulaire() : type de module de calcul ${CalculatorType[ct]} non pris en charge`); + f = new FormulaireBase(); } f.defaultProperties["calcType"] = ct; @@ -338,53 +349,10 @@ export class FormulaireService extends Observable { } public getConfigPathPrefix(ct: CalculatorType): string { - if (ct === undefined) { - throw new Error("FormulaireService.getConfigPathPrefix() : CalculatorType is undefined"); - } - - switch (ct) { - case CalculatorType.ConduiteDistributrice: - return "app/calculators/cond_distri/cond_distri."; - - case CalculatorType.LechaptCalmon: - return "app/calculators/lechapt-calmon/lechapt-calmon."; - - case CalculatorType.SectionParametree: - return "app/calculators/section-param/section-param."; - - case CalculatorType.RegimeUniforme: - return "app/calculators/regime-uniforme/regime-uniforme."; - - case CalculatorType.CourbeRemous: - return "app/calculators/remous/remous."; - - case CalculatorType.PabDimensions: - return "app/calculators/pab-dimensions/pab-dimensions."; - - 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."; - - case CalculatorType.Dever: - return "app/calculators/dever/dever."; - - case CalculatorType.Cloisons: - return "app/calculators/cloisons/cloisons."; - - case CalculatorType.MacroRugo: - return "app/calculators/macrorugo/macrorugo."; - - case CalculatorType.PabChute: - return "app/calculators/pab-chute/pab-chute."; - - default: - throw new Error("FormulaireService.getConfigPathPrefix() : valeur de CalculatorType " + ct + " non implémentée"); + if (! this.calculatorPaths.hasOwnProperty(ct)) { + throw new Error("FormulaireService.getConfigPathPrefix() : valeur de CalculatorType " + ct + " non implémentée"); } + return "app/calculators/" + this.calculatorPaths[ct] + "/" + this.calculatorPaths[ct] + "."; } /** diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 0a6edaaad48ae5e2ed5ba9e13b5029926a619c99..1772e4a1cacef09499863c4a643b84cf1f531a0a 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -80,6 +80,7 @@ "INFO_EXTRARES_LIB_B": "Surface width (m)", "INFO_EXTRARES_LIB_CV": "Cv: Velocity coefficient", "INFO_EXTRARES_LIB_CVQT": "CV.QT: Corrected discharge (m³/s)", + "INFO_EXTRARES_LIB_DHR": "DHR : Residual fall (m)", "INFO_EXTRARES_LIB_EC": "EC: Kinetic energy (m)", "INFO_EXTRARES_LIB_ENUM_MACRORUGOFLOWTYPE": "Flow type", "INFO_EXTRARES_LIB_FLU": "Subcritical water line", @@ -156,9 +157,11 @@ "INFO_OPTION_NONE_F": "None", "INFO_OUVRAGE": "Structure", "INFO_PABCHUTE_TITRE": "Fish ladder: fall", - "INFO_PABCHUTE_TITRE_COURT": "FL: fall", + "INFO_PABCHUTE_TITRE_COURT": "FL: fall between basins", "INFO_PABDIMENSIONS_TITRE": "Fish ladder: dimensions", "INFO_PABDIMENSIONS_TITRE_COURT": "FL: dimensions", + "INFO_PABNOMBRE_TITRE": "Fish ladder : number of basins", + "INFO_PABNOMBRE_TITRE_COURT": "FL : number", "INFO_PABPUISSANCE_TITRE": "Fish ladder: dissipated power", "INFO_PABPUISSANCE_TITRE_COURT": "FL: diss. power", "INFO_PARALLELSTRUCTURE_TITRE": "Parallel structures", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index d1457e74f8ba4bd3adf2cd8abc09cfb1944fa7fb..88e8961cedb57414279b777d088d3a6395443b9b 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -80,6 +80,7 @@ "INFO_EXTRARES_LIB_B": "Largeur au miroir (m)", "INFO_EXTRARES_LIB_CV": "Cv: Coefficient de vitesse d'approche", "INFO_EXTRARES_LIB_CVQT": "CV.QT: Débit corrigé (m³/s)", + "INFO_EXTRARES_LIB_DHR": "DHR: Chute résiduelle (m)", "INFO_EXTRARES_LIB_EC": "EC: Énergie cinétique (m)", "INFO_EXTRARES_LIB_ENUM_MACRORUGOFLOWTYPE": "Type d'écoulement", "INFO_EXTRARES_LIB_FLU": "Ligne d'eau fluviale", @@ -155,10 +156,12 @@ "INFO_OPTION_NONE": "Aucun", "INFO_OPTION_NONE_F": "Aucune", "INFO_OUVRAGE": "Ouvrage", - "INFO_PABCHUTE_TITRE": "Passe à bassin : chute", + "INFO_PABCHUTE_TITRE": "Passe à bassin : chute entre bassins", "INFO_PABCHUTE_TITRE_COURT": "PAB : chute", "INFO_PABDIMENSIONS_TITRE": "Passe à bassin : dimensions", "INFO_PABDIMENSIONS_TITRE_COURT": "PAB : dimensions", + "INFO_PABNOMBRE_TITRE": "Passe à bassin : nombre de bassins", + "INFO_PABNOMBRE_TITRE_COURT": "PAB : nombre", "INFO_PABPUISSANCE_TITRE": "Passe à bassin : puissance dissipée", "INFO_PABPUISSANCE_TITRE_COURT": "PAB : puissance", "INFO_PARALLELSTRUCTURE_TITRE": "Lois d'ouvrages",