Skip to content
Snippets Groups Projects
Commit 8d74156a authored by Dorchies David's avatar Dorchies David
Browse files

Merge branch...

Merge branch '585-restructurer-lechapt-et-calmon-pour-de-nouvelles-lois-de-pertes-de-charge' into 'devel'

Resolve "Restructurer Lechapt et Calmon pour de nouvelles lois de pertes de charge"

Closes #585

See merge request !193
parents 2b9740b7 91c69f90
No related branches found
No related tags found
2 merge requests!225Release v4.17.0,!193Resolve "Restructurer Lechapt et Calmon pour de nouvelles lois de pertes de charge"
Pipeline #140119 failed
Showing
with 92 additions and 28 deletions
// 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
......
devel
334-restructurer-lechapt-et-calmon-pour-de-nouvelles-lois-de-pertes-de-charge
[
{
"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"
}
]
{
"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
}
{
"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
}
......@@ -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({
......
......@@ -63,7 +63,7 @@
"path": "en-charge.jpg",
"credits": "Catherine Tailleux / Inrae"
},
"calculators": [ 1, 0 ]
"calculators": [ 35, 0 ]
},
{
"name": "LOIS_D_OUVRAGES",
......
......@@ -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
*/
......
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);
}
}
......@@ -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];
}
}
......
......@@ -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"]}`);
}
}
}
......@@ -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();
}
......
......@@ -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
......
......@@ -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",
......
......@@ -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",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment