diff --git a/spec/session/serialisation.spec.ts b/spec/session/serialisation.spec.ts index df1b487de98dc373034232e3c5f310e9052af2a8..f674253616fad61d1d292fd9b11ee04af8b27841 100644 --- a/spec/session/serialisation.spec.ts +++ b/spec/session/serialisation.spec.ts @@ -34,7 +34,7 @@ import { RectangularStructureParams } from "../../src/structure/rectangular_stru import { LoiDebit } from "../../src/structure/structure_props"; import { StructureWeirSubmergedLarinier, } from "../../src/structure/structure_weir_submerged_larinier"; import { TriangularTruncStructureParams } from "../../src/structure/structure_triangular_trunc_weir_params"; -import { StructureJetTypeStrict } from "../../src/structure/structure"; +import { StructureJetType } from "../../src/structure/structure"; import { CloisonsAvalParams } from "../../src/pab/cloison_aval_params"; import { Verificateur } from "../../src/verification/verificateur"; import { CloisonAval } from "../../src/pab/cloison_aval"; @@ -446,20 +446,18 @@ describe("sessions containing Solveur - ", () => { describe("sessions containing Verificateur - ", () => { - it("serialised session should contain 'nubToVerify', 'speciesList' and 'pabJetType' properties", () => { + it("serialised session should contain 'nubToVerify' and 'speciesList' properties", () => { Session.getInstance().clear(); const p = new Pab(new PabParams(1, 100, 99), new CloisonAval(new CloisonsAvalParams(1, 100, 99, 99.5))); const e = new Espece(new EspeceParams(2)); const v = new Verificateur(); v.nubToVerify = p; - v.pabJetType = StructureJetTypeStrict.PLONGEANT; v.speciesList = [ "4", e.uid ]; Session.getInstance().registerNubs([ e, p, v ]); const serialised = Session.getInstance().serialise(); expect(serialised).toContain(`"nubToVerify":"`); expect(serialised).toContain(`"speciesList":[`); - expect(serialised).toContain(`"pabJetType":"`); }); it("session with a Verificateur in last position should be loaded without errors", () => { @@ -473,8 +471,6 @@ describe("sessions containing Verificateur - ", () => { const ntv = verificateur.nubToVerify; expect(ntv).toBeDefined(); expect(ntv.uid).toBe("MG45Yj"); - const pjt = verificateur.pabJetType; - expect(pjt).toBe(StructureJetTypeStrict.PLONGEANT); const spl = verificateur.speciesList; expect(spl).toBeDefined(); expect(spl).toEqual([ "SPECIES_2", "SPECIES_6", "SPECIES_7b", "Nms4Nn" ]); @@ -491,8 +487,6 @@ describe("sessions containing Verificateur - ", () => { const ntv = verificateur.nubToVerify; expect(ntv).toBeDefined(); expect(ntv.uid).toBe("MG45Yj"); - const pjt = verificateur.pabJetType; - expect(pjt).toBe(StructureJetTypeStrict.PLONGEANT); const spl = verificateur.speciesList; expect(spl).toBeDefined(); expect(spl).toEqual([ "SPECIES_2", "SPECIES_6", "SPECIES_7b", "Nms4Nn" ]); diff --git a/spec/session/session.verificateur.first.ts b/spec/session/session.verificateur.first.ts index 34294912f60eec937cd37fc2cd81d8803c33198e..9577d0f2b0ef4f8e14490e2b27d69b023df9d77a 100644 --- a/spec/session/session.verificateur.first.ts +++ b/spec/session/session.verificateur.first.ts @@ -16,7 +16,6 @@ export const sessionVerificateurFirst = { props: { calcType: "Verificateur", nubToVerify: "MG45Yj", - pabJetType: "PLONGEANT", speciesList: [ "SPECIES_2", "SPECIES_6", @@ -108,7 +107,12 @@ export const sessionVerificateurFirst = { mode: "CALCUL" }, { - symbol: "DHMax", + symbol: "DHMaxS", + mode: "SINGLE", + value: 0.35 + }, + { + symbol: "DHMaxP", mode: "SINGLE", value: 0.35 }, @@ -118,12 +122,22 @@ export const sessionVerificateurFirst = { value: 0.3 }, { - symbol: "PMin", + symbol: "PMinS", + mode: "SINGLE", + value: 1 + }, + { + symbol: "PMinP", mode: "SINGLE", value: 1 }, { - symbol: "LMin", + symbol: "LMinS", + mode: "SINGLE", + value: 2.5 + }, + { + symbol: "LMinP", mode: "SINGLE", value: 2.5 }, @@ -284,7 +298,12 @@ export const sessionVerificateurFirst = { mode: "CALCUL" }, { - symbol: "DHMax", + symbol: "DHMaxS", + mode: "SINGLE", + value: 0.35 + }, + { + symbol: "DHMaxP", mode: "SINGLE", value: 0.35 }, @@ -294,12 +313,22 @@ export const sessionVerificateurFirst = { value: 0.3 }, { - symbol: "PMin", + symbol: "PMinS", + mode: "SINGLE", + value: 1 + }, + { + symbol: "PMinP", mode: "SINGLE", value: 1 }, { - symbol: "LMin", + symbol: "LMinS", + mode: "SINGLE", + value: 2.5 + }, + { + symbol: "LMinP", mode: "SINGLE", value: 2.5 }, diff --git a/spec/session/session.verificateur.last.ts b/spec/session/session.verificateur.last.ts index 6a4143d12ff216e71ad215e07ab59b37ea17b924..cab34a220a42bd9fc0f77c1ca7efebda3d6100ac 100644 --- a/spec/session/session.verificateur.last.ts +++ b/spec/session/session.verificateur.last.ts @@ -91,7 +91,12 @@ export const sessionVerificateurLast = { mode: "CALCUL" }, { - symbol: "DHMax", + symbol: "DHMaxS", + mode: "SINGLE", + value: 0.35 + }, + { + symbol: "DHMaxP", mode: "SINGLE", value: 0.35 }, @@ -101,12 +106,22 @@ export const sessionVerificateurLast = { value: 0.3 }, { - symbol: "PMin", + symbol: "PMinS", + mode: "SINGLE", + value: 1 + }, + { + symbol: "PMinP", mode: "SINGLE", value: 1 }, { - symbol: "LMin", + symbol: "LMinS", + mode: "SINGLE", + value: 2.5 + }, + { + symbol: "LMinP", mode: "SINGLE", value: 2.5 }, @@ -267,7 +282,12 @@ export const sessionVerificateurLast = { mode: "CALCUL" }, { - symbol: "DHMax", + symbol: "DHMaxS", + mode: "SINGLE", + value: 0.35 + }, + { + symbol: "DHMaxP", mode: "SINGLE", value: 0.35 }, @@ -277,12 +297,22 @@ export const sessionVerificateurLast = { value: 0.3 }, { - symbol: "PMin", + symbol: "PMinS", + mode: "SINGLE", + value: 1 + }, + { + symbol: "PMinP", mode: "SINGLE", value: 1 }, { - symbol: "LMin", + symbol: "LMinS", + mode: "SINGLE", + value: 2.5 + }, + { + symbol: "LMinP", mode: "SINGLE", value: 2.5 }, @@ -318,7 +348,6 @@ export const sessionVerificateurLast = { props: { calcType: "Verificateur", nubToVerify: "MG45Yj", - pabJetType: "PLONGEANT", speciesList: [ "SPECIES_2", "SPECIES_6", diff --git a/spec/verificateur/verificateur.spec.ts b/spec/verificateur/verificateur.spec.ts index 212e30fa2794b2ae26b36a01c9857da891d9ed35..a397b9dc42e2f10d7a2eb0e8ac5ea372482fca6d 100644 --- a/spec/verificateur/verificateur.spec.ts +++ b/spec/verificateur/verificateur.spec.ts @@ -5,7 +5,6 @@ import { Props } from "../../src/props"; import { CalculatorType } from "../../src/compute-node"; import { CloisonAval } from "../../src/pab/cloison_aval"; import { FishSpecies } from "../../src/verification/fish_species"; -import { StructureJetTypeStrict } from "../../src/structure/structure"; import { ParSimulation } from "../../src/par/par_simulation"; import { MacroRugo } from "../../src/macrorugo/macrorugo"; import { MacrorugoCompound } from "../../src/macrorugo/macrorugo_compound"; @@ -17,6 +16,8 @@ import { Cloisons } from "../../src/pab/cloisons"; import { MessageCode } from "../../src/util/message"; import { ParType } from "../../src/par/par"; import { MRCInclination } from "../../src/macrorugo/mrc-inclination"; +import { Espece } from "../../src/verification/espece"; +import { StructureJetType } from "../../src/structure/structure"; function createPab(): Pab { const pab = Session.getInstance().createSessionNub( @@ -98,14 +99,14 @@ describe("vérificateur de franchissement −", () => { // vérificateur const v = new Verificateur(); v.nubToVerify = pab; - v.pabJetType = StructureJetTypeStrict.SURFACE; v.speciesList.push(FishSpecies[FishSpecies.SPECIES_1]); // résultat const res = v.CalcSerie(); expect(res.ok).toBe(true); expect(res.vCalc).toBe(1); - expect(res.log.messages.length).toBe(0); + expect(res.log.messages.length).toBe(1); + expect(res.log.messages[0].code).toBe(MessageCode.INFO_VERIF_SPECIES_OK); expect(res.globalLog.messages.length).toBe(1); expect(res.globalLog.messages[0].code).toBe(MessageCode.INFO_VERIF_OK); }); @@ -119,41 +120,18 @@ describe("vérificateur de franchissement −", () => { // vérificateur const v = new Verificateur(); v.nubToVerify = pab; - v.pabJetType = StructureJetTypeStrict.PLONGEANT; v.speciesList.push(FishSpecies[FishSpecies.SPECIES_1]); // résultat const res = v.CalcSerie(); expect(res.ok).toBe(true); expect(res.vCalc).toBe(1); - expect(res.log.messages.length).toBe(0); + expect(res.log.messages.length).toBe(1); + expect(res.log.messages[0].code).toBe(MessageCode.INFO_VERIF_SPECIES_OK); expect(res.globalLog.messages.length).toBe(1); expect(res.globalLog.messages[0].code).toBe(MessageCode.INFO_VERIF_OK); }); - // wrong jet types - it("Type de jets", () => { - // contexte - const pab = loadExamplePab(); - // vérificateur - const v = new Verificateur(); - v.nubToVerify = pab; - v.pabJetType = StructureJetTypeStrict.PLONGEANT; - v.speciesList.push(FishSpecies[FishSpecies.SPECIES_1]); - // résultat - const res = v.CalcSerie(); - expect(res.ok).toBe(false); - - /* expect(res.globalLog.messages.length).toBe(1); - expect(res.globalLog.messages[0].code).toBe(MessageCode.ERROR_VERIF_KO); */ - expect(res.log.messages.length).toBe(1); - expect(res.log.messages[0].code).toBe(MessageCode.ERROR_VERIF_SPECIES_KO); - const r0 = v.species[0].result; - expect(r0.log.messages.length).toBe(6); // 5 cloisons + 1 downwall - expect(r0.log.messages[2].code).toBe(MessageCode.ERROR_VERIF_PAB_JETS); - expect(r0.log.messages[5].code).toBe(MessageCode.ERROR_VERIF_PAB_JETS_DW); - }); - // falls on Cloison / downwall it("Chute trop importante", () => { // contexte @@ -161,7 +139,6 @@ describe("vérificateur de franchissement −", () => { // vérificateur const v = new Verificateur(); v.nubToVerify = pab; - v.pabJetType = StructureJetTypeStrict.SURFACE; v.speciesList.push(FishSpecies[FishSpecies.SPECIES_9b]); // 0.2 < 0.227 // résultat const res = v.CalcSerie(); @@ -171,8 +148,8 @@ describe("vérificateur de franchissement −", () => { expect(res.log.messages[0].code).toBe(MessageCode.ERROR_VERIF_SPECIES_KO); const r0 = v.species[0].result; expect(r0.log.messages.length).toBe(6); // 5 cloisons + 1 downwall - expect(r0.log.messages[2].code).toBe(MessageCode.ERROR_VERIF_PAB_DHMAX); - expect(r0.log.messages[5].code).toBe(MessageCode.ERROR_VERIF_PAB_DHMAX_DW); + expect(r0.log.messages[2].code).toBe(MessageCode.ERROR_VERIF_PAB_DHMAX_JET); + expect(r0.log.messages[5].code).toBe(MessageCode.ERROR_VERIF_PAB_DHMAX_JET_DW); }); // weirs and slots witdh @@ -188,7 +165,6 @@ describe("vérificateur de franchissement −", () => { // vérificateur const v = new Verificateur(); v.nubToVerify = pab; - v.pabJetType = StructureJetTypeStrict.SURFACE; v.speciesList.push(FishSpecies[FishSpecies.SPECIES_3b]); // 0.35 < 0.4 // résultat const res = v.CalcSerie(); @@ -212,7 +188,6 @@ describe("vérificateur de franchissement −", () => { // vérificateur const v = new Verificateur(); v.nubToVerify = pab; - v.pabJetType = StructureJetTypeStrict.PLONGEANT; v.speciesList.push(FishSpecies[FishSpecies.SPECIES_1]); // résultat const res = v.CalcSerie(); @@ -222,7 +197,7 @@ describe("vérificateur de franchissement −", () => { expect(res.log.messages[0].code).toBe(MessageCode.ERROR_VERIF_SPECIES_KO); const r0 = v.species[0].result; expect(r0.log.messages.length).toBe(2); - expect(r0.log.messages[0].code).toBe(MessageCode.ERROR_VERIF_PAB_YMOY); + expect(r0.log.messages[0].code).toBe(MessageCode.ERROR_VERIF_PAB_YMOY_JET); expect(r0.log.messages[1].code).toBe(MessageCode.ERROR_VERIF_PAB_YMOY_2_DH); expect(res.globalLog.messages.length).toBe(0); }); @@ -237,7 +212,6 @@ describe("vérificateur de franchissement −", () => { // vérificateur const v = new Verificateur(); v.nubToVerify = pab; - v.pabJetType = StructureJetTypeStrict.PLONGEANT; v.speciesList.push(FishSpecies[FishSpecies.SPECIES_1]); // résultat const res = v.CalcSerie(); @@ -260,7 +234,6 @@ describe("vérificateur de franchissement −", () => { // vérificateur const v = new Verificateur(); v.nubToVerify = pab; - v.pabJetType = StructureJetTypeStrict.SURFACE; v.speciesList.push(FishSpecies[FishSpecies.SPECIES_1]); // 2.25 < 2.5 // résultat const res = v.CalcSerie(); @@ -270,7 +243,38 @@ describe("vérificateur de franchissement −", () => { expect(res.log.messages[0].code).toBe(MessageCode.ERROR_VERIF_SPECIES_KO); const r0 = v.species[0].result; expect(r0.log.messages.length).toBe(1); - expect(r0.log.messages[0].code).toBe(MessageCode.ERROR_VERIF_PAB_LMIN); + expect(r0.log.messages[0].code).toBe(MessageCode.ERROR_VERIF_PAB_LMIN_JET); + }); + + it("Plusieurs warnings entraînent la non-franchissabilité d'une cloison", () => { + // contexte + Session.getInstance().clear(); + const sess = `{"header":{"source":"jalhyd","format_version":"1.3","created":"2020-04-29T10:00:03.138Z"},"settings":{"precision":1e-7,"maxIterations":100,"displayPrecision":3},"documentation":"","session":[{"uid":"bjlnc2","props":{"calcType":"Espece","species":"SPECIES_CUSTOM"},"meta":{"title":"Croustibat®"},"children":[],"parameters":[{"symbol":"OK","mode":"CALCUL"},{"symbol":"DHMaxS","mode":"SINGLE","value":0.35},{"symbol":"DHMaxP","mode":"SINGLE","value":0.6},{"symbol":"BMin","mode":"SINGLE","value":0.18},{"symbol":"PMinS","mode":"SINGLE","value":0.9},{"symbol":"PMinP","mode":"SINGLE","value":0.9},{"symbol":"LMinS","mode":"SINGLE","value":2.5},{"symbol":"LMinP","mode":"SINGLE","value":25},{"symbol":"HMin","mode":"SINGLE","value":0.3},{"symbol":"YMin","mode":"SINGLE","value":0.4},{"symbol":"VMax","mode":"SINGLE","value":2.5},{"symbol":"YMinSB","mode":"SINGLE","value":0.2},{"symbol":"YMinPB","mode":"SINGLE","value":0.3}]},{"uid":"M29hc3","props":{"calcType":"Pab"},"meta":{"title":"PAB 1"},"children":[{"uid":"eDllOD","props":{"calcType":"Cloisons"},"children":[{"uid":"ZGMwc3","props":{"calcType":"Structure","structureType":"SeuilRectangulaire","loiDebit":"WeirSubmergedLarinier"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":98},{"symbol":"L","mode":"SINGLE","value":0.2},{"symbol":"CdWSL","mode":"SINGLE","value":0.75}]},{"uid":"cGs5OX","props":{"calcType":"Structure","structureType":"SeuilRectangulaire","loiDebit":"WeirSubmergedLarinier"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":101},{"symbol":"L","mode":"SINGLE","value":0.2},{"symbol":"CdWSL","mode":"SINGLE","value":0.75}]}],"parameters":[{"symbol":"LB","mode":"SINGLE","value":10},{"symbol":"BB","mode":"SINGLE","value":1},{"symbol":"ZRMB","mode":"SINGLE","value":100.5},{"symbol":"ZRAM","mode":"SINGLE","value":100.75},{"symbol":"QA","mode":"SINGLE","value":0}]}],"parameters":[{"symbol":"Q","mode":"SINGLE","value":2.349},{"symbol":"Z1","mode":"CALCUL"},{"symbol":"Z2","mode":"SINGLE","value":101}],"downWall":{"uid":"NzBlcD","props":{"calcType":"CloisonAval"},"children":[{"uid":"cG5xdX","props":{"calcType":"Structure","structureType":"SeuilRectangulaire","loiDebit":"WeirSubmergedLarinier"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":97.5},{"symbol":"L","mode":"SINGLE","value":0.2},{"symbol":"CdWSL","mode":"SINGLE","value":0.75}]},{"uid":"aGM1ZG","props":{"calcType":"Structure","structureType":"SeuilRectangulaire","loiDebit":"WeirSubmergedLarinier"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":100.5},{"symbol":"L","mode":"SINGLE","value":0.2},{"symbol":"CdWSL","mode":"SINGLE","value":0.75}]}],"parameters":[{"symbol":"ZRAM","mode":"SINGLE","value":100.25}]}}]}`; + Session.getInstance().unserialise(sess); + const pab = Session.getInstance().findNubByUid("M29hc3") as Pab; + const espece = Session.getInstance().findNubByUid("bjlnc2") as Espece; + // vérificateur et espèce personnalisée + const v = new Verificateur(); + v.nubToVerify = pab; + v.speciesList.push(espece.uid); + // résultat + const res = v.CalcSerie(); + expect(res.ok).toBe(false); + + expect(res.log.messages.length).toBe(1); + expect(res.log.messages[0].code).toBe(MessageCode.ERROR_VERIF_SPECIES_KO); + expect(res.log.messages[0].extraVar.speciesGroup).toBe("bjlnc2"); + const r0 = v.species[0].result; + expect(r0.log.messages.length).toBe(4); // 2 warning + 1 erreur "cloison infranchissable" + expect(r0.log.messages[0].code).toBe(MessageCode.WARNING_VERIF_PAB_DHMAX_JET); + expect(r0.log.messages[0].extraVar.jetType).toBe(StructureJetType.SURFACE); + expect(r0.log.messages[1].code).toBe(MessageCode.WARNING_VERIF_PAB_LMIN_JET); + expect(r0.log.messages[1].extraVar.jetType).toBe(StructureJetType.PLONGEANT); + expect(r0.log.messages[2].code).toBe(MessageCode.ERROR_VERIF_PAB_WALL_NOT_CROSSABLE); + expect(r0.log.messages[2].extraVar.N).toBe("1"); + expect(r0.log.messages[3].code).toBe(MessageCode.ERROR_VERIF_PAB_DHMAX_JET_DW); // downwall jets are both Surface (not the object of the test but still fails) + expect(r0.log.messages[3].extraVar.jetType).toBe(StructureJetType.SURFACE); + expect(res.globalLog.messages.length).toBe(0); }); }); @@ -290,7 +294,8 @@ describe("vérificateur de franchissement −", () => { expect(res.ok).toBe(true); expect(res.vCalc).toBe(1); - expect(res.log.messages.length).toBe(0); + expect(res.log.messages.length).toBe(1); + expect(res.log.messages[0].code).toBe(MessageCode.INFO_VERIF_SPECIES_OK); expect(res.globalLog.messages.length).toBe(1); expect(res.globalLog.messages[0].code).toBe(MessageCode.INFO_VERIF_OK); }); @@ -478,7 +483,8 @@ describe("vérificateur de franchissement −", () => { expect(res.ok).toBe(true); expect(res.vCalc).toBe(1); - expect(res.log.messages.length).toBe(0); + expect(res.log.messages.length).toBe(1); + expect(res.log.messages[0].code).toBe(MessageCode.INFO_VERIF_SPECIES_OK); expect(res.globalLog.messages.length).toBe(1); expect(res.globalLog.messages[0].code).toBe(MessageCode.INFO_VERIF_OK); }); @@ -545,7 +551,8 @@ describe("vérificateur de franchissement −", () => { expect(res.ok).toBe(true); expect(res.vCalc).toBe(1); - expect(res.log.messages.length).toBe(0); + expect(res.log.messages.length).toBe(1); + expect(res.log.messages[0].code).toBe(MessageCode.INFO_VERIF_SPECIES_OK); expect(res.globalLog.messages.length).toBe(1); expect(res.globalLog.messages[0].code).toBe(MessageCode.INFO_VERIF_OK); }); diff --git a/src/session.ts b/src/session.ts index ee6a5b798bee8481ca48a93697f4a03370f676fc..855e9858e61b91b00a3e68368291f180b0a2e24d 100644 --- a/src/session.ts +++ b/src/session.ts @@ -77,11 +77,9 @@ import { ParParams } from "./par/par_params"; import { ParSimulation } from "./par/par_simulation"; import { ParSimulationParams } from "./par/par_simulation_params"; import { FishSpecies } from "./verification/fish_species"; -import { StructureJetTypeStrict } from "./structure/structure"; import { Espece } from "./verification/espece"; import { EspeceParams } from "./verification/espece_params"; import { Verificateur } from "./verification/verificateur"; -import { VerificateurParams } from "./verification/verificateur_params"; export class Session { @@ -101,8 +99,7 @@ export class Session { structureType: StructureType, inclinedApron: MRCInclination, parType: ParType, - species: FishSpecies, - pabJetType: StructureJetTypeStrict, + species: FishSpecies }; @@ -703,10 +700,13 @@ export class Session { nub = new Espece( // default params are those for SPECIES_1 (Salmons and trouts) new EspeceParams( - 0.35, // DHMax - 0.3, // BMIn - 1, // PMin - 2.5, // LMin + 0.35, // DHMaxS + 0.35, // DHMaxP + 0.3, // BMin + 1, // PMinS + 1, // PMinP + 2.5, // LMinS + 2.5, // LMinP 0.3, // HMin 0.4, // YMin 2.5, // VMax diff --git a/src/structure/structure.ts b/src/structure/structure.ts index 26249151dea9648e9af8344bcd74ee698220838f..1797f8a421bd09e531498eddd726b2ad5196f068 100644 --- a/src/structure/structure.ts +++ b/src/structure/structure.ts @@ -42,17 +42,6 @@ export enum StructureJetType { /** Sans objet (orifice) */ SO } -/** - * Type de jet, sans l'option "Sans objet" - * @WARNING clodo trick: synchroniser les valeurs avec StructureJetType ! - * @TODO faire hériter StructureJetType de cet enum lorsque ce sera possible dans TypeScript - */ -export enum StructureJetTypeStrict { - /** Plongeant */ - PLONGEANT, - /** De surface */ - SURFACE -} /** * classe de calcul sur la conduite distributrice diff --git a/src/util/message.ts b/src/util/message.ts index f92773e8c09b56abee77840eb1cb4f0907fc8c0b..9c8f31a439c50a1b0de9b101653b5b05700a2dfc 100644 --- a/src/util/message.ts +++ b/src/util/message.ts @@ -198,9 +198,12 @@ export enum MessageCode { /** Vérificateur : les nubs Espece ont produit au moins un message de niveau erreur sur l'ensemble des résultats */ ERROR_VERIF_KO, - /** Vérificateur : le nub Espece pour le groupe %speciesGroup% a produit au moins un message de niveau erreur dans le résultat en cours*/ + /** Vérificateur : le nub Espece pour le groupe %speciesGroup% a produit au moins un message de niveau erreur dans le résultat en cours */ ERROR_VERIF_SPECIES_KO, + /** Vérificateur : le nub Espece pour le groupe %speciesGroup% n'a produit aucun message de niveau erreur */ + INFO_VERIF_SPECIES_OK, + /** Vérificateur, passe à macrorugosités : vitesse max. %V% trop élevée (maximum: %maxV%) */ ERROR_VERIF_MR_VMAX, @@ -219,39 +222,90 @@ export enum MessageCode { /** Vérificateur : aucun jeu de contraintes pour le couple espèce / type de passe */ ERROR_VERIF_NO_PRESET, - /** Vérificateur, passe à bassins : chute %DH% trop importante (maximum: %maxDH%) dans la cloison %N% */ + /** Vérificateur, passe à bassins : chute %DH% trop importante pour les deux types de jets (maximum: %maxDHS% et %maxDHP%) dans la cloison %N% */ ERROR_VERIF_PAB_DHMAX, - /** Vérificateur, passe à bassins : chute %DH% trop importante (maximum: %maxDH%) dans la cloison aval */ + /** Vérificateur, passe à bassins : chute %DH% trop importante pour les deux types de jets (maximum: %maxDHS% et %maxDHP%) dans la cloison aval */ ERROR_VERIF_PAB_DHMAX_DW, + /** Vérificateur, passe à bassins : chute %DH% trop importante pour le type de jet %jetType% (maximum: %maxDH%) dans la cloison %N% */ + ERROR_VERIF_PAB_DHMAX_JET, + + /** Vérificateur, passe à bassins : chute %DH% trop importante pour le type de jet %jetType% (maximum: %maxDH%) dans la cloison aval */ + ERROR_VERIF_PAB_DHMAX_JET_DW, + + /** Vérificateur, passe à bassins : chute %DH% trop importante pour le type de jet %jetType% (maximum: %maxDH%) dans la cloison %N%, mais la cloison est franchissable grâce à l'autre type de jet */ + WARNING_VERIF_PAB_DHMAX_JET, + + /** Vérificateur, passe à bassins : chute %DH% trop importante pour le type de jet %jetType% (maximum: %maxDH%) dans la cloison aval, mais la cloison est franchissable grâce à l'autre type de jet */ + WARNING_VERIF_PAB_DHMAX_JET_DW, + /** Vérificateur, passe à bassins : largeur de l'échancrure ou de la fente %L% insuffisante (minimum: %minB%) dans la cloison %NC%, ouvrage %NS% */ ERROR_VERIF_PAB_BMIN, /** Vérificateur, passe à bassins : largeur de l'échancrure ou de la fente %L% insuffisante (minimum: %minB%) dans la cloison aval, ouvrage %NS% */ ERROR_VERIF_PAB_BMIN_DW, - /** Vérificateur, passe à bassins : au moins un jet de type %required% requis, dans la cloison %N% */ - ERROR_VERIF_PAB_JETS, + /** Vérificateur, passe à bassins : largeur de l'échancrure ou de la fente %L% insuffisante (minimum: %minB%) dans la cloison %NC%, ouvrage %NS% */ + WARNING_VERIF_PAB_BMIN, + + /** Vérificateur, passe à bassins : largeur de l'échancrure ou de la fente %L% insuffisante (minimum: %minB%) dans la cloison aval, ouvrage %NS% */ + WARNING_VERIF_PAB_BMIN_DW, + + /** Vérificateur, passe à bassins : surface de l'orifice %S% insuffisante (minimum: %minS%) dans la cloison %NC%, ouvrage %NS% */ + ERROR_VERIF_PAB_SMIN, + + /** Vérificateur, passe à bassins : surface de l'orifice %S% insuffisante (minimum: %minS%) dans la cloison aval, ouvrage %NS% */ + ERROR_VERIF_PAB_SMIN_DW, + + /** Vérificateur, passe à bassins : surface de l'orifice %S% insuffisante (minimum: %minS%) dans la cloison %NC%, ouvrage %NS% */ + WARNING_VERIF_PAB_SMIN, - /** Vérificateur, passe à bassins : au moins un jet de type %required% requis, dans la cloison aval */ - ERROR_VERIF_PAB_JETS_DW, + /** Vérificateur, passe à bassins : surface de l'orifice %S% insuffisante (minimum: %minS%) dans la cloison aval, ouvrage %NS% */ + WARNING_VERIF_PAB_SMIN_DW, - /** Vérificateur, passe à bassins : longueur de bassin %LB% insuffisante (minimum: %minLB%) dans la cloison %N% */ + /** Vérificateur, passe à bassins : longueur de bassin %LB% insuffisante pour les deux types de jet (minimum: %minLBS% et %minLBP%) dans la cloison %N% */ ERROR_VERIF_PAB_LMIN, + /** Vérificateur, passe à bassins : longueur de bassin %LB% insuffisante pour le type de jet %jetType% (minimum: %minLB%) dans la cloison %N% */ + ERROR_VERIF_PAB_LMIN_JET, + + /** Vérificateur, passe à bassins : longueur de bassin %LB% insuffisante pour le type de jet %jetType% (minimum: %minLB%) dans la cloison %N% */ + WARNING_VERIF_PAB_LMIN_JET, + /** Vérificateur, passe à bassins : charge sur l'échancrure %h1% insuffisante (minimum: %minH%) dans la cloison aval, ouvrage %NS% */ ERROR_VERIF_PAB_HMIN, /** Vérificateur, passe à bassins : charge sur l'échancrure %h1% insuffisante (minimum: %minH%) dans la cloison %NC%, ouvrage %NS% */ ERROR_VERIF_PAB_HMIN_DW, - /** Vérificateur, passe à bassins : profondeur de bassin %PB% insuffisante (minimum: %minPB%) dans la cloison %N% */ + /** Vérificateur, passe à bassins : charge sur l'échancrure %h1% insuffisante (minimum: %minH%) dans la cloison aval, ouvrage %NS% */ + WARNING_VERIF_PAB_HMIN, + + /** Vérificateur, passe à bassins : charge sur l'échancrure %h1% insuffisante (minimum: %minH%) dans la cloison %NC%, ouvrage %NS% */ + WARNING_VERIF_PAB_HMIN_DW, + + /** Vérificateur, passe à bassins : profondeur de bassin %PB% insuffisante pour les deux types de jet (minimum: %minPBS% et %minPBP%) dans la cloison %N% */ ERROR_VERIF_PAB_YMOY, - /** Vérificateur, passe à bassins à jet mlongeant : profondeur de bassin %PB% inférieure à 2x la chute %DH% dans la cloison %N% */ + /** Vérificateur, passe à bassins : profondeur de bassin %PB% insuffisante pour le type de jet %jetType% (minimum: %minPB%) dans la cloison %N% */ + ERROR_VERIF_PAB_YMOY_JET, + + /** Vérificateur, passe à bassins : profondeur de bassin %PB% insuffisante pour le type de jet %jetType% (minimum: %minPB%) dans la cloison %N% */ + WARNING_VERIF_PAB_YMOY_JET, + + /** Vérificateur, passe à bassins, jet plongeant : profondeur de bassin %PB% inférieure à 2x la chute %DH% dans la cloison %N% */ ERROR_VERIF_PAB_YMOY_2_DH, + /** Vérificateur, passe à bassins, jet plongeant : profondeur de bassin %PB% inférieure à 2x la chute %DH% dans la cloison %N% */ + WARNING_VERIF_PAB_YMOY_2_DH, + + /** Vérificateur, passe à bassins : aucun ouvrage de la cloison %N% n'est franchissable */ + ERROR_VERIF_PAB_WALL_NOT_CROSSABLE, + + /** Vérificateur, passe à bassins : aucun ouvrage de la cloison aval n'est franchissable */ + ERROR_VERIF_PAB_DW_NOT_CROSSABLE, + /** Vérificateur, passe à ralentisseurs : présence d'une chute en bas de passe */ ERROR_VERIF_PAR_DH, diff --git a/src/verification/espece.ts b/src/verification/espece.ts index c57e19b752050132e83655d20d5239a8e3df7f9b..65b73f5b722d40c6f382958f9626b2859b640eb5 100644 --- a/src/verification/espece.ts +++ b/src/verification/espece.ts @@ -6,7 +6,7 @@ import { ParamCalculability } from "../param/param-definition"; import { FishSpecies } from "./fish_species"; import { Result } from "../util/result"; import { FishPass } from "../fish_pass"; -import { StructureJetTypeStrict } from "../structure/structure"; +import { StructureJetType } from "../structure/structure"; import { Message, MessageCode } from "../util/message"; import { ParSimulation } from "../par/par_simulation"; import { ParType } from "../par/par"; @@ -17,6 +17,8 @@ import { Pab } from "../pab/pab"; import { LoiDebit } from "../structure/structure_props"; import { RectangularStructureParams } from "../structure/rectangular_structure_params"; import { ParallelStructure } from "../structure/parallel_structure"; +import { StructureOrificeSubmergedParams } from "../structure/structure_orifice_submerged_params"; +import { Cloisons } from "../pab/cloisons"; /** * Settings for a given fish species (or custom settings), to verify crossing capacities on fish passes. @@ -33,12 +35,6 @@ export class Espece extends Nub implements Observer { */ protected _passToCheck: FishPass; - /** - * When checking a Pab, expected jet type for every Cloison. - * Passed by the Verificateur - */ - protected _pabJetType: StructureJetTypeStrict; - /** * For variating passes, index of the result to examine. * Passed by the Verificateur @@ -60,117 +56,108 @@ export class Espece extends Nub implements Observer { this.presets = {}; // PAB this.presets[CalculatorType.Pab] = {}; - // PAB - Plongeant - this.presets[CalculatorType.Pab][StructureJetTypeStrict.PLONGEANT] = {}; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.PLONGEANT][FishSpecies.SPECIES_1] = { - DHMax: 0.75, - PMin: 1, - HMin: 0.3, - LMin: 2 - }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.PLONGEANT][FishSpecies.SPECIES_2] = { - DHMax: 0.6, - PMin: 0.75, - HMin: 0.2, - LMin: 1.25 - }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.PLONGEANT][FishSpecies.SPECIES_4a] = { - DHMax: 0.4, - PMin: 0.75, - HMin: 0.2, - LMin: 1.25 - }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.PLONGEANT][FishSpecies.SPECIES_4b] = - this.presets[CalculatorType.Pab][StructureJetTypeStrict.PLONGEANT][FishSpecies.SPECIES_6] = { - DHMax: 0.3, - PMin: 0.75, - HMin: 0.2, - LMin: 1 - }; - // PAB - Surface - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE] = {}; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_1] = { - DHMax: 0.35, + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_1] = { + DHMaxS: 0.35, BMin: 0.3, - PMin: 1, - LMin: 2.5 + PMinS: 1, + LMinS: 2.5, + DHMaxP: 0.75, + PMinP: 1, + HMin: 0.3, + LMinP: 2 }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_2] = { - DHMax: 0.35, + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_2] = { + DHMaxS: 0.35, BMin: 0.2, - PMin: 1, - LMin: 1.75 + PMinS: 1, + LMinS: 1.75, + DHMaxP: 0.6, + PMinP: 0.75, + HMin: 0.2, + LMinP: 1.25 }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_3a] = - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_3b] = { - DHMax: 0.3, + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_3a] = + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_3b] = { + DHMaxS: 0.3, BMin: 0.4, - PMin: 1, - LMin: 3.5 + PMinS: 1, + LMinS: 3.5 }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_3c] = { - DHMax: 0.3, + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_3c] = { + DHMaxS: 0.3, BMin: 0.15, - PMin: 1, - LMin: 1.25 + PMinS: 1, + LMinS: 1.25 }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_4a] = { - DHMax: 0.35, + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_4a] = { + DHMaxS: 0.35, BMin: 0.2, - PMin: 1, - LMin: 1.75 + PMinS: 1, + LMinS: 1.75, + DHMaxP: 0.4, + PMinP: 0.75, + HMin: 0.2, + LMinP: 1.25 }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_4b] = { - DHMax: 0.3, + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_4b] = { + DHMaxS: 0.3, BMin: 0.15, - PMin: 0.75, - LMin: 1.25 + PMinS: 0.75, + LMinS: 1, + DHMaxP: 0.3, + PMinP: 0.75, + HMin: 0.2, + LMinP: 1 }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_5] = { - DHMax: 0.3, + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_5] = { + DHMaxS: 0.3, BMin: 0.3, - PMin: 0.75, - LMin: 2.5 + PMinS: 0.75, + LMinS: 2.5, }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_6] = { - DHMax: 0.3, + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_6] = { + DHMaxS: 0.3, BMin: 0.2, - PMin: 0.75, - LMin: 1.75 + PMinS: 0.75, + LMinS: 1.75, + DHMaxP: 0.3, + PMinP: 0.75, + HMin: 0.2, + LMinP: 1 }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_7a] = { - DHMax: 0.3, + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_7a] = { + DHMaxS: 0.3, BMin: 0.25, - PMin: 0.75, - LMin: 2 + PMinS: 0.75, + LMinS: 2 }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_7b] = { - DHMax: 0.3, + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_7b] = { + DHMaxS: 0.3, BMin: 0.15, - PMin: 0.75, - LMin: 1.25 - }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_8a] = - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_8b] = - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_8c] = - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_8d] = { - DHMax: 0.25, + PMinS: 0.75, + LMinS: 1.25 + }; + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_8a] = + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_8b] = + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_8c] = + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_8d] = { + DHMaxS: 0.25, BMin: 0.3, - PMin: 0.75, - LMin: 2.5 + PMinS: 0.75, + LMinS: 2.5 }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_9a] = { - DHMax: 0.25, + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_9a] = { + DHMaxS: 0.25, BMin: 0.25, - PMin: 0.75, - LMin: 2 + PMinS: 0.75, + LMinS: 2 }; - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_9b] = - this.presets[CalculatorType.Pab][StructureJetTypeStrict.SURFACE][FishSpecies.SPECIES_10] = { - DHMax: 0.2, + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_9b] = + this.presets[CalculatorType.Pab][FishSpecies.SPECIES_10] = { + DHMaxS: 0.2, BMin: 0.15, - PMin: 0.5, - LMin: 1.25 + PMinS: 0.5, + LMinS: 1.25 }; // PAR Simulation this.presets[CalculatorType.ParSimulation] = {}; @@ -288,17 +275,8 @@ export class Espece extends Nub implements Observer { this.loadPredefinedParametersValues(); } - public get pabJetType(): StructureJetTypeStrict { - return this._pabJetType; - } - - public set pabJetType(t: StructureJetTypeStrict) { - this._pabJetType = t; - this.loadPredefinedParametersValues(); - } - /** Returns 1 if the fish can go through the pass, 0 if it cannot */ - public Equation(sVarCalc: string): Result { + public Equation(): Result { // default result is 1 (OK) const res = new Result(1, this); @@ -310,12 +288,6 @@ export class Espece extends Nub implements Observer { pt = CalculatorType.MacroRugo; } - // load preset - let preset = this.presets[pt]; - if (pt === CalculatorType.Pab && this.pabJetType !== undefined) { - preset = preset[this.pabJetType]; - } - // get result to examine const r = this._passToCheck.result.resultElements[this.indexToCheck]; if (r === undefined) { @@ -323,7 +295,7 @@ export class Espece extends Nub implements Observer { } // is there a valid preset for the pass type / species couple ? - if (sp !== FishSpecies.SPECIES_CUSTOM && preset[sp] === undefined) { + if (sp !== FishSpecies.SPECIES_CUSTOM && this.presets[pt][sp] === undefined) { res.vCalc = 0; res.log.add(new Message(MessageCode.ERROR_VERIF_NO_PRESET)); return res; @@ -334,101 +306,96 @@ export class Espece extends Nub implements Observer { case CalculatorType.Pab: const passB = this._passToCheck as Pab; - // 1. jet types + // A -- walls let cloisonNumber = 1; - for (const c of passB.children) { - this.checkJetTypes(c, cloisonNumber, res); - cloisonNumber++; - } - // downwall - this.checkJetTypes(passB.downWall, undefined, res); - - // 2. falls - cloisonNumber = 1; - for (const c of passB.children) { - const iRes = c.result.resultElements[this.indexToCheck]; - if (this.prms.DHMax.singleValue !== undefined && iRes.values.DH > this.prms.DHMax.singleValue) { - res.vCalc = 0; - const m = new Message(MessageCode.ERROR_VERIF_PAB_DHMAX); - m.extraVar.N = String(cloisonNumber); - m.extraVar.DH = iRes.values.DH; - m.extraVar.maxDH = this.prms.DHMax.singleValue; - res.log.add(m); - } - cloisonNumber++; - } - // downwall - const ca = passB.downWall; - const iRes = ca.result.resultElements[this.indexToCheck]; - if (this.prms.DHMax.singleValue !== undefined && iRes.values.DH > this.prms.DHMax.singleValue) { - res.vCalc = 0; - const m = new Message(MessageCode.ERROR_VERIF_PAB_DHMAX_DW); - m.extraVar.DH = iRes.values.DH; - m.extraVar.maxDH = this.prms.DHMax.singleValue; - res.log.add(m); - } - - // 3. weirs and slots witdh - if (this.pabJetType === StructureJetTypeStrict.SURFACE) { - cloisonNumber = 1; - for (const c of passB.children) { - this.checkWeirsAndSlotsWidth(c, cloisonNumber, res); - cloisonNumber++; - } - } - // downwall - this.checkWeirsAndSlotsWidth(ca, undefined, res); - - // 4. basins depth - cloisonNumber = 1; - for (const c of passB.children) { - const iRes = c.result.resultElements[this.indexToCheck]; - if (this.prms.PMin.singleValue !== undefined && iRes.values.YMOY < this.prms.PMin.singleValue) { - res.vCalc = 0; - const m = new Message(MessageCode.ERROR_VERIF_PAB_YMOY); - m.extraVar.N = String(cloisonNumber); - m.extraVar.PB = iRes.values.YMOY; - m.extraVar.minPB = this.prms.PMin.singleValue; - res.log.add(m); - } - if (this.pabJetType === StructureJetTypeStrict.PLONGEANT) { - // depth < 2x fall + for (const wall of passB.children) { + const iRes = wall.result.resultElements[this.indexToCheck]; + const hasSJet = this.hasJet(wall, [ StructureJetType.SURFACE, StructureJetType.SO ]); + const hasPJet = this.hasJet(wall, StructureJetType.PLONGEANT); + + // Wall crossability array, one element for each device, by default every device is crossable; + // marked only when device is receiving a Warning, to avoid errors redundancy + const wca: boolean[] = []; + wca.length = wall.structures.length; + wca.fill(true); + + // 1. falls + this.checkFalls(wall, iRes, cloisonNumber, res, wca, hasSJet, hasPJet); + + // 2. weirs and slots witdh + this.checkWeirsAndSlotsWidth(wall, cloisonNumber, res, wca); + + // 3. basins depth + this.checkBasinDepth(wall, iRes, cloisonNumber, res, wca, hasSJet, hasPJet); + // diving jets only: depth < 2x fall + if (hasPJet) { if (iRes.values.YMOY < (2 * iRes.values.DH)) { - res.vCalc = 0; - const m = new Message(MessageCode.ERROR_VERIF_PAB_YMOY_2_DH); + let m: Message; + // diving jet fails, but surface jet exists + if (hasSJet) { + m = new Message(MessageCode.WARNING_VERIF_PAB_YMOY_2_DH) + const failingDevices = this.getDevicesHavingJet(wall, StructureJetType.PLONGEANT); + for (const idx of failingDevices) { + wca[idx] = false; + } + } else { + m = new Message(MessageCode.ERROR_VERIF_PAB_YMOY_2_DH) + res.vCalc = 0; + }; m.extraVar.N = String(cloisonNumber); m.extraVar.PB = iRes.values.YMOY; m.extraVar.DH = iRes.values.DH; res.log.add(m); } } - cloisonNumber++; - } - // 5. head on weirs - if (this.pabJetType === StructureJetTypeStrict.PLONGEANT) { - cloisonNumber = 1; - for (const c of passB.children) { - this.checkHeadOnWeirs(c, cloisonNumber, res); - cloisonNumber++; - } - } - // downwall - this.checkHeadOnWeirs(ca, undefined, res); + // 4. head on weirs + this.checkHeadOnWeirs(wall, cloisonNumber, res, wca); - // 6. basins length - cloisonNumber = 1; - for (const c of passB.children) { - if (this.prms.LMin.singleValue !== undefined && c.prms.LB.singleValue < this.prms.LMin.singleValue) { - res.vCalc = 0; - const m = new Message(MessageCode.ERROR_VERIF_PAB_LMIN); - m.extraVar.N = String(cloisonNumber); - m.extraVar.LB = c.prms.LB.singleValue; - m.extraVar.minLB = this.prms.LMin.singleValue; + // 5. basins length + this.checkBasinLength(wall, cloisonNumber, res, wca, hasSJet, hasPJet); + + // check crossability + let ok = false; + for (const devC of wca) { + ok = ok || devC; + } + if (! ok) { + const m = new Message(MessageCode.ERROR_VERIF_PAB_WALL_NOT_CROSSABLE); + m.extraVar.N = String(cloisonNumber); // keep the "+1" for readability res.log.add(m); } + cloisonNumber++; } + + // B -- downwall + const dw = passB.downWall; + const iRes = dw.result.resultElements[this.indexToCheck]; + const hasSJet = this.hasJet(dw, [ StructureJetType.SURFACE, StructureJetType.SO ]); + const hasPJet = this.hasJet(dw, StructureJetType.PLONGEANT); + // Downwall crossability array, one element for each device, by default every device is crossable; + // marked only when device is receiving a Warning, to avoid errors redundancy + const dwca: boolean[] = []; + dwca.length = dw.structures.length; + dwca.fill(true); + // 1. falls + this.checkFalls(dw, iRes, undefined, res, dwca, hasSJet, hasPJet); + // 2. weirs and slots witdh + this.checkWeirsAndSlotsWidth(dw, undefined, res, dwca); + // 3. head on weirs + this.checkHeadOnWeirs(dw, undefined, res, dwca); + // check crossability + let ok = false; + for (const devC of dwca) { + ok = ok || devC; + } + if (! ok) { + const m = new Message(MessageCode.ERROR_VERIF_PAB_DW_NOT_CROSSABLE); + res.log.add(m); + } + + break; case CalculatorType.ParSimulation: @@ -505,30 +472,233 @@ export class Espece extends Nub implements Observer { } /** - * Checks the weirs and slots widths on every structure of the given wall of a Pab - * @param c the Pab wall to check + * Checks the falls on every structure of the given wall of a Pab + * @param wall the current wall to check + * @param iRes the current result element to check on the wall result * @param cloisonNumber the number of the current wall in the Pab, undefined means downwall * @param res the current result to add logs to, and set value + * @param ca crossability array; mark non-crossable devices with "false" value at their index + * @param hasSJet true if current wall has at least one device with a surface jet (or an Orifice) + * @param hasPJet true if current wall has at least one device with a diving jet */ - protected checkWeirsAndSlotsWidth(c: ParallelStructure, cloisonNumber: number, res: Result) { - let structureNumber = 1; - for (const s of c.structures) { - // for "Villemonte 1947" ("échancrure") or "Fente noyée (Larinier 1992)" ("fente") only - if ([ LoiDebit.WeirVillemonte, LoiDebit.WeirSubmergedLarinier ].includes(s.loiDebit)) { - const structParams = s.prms as RectangularStructureParams; - if (this.prms.BMin.singleValue !== undefined && structParams.L.v < this.prms.BMin.singleValue) { - res.vCalc = 0; - let m: Message; + protected checkFalls(wall: ParallelStructure, iRes: ResultElement, cloisonNumber: number, res: Result, ca: boolean[], hasSJet: boolean, hasPJet: boolean) { + let fallSJetFails = (hasSJet && this.prms.DHMaxS.singleValue !== undefined && iRes.values.DH > this.prms.DHMaxS.singleValue); + let fallPJetFails = (hasPJet && this.prms.DHMaxP.singleValue !== undefined && iRes.values.DH > this.prms.DHMaxP.singleValue); + // error cases + if (fallSJetFails || fallPJetFails) { + let m: Message; + // everything fails: error + if (fallSJetFails && fallPJetFails) { + if (cloisonNumber === undefined) { + m = new Message(MessageCode.ERROR_VERIF_PAB_DHMAX_DW); + } else { + m = new Message(MessageCode.ERROR_VERIF_PAB_DHMAX); + m.extraVar.N = String(cloisonNumber); + } + res.vCalc = 0; + m.extraVar.maxDHS = this.prms.DHMaxS.singleValue; + m.extraVar.maxDHP = this.prms.DHMaxP.singleValue; + + } else { // only one type of jet fails, the other type may be present or not + + const failingJetType = fallSJetFails ? StructureJetType.SURFACE : StructureJetType.PLONGEANT; + // one jet fails, but other jet is present (and succeeds) + if ((fallSJetFails && hasPJet) || (fallPJetFails && hasSJet)) { if (cloisonNumber === undefined) { - m = new Message(MessageCode.ERROR_VERIF_PAB_BMIN_DW); + m = new Message(MessageCode.WARNING_VERIF_PAB_DHMAX_JET_DW); } else { - m = new Message(MessageCode.ERROR_VERIF_PAB_BMIN); - m.extraVar.NC = String(cloisonNumber); + m = new Message(MessageCode.WARNING_VERIF_PAB_DHMAX_JET); + m.extraVar.N = String(cloisonNumber); + } + const failingDevices = this.getDevicesHavingJet(wall, failingJetType); + for (const idx of failingDevices) { + ca[idx] = false; + } + } else { // one jet fails and there is no other jet + if (cloisonNumber === undefined) { + m = new Message(MessageCode.ERROR_VERIF_PAB_DHMAX_JET_DW); + } else { + m = new Message(MessageCode.ERROR_VERIF_PAB_DHMAX_JET); + m.extraVar.N = String(cloisonNumber); + } + res.vCalc = 0; + } + m.extraVar.maxDH = fallSJetFails ? this.prms.DHMaxS.singleValue : this.prms.DHMaxP.singleValue; + m.extraVar.jetType = failingJetType; + } + m.extraVar.DH = iRes.values.DH; + res.log.add(m); + } // else everything ok + } + + /** + * Checks the basin depth on every structure of the given wall of a Pab + * @param wall the current wall to check + * @param iRes the current result element to check on the wall result + * @param cloisonNumber the number of the current wall in the Pab, undefined means downwall + * @param res the current result to add logs to, and set value + * @param ca crossability array; mark non-crossable devices with "false" value at their index + * @param hasSJet true if current wall has at least one device with a surface jet (or an Orifice) + * @param hasPJet true if current wall has at least one device with a diving jet + */ + protected checkBasinDepth(wall: ParallelStructure, iRes: ResultElement, cloisonNumber: number, res: Result, ca: boolean[], hasSJet: boolean, hasPJet: boolean) { + let fallSJetFails = (hasSJet && this.prms.PMinS.singleValue !== undefined && iRes.values.YMOY < this.prms.PMinS.singleValue); + let fallPJetFails = (hasPJet && this.prms.PMinP.singleValue !== undefined && iRes.values.YMOY < this.prms.PMinP.singleValue); + // error cases + if (fallSJetFails || fallPJetFails) { + let m: Message; + // everything fails: error + if (fallSJetFails && fallPJetFails) { + m = new Message(MessageCode.ERROR_VERIF_PAB_YMOY); + m.extraVar.N = String(cloisonNumber); + res.vCalc = 0; + m.extraVar.minPBS = this.prms.PMinS.singleValue; + m.extraVar.minPBP = this.prms.PMinP.singleValue; + ca.fill(false); // no device is crossable + } else { // only one type of jet fails, the other type may be present or not + const failingJetType = fallSJetFails ? StructureJetType.SURFACE : StructureJetType.PLONGEANT; + // other jet is present (and succeeds) + if ((fallSJetFails && hasPJet) || (fallPJetFails && hasSJet)) { + m = new Message(MessageCode.WARNING_VERIF_PAB_YMOY_JET); + m.extraVar.N = String(cloisonNumber); + const failingDevices = this.getDevicesHavingJet(wall, failingJetType); + for (const idx of failingDevices) { + ca[idx] = false; + } + } else { // there is no other jet + m = new Message(MessageCode.ERROR_VERIF_PAB_YMOY_JET); + m.extraVar.N = String(cloisonNumber); + res.vCalc = 0; + } + m.extraVar.minPB = fallSJetFails ? this.prms.PMinS.singleValue : this.prms.PMinP.singleValue; + m.extraVar.jetType = failingJetType; + } + m.extraVar.PB = iRes.values.YMOY; + res.log.add(m); + } // else everything ok + } + + /** + * Checks the basin length on every structure of the given wall of a Pab + * @param wall the current wall to check + * @param cloisonNumber the number of the current wall in the Pab, undefined means downwall + * @param res the current result to add logs to, and set value + * @param ca crossability array; mark non-crossable devices with "false" value at their index + * @param hasSJet true if current wall has at least one device with a surface jet (or an Orifice) + * @param hasPJet true if current wall has at least one device with a diving jet + */ + protected checkBasinLength(wall: Cloisons, cloisonNumber: number, res: Result, ca: boolean[], hasSJet: boolean, hasPJet: boolean) { + let fallSJetFails = (hasSJet && this.prms.LMinS.singleValue !== undefined && wall.prms.LB.singleValue < this.prms.LMinS.singleValue); + let fallPJetFails = (hasPJet && this.prms.LMinP.singleValue !== undefined && wall.prms.LB.singleValue < this.prms.LMinP.singleValue); + // error cases + if (fallSJetFails || fallPJetFails) { + let m: Message; + // everything fails: error + if (fallSJetFails && fallPJetFails) { + m = new Message(MessageCode.ERROR_VERIF_PAB_LMIN); + m.extraVar.N = String(cloisonNumber); + res.vCalc = 0; + m.extraVar.minLBS = this.prms.LMinS.singleValue; + m.extraVar.minLBP = this.prms.LMinP.singleValue; + ca.fill(false); // no device is crossable + } else { // only one type of jet fails, the other type may be present or not + const failingJetType = fallSJetFails ? StructureJetType.SURFACE : StructureJetType.PLONGEANT; + // other jet is present (and succeeds) + if ((fallSJetFails && hasPJet) || (fallPJetFails && hasSJet)) { + m = new Message(MessageCode.WARNING_VERIF_PAB_LMIN_JET); + m.extraVar.N = String(cloisonNumber); + const failingDevices = this.getDevicesHavingJet(wall, failingJetType); + for (const idx of failingDevices) { + ca[idx] = false; + } + } else { // there is no other jet + m = new Message(MessageCode.ERROR_VERIF_PAB_LMIN_JET); + m.extraVar.N = String(cloisonNumber); + res.vCalc = 0; + } + m.extraVar.minLB = fallSJetFails ? this.prms.LMinS.singleValue : this.prms.LMinP.singleValue; + m.extraVar.jetType = failingJetType; + } + m.extraVar.LB = wall.prms.LB.singleValue; + res.log.add(m); + } // else everything ok + } + + /** + * Checks the weirs and slots widths on every structure of the given wall of a Pab + * @param wall the Pab wall to check + * @param cloisonNumber the number of the current wall in the Pab, undefined means downwall + * @param res the current result to add logs to, and set value + * @param ca crossability array; mark non-crossable devices with "false" value at their index + */ + protected checkWeirsAndSlotsWidth(wall: ParallelStructure, cloisonNumber: number, res: Result, ca: boolean[]) { + let structureNumber = 1; + for (const device of wall.structures) { + const hasOtherDevicesThanWeirs = ( + this.hasJet(wall, [ StructureJetType.PLONGEANT ]) + || (this.getDevicesHavingLaw(wall, [ LoiDebit.WeirVillemonte, LoiDebit.WeirSubmergedLarinier ]).length < wall.structures.length) + ); + const hasOtherDevicesThanOrifice = ( + this.hasJet(wall, [ StructureJetType.PLONGEANT ]) + || (this.getDevicesHavingLaw(wall, LoiDebit.OrificeSubmerged).length < wall.structures.length) + ); + const iRes = device.result.resultElements[this.indexToCheck]; + const jt = iRes.values["ENUM_StructureJetType"]; + if (jt !== StructureJetType.PLONGEANT) { + // Surface jets: for "Villemonte 1947" ("échancrure") or "Fente noyée (Larinier 1992)" ("fente") only + if ([ LoiDebit.WeirVillemonte, LoiDebit.WeirSubmergedLarinier ].includes(device.loiDebit)) { + const structParams = device.prms as RectangularStructureParams; + if (this.prms.BMin.singleValue !== undefined && structParams.L.v < this.prms.BMin.singleValue) { + let m: Message; + if (hasOtherDevicesThanWeirs) { + ca[structureNumber - 1] = false; // device is not crossable + if (cloisonNumber === undefined) { + m = new Message(MessageCode.WARNING_VERIF_PAB_BMIN_DW); + } else { + m = new Message(MessageCode.WARNING_VERIF_PAB_BMIN); + m.extraVar.NC = String(cloisonNumber); + } + } else { + res.vCalc = 0; + if (cloisonNumber === undefined) { + m = new Message(MessageCode.ERROR_VERIF_PAB_BMIN_DW); + } else { + m = new Message(MessageCode.ERROR_VERIF_PAB_BMIN); + m.extraVar.NC = String(cloisonNumber); + } + } + m.extraVar.NS = String(structureNumber); + m.extraVar.L = structParams.L.v; + m.extraVar.minB = this.prms.BMin.singleValue; + res.log.add(m); + } + } else if (device.loiDebit === LoiDebit.OrificeSubmerged) { + const structParams = device.prms as StructureOrificeSubmergedParams; + // Orifices (no jet) + if (this.prms.BMin.singleValue !== undefined && structParams.S.v < Math.pow(this.prms.BMin.singleValue, 2)) { + let m: Message; + if (hasOtherDevicesThanOrifice) { + ca[structureNumber - 1] = false; // device is not crossable + if (cloisonNumber === undefined) { + m = new Message(MessageCode.WARNING_VERIF_PAB_SMIN_DW); + } else { + m = new Message(MessageCode.WARNING_VERIF_PAB_SMIN); + m.extraVar.NC = String(cloisonNumber); + } + } else { + res.vCalc = 0; + if (cloisonNumber === undefined) { + m = new Message(MessageCode.ERROR_VERIF_PAB_SMIN_DW); + } else { + m = new Message(MessageCode.ERROR_VERIF_PAB_SMIN); + m.extraVar.NC = String(cloisonNumber); + } + } + m.extraVar.NS = String(structureNumber); + m.extraVar.S = structParams.S.v; + m.extraVar.minS = Math.pow(this.prms.BMin.singleValue, 2); + res.log.add(m); } - m.extraVar.NS = String(structureNumber); - m.extraVar.L = structParams.L.v; - m.extraVar.minB = this.prms.BMin.singleValue; - res.log.add(m); } } structureNumber++; @@ -537,69 +707,99 @@ export class Espece extends Nub implements Observer { /** * Checks the head on weirs on every structure of the given wall of a Pab - * @param c the Pab wall to check + * @param wall the Pab wall to check * @param cloisonNumber the number of the current wall in the Pab, undefined means downwall * @param res the current result to add logs to, and set value + * @param ca crossability array; mark non-crossable devices with "false" value at their index */ - protected checkHeadOnWeirs(c: ParallelStructure, cloisonNumber: number, res: Result) { + protected checkHeadOnWeirs(wall: ParallelStructure, cloisonNumber: number, res: Result, ca: boolean[]) { let structureNumber = 1; - for (const s of c.structures) { - // for "Villemonte 1947" ("échancrure") only - if (s.loiDebit === LoiDebit.WeirVillemonte && this.prms.HMin.singleValue !== undefined && s.prms.h1.v < this.prms.HMin.singleValue) { - res.vCalc = 0; - let m: Message; - if (cloisonNumber === undefined) { - m = new Message(MessageCode.ERROR_VERIF_PAB_HMIN_DW); - } else { - m = new Message(MessageCode.ERROR_VERIF_PAB_HMIN); - m.extraVar.NC = String(cloisonNumber); + const hasOtherDevices = ( + this.hasJet(wall, [ StructureJetType.SURFACE, StructureJetType.SO ]) + || (this.getDevicesHavingLaw(wall, LoiDebit.WeirVillemonte).length < wall.structures.length) + ); + for (const device of wall.structures) { + const iRes = device.result.resultElements[this.indexToCheck]; + const jt = iRes.values["ENUM_StructureJetType"]; + if (jt === StructureJetType.PLONGEANT) { + // for "Villemonte 1947" ("échancrure") only + if (device.loiDebit === LoiDebit.WeirVillemonte && this.prms.HMin.singleValue !== undefined && device.prms.h1.v < this.prms.HMin.singleValue) { + let m: Message; + if (hasOtherDevices) { + ca[structureNumber - 1] = false; // device is not crossable + if (cloisonNumber === undefined) { + m = new Message(MessageCode.WARNING_VERIF_PAB_HMIN_DW); + } else { + m = new Message(MessageCode.WARNING_VERIF_PAB_HMIN); + m.extraVar.NC = String(cloisonNumber); + } + } else { + res.vCalc = 0; + if (cloisonNumber === undefined) { + m = new Message(MessageCode.ERROR_VERIF_PAB_HMIN_DW); + } else { + m = new Message(MessageCode.ERROR_VERIF_PAB_HMIN); + m.extraVar.NC = String(cloisonNumber); + } + } + m.extraVar.NS = String(structureNumber); + m.extraVar.h1 = device.prms.h1.v; + m.extraVar.minH = this.prms.HMin.singleValue; + res.log.add(m); } - m.extraVar.NS = String(structureNumber); - m.extraVar.h1 = s.prms.h1.v; - m.extraVar.minH = this.prms.HMin.singleValue; - res.log.add(m); } structureNumber++; } } /** - * Checks the jet type on every structure of the given wall of a Pab - * @param c the Pab wall to check - * @param cloisonNumber the number of the current wall in the Pab, undefined means downwall - * @param res the current result to add logs to, and set value + * Returns true if given wall has at least one device with a jet type among given jetTypes */ - protected checkJetTypes(c: ParallelStructure, cloisonNumber: number, res: Result): boolean { - let nbSurface = 0; - let nbPlongeant = 0; - // test jet type for each device - for (const s of c.structures) { - const jt = s.result.resultElements[this.indexToCheck].values["ENUM_StructureJetType"]; - if (jt === StructureJetTypeStrict.SURFACE) { - nbSurface++; - } else if (jt === StructureJetTypeStrict.PLONGEANT) { - nbPlongeant++; + protected hasJet(wall: ParallelStructure, jetTypes: StructureJetType | StructureJetType[]): boolean { + if (! Array.isArray(jetTypes)) { + jetTypes = [ jetTypes ]; + } + for (const device of wall.structures) { + const deviceJetType = device.result.resultElements[this.indexToCheck].values["ENUM_StructureJetType"]; + if (jetTypes.includes(deviceJetType)) { + return true; } } - let jetsOK: boolean; - if (this.pabJetType === StructureJetTypeStrict.SURFACE) { - jetsOK = (nbSurface > 0); - } else if (this.pabJetType === StructureJetTypeStrict.PLONGEANT) { - jetsOK = (nbPlongeant > 0); + return false; + } + + /** + * Returns indexes of the devices having given jet type, on the given wall + * @param wall wall to check devices on + * @param t jet type + */ + protected getDevicesHavingJet(wall: ParallelStructure, t: StructureJetType): number[] { + const idxs: number[] = []; + for (let i = 0; i < wall.structures.length; i++) { + const deviceJetType = wall.structures[i].result.resultElements[this.indexToCheck].values["ENUM_StructureJetType"]; + if (deviceJetType === t) { + idxs.push(i); + } } - if (! jetsOK) { - res.vCalc = 0; - let m: Message; - if (cloisonNumber === undefined) { - m = new Message(MessageCode.ERROR_VERIF_PAB_JETS_DW); - } else { - m = new Message(MessageCode.ERROR_VERIF_PAB_JETS); - m.extraVar.N = String(cloisonNumber); + return idxs; + } + + /** + * Returns indexes of the devices having given discharge law, on the given wall + * @param wall wall to check devices on + * @param l discharge law + */ + protected getDevicesHavingLaw(wall: ParallelStructure, l: LoiDebit | LoiDebit[]): number[] { + const idxs: number[] = []; + if (! Array.isArray(l)) { + l = [ l ]; + } + for (let i = 0; i < wall.structures.length; i++) { + if (l.includes(wall.structures[i].loiDebit)) { + idxs.push(i); } - m.extraVar.required = StructureJetTypeStrict[this.pabJetType]; - res.log.add(m); } - return jetsOK; + return idxs; } /** @@ -661,9 +861,6 @@ export class Espece extends Nub implements Observer { for (const p of this.prms) { if (p.symbol !== "OK") { let preset = this.presets[pt]; - if (pt === CalculatorType.Pab && this.pabJetType !== undefined) { - preset = preset[this.pabJetType]; - } if (preset[sp] !== undefined) { // if (preset[sp][p.symbol] !== undefined) console.log(`-> setting ${p.symbol} to ${preset[sp][p.symbol]}`); p.singleValue = preset[sp][p.symbol]; diff --git a/src/verification/espece_params.ts b/src/verification/espece_params.ts index ed7982353ae771a9172d5259d50045e9e77db5c5..0c1ad65291e65a1740b2704c8a9f089a7a5cfc5c 100644 --- a/src/verification/espece_params.ts +++ b/src/verification/espece_params.ts @@ -1,5 +1,5 @@ import { ParamsEquation } from "../param/params-equation"; -import { ParamDefinition, ParamFamily } from "../param/param-definition"; +import { ParamDefinition } from "../param/param-definition"; import { ParamDomainValue } from "../param/param-domain"; export class EspeceParams extends ParamsEquation { @@ -7,27 +7,30 @@ export class EspeceParams extends ParamsEquation { /** Résultat de la vérification (seul paramètre calculable) */ private _OK: ParamDefinition; - /** Chute maximale (m) */ - private _DHMax: ParamDefinition; + /** Chute maximale (m) (PAB, jet de Surface) */ + private _DHMaxS: ParamDefinition; - /** Chute préconisée (m) */ - // private _DH: ParamDefinition; + /** Chute maximale (m) (PAB, jet Plongeant) */ + private _DHMaxP: ParamDefinition; /** Largeur minimale de fente ou échancrure latérale (m) (PAB jet de surface) */ private _BMin: ParamDefinition; - /** Profondeur minimale de bassin (m) (PAB, MacroRugo rangées périodiques) */ - private _PMin: ParamDefinition; + /** Profondeur minimale de bassin (m) (PAB, jet de Surface) */ + private _PMinS: ParamDefinition; - /** Longueur minimale de bassins (m) (PAB) */ - private _LMin: ParamDefinition; + /** Profondeur minimale de bassin (m) (PAB, jet Plongeant) */ + private _PMinP: ParamDefinition; + + /** Longueur minimale de bassins (m) (PAB, jet de Surface) */ + private _LMinS: ParamDefinition; + + /** Longueur minimale de bassins (m) (PAB, jet Plongeant) */ + private _LMinP: ParamDefinition; /** Charge minimale sur l'échancrure (m) (PAB jet plongeant) */ private _HMin: ParamDefinition; - /** Charge minimale sur les seuils (m) (MacroRugo à rangées périodiques - on ne les fait pas ?) */ - // private _HMinW: ParamDefinition; - /** Tirant d'eau minimum (m) (MacroRugo enrochements régulièrement répartis) */ private _YMin: ParamDefinition; @@ -40,29 +43,34 @@ export class EspeceParams extends ParamsEquation { /** Tirant d'eau minimum sur les ralentisseurs plans (m) */ private _YMinPB: ParamDefinition; - constructor(rDHMax: number/* , rDH: number */, rBMin?: number, rPMin?: number, rLMin?: number, rHMin?: number/* , rHMinW?: number */, rYMin?: number, rVMax?: number, rYMinSB?: number, rYMinPB?: number) { + constructor( + rDHMaxS: number, rDHMaxP?: number, rBMin?: number, rPMinS?: number, rPMinP?: number, rLMinS?: number, + rLMinP?: number,rHMin?: number, rYMin?: number, rVMax?: number, rYMinSB?: number, rYMinPB?: number + ) { super(); this._OK = new ParamDefinition(this, "OK", ParamDomainValue.POS, ""); - this._DHMax = new ParamDefinition(this, "DHMax", ParamDomainValue.POS, "m", rDHMax); - // this._DH = new ParamDefinition(this, "DH", ParamDomainValue.POS, "m", rDH); + this._DHMaxS = new ParamDefinition(this, "DHMaxS", ParamDomainValue.POS, "m", rDHMaxS); + this._DHMaxP = new ParamDefinition(this, "DHMaxP", ParamDomainValue.POS, "m", rDHMaxP); this._BMin = new ParamDefinition(this, "BMin", ParamDomainValue.POS, "m", rBMin); - this._PMin = new ParamDefinition(this, "PMin", ParamDomainValue.POS, "m", rPMin); - this._LMin = new ParamDefinition(this, "LMin", ParamDomainValue.POS, "m", rLMin); + this._PMinS = new ParamDefinition(this, "PMinS", ParamDomainValue.POS, "m", rPMinS); + this._PMinP = new ParamDefinition(this, "PMinP", ParamDomainValue.POS, "m", rPMinP); + this._LMinS = new ParamDefinition(this, "LMinS", ParamDomainValue.POS, "m", rLMinS); + this._LMinP = new ParamDefinition(this, "LMinP", ParamDomainValue.POS, "m", rLMinP); this._HMin = new ParamDefinition(this, "HMin", ParamDomainValue.POS, "m", rHMin); - // this._HMinW = new ParamDefinition(this, "HMinW", ParamDomainValue.POS, "m", rHMinW); this._YMin = new ParamDefinition(this, "YMin", ParamDomainValue.POS, "m", rYMin); this._VMax = new ParamDefinition(this, "VMax", ParamDomainValue.POS, "m", rVMax); this._YMinSB = new ParamDefinition(this, "YMinSB", ParamDomainValue.POS, "m", rYMinSB); this._YMinPB = new ParamDefinition(this, "YMinPB", ParamDomainValue.POS, "m", rYMinPB); this.addParamDefinition(this._OK); - this.addParamDefinition(this._DHMax); - // this.addParamDefinition(this._DH); + this.addParamDefinition(this._DHMaxS); + this.addParamDefinition(this._DHMaxP); this.addParamDefinition(this._BMin); - this.addParamDefinition(this._PMin); - this.addParamDefinition(this._LMin); + this.addParamDefinition(this._PMinS); + this.addParamDefinition(this._PMinP); + this.addParamDefinition(this._LMinS); + this.addParamDefinition(this._LMinP); this.addParamDefinition(this._HMin); - // this.addParamDefinition(this._HMinW); this.addParamDefinition(this._YMin); this.addParamDefinition(this._VMax); this.addParamDefinition(this._YMinSB); @@ -73,34 +81,38 @@ export class EspeceParams extends ParamsEquation { return this._OK; } - public get DHMax(): ParamDefinition { - return this._DHMax; + public get DHMaxS(): ParamDefinition { + return this._DHMaxS; } - /* public get DH(): ParamDefinition { - return this._DH; - } */ + public get DHMaxP(): ParamDefinition { + return this._DHMaxP; + } public get BMin(): ParamDefinition { return this._BMin; } - public get PMin(): ParamDefinition { - return this._PMin; + public get PMinS(): ParamDefinition { + return this._PMinS; } - public get LMin(): ParamDefinition { - return this._LMin; + public get PMinP(): ParamDefinition { + return this._PMinP; + } + + public get LMinS(): ParamDefinition { + return this._LMinS; + } + + public get LMinP(): ParamDefinition { + return this._LMinP; } public get HMin(): ParamDefinition { return this._HMin; } - /* public get HMinW(): ParamDefinition { - return this._HMinW; - } */ - public get YMin(): ParamDefinition { return this._YMin; } diff --git a/src/verification/verificateur.ts b/src/verification/verificateur.ts index 5a50328370a9c1281c27fe17d1cd5b57265698a2..98b39a501ac57fd167279beaaf93d28e4d079f6e 100644 --- a/src/verification/verificateur.ts +++ b/src/verification/verificateur.ts @@ -9,7 +9,6 @@ import { EspeceParams } from "./espece_params"; import { FishPass } from "../fish_pass"; import { Message, MessageCode } from "../util/message"; import { VerificateurParams } from "./verificateur_params"; -import { StructureJetTypeStrict } from "../structure/structure"; export class Verificateur extends Nub implements Observer { @@ -22,8 +21,6 @@ export class Verificateur extends Nub implements Observer { this._props.addObserver(this); // UID of Session Nub to verify this.nubToVerify = undefined; - // Jet type when verifying a Pab - this.pabJetType = StructureJetTypeStrict.SURFACE; // List of fish species to check the pass against this.speciesList = []; this._species = []; @@ -46,14 +43,6 @@ export class Verificateur extends Nub implements Observer { this.properties.setPropValue("speciesList", l); } - public get pabJetType(): StructureJetTypeStrict { - return this._props.getPropValue("pabJetType"); - } - - public set pabJetType(j: StructureJetTypeStrict) { - this.properties.setPropValue("pabJetType", j); - } - /** finds the Nub to verify by its UID */ public get nubToVerify(): FishPass { let nub: Nub; @@ -114,25 +103,24 @@ export class Verificateur extends Nub implements Observer { // console.log("Equation ! Nub UID =", this.nubToVerify.uid); let spIndex = 0; - for (const nub of this._species) { + for (const speciesNub of this._species) { // give the pass pointer - nub.passToCheck = this.nubToVerify; - if (this.nubToVerify.calcType === CalculatorType.Pab) { - // give the jet type for Pab - nub.pabJetType = this.pabJetType; - } + speciesNub.passToCheck = this.nubToVerify; // @TODO give the index to check if pass is variating - nub.indexToCheck = 0; + speciesNub.indexToCheck = 0; - const subRes = nub.Calc(); - // subRes.resultElement.log + const subRes = speciesNub.Calc(); + let m: Message; // if at least one error log in Espece nub, add one at Verificateur level, so that .ok is false if (subRes.hasErrorMessages()) { - const m = new Message(MessageCode.ERROR_VERIF_SPECIES_KO); - m.extraVar.speciesGroup = this.speciesList[spIndex]; - r.resultElement.addMessage(m); + m = new Message(MessageCode.ERROR_VERIF_SPECIES_KO); + } else { + // else add a success info message + m = new Message(MessageCode.INFO_VERIF_SPECIES_OK); } + m.extraVar.speciesGroup = this.speciesList[spIndex]; + r.resultElement.addMessage(m); // @TODO remove vCalc as no parameter is calculated ? if (subRes.vCalc === 0) {