Skip to content
Snippets Groups Projects
Commit a0146ef7 authored by Mathias Chouet's avatar Mathias Chouet Committed by mathias.chouet
Browse files

Fix #382 - PAR: add button to generate ParSimulation

parent cef0c491
No related branches found
No related tags found
1 merge request!99Devel - PAR
......@@ -120,6 +120,11 @@
{{ uitextGenerateRuSp }}
</button>
<button mat-raised-button color="accent" id="generate-par-simulation" *ngIf="isPAR" (click)="generatePARSimulation()"
[disabled]="! generatePARSimulationEnabled" [title]="uitextGenerateParSimulationTitle">
{{ uitextGeneratePARSimulation }}
</button>
<mat-card-content>
<calc-results id="resultsComp" (afterViewChecked)="onCalcResultsViewChecked()"></calc-results>
</mat-card-content>
......
......@@ -16,6 +16,9 @@ import {
round,
Nub,
RegimeUniforme
Par,
ParSimulationParams,
ParSimulation
} from "jalhyd";
import { generateValuesCombination } from "../../util";
......@@ -216,6 +219,10 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
return this.intlService.localizeText("INFO_CALCULATOR_RESULTS_GENERATE_RU_SP");
}
public get uitextGeneratePARSimulation() {
return this.intlService.localizeText("INFO_CALCULATOR_RESULTS_GENERATE_PAR_SIMULATION");
}
public get uitextOpenHelp() {
return this.intlService.localizeText("INFO_CALCULATOR_OPEN_HELP");
}
......@@ -594,19 +601,27 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
return this.is(CalculatorType.RegimeUniforme);
}
// true if current Nub is PAR
public get isPAR() {
return this.is(CalculatorType.Par);
}
/**
* Returns true if no parameter is varying
* Returns true if no parameter is varying; ignores parameters having
* one of the given {except} symbols, if any
*/
private allParamsAreFixed() {
private allParamsAreFixed(except: string[] = []) {
let ret = true;
for (const p of this._formulaire.currentNub.parameterIterator) {
if (p.valueMode === ParamValueMode.LINK) {
ret = ret && (! p.hasMultipleValues);
} else {
// avoid calling hasMultipleValues here, because changing parameter mode in GUI
// switches valueMode before setting min/max/step or valuesList, and iterator
// checker fails to count values that do not exist yet
ret = ret && (! [ ParamValueMode.LISTE, ParamValueMode.MINMAX ].includes(p.valueMode));
if (! except.includes(p.symbol)) {
if (p.valueMode === ParamValueMode.LINK) {
ret = ret && (! p.hasMultipleValues);
} else {
// avoid calling hasMultipleValues here, because changing parameter mode in GUI
// switches valueMode before setting min/max/step or valuesList, and iterator
// checker fails to count values that do not exist yet
ret = ret && (! [ ParamValueMode.LISTE, ParamValueMode.MINMAX ].includes(p.valueMode));
}
}
}
return ret;
......@@ -621,7 +636,7 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
public get uitextGeneratePabTitle() {
if (! this.hasResults) {
return this.intlService.localizeText("INFO_CALCULER_D_ABORD");
return this.intlService.localizeText("INFO_CALCULATE_FIRST");
}
if (! this.allParamsAreFixed()) {
return this.intlService.localizeText("INFO_PARAMETRES_FIXES");
......@@ -687,7 +702,7 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
public get uitextGenerateSPAmontTitle(): string {
if (! this.generateSPAmontEnabled) {
return this.intlService.localizeText("INFO_CALCULER_D_ABORD");
return this.intlService.localizeText("INFO_CALCULATE_FIRST");
} else {
return "";
}
......@@ -695,7 +710,7 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
public get uitextGenerateSPAvalTitle(): string {
if (! this.generateSPAvalEnabled) {
return this.intlService.localizeText("INFO_CALCULER_D_ABORD");
return this.intlService.localizeText("INFO_CALCULATE_FIRST");
} else {
return "";
}
......@@ -825,6 +840,73 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
// calculate
f.doCompute();
// go to new SP
}
);
}
public get generatePARSimulationEnabled(): boolean {
const parCalage = (this._formulaire.currentNub as Par);
return (
this.hasResults
&& ! parCalage.result.hasErrorMessages()
&& this.allParamsAreFixed([ "Z1", "Q" ]) // only Z1 and Q may vary
);
}
public get uitextGenerateParSimulationTitle(): string {
if (! this.allParamsAreFixed([ "Z1", "Q" ])) {
return this.intlService.localizeText("INFO_ONLY_Z1_Q_MAY_VARY");
}
const parCalage = (this._formulaire.currentNub as Par);
if (! this.hasResults || parCalage.result.hasErrorMessages()) {
return this.intlService.localizeText("INFO_CALCULATE_FIRST");
}
return "";
}
/**
* Génère une simulation de passe à ralentisseurs à partir du calage en cours
*/
public generatePARSimulation() {
const parCalage = (this._formulaire.currentNub as Par);
const pcal = parCalage.prms;
// copy base params
const psim = new ParSimulationParams(
undefined, // Q
undefined, // Z1
pcal.Z2.singleValue, pcal.S.singleValue, pcal.P.singleValue,
undefined, // Nb
undefined, // ZR1
pcal.ZD1.singleValue,
undefined, // ZR2
undefined, // ZD2
pcal.L.singleValue, pcal.a.singleValue, pcal.N.singleValue, pcal.M.singleValue
);
const parSimulation = new ParSimulation(psim);
Session.getInstance().registerNub(parSimulation);
// copy other params
parSimulation.parType = parCalage.parType;
// Z1 and Q, that might be variating
psim.Z1.copyValuesFrom(pcal.Z1);
psim.Q.copyValuesFrom(pcal.Q);
// P, Nb, ZR1
if (pcal.P.singleValue === undefined) {
psim.P.singleValue = round(parCalage.result.values.P, 3);
}
psim.Nb.singleValue = parCalage.result.values.Nb;
psim.ZR1.singleValue = round(parCalage.result.values.ZR1, 3);
// ZR2, ZD2
if (pcal.Z2.singleValue !== undefined) {
psim.ZD2.singleValue = round(parCalage.result.values.ZD2, 3);
psim.ZR2.singleValue = round(parCalage.result.values.ZR2, 3);
}
this.formulaireService.createFormulaire(CalculatorType.ParSimulation, parSimulation)
.then((f: FormulaireDefinition) => {
// calculate
f.doCompute();
// go to new ParSimulation
this.router.navigate(["/calculator", f.uid]).then();
}
);
......
......@@ -74,6 +74,7 @@
"INFO_CALCULATOR_PARAMFIXES": "Fixed parameters",
"INFO_CALCULATOR_RESULTS_GENERATE_PAB": "Generate a fish ladder",
"INFO_CALCULATOR_RESULTS_GENERATE_RU_SP": "Hydraulic details of section",
"INFO_CALCULATOR_RESULTS_GENERATE_PAR_SIMULATION": "Generation a humpback fishway simulation",
"INFO_CALCULATOR_RESULTS_GENERATE_SP_AMONT": "Hydraulic details of upstream section",
"INFO_CALCULATOR_RESULTS_GENERATE_SP_AVAL": "Hydraulic details of downstream section",
"INFO_CALCULATOR_RESULTS_TITLE": "Results",
......@@ -332,6 +333,7 @@
"INFO_MACRORUGOCOMPOUND_TITRE": "Compound rock-ramp fishpasses",
"INFO_MACRORUGOCOMPOUND_TITRE_COURT": "Compound RR",
"INFO_MACRORUGOCOMPOUND_LINCL": "Lateral inclination (m/m): ",
"INFO_ONLY_Z1_Q_MAY_VARY": "Only upstream elevation and flow may vary",
"INFO_PENTE_TITRE": "Slope",
"INFO_PENTE_TITRE_COURT": "Slope",
"INFO_MENU_EMPTY_SESSION_TITLE": "New session",
......@@ -363,7 +365,7 @@
"INFO_PAB_BASSINS": "Basins",
"INFO_PAB_OUVRAGES": "Devices",
"INFO_PAB_EDIT_VALUES": "Modify values",
"INFO_CALCULER_D_ABORD": "Calculate this module first",
"INFO_CALCULATE_FIRST": "Calculate this module first",
"INFO_PAB_NUM_BASSIN": "Basin #",
"INFO_PAB_HEADER_TYPE": "Type",
"INFO_PAB_HEADER_PARAMETERS": "Parameters",
......@@ -393,11 +395,11 @@
"INFO_PABPUISSANCE_TITRE_COURT": "FL: diss. power",
"INFO_PABPUISSANCE_TITRE": "Fish ladder: dissipated power",
"INFO_PARALLELSTRUCTURE_TITRE_COURT": "// structures",
"INFO_PARSIMULATION_TITRE": "Humpback fishway: simulation",
"INFO_PARSIMULATION_TITRE_COURT": "HF: simulation",
"INFO_PARALLELSTRUCTURE_TITRE": "Parallel structures",
"INFO_PAR_TITRE": "Humpback fishway: setup",
"INFO_PAR_TITRE_COURT": "HF: setup",
"INFO_PARSIMULATION_TITRE": "Humpback fishway: simulation",
"INFO_PARSIMULATION_TITRE_COURT": "HF: simulation",
"INFO_PARAMFIELD_AWAITING_CALCULATION": "Awaiting calculation",
"INFO_PARAMFIELD_BOUNDARY_CONDITIONS": "Boundary conditions",
"INFO_PARAMFIELD_CALCULATED": "Calculated",
......
......@@ -74,6 +74,7 @@
"INFO_CALCULATOR_PARAMFIXES": "Paramètres fixés",
"INFO_CALCULATOR_RESULTS_GENERATE_PAB": "Générer une passe à bassins",
"INFO_CALCULATOR_RESULTS_GENERATE_RU_SP": "Détails hydrauliques de la section",
"INFO_CALCULATOR_RESULTS_GENERATE_PAR_SIMULATION": "Générer une simulation de passe à ralentisseurs",
"INFO_CALCULATOR_RESULTS_GENERATE_SP_AMONT": "Détails hydrauliques de la section amont",
"INFO_CALCULATOR_RESULTS_GENERATE_SP_AVAL": "Détails hydrauliques de la section aval",
"INFO_CALCULATOR_RESULTS_TITLE": "Résultats",
......@@ -218,6 +219,7 @@
"INFO_LIB_BB": "Largeur du bassin",
"INFO_LIB_BETA": "Coefficient béta",
"INFO_LIB_BT": "Demi-ouverture du triangle",
"INFO_LIB_CD": "Coefficient de débit",
"INFO_LIB_CDGR": "Coefficient de débit vanne",
"INFO_LIB_CDCUNGE": "Coefficient de débit",
"INFO_LIB_CDWR": "Coefficient de débit seuil",
......@@ -332,6 +334,7 @@
"INFO_MACRORUGOCOMPOUND_TITRE": "Passe à macro-rugosités complexe",
"INFO_MACRORUGOCOMPOUND_TITRE_COURT": "M-Rugo complexe",
"INFO_MACRORUGOCOMPOUND_LINCL": "Dévers latéral (m/m)&nbsp;:",
"INFO_ONLY_Z1_Q_MAY_VARY": "Seuls la cote amont et le débit peuvent varier",
"INFO_PENTE_TITRE": "Pente",
"INFO_PENTE_TITRE_COURT": "Pente",
"INFO_MENU_EMPTY_SESSION_TITLE": "Nouvelle session",
......@@ -363,7 +366,7 @@
"INFO_PAB_BASSINS": "Bassins",
"INFO_PAB_OUVRAGES": "Ouvrages",
"INFO_PAB_EDIT_VALUES": "Modifier les valeurs",
"INFO_CALCULER_D_ABORD": "Calculer ce module d'abord",
"INFO_CALCULATE_FIRST": "Calculer ce module d'abord",
"INFO_PAB_NUM_BASSIN": "N° de bassin",
"INFO_PAB_HEADER_TYPE": "Type",
"INFO_PAB_HEADER_PARAMETERS": "Paramètres",
......
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