Skip to content
Snippets Groups Projects
Commit e1a41604 authored by Mathias Chouet's avatar Mathias Chouet
Browse files

Fix #382 - PAR: add button to generate ParSimulation

parent 2ad6086e
No related branches found
No related tags found
No related merge requests found
...@@ -120,6 +120,11 @@ ...@@ -120,6 +120,11 @@
{{ uitextGenerateRuSp }} {{ uitextGenerateRuSp }}
</button> </button>
<button mat-raised-button color="accent" id="generate-par-simulation" *ngIf="isPAR" (click)="generatePARSimulation()"
[disabled]="! generatePARSimulationEnabled" [title]="uitextGenerateParSimulationTitle">
{{ uitextGeneratePARSimulation }}
</button>
<mat-card-content> <mat-card-content>
<calc-results id="resultsComp" (afterViewChecked)="onCalcResultsViewChecked()"></calc-results> <calc-results id="resultsComp" (afterViewChecked)="onCalcResultsViewChecked()"></calc-results>
</mat-card-content> </mat-card-content>
......
...@@ -16,6 +16,9 @@ import { ...@@ -16,6 +16,9 @@ import {
round, round,
Nub, Nub,
RegimeUniforme RegimeUniforme
Par,
ParSimulationParams,
ParSimulation
} from "jalhyd"; } from "jalhyd";
import { generateValuesCombination } from "../../util"; import { generateValuesCombination } from "../../util";
...@@ -216,6 +219,10 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe ...@@ -216,6 +219,10 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
return this.intlService.localizeText("INFO_CALCULATOR_RESULTS_GENERATE_RU_SP"); 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() { public get uitextOpenHelp() {
return this.intlService.localizeText("INFO_CALCULATOR_OPEN_HELP"); return this.intlService.localizeText("INFO_CALCULATOR_OPEN_HELP");
} }
...@@ -594,19 +601,27 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe ...@@ -594,19 +601,27 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
return this.is(CalculatorType.RegimeUniforme); 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; let ret = true;
for (const p of this._formulaire.currentNub.parameterIterator) { for (const p of this._formulaire.currentNub.parameterIterator) {
if (p.valueMode === ParamValueMode.LINK) { if (! except.includes(p.symbol)) {
ret = ret && (! p.hasMultipleValues); if (p.valueMode === ParamValueMode.LINK) {
} else { ret = ret && (! p.hasMultipleValues);
// avoid calling hasMultipleValues here, because changing parameter mode in GUI } else {
// switches valueMode before setting min/max/step or valuesList, and iterator // avoid calling hasMultipleValues here, because changing parameter mode in GUI
// checker fails to count values that do not exist yet // switches valueMode before setting min/max/step or valuesList, and iterator
ret = ret && (! [ ParamValueMode.LISTE, ParamValueMode.MINMAX ].includes(p.valueMode)); // checker fails to count values that do not exist yet
ret = ret && (! [ ParamValueMode.LISTE, ParamValueMode.MINMAX ].includes(p.valueMode));
}
} }
} }
return ret; return ret;
...@@ -621,7 +636,7 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe ...@@ -621,7 +636,7 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
public get uitextGeneratePabTitle() { public get uitextGeneratePabTitle() {
if (! this.hasResults) { if (! this.hasResults) {
return this.intlService.localizeText("INFO_CALCULER_D_ABORD"); return this.intlService.localizeText("INFO_CALCULATE_FIRST");
} }
if (! this.allParamsAreFixed()) { if (! this.allParamsAreFixed()) {
return this.intlService.localizeText("INFO_PARAMETRES_FIXES"); return this.intlService.localizeText("INFO_PARAMETRES_FIXES");
...@@ -687,7 +702,7 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe ...@@ -687,7 +702,7 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
public get uitextGenerateSPAmontTitle(): string { public get uitextGenerateSPAmontTitle(): string {
if (! this.generateSPAmontEnabled) { if (! this.generateSPAmontEnabled) {
return this.intlService.localizeText("INFO_CALCULER_D_ABORD"); return this.intlService.localizeText("INFO_CALCULATE_FIRST");
} else { } else {
return ""; return "";
} }
...@@ -695,7 +710,7 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe ...@@ -695,7 +710,7 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
public get uitextGenerateSPAvalTitle(): string { public get uitextGenerateSPAvalTitle(): string {
if (! this.generateSPAvalEnabled) { if (! this.generateSPAvalEnabled) {
return this.intlService.localizeText("INFO_CALCULER_D_ABORD"); return this.intlService.localizeText("INFO_CALCULATE_FIRST");
} else { } else {
return ""; return "";
} }
...@@ -825,6 +840,73 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe ...@@ -825,6 +840,73 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
// calculate // calculate
f.doCompute(); f.doCompute();
// go to new SP // 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(); this.router.navigate(["/calculator", f.uid]).then();
} }
); );
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
"INFO_CALCULATOR_PARAMFIXES": "Fixed parameters", "INFO_CALCULATOR_PARAMFIXES": "Fixed parameters",
"INFO_CALCULATOR_RESULTS_GENERATE_PAB": "Generate a fish ladder", "INFO_CALCULATOR_RESULTS_GENERATE_PAB": "Generate a fish ladder",
"INFO_CALCULATOR_RESULTS_GENERATE_RU_SP": "Hydraulic details of section", "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_AMONT": "Hydraulic details of upstream section",
"INFO_CALCULATOR_RESULTS_GENERATE_SP_AVAL": "Hydraulic details of downstream section", "INFO_CALCULATOR_RESULTS_GENERATE_SP_AVAL": "Hydraulic details of downstream section",
"INFO_CALCULATOR_RESULTS_TITLE": "Results", "INFO_CALCULATOR_RESULTS_TITLE": "Results",
...@@ -331,6 +332,7 @@ ...@@ -331,6 +332,7 @@
"INFO_MACRORUGOCOMPOUND_TITRE": "Compound rock-ramp fishpasses", "INFO_MACRORUGOCOMPOUND_TITRE": "Compound rock-ramp fishpasses",
"INFO_MACRORUGOCOMPOUND_TITRE_COURT": "Compound RR", "INFO_MACRORUGOCOMPOUND_TITRE_COURT": "Compound RR",
"INFO_MACRORUGOCOMPOUND_LINCL": "Lateral inclination (m/m): ", "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": "Slope",
"INFO_PENTE_TITRE_COURT": "Slope", "INFO_PENTE_TITRE_COURT": "Slope",
"INFO_MENU_EMPTY_SESSION_TITLE": "New session", "INFO_MENU_EMPTY_SESSION_TITLE": "New session",
...@@ -362,7 +364,7 @@ ...@@ -362,7 +364,7 @@
"INFO_PAB_BASSINS": "Basins", "INFO_PAB_BASSINS": "Basins",
"INFO_PAB_OUVRAGES": "Devices", "INFO_PAB_OUVRAGES": "Devices",
"INFO_PAB_EDIT_VALUES": "Modify values", "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_NUM_BASSIN": "Basin #",
"INFO_PAB_HEADER_TYPE": "Type", "INFO_PAB_HEADER_TYPE": "Type",
"INFO_PAB_HEADER_PARAMETERS": "Parameters", "INFO_PAB_HEADER_PARAMETERS": "Parameters",
...@@ -382,11 +384,11 @@ ...@@ -382,11 +384,11 @@
"INFO_PABPUISSANCE_TITRE_COURT": "FL: diss. power", "INFO_PABPUISSANCE_TITRE_COURT": "FL: diss. power",
"INFO_PABPUISSANCE_TITRE": "Fish ladder: dissipated power", "INFO_PABPUISSANCE_TITRE": "Fish ladder: dissipated power",
"INFO_PARALLELSTRUCTURE_TITRE_COURT": "// structures", "INFO_PARALLELSTRUCTURE_TITRE_COURT": "// structures",
"INFO_PARSIMULATION_TITRE": "Humpback fishway: simulation",
"INFO_PARSIMULATION_TITRE_COURT": "HF: simulation",
"INFO_PARALLELSTRUCTURE_TITRE": "Parallel structures", "INFO_PARALLELSTRUCTURE_TITRE": "Parallel structures",
"INFO_PAR_TITRE": "Humpback fishway: setup", "INFO_PAR_TITRE": "Humpback fishway: setup",
"INFO_PAR_TITRE_COURT": "HF: 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_AWAITING_CALCULATION": "Awaiting calculation",
"INFO_PARAMFIELD_BOUNDARY_CONDITIONS": "Boundary conditions", "INFO_PARAMFIELD_BOUNDARY_CONDITIONS": "Boundary conditions",
"INFO_PARAMFIELD_CALCULATED": "Calculated", "INFO_PARAMFIELD_CALCULATED": "Calculated",
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
"INFO_CALCULATOR_PARAMFIXES": "Paramètres fixés", "INFO_CALCULATOR_PARAMFIXES": "Paramètres fixés",
"INFO_CALCULATOR_RESULTS_GENERATE_PAB": "Générer une passe à bassins", "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_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_AMONT": "Détails hydrauliques de la section amont",
"INFO_CALCULATOR_RESULTS_GENERATE_SP_AVAL": "Détails hydrauliques de la section aval", "INFO_CALCULATOR_RESULTS_GENERATE_SP_AVAL": "Détails hydrauliques de la section aval",
"INFO_CALCULATOR_RESULTS_TITLE": "Résultats", "INFO_CALCULATOR_RESULTS_TITLE": "Résultats",
...@@ -217,6 +218,7 @@ ...@@ -217,6 +218,7 @@
"INFO_LIB_BB": "Largeur du bassin", "INFO_LIB_BB": "Largeur du bassin",
"INFO_LIB_BETA": "Coefficient béta", "INFO_LIB_BETA": "Coefficient béta",
"INFO_LIB_BT": "Demi-ouverture du triangle", "INFO_LIB_BT": "Demi-ouverture du triangle",
"INFO_LIB_CD": "Coefficient de débit",
"INFO_LIB_CDGR": "Coefficient de débit vanne", "INFO_LIB_CDGR": "Coefficient de débit vanne",
"INFO_LIB_CDWR": "Coefficient de débit seuil", "INFO_LIB_CDWR": "Coefficient de débit seuil",
"INFO_LIB_CDWSL": "Coefficient de débit fente", "INFO_LIB_CDWSL": "Coefficient de débit fente",
...@@ -330,6 +332,7 @@ ...@@ -330,6 +332,7 @@
"INFO_MACRORUGOCOMPOUND_TITRE": "Passe à macro-rugosités complexe", "INFO_MACRORUGOCOMPOUND_TITRE": "Passe à macro-rugosités complexe",
"INFO_MACRORUGOCOMPOUND_TITRE_COURT": "M-Rugo complexe", "INFO_MACRORUGOCOMPOUND_TITRE_COURT": "M-Rugo complexe",
"INFO_MACRORUGOCOMPOUND_LINCL": "Dévers latéral (m/m)&nbsp;:", "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": "Pente",
"INFO_PENTE_TITRE_COURT": "Pente", "INFO_PENTE_TITRE_COURT": "Pente",
"INFO_MENU_EMPTY_SESSION_TITLE": "Nouvelle session", "INFO_MENU_EMPTY_SESSION_TITLE": "Nouvelle session",
...@@ -361,7 +364,7 @@ ...@@ -361,7 +364,7 @@
"INFO_PAB_BASSINS": "Bassins", "INFO_PAB_BASSINS": "Bassins",
"INFO_PAB_OUVRAGES": "Ouvrages", "INFO_PAB_OUVRAGES": "Ouvrages",
"INFO_PAB_EDIT_VALUES": "Modifier les valeurs", "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_NUM_BASSIN": "N° de bassin",
"INFO_PAB_HEADER_TYPE": "Type", "INFO_PAB_HEADER_TYPE": "Type",
"INFO_PAB_HEADER_PARAMETERS": "Paramètres", "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