Commit ab82e028 authored by Mathias Chouet's avatar Mathias Chouet 🍝
Browse files

Removed Lechapt-Calmon and SectionParametree dependencies from config, use...

Removed Lechapt-Calmon and SectionParametree dependencies from config, use hardcoded presets from model instead
parent 1a73ac2a
...@@ -76,9 +76,9 @@ Custom Material SVG Icons will only show up when the application is deployed on ...@@ -76,9 +76,9 @@ Custom Material SVG Icons will only show up when the application is deployed on
constructor(rL: number, rW: number, rA:number=undefined) { constructor(rL: number, rW: number, rA:number=undefined) {
super(); super();
this._L = new ParamDefinition(this, ComputeNodeType.LechaptCalmon, 'L', ParamDomainValue.POS, rL); this._L = new ParamDefinition(this, ComputeNodeType.LechaptCalmon, 'L', "m", ParamDomainValue.POS, rL);
this._W = new ParamDefinition(this, ComputeNodeType.LechaptCalmon, 'W', ParamDomainValue.POS, rW); this._W = new ParamDefinition(this, ComputeNodeType.LechaptCalmon, 'W', "m", ParamDomainValue.POS, rW);
this._A = new ParamDefinition(this, ComputeNodeType.LechaptCalmon, 'A', ParamDomainValue.POS, rA); this._A = new ParamDefinition(this, ComputeNodeType.LechaptCalmon, 'A', undefined, ParamDomainValue.POS, rA);
this.addParamDefinition(this._L); this.addParamDefinition(this._L);
this.addParamDefinition(this._W); this.addParamDefinition(this._W);
......
...@@ -7,194 +7,22 @@ ...@@ -7,194 +7,22 @@
{ {
"id": "select_material", "id": "select_material",
"type": "select", "type": "select",
"select": [ "source": "lechapt_calmon_materials"
{
"id": "select_material_0"
},
{
"id": "select_material_1"
},
{
"id": "select_material_2"
},
{
"id": "select_material_3"
},
{
"id": "select_material_4"
},
{
"id": "select_material_5"
},
{
"id": "select_material_6"
},
{
"id": "select_material_7"
},
{
"id": "select_material_8"
},
{
"id": "select_material_9"
}
]
}, },
{ {
"type": "input", "type": "input",
"id": "L", "id": "L",
"unit": "", "unit": ""
"dep_value": [
{
"refid": "select_material",
"refvalue": "select_material_1",
"value": "1.863"
},
{
"refid": "select_material",
"refvalue": "select_material_2",
"value": "1.601"
},
{
"refid": "select_material",
"refvalue": "select_material_3",
"value": "1.40"
},
{
"refid": "select_material",
"refvalue": "select_material_4",
"value": "1.16"
},
{
"refid": "select_material",
"refvalue": "select_material_5",
"value": "1.1"
},
{
"refid": "select_material",
"refvalue": "select_material_6",
"value": "1.049"
},
{
"refid": "select_material",
"refvalue": "select_material_7",
"value": "1.01"
},
{
"refid": "select_material",
"refvalue": "select_material_8",
"value": "0.916"
},
{
"refid": "select_material",
"refvalue": "select_material_9",
"value": "0.971"
}
]
}, },
{ {
"type": "input", "type": "input",
"id": "M", "id": "M",
"unit": "", "unit": ""
"dep_value": [
{
"refid": "select_material",
"refvalue": "select_material_1",
"value": "2"
},
{
"refid": "select_material",
"refvalue": "select_material_2",
"value": "1.975"
},
{
"refid": "select_material",
"refvalue": "select_material_3",
"value": "1.96"
},
{
"refid": "select_material",
"refvalue": "select_material_4",
"value": "1.93"
},
{
"refid": "select_material",
"refvalue": "select_material_5",
"value": "1.89"
},
{
"refid": "select_material",
"refvalue": "select_material_6",
"value": "1.86"
},
{
"refid": "select_material",
"refvalue": "select_material_7",
"value": "1.84"
},
{
"refid": "select_material",
"refvalue": "select_material_8",
"value": "1.78"
},
{
"refid": "select_material",
"refvalue": "select_material_9",
"value": "1.81"
}
]
}, },
{ {
"type": "input", "type": "input",
"id": "N", "id": "N",
"unit": "", "unit": ""
"dep_value": [
{
"refid": "select_material",
"refvalue": "select_material_1",
"value": "5.33"
},
{
"refid": "select_material",
"refvalue": "select_material_2",
"value": "5.25"
},
{
"refid": "select_material",
"refvalue": "select_material_3",
"value": "5.19"
},
{
"refid": "select_material",
"refvalue": "select_material_4",
"value": "5.11"
},
{
"refid": "select_material",
"refvalue": "select_material_5",
"value": "5.01"
},
{
"refid": "select_material",
"refvalue": "select_material_6",
"value": "4.93"
},
{
"refid": "select_material",
"refvalue": "select_material_7",
"value": "4.88"
},
{
"refid": "select_material",
"refvalue": "select_material_8",
"value": "4.78"
},
{
"refid": "select_material",
"refvalue": "select_material_9",
"value": "4.81"
}
]
} }
] ]
}, },
......
...@@ -7,96 +7,43 @@ ...@@ -7,96 +7,43 @@
{ {
"id": "select_section", "id": "select_section",
"type": "select", "type": "select",
"select": [ "source": "acsection_available_sections"
{
"id": "select_section_trapez",
"enum": "ComputeNodeType.SectionTrapeze"
},
{
"id": "select_section_rect",
"enum": "ComputeNodeType.SectionRectangle"
},
{
"id": "select_section_circ",
"enum": "ComputeNodeType.SectionCercle"
},
{
"id": "select_section_puiss",
"enum": "ComputeNodeType.SectionPuissance"
}
]
}, },
{ {
"type": "input", "type": "input",
"id": "LargeurFond", "id": "LargeurFond",
"unit": "m", "unit": "m",
"nodeType": "SectionTrapeze", "nodeType": "SectionTrapeze"
"dep_exist": [
{
"refid": "select_section",
"refvalue": "select_section_trapez"
}
]
}, },
{ {
"type": "input", "type": "input",
"id": "Fruit", "id": "Fruit",
"nodeType": "SectionTrapeze", "nodeType": "SectionTrapeze",
"unit": "m/m", "unit": "m/m"
"dep_exist": [
{
"refid": "select_section",
"refvalue": "select_section_trapez"
}
]
}, },
{ {
"type": "input", "type": "input",
"id": "LargeurBerge", "id": "LargeurBerge",
"unit": "m", "unit": "m",
"nodeType": "SectionRectangle", "nodeType": "SectionRectangle"
"dep_exist": [
{
"refid": "select_section",
"refvalue": "select_section_rect"
}
]
}, },
{ {
"type": "input", "type": "input",
"id": "D", "id": "D",
"unit": "m", "unit": "m",
"nodeType": "SectionCercle", "nodeType": "SectionCercle"
"dep_exist": [
{
"refid": "select_section",
"refvalue": "select_section_circ"
}
]
}, },
{ {
"type": "input", "type": "input",
"id": "k", "id": "k",
"unit": "", "unit": "",
"nodeType": "SectionPuissance", "nodeType": "SectionPuissance"
"dep_exist": [
{
"refid": "select_section",
"refvalue": "select_section_puiss"
}
]
}, },
{ {
"type": "input", "type": "input",
"id": "LargeurBerge", "id": "LargeurBerge",
"unit": "m", "unit": "m",
"nodeType": "SectionPuissance", "nodeType": "SectionPuissance"
"dep_exist": [
{
"refid": "select_section",
"refvalue": "select_section_puiss"
}
]
} }
] ]
}, },
......
...@@ -12,9 +12,9 @@ import { NgParameter } from "../../formulaire/ngparam"; ...@@ -12,9 +12,9 @@ import { NgParameter } from "../../formulaire/ngparam";
export class NgBaseParam extends Observable { export class NgBaseParam extends Observable {
private _param: ParamDefinition; private _param: ParamDefinition;
constructor(symb: string, d: ParamDomain | ParamDomainValue, val: number) { constructor(symb: string, d: ParamDomain | ParamDomainValue, val: number, unit?: string) {
super(); super();
this._param = new ParamDefinition(null, symb, d, val); this._param = new ParamDefinition(null, symb, d, unit, val);
} }
public get param() { public get param() {
......
import { Observer } from "jalhyd"; import { LechaptCalmon, Observer } from "jalhyd";
import { SelectField } from "../../select-field"; import { SelectField } from "../../select-field";
import { FormulaireBase } from "./form-base"; import { FormulaireBase } from "./form-base";
import { NgParamInputComponent } from "../../../components/ngparam-input/ngparam-input.component"; import { NgParamInputComponent } from "../../../components/ngparam-input/ngparam-input.component";
...@@ -24,7 +24,15 @@ export class FormulaireLechaptCalmon extends FormulaireBase implements Observer ...@@ -24,7 +24,15 @@ export class FormulaireLechaptCalmon extends FormulaireBase implements Observer
// en cas de changement de valeur du select de matériau, effacement des résultats et MAJ des champs L,M,N // en cas de changement de valeur du select de matériau, effacement des résultats et MAJ des champs L,M,N
if (sender instanceof SelectField) { if (sender instanceof SelectField) {
if (data.action === "select") { if (data.action === "select") {
if (data.value._value !== "") {
(this.currentNub as LechaptCalmon).applyMaterialPreset(data.value._value);
}
// update GUI
this.getParamFromSymbol("L").notifyValueModified(this);
this.getParamFromSymbol("M").notifyValueModified(this);
this.getParamFromSymbol("N").notifyValueModified(this);
this.reset(); this.reset();
} }
} }
if (sender instanceof NgParamInputComponent) { if (sender instanceof NgParamInputComponent) {
......
import { FormulaireElement } from "./formulaire-element"; import { FormulaireElement } from "./formulaire-element";
import { ValueDependency } from "./dependency/value-dependency";
import { Dependency } from "./dependency/dependency";
import { isNumber } from "util";
export abstract class Field extends FormulaireElement { export abstract class Field extends FormulaireElement {
public abstract getValue(): any; public abstract getValue(): any;
public abstract setValue(sender: any, val: any): void; public abstract setValue(sender: any, val: any): void;
private parse_value_dependencies(json: {}) {
for (const di in json) {
const d = json[di];
const masterValue = d["refvalue"];
const dep = new ValueDependency(this, d["refid"], masterValue);
dep.slaveValue = d["value"];
this._dependencies.push(dep);
}
}
public parseDependencies(json: {}) {
super.parseDependencies(json);
const dep = json["dep_value"];
if (dep !== undefined) {
this.parse_value_dependencies(dep);
}
}
/**
* applique une dépendance dont la condition a été vérifiée
*/
public applyDependency(d: Dependency) {
if (d instanceof ValueDependency) {
if (isNumber(d.slaveValue)) {
this.setValue(this, +d.slaveValue);
} else {
this.setValue(this, d.slaveValue);
}
} else {
super.applyDependency(d);
}
}
} }
...@@ -307,7 +307,7 @@ export class NgParameter extends InputField implements Observer { ...@@ -307,7 +307,7 @@ export class NgParameter extends InputField implements Observer {
/** /**
* notification envoyée après la modification de la valeur du paramètre * notification envoyée après la modification de la valeur du paramètre
*/ */
private notifyValueModified(sender: any) { public notifyValueModified(sender: any) {
let val: number; let val: number;
if (this._paramDef.valueMode === ParamValueMode.SINGLE) { if (this._paramDef.valueMode === ParamValueMode.SINGLE) {
val = this._paramDef.singleValue; val = this._paramDef.singleValue;
......
import { StructureType, LoiDebit, ComputeNodeType, MethodeResolution } from "jalhyd"; import { LechaptCalmon, acSection } from "jalhyd";
import { Field } from "./field"; import { Field } from "./field";
import { SelectEntry } from "./select-entry"; import { SelectEntry } from "./select-entry";
...@@ -111,8 +111,29 @@ export class SelectField extends Field { ...@@ -111,8 +111,29 @@ export class SelectField extends Field {
public parseConfig(field: {}, data?: {}) { public parseConfig(field: {}, data?: {}) {
this._confId = field["id"]; this._confId = field["id"];
const values = field["select"]; const source = field["source"];
for (const v of values) { // ad-hoc cases
switch (source) {
case "lechapt_calmon_materials":
this.addEntry(new SelectEntry("select_material_empty", ""));
let i = 0;
for (const mat of LechaptCalmon.materials) {
const e: SelectEntry = new SelectEntry("select_material_" + (i + 1), i);
this.addEntry(e);
i++;
}
break;
case "acsection_available_sections":
for (const sec of acSection.availableSectionTypes) {
const e: SelectEntry = new SelectEntry("select_section_" + sec.id, sec.value);
console.log(">> adding entry", e);
this.addEntry(e);
}
break;
}
/* for (const v of values) {
let val: string; let val: string;
if (v.enum) { if (v.enum) {
const tmp = v.enum.split("."); const tmp = v.enum.split(".");
...@@ -143,6 +164,6 @@ export class SelectField extends Field { ...@@ -143,6 +164,6 @@ export class SelectField extends Field {
const id = v["id"]; const id = v["id"];
const e: SelectEntry = new SelectEntry(id, val); const e: SelectEntry = new SelectEntry(id, val);
this.addEntry(e); this.addEntry(e);
} } */
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment