Skip to content
Snippets Groups Projects
Commit af0d46a0 authored by mathias.chouet's avatar mathias.chouet
Browse files

interface for module Trigo

parent 4e725515
No related branches found
No related tags found
1 merge request!69Resolve "Module y = a.x + b"
......@@ -23,7 +23,7 @@ describe("ngHyd − calculate all parameters of all calculators", () => {
11, 12, 13, 15, 17, 18, 19, 20,
21,
// 22 - Solveur is not calculated here because it is not independent
23
23, 24
];
// for each calculator
......
......@@ -25,7 +25,7 @@ describe("ngHyd − check translation of all calculators", () => {
});
// get calculators list (IDs) @TODO read it from config, but can't import jalhyd here :/
const calcTypes = [ 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 17, 18, 19, 20, 21, 22, 23 ];
const calcTypes = [ 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 17, 18, 19, 20, 21, 22, 23, 24 ];
// options of "Language" selector on preferences page
const langs = [ "English", "Français" ];
......
......@@ -23,7 +23,7 @@ describe("ngHyd − clone all calculators with all possible <select> values", ()
11, 12, 13, 15, 17, 18, 19, 20,
21,
// 22 - Solveur is not cloned here because it is not independent
23
23, 24
];
// for each calculator
......
[
{
"id": "fs_trigo",
"type": "fieldset",
"defaultOperation": "COS",
"defaultUnit": "DEG",
"fields": [
{
"id": "select_operation",
"type": "select",
"source": "trigo_operation"
},
{
"id": "select_unit",
"type": "select",
"source": "trigo_unit"
}
]
},
{
"id": "fs_params",
"type": "fieldset",
"fields": [ "X", "Y" ]
},
{
"type": "options",
"idCal": "Y",
"operationSelectId": "select_operation",
"unitSelectId": "select_unit",
"_help": "util/trigo.html"
}
]
\ No newline at end of file
{
"fs_trigo": "Trigonometric parameters",
"select_operation": "Operation",
"select_operation_0": "cos",
"select_operation_1": "sin",
"select_operation_2": "tan",
"select_operation_3": "cosh",
"select_operation_4": "sinh",
"select_operation_5": "tanh",
"select_unit": "Unit",
"select_unit_0": "Degrees",
"select_unit_1": "Radians",
"fs_params": "Equation parameters",
"X": "X",
"Y": "Y"
}
\ No newline at end of file
{
"fs_trigo": "Paramètres trigonométriques",
"select_operation": "Opération",
"select_operation_0": "cos",
"select_operation_1": "sin",
"select_operation_2": "tan",
"select_operation_3": "cosh",
"select_operation_4": "sinh",
"select_operation_5": "tanh",
"select_unit": "Unité",
"select_unit_0": "Degrés",
"select_unit_1": "Radians",
"fs_params": "Paramètres de l'équation",
"X": "X",
"Y": "Y"
}
\ No newline at end of file
import { IObservable } from "jalhyd";
import { FormulaireBase } from "./form-base";
import { FieldSet } from "../../fieldset";
import { FormResultFixedVar } from "../form-result-fixedvar";
/**
* Formulaire pour les fonctions trigonométriques
*/
export class FormulaireTrigo extends FormulaireBase {
/** id of select configuring operation */
private _operationSelectId: string;
/** id of select configuring unit */
private _unitSelectId: string;
protected parseOptions(json: {}) {
super.parseOptions(json);
this._operationSelectId = this.getOption(json, "operationSelectId");
this._unitSelectId = this.getOption(json, "unitSelectId");
}
public afterParseFieldset(fs: FieldSet) {
if (this._operationSelectId) {
const sel = fs.getFormulaireNodeById(this._operationSelectId);
if (sel) {
fs.properties.addObserver(this);
}
}
if (this._unitSelectId) {
const sel = fs.getFormulaireNodeById(this._unitSelectId);
if (sel) {
fs.properties.addObserver(this);
}
}
}
// interface Observer
public update(sender: IObservable, data: any) {
super.update(sender, data);
if (data.action === "propertyChange") {
/* if (data.name === "gridType") {
this.reset();
// Inclined grids have more input fields (OEntH and cIncl)
this.getFieldsetById("fs_grille").updateFields();
// Alpha and Beta are not always shown
this.getFieldsetById("fs_plan").updateFields();
} */
}
}
}
......@@ -11,6 +11,8 @@ import {
GrilleProfile,
BiefRegime,
Solveur,
TrigoOperation,
TrigoUnit,
} from "jalhyd";
import { FormulaireElement } from "./formulaire-element";
......@@ -288,6 +290,11 @@ export class FieldSet extends FormulaireElement implements Observer {
case "fs_water_line": // Bief
this.setSelectValueFromProperty("select_regime", "regime");
break;
case "fs_trigo": // Trigo
this.setSelectValueFromProperty("select_operation", "trigoOperation");
this.setSelectValueFromProperty("select_unit", "trigoUnit");
break;
}
}
......@@ -351,6 +358,8 @@ export class FieldSet extends FormulaireElement implements Observer {
this.setPropertyValueFromConfig(json, "defaultGridType", "gridType", GrilleType);
this.setPropertyValueFromConfig(json, "defaultRegime", "regime", BiefRegime);
this.setPropertyValueFromConfig(json, "varCalc", "varCalc");
this.setPropertyValueFromConfig(json, "defaultOperation", "trigoOperation", TrigoOperation);
this.setPropertyValueFromConfig(json, "defaultUnit", "trigoUnit", TrigoUnit);
this.updateFields();
}
......@@ -402,6 +411,7 @@ export class FieldSet extends FormulaireElement implements Observer {
switch (data.action) {
case "select":
const senderId: string = sender.id.replace(/\d+$/, "");
console.log("fieldset.update()", sender.constructor.name, data);
switch (senderId) {
case "select_section": // sections paramétrées, courbes de remous, régimes uniformes
// "nodeType" is a property of the section child, not of the parent
......@@ -442,6 +452,12 @@ export class FieldSet extends FormulaireElement implements Observer {
case "select_regime": // Bief
this.setPropValue("regime", data.value.value);
break;
case "select_operation": // Trigo
this.setPropValue("trigoOperation", data.value.value);
break;
case "select_unit": // Trigo
this.setPropValue("trigoUnit", data.value.value);
break;
}
break;
}
......
......@@ -9,9 +9,8 @@ import {
LoiDebit,
GrilleType,
GrilleProfile,
Solveur,
ParamValueMode,
Session
TrigoUnit,
TrigoOperation
} from "jalhyd";
import { Field } from "./field";
......@@ -198,6 +197,17 @@ export class SelectField extends Field {
this.addEntry(new SelectEntry(this._entriesBaseId + BiefRegime.Fluvial, BiefRegime.Fluvial));
this.addEntry(new SelectEntry(this._entriesBaseId + BiefRegime.Torrentiel, BiefRegime.Torrentiel));
break;
case "trigo_operation": // Trigo: opération (cos, sin…)
for (let j = 0; j < Object.keys(TrigoOperation).length / 2; j++) {
this.addEntry(new SelectEntry(this._entriesBaseId + j, j));
}
break;
case "trigo_unit": // Trigo: unité (degrés, radians)
this.addEntry(new SelectEntry(this._entriesBaseId + TrigoUnit.DEG, TrigoUnit.DEG));
this.addEntry(new SelectEntry(this._entriesBaseId + TrigoUnit.RAD, TrigoUnit.RAD));
break;
}
this.afterParseConfig();
......
......@@ -87,6 +87,7 @@ export class FormulaireService extends Observable {
this.calculatorPaths[CalculatorType.Bief] = "bief";
this.calculatorPaths[CalculatorType.Solveur] = "solveur";
this.calculatorPaths[CalculatorType.YAXB] = "yaxb";
this.calculatorPaths[CalculatorType.Trigo] = "trigo";
}
private get _intlService(): I18nService {
......
......@@ -467,8 +467,10 @@
"INFO_EXAMPLE_LABEL_PAB_COMPLETE": "Standard fish ladder",
"INFO_EXAMPLES_TITLE": "Examples",
"INFO_EXAMPLES_SUBTITLE": "Load standard examples",
"INFO_YAXB_TITRE": "Y = A.X + B",
"INFO_YAXB_TITRE_COURT": "Y=A.X+B",
"INFO_YAXB_TITRE": "Linear function",
"INFO_YAXB_TITRE_COURT": "Linear f.",
"INFO_TRIGO_TITRE": "Trigonometric function",
"INFO_TRIGO_TITRE_COURT": "Trigo. f.",
"WARNING_WARNINGS_ABSTRACT": "%nb% warnings occurred during calculation",
"WARNING_REMOUS_ARRET_CRITIQUE": "Calculation stopped: critical elevation reached at abscissa %x%",
"WARNING_STRUCTUREKIVI_HP_TROP_ELEVE": "h/p must not be greater than 2.5. h/p is forced to 2.5",
......
......@@ -466,8 +466,10 @@
"INFO_EXAMPLE_LABEL_PAB_COMPLETE": "Passe à bassins type",
"INFO_EXAMPLES_TITLE": "Exemples",
"INFO_EXAMPLES_SUBTITLE": "Charger des exemples types",
"INFO_YAXB_TITRE": "Y = A.X + B",
"INFO_YAXB_TITRE_COURT": "Y=A.X+B",
"INFO_YAXB_TITRE": "Fonction affine",
"INFO_YAXB_TITRE_COURT": "F. affine",
"INFO_TRIGO_TITRE": "Fonction trigonométrique",
"INFO_TRIGO_TITRE_COURT": "F. trigo.",
"WARNING_WARNINGS_ABSTRACT": "%nb% avertissements rencontrés lors du calcul",
"WARNING_REMOUS_ARRET_CRITIQUE": "Arrêt du calcul&nbsp;: hauteur critique atteinte à l'abscisse %x%",
"WARNING_STRUCTUREKIVI_HP_TROP_ELEVE": "h/p ne doit pas être supérieur à 2,5. h/p est forcé à 2,5",
......
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