Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Service/WaveConditionsCalculationServiceBase.cs =================================================================== diff -u -r4098e7338585cd9047636c465ffcb213c12bf987 -rdd347e5ef5916532cce1004e1941e8523ec448b4 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Service/WaveConditionsCalculationServiceBase.cs (.../WaveConditionsCalculationServiceBase.cs) (revision 4098e7338585cd9047636c465ffcb213c12bf987) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Service/WaveConditionsCalculationServiceBase.cs (.../WaveConditionsCalculationServiceBase.cs) (revision dd347e5ef5916532cce1004e1941e8523ec448b4) @@ -1,4 +1,4 @@ -// Copyright (C) Stichting Deltares 2017. All rights reserved. +// Copyright (C) Stichting Deltares 2018. All rights reserved. // // This file is part of Ringtoets. // @@ -22,7 +22,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.IO; using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.IO; @@ -31,12 +30,13 @@ using Ringtoets.Common.IO.HydraRing; using Ringtoets.Common.Service; using Ringtoets.Common.Service.ValidationRules; -using Ringtoets.HydraRing.Calculation.Calculator; -using Ringtoets.HydraRing.Calculation.Calculator.Factory; -using Ringtoets.HydraRing.Calculation.Data.Input.WaveConditions; -using Ringtoets.HydraRing.Calculation.Exceptions; using Ringtoets.Revetment.Data; using Ringtoets.Revetment.Service.Properties; +using Riskeer.HydraRing.Calculation.Calculator; +using Riskeer.HydraRing.Calculation.Calculator.Factory; +using Riskeer.HydraRing.Calculation.Data.Input; +using Riskeer.HydraRing.Calculation.Data.Input.WaveConditions; +using Riskeer.HydraRing.Calculation.Exceptions; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; @@ -123,18 +123,16 @@ /// The 'b' factor decided on failure mechanism level. /// The 'c' factor decided on failure mechanism level. /// The norm to use as the target. - /// The file path of the hydraulic boundary database. - /// The preprocessor directory. + /// The hydraulic boundary database to perform the calculations with. /// An of . - /// Preprocessing is disabled when equals . - /// Thrown when , - /// or - /// is null. - /// Thrown when the + /// Preprocessing is disabled when the preprocessor directory equals . + /// Thrown when or + /// is null. + /// Thrown when the hydraulic boundary database file path /// contains invalid characters. /// Thrown when: /// - /// No settings database file could be found at the location of + /// No settings database file could be found at the location of the hydraulic boundary database file path /// with the same name. /// Unable to open settings database file. /// Unable to read required data from database file. @@ -148,14 +146,18 @@ RoundedDouble b, RoundedDouble c, double norm, - string hydraulicBoundaryDatabaseFilePath, - string preprocessorDirectory) + HydraulicBoundaryDatabase hydraulicBoundaryDatabase) { if (waveConditionsInput == null) { throw new ArgumentNullException(nameof(waveConditionsInput)); } + if (hydraulicBoundaryDatabase == null) + { + throw new ArgumentNullException(nameof(hydraulicBoundaryDatabase)); + } + var calculationsFailed = 0; var outputs = new List(); @@ -176,8 +178,7 @@ c, norm, waveConditionsInput, - hydraulicBoundaryDatabaseFilePath, - preprocessorDirectory); + HydraulicBoundaryCalculationSettingsFactory.CreateSettings(hydraulicBoundaryDatabase)); if (output != null) { @@ -254,17 +255,15 @@ /// The 'c' factor decided on failure mechanism level. /// The norm to use as the target. /// The input that is different per calculation. - /// The path which points to the hydraulic boundary database file. - /// The preprocessor directory. + /// The containing all data + /// to perform a hydraulic boundary calculation. /// A if the calculation was successful; or null if it was canceled. - /// Preprocessing is disabled when equals . - /// Thrown when or - /// is null. - /// Thrown when the + /// Preprocessing is disabled when the preprocessor directory equals . + /// Thrown when the hydraulic boundary database file path /// contains invalid characters. /// Thrown when: /// - /// No settings database file could be found at the location of + /// No settings database file could be found at the location of the hydraulic boundary database file path /// with the same name. /// Unable to open settings database file. /// Unable to read required data from database file. @@ -276,13 +275,11 @@ RoundedDouble c, double norm, WaveConditionsInput input, - string hydraulicBoundaryDatabaseFilePath, - string preprocessorDirectory) + HydraulicBoundaryCalculationSettings calculationSettings) { - string hlcdDirectory = Path.GetDirectoryName(hydraulicBoundaryDatabaseFilePath); - calculator = HydraRingCalculatorFactory.Instance.CreateWaveConditionsCosineCalculator(hlcdDirectory, preprocessorDirectory); - WaveConditionsCosineCalculationInput calculationInput = CreateInput(waterLevel, a, b, c, norm, input, hydraulicBoundaryDatabaseFilePath, - !string.IsNullOrEmpty(preprocessorDirectory)); + HydraRingCalculationSettings settings = HydraRingCalculationSettingsFactory.CreateSettings(calculationSettings); + calculator = HydraRingCalculatorFactory.Instance.CreateWaveConditionsCosineCalculator(settings); + WaveConditionsCosineCalculationInput calculationInput = CreateInput(waterLevel, a, b, c, norm, input, calculationSettings); WaveConditionsOutput output; var exceptionThrown = false; @@ -357,14 +354,14 @@ /// The 'c' factor decided on failure mechanism level. /// The norm to use as the target. /// The input that is different per calculation. - /// The path to the hydraulic boundary database file. - /// Indicator whether to use the preprocessor in the calculation. + /// The containing all data + /// to perform a hydraulic boundary calculation. /// A . - /// Thrown when the + /// Thrown when the hydraulic boundary database file path. /// contains invalid characters. /// Thrown when: /// - /// No settings database file could be found at the location of + /// No settings database file could be found at the location of the hydraulic boundary database file path /// with the same name. /// Unable to open settings database file. /// Unable to read required data from database file. @@ -376,8 +373,7 @@ RoundedDouble c, double norm, WaveConditionsInput input, - string hydraulicBoundaryDatabaseFilePath, - bool usePreprocessor) + HydraulicBoundaryCalculationSettings calculationSettings) { var waveConditionsCosineCalculationInput = new WaveConditionsCosineCalculationInput( 1, @@ -391,7 +387,9 @@ b, c); - HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(waveConditionsCosineCalculationInput, hydraulicBoundaryDatabaseFilePath, usePreprocessor); + HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(waveConditionsCosineCalculationInput, + calculationSettings.HydraulicBoundaryDatabaseFilePath, + !string.IsNullOrEmpty(calculationSettings.PreprocessorDirectory)); return waveConditionsCosineCalculationInput; }