diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 02ecfc7824fbc6f868d490071213f16fd678128f..968194eae05f5be6a9ad2153d9b61192ffa6656e 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -11,7 +11,6 @@ import { ErrorService } from "./services/error/error.service"; import { FormulaireService } from "./services/formulaire/formulaire.service"; import { FormulaireDefinition } from "./formulaire/definition/form-definition"; import { ServiceFactory } from "./services/service-factory"; -import { ParamService } from "./services/param/param.service"; import { HttpService } from "./services/http/http.service"; import { ApplicationSetupService } from "./services/app-setup/app-setup.service"; import { nghydDateRev } from "../date_revision"; @@ -61,7 +60,6 @@ export class AppComponent implements OnInit, OnDestroy, Observer { constructor( private intlService: I18nService, - private paramService: ParamService, private appSetupService: ApplicationSetupService, private appRef: ApplicationRef, private errorService: ErrorService, @@ -76,7 +74,6 @@ export class AppComponent implements OnInit, OnDestroy, Observer { ) { ServiceFactory.instance.httpService = httpService; ServiceFactory.instance.applicationSetupService = appSetupService; - ServiceFactory.instance.paramService = paramService; ServiceFactory.instance.i18nService = intlService; ServiceFactory.instance.formulaireService = formulaireService; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index e20d5253434d242703797cfb785a3a3fda1a78e7..13c9b193d338e87f41f9f17ee3ce0c753f01d169 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -37,7 +37,6 @@ import { RouterModule, Routes } from "@angular/router"; import { NgxMdModule } from "ngx-md"; import { FormulaireService } from "./services/formulaire/formulaire.service"; -import { ParamService } from "./services/param/param.service"; import { I18nService } from "./services/internationalisation/internationalisation.service"; import { HttpService } from "./services/http/http.service"; import { ApplicationSetupService } from "./services/app-setup/app-setup.service"; @@ -184,7 +183,6 @@ const appRoutes: Routes = [ FormulaireService, HttpService, I18nService, - ParamService, { provide: ErrorStateMatcher, useClass: ImmediateErrorStateMatcher diff --git a/src/app/calculators/section-param/section-param.fr.json b/src/app/calculators/section-param/section-param.fr.json index 3620678ebb05f5925ca984d4b85538be3e0b1d8f..891e7b95eb8d399f66a6ddaec27cc4e6e59562a6 100644 --- a/src/app/calculators/section-param/section-param.fr.json +++ b/src/app/calculators/section-param/section-param.fr.json @@ -40,5 +40,23 @@ "select_target_J": "La perte de charge (m)", "select_target_I-J": "Variation linéaire de l'énergie spécifique (m/m)", "select_target_Imp": "Impulsion (N)", - "select_target_Tau0": "La force tractrice (Pa)" -} \ No newline at end of file + "select_target_Tau0": "La force tractrice (Pa)", + + "Hs": "Charge spécifique", + "Hsc": "Charge critique", + "B": "Largeur au miroir", + "P": "Périmètre mouillé", + "S": "Surface mouillée", + "R": "Rayon hydraulique", + "V": "Vitesse moyenne", + "Fr": "Froude", + "Yc": "Tirant d'eau critique", + "Yn": "Tirant d'eau normal", + "Yf": "Tirant d'eau fluvial", + "Yt": "Tirant d'eau torrentiel", + "Yco": "Tirant d'eau conjugué", + "J": "Perte de charge", + "I-J": "Variation linéaire de l'énergie spécifique", + "Imp": "Impulsion", + "Tau0": "Force tractrice" +} diff --git a/src/app/formulaire/definition/concrete/form-section-parametree.ts b/src/app/formulaire/definition/concrete/form-section-parametree.ts index 651ec045358362be6e6a3efbd4e21b7a2b5a1c13..9d7da09abf17b8ab5804995650c3ee1097526792 100644 --- a/src/app/formulaire/definition/concrete/form-section-parametree.ts +++ b/src/app/formulaire/definition/concrete/form-section-parametree.ts @@ -23,6 +23,8 @@ export class FormulaireSectionParametree extends FormulaireDefinition { this._formSection = new FormDefSection(this); this._formSectionResult = new FormResultSection(this, this._formSection); this._formCompute = new FormComputeSectionParametree(this, this._formSection, this._formSectionResult); + // default properties + this._props["varCalc"] = "Hs"; } protected parseOptions(json: {}) { diff --git a/src/app/formulaire/definition/form-compute-section-parametree.ts b/src/app/formulaire/definition/form-compute-section-parametree.ts index ab2c327b54088ca42c14fb962d9590b6a6886923..9640c2e47eb432bfe6a3a29ba4bb913b5533ffab 100644 --- a/src/app/formulaire/definition/form-compute-section-parametree.ts +++ b/src/app/formulaire/definition/form-compute-section-parametree.ts @@ -1,33 +1,25 @@ -import { SectionParametree, acSection, Result } from "jalhyd"; +import { SectionParametree, acSection, Result, ParamDomain, ParamDefinition, ParamDomainValue } from "jalhyd"; import { FormCompute } from "./form-compute"; import { NgParameter } from "../ngparam"; import { FormResult } from "./form-result"; import { FormDefSection } from "./form-def-section"; import { FormResultSection } from "./form-result-section"; -import { FixedResults } from "../../results/fixed-results"; import { VarResults } from "../../results/var-results"; import { SectionResults } from "../../results/section-results"; import { FormulaireDefinition } from "./form-definition"; -import { ServiceFactory } from "../../services/service-factory"; -import { ParamService } from "../../services/param/param.service"; +import { FormulaireNode } from "../formulaire-node"; export class FormComputeSectionParametree extends FormCompute { - private _paramService: ParamService; constructor(formBase: FormulaireDefinition, private _formSection: FormDefSection, formResult: FormResult) { super(formBase, formResult); - this._paramService = ServiceFactory.instance.paramService; } private get _formSectionResult(): FormResultSection { return this._formResult as FormResultSection; } - private get _fixResults(): FixedResults { - return this._formSectionResult.fixedResults; - } - private get _varResults(): VarResults { return this._formSectionResult.varResults; } @@ -42,7 +34,6 @@ export class FormComputeSectionParametree extends FormCompute { */ private doComputeSectionVar(varParam: NgParameter) { const computePrec: number = this._formBase.getParameterValue("Pr"); // précision de calcul - const nDigits = -Math.log10(computePrec); this._formSectionResult.addSectionFixedParameters(false); @@ -51,17 +42,14 @@ export class FormComputeSectionParametree extends FormCompute { const sectNub: SectionParametree = this._formBase.currentNub as SectionParametree; const sect: acSection = sectNub.section; - const prms = sectNub.parameters; this._sectionResults.section = sect; this._varResults.variatedParameter = varParam; - const computedParam: NgParameter = this._paramService.createParameter(computedParamInfo.symbol, this._formBase); + const computedParam: NgParameter = this.createParameter(computedParamInfo.symbol, this._formBase); this._varResults.calculatedParameter = computedParam; - const compSymbol: string = computedParamInfo["symbol"]; - this._varResults.result = this.runNubCalc(sectNub, computedParam, computePrec); this._varResults.graphTitle = computedParamInfo.symbol + " = f( " + varParam.symbol + " )"; this._varResults.update(false); @@ -92,4 +80,65 @@ export class FormComputeSectionParametree extends FormCompute { this._formSectionResult.addSectionFixedParameters(false); this._formSectionResult.fixedResults.result = tmpResult; } + + /** + * + * @param calcType crée un NgParameter n'appartenant pas à un ComputeNode + * @param symbol symbole du paramètre à créer + */ + private createParameter(symbol: string, parent: FormulaireNode): NgParameter { + let p: NgParameter; + const dom = new ParamDomain(ParamDomainValue.POS_NULL); + p = new NgParameter(new ParamDefinition(null, symbol, dom), parent); + p.confId = symbol; + + switch (symbol) { + case "Hs": + case "Hsc": + case "B": + case "P": + case "R": + case "Yc": + case "Yn": + case "Yf": + case "Yt": + case "Yco": + case "J": + p.unit = "m"; + break; + + case "S": + p.unit = "m2"; + break; + + case "V": + p.unit = "m/s"; + break; + + case "I-J": + p.unit = "m/m"; + break; + + case "Fr": + p.unit = ""; + break; + + case "Imp": + p.unit = "N"; + break; + + case "Tau0": + p.unit = "Pa"; + break; + + case "Pr": + break; + + default: + throw new Error(`ParamService.createParameter() : symbole ${symbol} non pris en charge`); + } + p.updateLocalisation(this._formBase.specificLocalisation); + + return p; + } } diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index 469f34060853ce75b3a41a160afbe958ac42915b..c683185d7815ee961801afba01425b58f90cdedd 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -5,8 +5,6 @@ import { NgParameter, ParamRadioConfig } from "../ngparam"; import { Field } from "../field"; import { StringMap } from "../../stringmap"; import { FormulaireNode } from "../formulaire-node"; -import { ServiceFactory } from "../../services/service-factory"; -import { ParamService } from "../../services/param/param.service"; import { FieldSet } from "../fieldset"; import { FieldsetContainer } from "../fieldset-container"; import { SelectField } from "../select-field"; @@ -19,36 +17,26 @@ import { CalculatorResults } from "../../results/calculator-results"; * classe de base pour tous les formulaires */ export abstract class FormulaireDefinition extends FormulaireNode implements Observer { - /** - * nom du module de calcul - */ + /** nom du module de calcul */ private _calculatorName: string; - /** - * Nub courant - */ + /** Nub courant */ protected _currentNub: Nub; - /** - * propriétés par défaut (lues si _currentNub === undefined ) - */ + /** propriétés par défaut (lues si _currentNub === undefined ) */ protected _props = {}; - /** - * fichier de configuration - */ + /** fichier de configuration */ private _jsonConfig: {}; - /** - * aide en ligne - */ + /** aide en ligne */ private _helpLink: string; - protected _paramService: ParamService; + /** clé-valeurs du fichier de localisation spécifique à ce module */ + private _specificLocalisation: StringMap; constructor() { super(undefined); - this._paramService = ServiceFactory.instance.paramService; } // surcharge de FormulaireNode::get:uid() @@ -61,6 +49,10 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs } } + public get specificLocalisation() { + return this._specificLocalisation; + } + public get calculatorType(): CalculatorType { const props = this._currentNub === undefined ? this.defaultProperties : (this._currentNub.properties as Props).props; return props["calcType"]; @@ -409,6 +401,7 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs public abstract get results(): CalculatorResults[]; public updateLocalisation(localisation: StringMap) { + this._specificLocalisation = localisation; for (const fe of this.topFormElements) { fe.updateLocalisation(localisation); } diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 0bfc3a85f487991a6041dc9eae4cec5da8cb0b22..66973a18418926c50849865ffd384027bc79f299 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -1,4 +1,5 @@ -import { CalculatorType, ComputeNodeType, ParamDefinition, LoiDebit, StructureType, Props, Observer, Nub, MethodeResolution } from "jalhyd"; +import { CalculatorType, ComputeNodeType, ParamDefinition, LoiDebit, StructureType, + Props, Observer, Nub, MethodeResolution, ParamCalculability, ParamDomain, ParamDomainValue } from "jalhyd"; import { FormulaireElement } from "./formulaire-element"; import { Field } from "./field"; @@ -6,10 +7,10 @@ import { CheckField } from "./check-field"; import { SelectField } from "./select-field"; import { NgParameter, ParamRadioConfig } from "./ngparam"; import { ServiceFactory } from "../services/service-factory"; -import { ParamService } from "../services/param/param.service"; import { FormulaireDefinition } from "./definition/form-definition"; import { StringMap } from "../stringmap"; import { FormulaireNode } from "./formulaire-node"; +import { ApplicationSetupService } from "../services/app-setup/app-setup.service"; export class FieldSet extends FormulaireElement implements Observer { /** @@ -27,14 +28,11 @@ export class FieldSet extends FormulaireElement implements Observer { */ private _jsonConfig: {}; - /** - * propriétés déterminant l'état actuel du FieldSet (type de section, loi de débit, ...) - */ - // private _props: Props; + private _appSetupService: ApplicationSetupService; constructor(parent: FormulaireNode) { super(parent); - // this._props = new Props(); + this._appSetupService = ServiceFactory.instance.applicationSetupService; } public get nub(): Nub { @@ -136,13 +134,12 @@ export class FieldSet extends FormulaireElement implements Observer { private parse_input(json: {}, default_radio_config: string): NgParameter { // console.log("parsing input", json); const input_id: string = json["id"]; - const paramService: ParamService = ServiceFactory.instance.paramService; let res: NgParameter; switch (input_id) { case "Pr": - res = paramService.createParameter(input_id, this); + res = this.createAccuracyParameter(this); break; default: @@ -212,6 +209,15 @@ export class FieldSet extends FormulaireElement implements Observer { } } + private createAccuracyParameter(parent: FormulaireNode): NgParameter { + const d = new ParamDomain(ParamDomainValue.INTERVAL, 1e-10, 100); + const p = new ParamDefinition(null, "Pr", d, this._appSetupService.computePrecision); + p.calculability = ParamCalculability.FREE; + const np = new NgParameter(p, parent); + np.confId = "Pr"; + return np; + } + /** * Reflects all properties values in the interface, through the values of the <select> fields */ @@ -248,7 +254,8 @@ export class FieldSet extends FormulaireElement implements Observer { this.setSelectValueFromProperty("select_resolution", "methodeResolution"); break; - case "fs_target_data": + case "fs_target_data": // courbe de remous + case "fs_computed_var": // section paramétrée this.setSelectValueFromProperty("select_target", "varCalc"); break; diff --git a/src/app/formulaire/formulaire-element.ts b/src/app/formulaire/formulaire-element.ts index c2347b6ee8574b780f72c560a8e617024fd087bf..fd3f87b746074a49131d56bb16e3630a79e212c5 100644 --- a/src/app/formulaire/formulaire-element.ts +++ b/src/app/formulaire/formulaire-element.ts @@ -188,7 +188,7 @@ export abstract class FormulaireElement extends FormulaireNode { if (loc[key] !== undefined) { this._label = this.intlService.localizeText(key, loc); } else { - // Recherche du code dans locale/error_message.xx.json + // Recherche du code dans locale/message.xx.json this._label = this.intlService.localizeText("INFO_LIB_" + key.replace(/\d+$/, "").toLocaleUpperCase()); } for (const f of this.getKids()) { diff --git a/src/app/results/param-calc-results.ts b/src/app/results/param-calc-results.ts index 5a3d6adecb6b00a17a7870c49198cbe012ff321c..bdcabde2d0ce7879a4e4a88f71af88cb3f27d176 100644 --- a/src/app/results/param-calc-results.ts +++ b/src/app/results/param-calc-results.ts @@ -15,17 +15,17 @@ export abstract class CalculatedParamResults extends CalculatorResults { /** * titre de la colonne */ - private _calculatedParamHeader: string; + public calculatedParameterHeader: string; /** * résultat du calcul sur le paramètre calculé */ - protected _result: Result; + public result: Result; protected reset() { this._calculatedParam = undefined; - this._calculatedParamHeader = undefined; - this._result = undefined; + this.calculatedParameterHeader = undefined; + this.result = undefined; } public get calculatedParameter(): NgParameter { @@ -34,40 +34,24 @@ export abstract class CalculatedParamResults extends CalculatorResults { public set calculatedParameter(p: NgParameter) { this._calculatedParam = p; - this._calculatedParamHeader = CalculatorResults.paramLabel(this._calculatedParam, true); - } - - public get calculatedParameterHeader() { - return this._calculatedParamHeader; - } - - public set calculatedParameterHeader(s: string) { - this._calculatedParamHeader = s; - } - - public get result(): Result { - return this._result; - } - - public set result(r: Result) { - this._result = r; + this.calculatedParameterHeader = CalculatorResults.paramLabel(this._calculatedParam, true); } public get hasResults(): boolean { - if (this._result === undefined) { + if (this.result === undefined) { return false; } - return this._result.ok; + return this.result.ok; } public get hasLog(): boolean { - if (this._result === undefined) { + if (this.result === undefined) { return false; } - return this._result.hasLog; + return this.result.hasLog; } public get log(): cLog { - return this._result && this._result.log; // return x === undefined ? undefined : x.y + return this.result && this.result.log; // return x === undefined ? undefined : x.y } } diff --git a/src/app/results/var-results.ts b/src/app/results/var-results.ts index 657dd44f690b3ea84912c475aa618697e1421765..177f36a60c21f185616cd8b0bf4b6a7ebdc574d2 100644 --- a/src/app/results/var-results.ts +++ b/src/app/results/var-results.ts @@ -93,7 +93,7 @@ export class VarResults extends CalculatedParamResults { } public get resultElements(): ResultElement[] { - return this._result.resultElements; + return this.result.resultElements; } public get graphTitle() { @@ -122,14 +122,14 @@ export class VarResults extends CalculatedParamResults { } // valeurs du paramètre à calculer - for (const r of this._result.resultElements) { + for (const r of this.result.resultElements) { this._yValues.push(r.vCalc); } // clés des résultats supplémentaires if (this._extraResultKeys.length === 0) { - for (const re of this._result.resultElements) { // re:ResultElement + for (const re of this.result.resultElements) { // re:ResultElement for (const erk in re.extraResults) { if (!this._extraResultKeys.includes(erk)) { this._extraResultKeys.push(erk); diff --git a/src/app/services/param/param.service.ts b/src/app/services/param/param.service.ts deleted file mode 100644 index d34637e7cceef72876219acb33832bab733a92bb..0000000000000000000000000000000000000000 --- a/src/app/services/param/param.service.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { ParamDomain, ParamDefinition, ParamDomainValue, ParamCalculability, Session, Props, Nub, ParallelStructure } from "jalhyd"; - -import { NgParameter } from "../../formulaire/ngparam"; -import { Injectable } from "@angular/core"; -import { I18nService } from "../internationalisation/internationalisation.service"; -import { ApplicationSetupService } from "../app-setup/app-setup.service"; -import { FormulaireNode } from "../../formulaire/formulaire-node"; - -@Injectable() -export class ParamService { - - constructor( - private i18nService: I18nService, - private applicationSetupService: ApplicationSetupService - ) { } - - private get _intlService(): I18nService { - return this.i18nService; - } - - private get _appSetupService(): ApplicationSetupService { - return this.applicationSetupService; - } - - private createAccuracyParameter(): ParamDefinition { - const d = new ParamDomain(ParamDomainValue.INTERVAL, 1e-10, 100); - const p = new ParamDefinition(null, "Pr", d, this._appSetupService.computePrecision); - p.calculability = ParamCalculability.FREE; - return p; - } - - /** - * - * @param calcType crée un NgParameter n'appartenant pas à un ComputeNode - * @param symbol symbole du paramètre à créer - */ - public createParameter(symbol: string, parent: FormulaireNode): NgParameter { - let p: NgParameter; - if (symbol === "Pr") { - const prmDef: ParamDefinition = this.createAccuracyParameter(); - p = new NgParameter(prmDef.clone(), parent); - p.confId = "Pr"; - } else { - const dom = new ParamDomain(ParamDomainValue.POS_NULL); - p = new NgParameter(new ParamDefinition(null, symbol, dom), parent); - p.confId = symbol; - - switch (symbol) { - case "Hs": - case "Hsc": - case "B": - case "P": - case "R": - case "Yc": - case "Yn": - case "Yf": - case "Yt": - case "Yco": - case "J": - p.unit = "m"; - break; - - case "S": - p.unit = "m2"; - break; - - case "V": - p.unit = "m/s"; - break; - - case "I-J": - p.unit = "m/m"; - break; - - case "Fr": - p.unit = ""; - break; - - case "Imp": - p.unit = "N"; - break; - - case "Tau0": - p.unit = "Pa"; - break; - - case "Pr": - break; - - default: - throw new Error(`ParamService.createParameter() : symbole ${symbol} non pris en charge`); - } - p.updateLocalisation(this._intlService.currentMap); - } - - return p; - } -} diff --git a/src/app/services/service-factory.ts b/src/app/services/service-factory.ts index 0e84febabaaa2f1120406de9e2370b4be7b5d9da..0627bdf99a223a0bf9b7712945dcdb7849075c1a 100644 --- a/src/app/services/service-factory.ts +++ b/src/app/services/service-factory.ts @@ -1,5 +1,4 @@ import { ApplicationSetupService } from "./app-setup/app-setup.service"; -import { ParamService } from "./param/param.service"; import { FormulaireService } from "./formulaire/formulaire.service"; import { I18nService } from "./internationalisation/internationalisation.service"; import { HttpService } from "./http/http.service"; @@ -11,8 +10,6 @@ export class ServiceFactory { public applicationSetupService: ApplicationSetupService; - public paramService: ParamService; - public formulaireService: FormulaireService; public i18nService: I18nService; diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index d1a56cc1cfd1a8efc8fa949fdfa7579f129eec91..4c96c5aa529c5c762ae469348b291a11780edf5b 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -112,7 +112,7 @@ "INFO_LIB_ALPHA": "Alpha coefficient", "INFO_LIB_BETA": "Beta coefficient", "INFO_LIB_CD": "Discharge coefficient", - "INFO_LIB_BT": "Half opening of the triangle (m)", + "INFO_LIB_BT": "Half opening of the triangle", "INFO_LIB_FS_PARAM_CALC": "Calculation parameters", "INFO_LIB_FS_OUVRAGE": "Device", "INFO_LIB_L": "Weir width", @@ -123,8 +123,8 @@ "INFO_LIB_SELECT_OUVRAGE": "Device", "INFO_LIB_SELECT_OUVRAGE_SEUIL_RECT": "Rectangular weir", "INFO_LIB_ZDV": "Crest weir elevation or gate base", - "INFO_LIB_ZRAM": "Upstream apron elevation (m)", - "INFO_LIB_ZT": "Triangle top elevation (m)", + "INFO_LIB_ZRAM": "Upstream apron elevation", + "INFO_LIB_ZT": "Triangle top elevation", "INFO_MACRORUGO_TITRE": "Rock-ramp fishpasses", "INFO_MACRORUGO_TITRE_COURT": "RR fishpasses", "INFO_MENU_HELP_TITLE": "Help", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 8dbc1646b5caefed4424d5b3d577d7e748864dc9..69ceb18ec82ee75e9a9173fb7c36863143559722 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -112,7 +112,7 @@ "INFO_LIB_ALPHA": "Coefficient alpha", "INFO_LIB_BETA": "Coefficient béta", "INFO_LIB_CD": "Coefficient de débit", - "INFO_LIB_BT": "Demi-ouverture du triangle (m)", + "INFO_LIB_BT": "Demi-ouverture du triangle", "INFO_LIB_FS_PARAM_CALC": "Paramètres de calcul", "INFO_LIB_FS_OUVRAGE": "Ouvrage", "INFO_LIB_L": "Largeur du déversoir", @@ -123,8 +123,8 @@ "INFO_LIB_SELECT_OUVRAGE": "Ouvrage", "INFO_LIB_SELECT_OUVRAGE_SEUIL_RECT": "Seuil rectangulaire", "INFO_LIB_ZDV": "Cote de la crête du déversoir ou du radier de la vanne", - "INFO_LIB_ZRAM": "Cote du radier amont (m)", - "INFO_LIB_ZT": "Cote haute du triangle (m)", + "INFO_LIB_ZRAM": "Cote du radier amont", + "INFO_LIB_ZT": "Cote haute du triangle", "INFO_MENU_HELP_TITLE": "Aide", "INFO_MENU_LOAD_SESSION_TITLE": "Charger une session", "INFO_MENU_SAVE_SESSION_TITLE": "Enregistrer la session",