Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Activities/HydraRingActivityFactory.cs
===================================================================
diff -u
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Activities/HydraRingActivityFactory.cs (revision 0)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Activities/HydraRingActivityFactory.cs (revision 67100b9ae4581855aa4b6e1675c3fdf550614c7a)
@@ -0,0 +1,59 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Ringtoets.HydraRing.Calculation.Data;
+using Ringtoets.HydraRing.Calculation.Data.Input;
+using Ringtoets.HydraRing.Calculation.Data.Output;
+using Ringtoets.HydraRing.Calculation.Services;
+
+namespace Ringtoets.HydraRing.Calculation.Activities
+{
+ ///
+ /// Factory for creating Hydra-Ring activities.
+ ///
+ /// The current implementation of this factory is not thread safe (calculations should be performed one at a time).
+ public static class HydraRingActivityFactory
+ {
+ private static readonly HydraRingCalculationService hydraRingCalculationService = new HydraRingCalculationService();
+
+ ///
+ /// Creates a new instance of the class.
+ ///
+ /// The name of the activity.
+ /// The directory of the HLCD file that should be used for performing the calculation.
+ /// The id of the ring to perform the calculation for.
+ /// The to use while executing the calculation.
+ /// The to use while executing the calculation.
+ /// The input of the calculation to perform.
+ /// The action to perform after the calculation is performed.
+ public static TargetProbabilityCalculationActivity Create(string name,
+ string hlcdDirectory,
+ string ringId,
+ HydraRingTimeIntegrationSchemeType timeIntegrationSchemeType,
+ HydraRingUncertaintiesType uncertaintiesType,
+ TargetProbabilityCalculationInput targetProbabilityCalculationInput,
+ Action handleCalculationOutputAction)
+ {
+ return new TargetProbabilityCalculationActivity(name, hlcdDirectory, ringId, timeIntegrationSchemeType, uncertaintiesType, targetProbabilityCalculationInput, handleCalculationOutputAction, hydraRingCalculationService);
+ }
+ }
+}
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Activities/TargetProbabilityCalculationActivity.cs
===================================================================
diff -u
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Activities/TargetProbabilityCalculationActivity.cs (revision 0)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Activities/TargetProbabilityCalculationActivity.cs (revision 67100b9ae4581855aa4b6e1675c3fdf550614c7a)
@@ -0,0 +1,100 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Core.Common.Base.Service;
+using Ringtoets.HydraRing.Calculation.Data;
+using Ringtoets.HydraRing.Calculation.Data.Input;
+using Ringtoets.HydraRing.Calculation.Data.Output;
+using Ringtoets.HydraRing.Calculation.Services;
+
+namespace Ringtoets.HydraRing.Calculation.Activities
+{
+ ///
+ /// for running a type 2 calculation via Hydra-Ring ("iterate towards a target probability, provided as reliability index").
+ ///
+ public class TargetProbabilityCalculationActivity : Activity
+ {
+ private readonly string name;
+ private readonly string hlcdDirectory;
+ private readonly string ringId;
+ private readonly HydraRingTimeIntegrationSchemeType timeIntegrationSchemeType;
+ private readonly HydraRingUncertaintiesType uncertaintiesType;
+ private readonly TargetProbabilityCalculationInput targetProbabilityCalculationInput;
+ private readonly Action handleCalculationOutputAction;
+ private readonly HydraRingCalculationService hydraRingCalculationService;
+ private TargetProbabilityCalculationOutput targetProbabilityCalculationOutput;
+
+ ///
+ /// Creates a new instance of the class.
+ ///
+ /// The name of the activity.
+ /// The directory of the HLCD file that should be used for performing the calculation.
+ /// The id of the ring to perform the calculation for.
+ /// The to use while executing the calculation.
+ /// The to use while executing the calculation.
+ /// The input of the calculation to perform.
+ /// The action to perform after the calculation is performed.
+ /// The service to use for performing the calculation.
+ internal TargetProbabilityCalculationActivity(
+ string name,
+ string hlcdDirectory,
+ string ringId,
+ HydraRingTimeIntegrationSchemeType timeIntegrationSchemeType,
+ HydraRingUncertaintiesType uncertaintiesType,
+ TargetProbabilityCalculationInput targetProbabilityCalculationInput,
+ Action handleCalculationOutputAction,
+ HydraRingCalculationService hydraRingCalculationService)
+ {
+ this.name = name;
+ this.hlcdDirectory = hlcdDirectory;
+ this.ringId = ringId;
+ this.timeIntegrationSchemeType = timeIntegrationSchemeType;
+ this.uncertaintiesType = uncertaintiesType;
+ this.targetProbabilityCalculationInput = targetProbabilityCalculationInput;
+ this.handleCalculationOutputAction = handleCalculationOutputAction;
+ this.hydraRingCalculationService = hydraRingCalculationService;
+ }
+
+ public override string Name
+ {
+ get
+ {
+ return name;
+ }
+ }
+
+ protected override void OnRun()
+ {
+ targetProbabilityCalculationOutput = hydraRingCalculationService.PerformCalculation(hlcdDirectory, ringId, timeIntegrationSchemeType, uncertaintiesType, targetProbabilityCalculationInput);
+ }
+
+ protected override void OnCancel()
+ {
+ hydraRingCalculationService.CancelRunningCalculation();
+ }
+
+ protected override void OnFinish()
+ {
+ handleCalculationOutputAction(targetProbabilityCalculationOutput);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj
===================================================================
diff -u -r5acab76606f99e1ce397803e7fcaaa1cc42aa3eb -r67100b9ae4581855aa4b6e1675c3fdf550614c7a
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj (.../Ringtoets.HydraRing.Calculation.csproj) (revision 5acab76606f99e1ce397803e7fcaaa1cc42aa3eb)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj (.../Ringtoets.HydraRing.Calculation.csproj) (revision 67100b9ae4581855aa4b6e1675c3fdf550614c7a)
@@ -46,8 +46,8 @@
-
-
+
+
@@ -67,16 +67,16 @@
-
+
-
-
-
+
+
+
Fisheye: Tag 67100b9ae4581855aa4b6e1675c3fdf550614c7a refers to a dead (removed) revision in file `Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/HydraRingActivityFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 67100b9ae4581855aa4b6e1675c3fdf550614c7a refers to a dead (removed) revision in file `Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/HydraRingCalculationService.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 67100b9ae4581855aa4b6e1675c3fdf550614c7a refers to a dead (removed) revision in file `Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/HydraRingConfigurationService.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 67100b9ae4581855aa4b6e1675c3fdf550614c7a refers to a dead (removed) revision in file `Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/HydraRingInitializationService.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 67100b9ae4581855aa4b6e1675c3fdf550614c7a refers to a dead (removed) revision in file `Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/HydraRingProcessFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 67100b9ae4581855aa4b6e1675c3fdf550614c7a refers to a dead (removed) revision in file `Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/TargetProbabilityCalculationActivity.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Services/HydraRingCalculationService.cs
===================================================================
diff -u
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Services/HydraRingCalculationService.cs (revision 0)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Services/HydraRingCalculationService.cs (revision 67100b9ae4581855aa4b6e1675c3fdf550614c7a)
@@ -0,0 +1,103 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using Ringtoets.HydraRing.Calculation.Data;
+using Ringtoets.HydraRing.Calculation.Data.Input;
+using Ringtoets.HydraRing.Calculation.Data.Output;
+using Ringtoets.HydraRing.Calculation.Parsers;
+
+namespace Ringtoets.HydraRing.Calculation.Services
+{
+ ///
+ /// Service that provides methods for performing Hydra-Ring calculations.
+ ///
+ public class HydraRingCalculationService
+ {
+ private static Process hydraRingProcess;
+
+ ///
+ /// This method performs a type 2 calculation via Hydra-Ring ("iterate towards a target probability, provided as reliability index").
+ ///
+ /// The directory of the HLCD file that should be used for performing the calculation.
+ /// The id of the ring to perform the calculation for.
+ /// The to use while executing the calculation.
+ /// The to use while executing the calculation.
+ /// The input of the calculation to perform.
+ /// A or null when something went wrong.
+ public virtual TargetProbabilityCalculationOutput PerformCalculation(string hlcdDirectory, string ringId, HydraRingTimeIntegrationSchemeType timeIntegrationSchemeType, HydraRingUncertaintiesType uncertaintiesType, TargetProbabilityCalculationInput targetProbabilityCalculationInput)
+ {
+ return PerformCalculation(hlcdDirectory, ringId, timeIntegrationSchemeType, uncertaintiesType, targetProbabilityCalculationInput, (outputFilePath, ouputDatabasePath) => TargetProbabilityCalculationParser.Parse(outputFilePath, targetProbabilityCalculationInput.DikeSection.SectionId));
+ }
+
+ ///
+ /// Cancels any currently running Hydra-Ring calculation.
+ ///
+ public virtual void CancelRunningCalculation()
+ {
+ if (hydraRingProcess != null && !hydraRingProcess.HasExited)
+ {
+ hydraRingProcess.StandardInput.WriteLine("b");
+ }
+ }
+
+ private static T PerformCalculation(string hlcdDirectory, string ringId, HydraRingTimeIntegrationSchemeType timeIntegrationSchemeType, HydraRingUncertaintiesType uncertaintiesType, HydraRingCalculationInput hydraRingCalculationInput, Func parseFunction)
+ {
+ var hydraulicBoundaryLocationId = hydraRingCalculationInput.HydraulicBoundaryLocationId;
+
+ // Create a working directory
+ var workingDirectory = CreateWorkingDirectory(hydraulicBoundaryLocationId.ToString());
+
+ // Write the initialization script
+ var hydraRingInitializationService = new HydraRingInitializationService(hydraRingCalculationInput.FailureMechanismType, hydraulicBoundaryLocationId, hlcdDirectory, workingDirectory);
+ File.WriteAllText(hydraRingInitializationService.IniFilePath, hydraRingInitializationService.GenerateInitializationScript());
+
+ // Write the database creation script
+ var hydraRingConfigurationService = new HydraRingConfigurationService(ringId, timeIntegrationSchemeType, uncertaintiesType);
+ hydraRingConfigurationService.AddHydraRingCalculationInput(hydraRingCalculationInput);
+ File.WriteAllText(hydraRingInitializationService.DataBaseCreationScriptFilePath, hydraRingConfigurationService.GenerateDataBaseCreationScript());
+
+ // Perform the calculation
+ hydraRingProcess = HydraRingProcessFactory.Create(hydraRingInitializationService.MechanismComputationExeFilePath, hydraRingInitializationService.IniFilePath, workingDirectory);
+ hydraRingProcess.Start();
+ hydraRingProcess.WaitForExit();
+
+ // Parse and return the output
+ return parseFunction(hydraRingInitializationService.OutputFilePath, hydraRingInitializationService.OutputDataBasePath);
+ }
+
+ private static string CreateWorkingDirectory(string folderName)
+ {
+ var workingDirectory = Path.Combine(Path.GetTempPath(), folderName);
+
+ if (Directory.Exists(workingDirectory))
+ {
+ Directory.Delete(workingDirectory, true);
+ }
+
+ Directory.CreateDirectory(workingDirectory);
+
+ return workingDirectory;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Services/HydraRingConfigurationService.cs
===================================================================
diff -u
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Services/HydraRingConfigurationService.cs (revision 0)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Services/HydraRingConfigurationService.cs (revision 67100b9ae4581855aa4b6e1675c3fdf550614c7a)
@@ -0,0 +1,708 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Globalization;
+using System.Linq;
+using Ringtoets.HydraRing.Calculation.Data;
+using Ringtoets.HydraRing.Calculation.Data.Input;
+using Ringtoets.HydraRing.Calculation.Providers;
+
+namespace Ringtoets.HydraRing.Calculation.Services
+{
+ ///
+ /// Service for generating the database creation script that is necessary for performing Hydra-Ring calculations.
+ /// The following Hydra-Ring features are not exposed (yet):
+ ///
+ /// -
+ /// Combination of multiple dike sections
+ ///
+ /// -
+ /// Coupling two hydraulic boundary stations
+ ///
+ /// -
+ /// Performing revetment calculations (DesignTables > LayerId)
+ ///
+ /// -
+ /// Performing piping calculations (DesignTables > AlternativeId)
+ ///
+ /// -
+ /// Type 3 computations (DesignTables > Method)
+ ///
+ ///
+ /// In the end, the configuration can be used to generate a Hydra-Ring database creation script.
+ ///
+ internal class HydraRingConfigurationService
+ {
+ private const double defaultLayerId = 1;
+ private const double defaultAlternativeId = 1;
+ private const double defaultHydraRingValue = 0.0;
+
+ private readonly string ringId;
+ private readonly IList hydraRingCalculationInputs;
+ private readonly SubMechanismSettingsProvider subMechanismSettingsProvider = new SubMechanismSettingsProvider();
+ private readonly FailureMechanismSettingsProvider failureMechanismSettingsProvider = new FailureMechanismSettingsProvider();
+ private readonly FailureMechanismDefaultsProvider failureMechanismDefaultsProvider = new FailureMechanismDefaultsProvider();
+ private readonly VariableDefaultsProvider variableDefaultsProvider = new VariableDefaultsProvider();
+ private readonly HydraRingTimeIntegrationSchemeType timeIntegrationSchemeType;
+ private readonly HydraRingUncertaintiesType uncertaintiesType;
+
+ ///
+ /// Creates a new instance of the class.
+ ///
+ /// The id of the ring to perform Hydra-Ring calculations for.
+ /// The to use while performing Hydra-Ring calculations.
+ /// The to use while performing Hydra-Ring calculations.
+ public HydraRingConfigurationService(string ringId, HydraRingTimeIntegrationSchemeType timeIntegrationSchemeType, HydraRingUncertaintiesType uncertaintiesType)
+ {
+ hydraRingCalculationInputs = new List();
+
+ this.ringId = ringId;
+ this.timeIntegrationSchemeType = timeIntegrationSchemeType;
+ this.uncertaintiesType = uncertaintiesType;
+ }
+
+ ///
+ /// Gets the id of the ring to perform Hydra-Ring calculations for.
+ ///
+ public string RingId
+ {
+ get
+ {
+ return ringId;
+ }
+ }
+
+ ///
+ /// Gets the to use while performing Hydra-Ring calculations.
+ ///
+ public HydraRingTimeIntegrationSchemeType? TimeIntegrationSchemeType
+ {
+ get
+ {
+ return timeIntegrationSchemeType;
+ }
+ }
+
+ ///
+ /// Gets the to use while performing Hydra-Ring calculations.
+ ///
+ public HydraRingUncertaintiesType? UncertaintiesType
+ {
+ get
+ {
+ return uncertaintiesType;
+ }
+ }
+
+ ///
+ /// Adds Hydra-Ring calculation input to the configuration.
+ ///
+ /// The calculation input to add to the configuration.
+ public void AddHydraRingCalculationInput(HydraRingCalculationInput hydraRingCalculationInput)
+ {
+ hydraRingCalculationInputs.Add(hydraRingCalculationInput);
+ }
+
+ ///
+ /// Generates the database creation script necessary for performing Hydra-Ring calculations.
+ ///
+ /// The database creation script.
+ public string GenerateDataBaseCreationScript()
+ {
+ var configurationDictionary = new Dictionary>();
+
+ InitializeHydraulicModelsConfiguration(configurationDictionary);
+ InitializeSectionsConfiguration(configurationDictionary);
+ InitializeDesignTablesConfiguration(configurationDictionary);
+ InitializeNumericsConfiguration(configurationDictionary);
+ InitializeVariableDatasConfiguration(configurationDictionary);
+ InitializeCalculationProfilesConfiguration(configurationDictionary);
+ InitializeSectionFaultTreeModelsConfiguration(configurationDictionary);
+ InitializeSectionSubMechanismModelsConfiguration(configurationDictionary);
+ InitializeFetchesConfiguration(configurationDictionary);
+ InitializeAreaPointsConfiguration(configurationDictionary);
+ InitializePresentationSectionsConfiguration(configurationDictionary);
+ InitializeProfilesConfiguration(configurationDictionary);
+ InitializeForelandModelsConfiguration(configurationDictionary);
+ InitializeForelandsConfiguration(configurationDictionary);
+ InitializeProbabilityAlternativesConfiguration(configurationDictionary);
+ InitializeSetUpHeightsConfiguration(configurationDictionary);
+ InitializeCalcWindDirectionsConfiguration(configurationDictionary);
+ InitializeSwellsConfiguration(configurationDictionary);
+ InitializeWaveReductionsConfiguration(configurationDictionary);
+ InitializeAreasConfiguration(configurationDictionary);
+ InitializeProjectsConfiguration(configurationDictionary);
+
+ return GenerateDataBaseCreationScript(configurationDictionary);
+ }
+
+ private void InitializeHydraulicModelsConfiguration(Dictionary> configurationDictionary)
+ {
+ configurationDictionary["HydraulicModels"] = new List
+ {
+ new OrderedDictionary
+ {
+ {
+ "TimeIntegrationSchemeID", (int?) TimeIntegrationSchemeType
+ },
+ {
+ "UncertaintiesID", (int?) UncertaintiesType
+ },
+ {
+ "DataSetName", "WTI 2017" // Fixed: use the WTI 2017 set of station locations
+ }
+ }
+ };
+ }
+
+ private void InitializeSectionsConfiguration(Dictionary> configurationDictionary)
+ {
+ var orderedDictionaries = new List();
+
+ foreach (var hydraRingCalculationInput in hydraRingCalculationInputs)
+ {
+ var hydraRingDikeSection = hydraRingCalculationInput.DikeSection;
+
+ orderedDictionaries.Add(new OrderedDictionary
+ {
+ {
+ "SectionId", hydraRingDikeSection.SectionId
+ },
+ {
+ "PresentationId", 1 // Fixed: no support for combination of multiple dike sections
+ },
+ {
+ "MainMechanismId", 1 // Fixed: no support for combination of multiple dike sections
+ },
+ {
+ "Name", hydraRingDikeSection.SectionName
+ },
+ {
+ "Description", hydraRingDikeSection.SectionName // Just use the section name
+ },
+ {
+ "RingCoordinateBegin", GetHydraRingValue(hydraRingDikeSection.SectionBeginCoordinate)
+ },
+ {
+ "RingCoordinateEnd", GetHydraRingValue(hydraRingDikeSection.SectionEndCoordinate)
+ },
+ {
+ "XCoordinate", GetHydraRingValue(hydraRingDikeSection.CrossSectionXCoordinate)
+ },
+ {
+ "YCoordinate", GetHydraRingValue(hydraRingDikeSection.CrossSectionYCoordinate)
+ },
+ {
+ "StationId1", hydraRingCalculationInput.HydraulicBoundaryLocationId
+ },
+ {
+ "StationId2", hydraRingCalculationInput.HydraulicBoundaryLocationId // Same as "StationId1": no support for coupling two stations
+ },
+ {
+ "Relative", 100.0 // Fixed: no support for coupling two stations
+ },
+ {
+ "Normal", GetHydraRingValue(hydraRingDikeSection.CrossSectionNormal)
+ },
+ {
+ "Length", GetHydraRingValue(hydraRingDikeSection.SectionLength)
+ }
+ });
+ }
+
+ configurationDictionary["Sections"] = orderedDictionaries;
+ }
+
+ private void InitializeDesignTablesConfiguration(Dictionary> configurationDictionary)
+ {
+ var orderedDictionaries = new List();
+
+ foreach (var hydraRingCalculationInput in hydraRingCalculationInputs)
+ {
+ var failureMechanismDefaults = failureMechanismDefaultsProvider.GetFailureMechanismDefaults(hydraRingCalculationInput.FailureMechanismType);
+ var failureMechanismSettings = failureMechanismSettingsProvider.GetFailureMechanismSettings(hydraRingCalculationInput.FailureMechanismType);
+
+ orderedDictionaries.Add(new OrderedDictionary
+ {
+ {
+ "SectionId", hydraRingCalculationInput.DikeSection.SectionId
+ },
+ {
+ "MechanismId", failureMechanismDefaults.MechanismId
+ },
+ {
+ "LayerId", defaultLayerId // Fixed: no support for revetments
+ },
+ {
+ "AlternativeId", defaultAlternativeId // Fixed: no support for piping
+ },
+ {
+ "Method", hydraRingCalculationInput.CalculationTypeId
+ },
+ {
+ "VariableId", failureMechanismDefaults.VariableId
+ },
+ {
+ "LoadVariableId", defaultHydraRingValue // Fixed: not relevant
+ },
+ {
+ "TableMin", defaultHydraRingValue // Fixed: no support for type 3 computations (see "Method")
+ },
+ {
+ "TableMax", defaultHydraRingValue // Fixed: no support for type 3 computations (see "Method")
+ },
+ {
+ "TableStepSize", defaultHydraRingValue // Fixed: no support for type 3 computations (see "Method")
+ },
+ {
+ "ValueMin", GetHydraRingValue(failureMechanismSettings.ValueMin)
+ },
+ {
+ "ValueMax", GetHydraRingValue(failureMechanismSettings.ValueMax)
+ },
+ {
+ "Beta", GetHydraRingValue(hydraRingCalculationInput.Beta)
+ }
+ });
+ }
+
+ configurationDictionary["DesignTables"] = orderedDictionaries;
+ }
+
+ private void InitializeNumericsConfiguration(Dictionary> configurationDictionary)
+ {
+ var orderDictionaries = new List();
+
+ foreach (var hydraRingCalculationInput in hydraRingCalculationInputs)
+ {
+ var failureMechanismDefaults = failureMechanismDefaultsProvider.GetFailureMechanismDefaults(hydraRingCalculationInput.FailureMechanismType);
+
+ foreach (var subMechanismId in failureMechanismDefaults.SubMechanismIds)
+ {
+ var subMechanismSettings = subMechanismSettingsProvider.GetSubMechanismSettings(hydraRingCalculationInput.FailureMechanismType, subMechanismId, ringId);
+
+ orderDictionaries.Add(new OrderedDictionary
+ {
+ {
+ "SectionId", hydraRingCalculationInput.DikeSection.SectionId
+ },
+ {
+ "MechanismId", failureMechanismDefaults.MechanismId
+ },
+ {
+ "LayerId", defaultLayerId // Fixed: no support for revetments
+ },
+ {
+ "AlternativeId", defaultAlternativeId // Fixed: no support for piping
+ },
+ {
+ "SubMechanismId", subMechanismId
+ },
+ {
+ "Method", subMechanismSettings.CalculationTechniqueId
+ },
+ {
+ "FormStartMethod", subMechanismSettings.FormStartMethod
+ },
+ {
+ "FormNumberOfIterations", subMechanismSettings.FormNumberOfIterations
+ },
+ {
+ "FormRelaxationFactor", GetHydraRingValue(subMechanismSettings.FormRelaxationFactor)
+ },
+ {
+ "FormEpsBeta", GetHydraRingValue(subMechanismSettings.FormEpsBeta)
+ },
+ {
+ "FormEpsHOH", GetHydraRingValue(subMechanismSettings.FormEpsHoh)
+ },
+ {
+ "FormEpsZFunc", GetHydraRingValue(subMechanismSettings.FormEpsZFunc)
+ },
+ {
+ "DsStartMethod", subMechanismSettings.DsStartMethod
+ },
+ {
+ "DsIterationmethod", 1 // Fixed: not relevant
+ },
+ {
+ "DsMinNumberOfIterations", subMechanismSettings.DsMinNumberOfIterations
+ },
+ {
+ "DsMaxNumberOfIterations", subMechanismSettings.DsMaxNumberOfIterations
+ },
+ {
+ "DsVarCoefficient", GetHydraRingValue(subMechanismSettings.DsVarCoefficient)
+ },
+ {
+ "NiUMin", GetHydraRingValue(subMechanismSettings.NiUMin)
+ },
+ {
+ "NiUMax", GetHydraRingValue(subMechanismSettings.NiUMax)
+ },
+ {
+ "NiNumberSteps", subMechanismSettings.NiNumberSteps
+ }
+ });
+ }
+ }
+
+ configurationDictionary["Numerics"] = orderDictionaries;
+ }
+
+ private void InitializeVariableDatasConfiguration(Dictionary> configurationDictionary)
+ {
+ var orderDictionaries = new List();
+
+ foreach (var hydraRingCalculationInput in hydraRingCalculationInputs)
+ {
+ var failureMechanismDefaults = failureMechanismDefaultsProvider.GetFailureMechanismDefaults(hydraRingCalculationInput.FailureMechanismType);
+
+ foreach (var hydraRingVariable in hydraRingCalculationInput.Variables)
+ {
+ var variableDefaults = variableDefaultsProvider.GetVariableDefaults(hydraRingCalculationInput.FailureMechanismType, hydraRingVariable.VariableId);
+
+ orderDictionaries.Add(new OrderedDictionary
+ {
+ {
+ "SectionId", hydraRingCalculationInput.DikeSection.SectionId
+ },
+ {
+ "MechanismId", failureMechanismDefaults.MechanismId
+ },
+ {
+ "LayerId", defaultLayerId // Fixed: no support for revetments
+ },
+ {
+ "AlternativeId", defaultAlternativeId // Fixed: no support for piping
+ },
+ {
+ "VariableId", hydraRingVariable.VariableId
+ },
+ {
+ "Value", hydraRingVariable.DistributionType == HydraRingDistributionType.Deterministic
+ ? GetHydraRingValue(hydraRingVariable.Value)
+ : defaultHydraRingValue
+ },
+ {
+ "DistributionType", (int?) hydraRingVariable.DistributionType
+ },
+ {
+ "Parameter1", hydraRingVariable.DistributionType != HydraRingDistributionType.Deterministic
+ ? GetHydraRingValue(hydraRingVariable.Mean)
+ : defaultHydraRingValue
+ },
+ {
+ "Parameter2", hydraRingVariable.DistributionType != HydraRingDistributionType.Deterministic
+ && hydraRingVariable.DeviationType == HydraRingDeviationType.Standard
+ ? GetHydraRingValue(hydraRingVariable.Variability)
+ : defaultHydraRingValue
+ },
+ {
+ "Parameter3", hydraRingVariable.DistributionType == HydraRingDistributionType.LogNormal
+ ? GetHydraRingValue(hydraRingVariable.Shift)
+ : defaultHydraRingValue
+ },
+ {
+ "Parameter4", defaultHydraRingValue // Fixed: Not relevant
+ },
+ {
+ "DeviationType", (int?) hydraRingVariable.DeviationType
+ },
+ {
+ "CoefficientOfVariation", hydraRingVariable.DistributionType != HydraRingDistributionType.Deterministic
+ && hydraRingVariable.DeviationType == HydraRingDeviationType.Variation
+ ? GetHydraRingValue(hydraRingVariable.Variability)
+ : defaultHydraRingValue
+ },
+ {
+ "CorrelationLength", GetHydraRingValue(variableDefaults.CorrelationLength)
+ }
+ });
+ }
+ }
+
+ configurationDictionary["VariableDatas"] = orderDictionaries;
+ }
+
+ private void InitializeCalculationProfilesConfiguration(Dictionary> configurationDictionary)
+ {
+ var orderDictionaries = new List();
+
+ foreach (var hydraRingCalculationInput in hydraRingCalculationInputs)
+ {
+ for (var i = 0; i < hydraRingCalculationInput.ProfilePoints.Count(); i++)
+ {
+ var hydraRingProfilePoint = hydraRingCalculationInput.ProfilePoints.ElementAt(i);
+
+ orderDictionaries.Add(new OrderedDictionary
+ {
+ {
+ "SectionId", hydraRingCalculationInput.DikeSection.SectionId
+ },
+ {
+ "SequenceNumber", i + 1
+ },
+ {
+ "XCoordinate", GetHydraRingValue(hydraRingProfilePoint.X)
+ },
+ {
+ "ZCoordinate", GetHydraRingValue(hydraRingProfilePoint.Z)
+ },
+ {
+ "Roughness", GetHydraRingValue(hydraRingProfilePoint.Roughness)
+ }
+ });
+ }
+ }
+
+ configurationDictionary["CalculationProfiles"] = orderDictionaries;
+ }
+
+ private void InitializeSectionFaultTreeModelsConfiguration(Dictionary> configurationDictionary)
+ {
+ var orderedDictionaries = new List();
+
+ foreach (var hydraRingCalculationInput in hydraRingCalculationInputs)
+ {
+ var failureMechanismDefaults = failureMechanismDefaultsProvider.GetFailureMechanismDefaults(hydraRingCalculationInput.FailureMechanismType);
+ var failureMechanismSettings = failureMechanismSettingsProvider.GetFailureMechanismSettings(hydraRingCalculationInput.FailureMechanismType);
+
+ orderedDictionaries.Add(new OrderedDictionary
+ {
+ {
+ "SectionId", hydraRingCalculationInput.DikeSection.SectionId
+ },
+ {
+ "MechanismId", failureMechanismDefaults.MechanismId
+ },
+ {
+ "LayerId", defaultLayerId // Fixed: no support for revetments
+ },
+ {
+ "AlternativeId", defaultAlternativeId // Fixed: no support for piping
+ },
+ {
+ "FaultTreeModelId", failureMechanismSettings.FaultTreeModelId
+ }
+ });
+ }
+
+ configurationDictionary["SectionFaultTreeModels"] = orderedDictionaries;
+ }
+
+ private void InitializeSectionSubMechanismModelsConfiguration(Dictionary> configurationDictionary)
+ {
+ var orderedDictionaries = new List();
+
+ foreach (var hydraRingCalculationInput in hydraRingCalculationInputs)
+ {
+ var failureMechanismDefaults = failureMechanismDefaultsProvider.GetFailureMechanismDefaults(hydraRingCalculationInput.FailureMechanismType);
+
+ foreach (var subMechanismId in failureMechanismDefaults.SubMechanismIds)
+ {
+ var subMechanismModelId = hydraRingCalculationInput.GetSubMechanismModelId(subMechanismId);
+
+ if (subMechanismModelId != null)
+ {
+ orderedDictionaries.Add(new OrderedDictionary
+ {
+ {
+ "SectionId", hydraRingCalculationInput.DikeSection.SectionId
+ },
+ {
+ "MechanismId", failureMechanismDefaults.MechanismId
+ },
+ {
+ "LayerId", defaultLayerId // Fixed: no support for revetments
+ },
+ {
+ "AlternativeId", defaultAlternativeId // Fixed: no support for piping
+ },
+ {
+ "SubMechanismId", subMechanismId
+ },
+ {
+ "SubMechanismModelId", subMechanismModelId
+ }
+ });
+ }
+ }
+ }
+
+ configurationDictionary["SectionSubMechanismModels"] = orderedDictionaries;
+ }
+
+ private void InitializeFetchesConfiguration(Dictionary> configurationDictionary)
+ {
+ configurationDictionary["Fetches"] = new List();
+ }
+
+ private void InitializeAreaPointsConfiguration(Dictionary> configurationDictionary)
+ {
+ configurationDictionary["AreaPoints"] = new List();
+ }
+
+ private void InitializePresentationSectionsConfiguration(Dictionary> configurationDictionary)
+ {
+ configurationDictionary["PresentationSections"] = new List();
+ }
+
+ private void InitializeProfilesConfiguration(Dictionary> configurationDictionary)
+ {
+ configurationDictionary["Profiles"] = new List();
+ }
+
+ private void InitializeForelandModelsConfiguration(Dictionary> configurationDictionary)
+ {
+ configurationDictionary["ForelandModels"] = new List();
+ }
+
+ private void InitializeForelandsConfiguration(Dictionary> configurationDictionary)
+ {
+ configurationDictionary["Forelands"] = new List();
+ }
+
+ private void InitializeProbabilityAlternativesConfiguration(Dictionary> configurationDictionary)
+ {
+ configurationDictionary["ProbabilityAlternatives"] = new List();
+ }
+
+ private void InitializeSetUpHeightsConfiguration(Dictionary> configurationDictionary)
+ {
+ configurationDictionary["SetUpHeights"] = new List();
+ }
+
+ private void InitializeCalcWindDirectionsConfiguration(Dictionary> configurationDictionary)
+ {
+ configurationDictionary["CalcWindDirections"] = new List();
+ }
+
+ private void InitializeSwellsConfiguration(Dictionary> configurationDictionary)
+ {
+ configurationDictionary["Swells"] = new List();
+ }
+
+ private void InitializeWaveReductionsConfiguration(Dictionary> configurationDictionary)
+ {
+ configurationDictionary["WaveReductions"] = new List();
+ }
+
+ private void InitializeAreasConfiguration(Dictionary> configurationDictionary)
+ {
+ configurationDictionary["Areas"] = new List
+ {
+ new OrderedDictionary
+ {
+ {
+ "aDefault", 1 // Fixed: not relevant
+ },
+ {
+ "bDefault", "1" // Fixed: not relevant
+ },
+ {
+ "cDefault", "Nederland" // Fixed: not relevant
+ }
+ }
+ };
+ }
+
+ private void InitializeProjectsConfiguration(Dictionary> configurationDictionary)
+ {
+ configurationDictionary["Projects"] = new List
+ {
+ new OrderedDictionary
+ {
+ {
+ "aDefault", 1 // Fixed: not relevant
+ },
+ {
+ "bDefault", "WTI 2017" // Fixed: not relevant
+ },
+ {
+ "cDefault", "Ringtoets calculation" // Fixed: not relevant
+ }
+ }
+ };
+ }
+
+ private static string GenerateDataBaseCreationScript(Dictionary> configurationDictionary)
+ {
+ var lines = new List();
+
+ foreach (var tableName in configurationDictionary.Keys)
+ {
+ lines.Add("DELETE FROM [" + tableName + "];");
+
+ if (configurationDictionary[tableName].Count <= 0)
+ {
+ lines.Add("");
+
+ continue;
+ }
+
+ foreach (var orderedDictionary in configurationDictionary[tableName])
+ {
+ var valueStrings = new List();
+
+ foreach (var val in orderedDictionary.Values)
+ {
+ if (val == null)
+ {
+ valueStrings.Add("NULL");
+ continue;
+ }
+
+ if (val is string)
+ {
+ valueStrings.Add("'" + val + "'");
+ continue;
+ }
+
+ if (val is double)
+ {
+ valueStrings.Add(((double) val).ToString(CultureInfo.InvariantCulture));
+ continue;
+ }
+
+ valueStrings.Add(val.ToString());
+ }
+
+ var valuesString = string.Join(", ", valueStrings);
+
+ lines.Add("INSERT INTO [" + tableName + "] VALUES (" + valuesString + ");");
+ }
+
+ lines.Add("");
+ }
+
+ return string.Join(Environment.NewLine, lines);
+ }
+
+ private static double? GetHydraRingValue(double value)
+ {
+ return !double.IsNaN(value) ? value : defaultHydraRingValue;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Services/HydraRingInitializationService.cs
===================================================================
diff -u
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Services/HydraRingInitializationService.cs (revision 0)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Services/HydraRingInitializationService.cs (revision 67100b9ae4581855aa4b6e1675c3fdf550614c7a)
@@ -0,0 +1,184 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.IO;
+using System.Reflection;
+using Ringtoets.HydraRing.Calculation.Data;
+using Ringtoets.HydraRing.Calculation.Providers;
+
+namespace Ringtoets.HydraRing.Calculation.Services
+{
+ ///
+ /// Service for:
+ ///
+ /// -
+ /// generating an initialization script that is necessary for performing Hydra-Ring calculations;
+ ///
+ /// -
+ /// providing the corresponding file paths.
+ ///
+ ///
+ ///
+ internal class HydraRingInitializationService
+ {
+ private readonly int mechanismId;
+ private readonly int sectionId;
+ private readonly string iniFilePath;
+ private readonly string dataBaseCreationScriptFileName;
+ private readonly string dataBaseCreationScriptFilePath;
+ private readonly string logFileName;
+ private readonly string logFilePath;
+ private readonly string outputFileName;
+ private readonly string outputFilePath;
+ private readonly string outputDataBasePath;
+ private readonly string hlcdFilePath;
+ private readonly string mechanismComputationExeFilePath;
+ private readonly string configurationDatabaseFilePath;
+
+ ///
+ /// Creates a new instance of the class.
+ ///
+ /// The failure mechanism type.
+ /// The section id.
+ /// The HLCD directory.
+ /// The working directory.
+ public HydraRingInitializationService(HydraRingFailureMechanismType failureMechanismType, int sectionId, string hlcdDirectory, string workingDirectory)
+ {
+ mechanismId = new FailureMechanismDefaultsProvider().GetFailureMechanismDefaults(failureMechanismType).MechanismId;
+ this.sectionId = sectionId;
+
+ // Initialize input/output file paths
+ var iniFileName = sectionId + ".ini";
+ iniFilePath = Path.Combine(workingDirectory, iniFileName);
+ dataBaseCreationScriptFileName = sectionId + ".sql";
+ dataBaseCreationScriptFilePath = Path.Combine(workingDirectory, dataBaseCreationScriptFileName);
+ logFileName = sectionId + ".log";
+ logFilePath = Path.Combine(workingDirectory, logFileName);
+ outputFileName = "designTable.txt";
+ outputFilePath = Path.Combine(workingDirectory, outputFileName);
+ outputDataBasePath = Path.Combine(workingDirectory, "temp.sqlite");
+ hlcdFilePath = Path.Combine(hlcdDirectory, "HLCD.sqlite");
+
+ // Initialize Hydra-Ring file paths
+ var hydraRingDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"HydraRing");
+ mechanismComputationExeFilePath = Path.Combine(hydraRingDirectory, "MechanismComputation.exe");
+ configurationDatabaseFilePath = Path.Combine(hydraRingDirectory, "config.sqlite");
+ }
+
+ ///
+ /// Gets the ini file path.
+ ///
+ public string IniFilePath
+ {
+ get
+ {
+ return iniFilePath;
+ }
+ }
+
+ ///
+ /// Gets the database creation script file path.
+ ///
+ public string DataBaseCreationScriptFilePath
+ {
+ get
+ {
+ return dataBaseCreationScriptFilePath;
+ }
+ }
+
+ ///
+ /// Gets the log file path.
+ ///
+ public string LogFilePath
+ {
+ get
+ {
+ return logFilePath;
+ }
+ }
+
+ ///
+ /// Gets the output file path.
+ ///
+ public string OutputFilePath
+ {
+ get
+ {
+ return outputFilePath;
+ }
+ }
+
+ ///
+ /// Gets the output database path.
+ ///
+ public string OutputDataBasePath
+ {
+ get
+ {
+ return outputDataBasePath;
+ }
+ }
+
+ ///
+ /// Gets the HLCD file path.
+ ///
+ public string HlcdFilePath
+ {
+ get
+ {
+ return hlcdFilePath;
+ }
+ }
+
+ ///
+ /// Gets the path of the MechanismComputation.exe file.
+ ///
+ public string MechanismComputationExeFilePath
+ {
+ get
+ {
+ return mechanismComputationExeFilePath;
+ }
+ }
+
+ ///
+ /// Generates the initialization script necessary for performing Hydra-Ring calculations.
+ ///
+ /// The initialization script.
+ public string GenerateInitializationScript()
+ {
+ return string.Join(Environment.NewLine,
+ "section = " + sectionId,
+ "mechanism = " + mechanismId,
+ "alternative = 1", // Fixed: no support for piping
+ "layer = 1", // Fixed: no support for revetments
+ "logfile = " + logFileName,
+ "outputverbosity = basic",
+ "outputtofile = file",
+ "projectdbfilename = " + dataBaseCreationScriptFileName,
+ "outputfilename = " + outputFileName,
+ "configdbfilename = " + configurationDatabaseFilePath,
+ "hydraulicdbfilename = " + hlcdFilePath);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Services/HydraRingProcessFactory.cs
===================================================================
diff -u
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Services/HydraRingProcessFactory.cs (revision 0)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Services/HydraRingProcessFactory.cs (revision 67100b9ae4581855aa4b6e1675c3fdf550614c7a)
@@ -0,0 +1,54 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Diagnostics;
+
+namespace Ringtoets.HydraRing.Calculation.Services
+{
+ ///
+ /// Factory for creating instances that can be used for performing Hydra-Ring calculations.
+ ///
+ public static class HydraRingProcessFactory
+ {
+ ///
+ /// Creates a that can be used for performing a Hydra-Ring calculation.
+ ///
+ /// The path to the MechanismComputation.exe file that should be used for the calculation.
+ /// The path to the ini file that should be used during the calculation.
+ /// The working directory that should be used during the calculation.
+ ///
+ public static Process Create(string mechanismComputationExeFilePath, string iniFilePath, string workingDirectory)
+ {
+ return new Process
+ {
+ StartInfo = new ProcessStartInfo(mechanismComputationExeFilePath, iniFilePath)
+ {
+ WorkingDirectory = workingDirectory,
+ UseShellExecute = false,
+ CreateNoWindow = true,
+ RedirectStandardInput = true,
+ RedirectStandardOutput = true,
+ RedirectStandardError = true
+ }
+ };
+ }
+ }
+}
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Activities/TargetProbabilityCalculationActivityTest.cs
===================================================================
diff -u
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Activities/TargetProbabilityCalculationActivityTest.cs (revision 0)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Activities/TargetProbabilityCalculationActivityTest.cs (revision 67100b9ae4581855aa4b6e1675c3fdf550614c7a)
@@ -0,0 +1,145 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using Core.Common.Base.Service;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.HydraRing.Calculation.Activities;
+using Ringtoets.HydraRing.Calculation.Data;
+using Ringtoets.HydraRing.Calculation.Data.Input;
+using Ringtoets.HydraRing.Calculation.Data.Output;
+using Ringtoets.HydraRing.Calculation.Services;
+
+namespace Ringtoets.HydraRing.Calculation.Test.Activities
+{
+ [TestFixture]
+ public class TargetProbabilityCalculationActivityTest
+ {
+ [Test]
+ public void ParameteredConstructor_ExpectedValues()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var hydraRingCalculationService = mocks.StrictMock();
+ var targetProbabilityCalculationInputImplementation = new TargetProbabilityCalculationInputImplementation(1, 10000);
+
+ mocks.ReplayAll();
+
+ // Call
+ var activity = new TargetProbabilityCalculationActivity("Name of activity", "hlcdDirectory", "ringId", HydraRingTimeIntegrationSchemeType.FBC, HydraRingUncertaintiesType.All, targetProbabilityCalculationInputImplementation, null, hydraRingCalculationService);
+
+ // Assert
+ Assert.IsInstanceOf(activity);
+ Assert.AreEqual("Name of activity", activity.Name);
+ Assert.IsNull(activity.ProgressText);
+ Assert.AreEqual(ActivityState.None, activity.State);
+ }
+
+ [Test]
+ public void Run_TargetProbabilityCalculationActivity_PerformCalculationCalledWithCorrectParameters()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var hydraRingCalculationService = mocks.StrictMock();
+ var targetProbabilityCalculationOutput = mocks.StrictMock(1.1, 2.2);
+ var targetProbabilityCalculationInputImplementation = new TargetProbabilityCalculationInputImplementation(1, 10000);
+
+ const string hlcdDirectory = "hlcdDirectory";
+ const string ringId = "ringId";
+ const HydraRingUncertaintiesType uncertaintiesType = HydraRingUncertaintiesType.All;
+ const HydraRingTimeIntegrationSchemeType timeIntegrationSchemeType = HydraRingTimeIntegrationSchemeType.FBC;
+
+ hydraRingCalculationService.Expect(hcs => hcs.PerformCalculation(hlcdDirectory, ringId, timeIntegrationSchemeType, uncertaintiesType, targetProbabilityCalculationInputImplementation)).Return(targetProbabilityCalculationOutput);
+
+ mocks.ReplayAll();
+
+ var activity = new TargetProbabilityCalculationActivity("Name of activity", hlcdDirectory, ringId, timeIntegrationSchemeType, uncertaintiesType, targetProbabilityCalculationInputImplementation, null, hydraRingCalculationService);
+
+ // Call
+ activity.Run();
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Cancel_TargetProbabilityCalculationActivity_CancelRunningCalculationCalled()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var hydraRingCalculationService = mocks.StrictMock();
+ var targetProbabilityCalculationInputImplementation = new TargetProbabilityCalculationInputImplementation(1, 10000);
+
+ hydraRingCalculationService.Expect(hcs => hcs.CancelRunningCalculation());
+
+ mocks.ReplayAll();
+
+ var activity = new TargetProbabilityCalculationActivity("Name of activity", "hlcdDirectory", "ringId", HydraRingTimeIntegrationSchemeType.FBC, HydraRingUncertaintiesType.All, targetProbabilityCalculationInputImplementation, null, hydraRingCalculationService);
+
+ // Call
+ activity.Cancel();
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Finish_TargetProbabilityCalculationActivity_OutputActionPerformed()
+ {
+ // Setup
+ var count = 0;
+ var mocks = new MockRepository();
+ var hydraRingCalculationService = mocks.StrictMock();
+ var targetProbabilityCalculationInputImplementation = new TargetProbabilityCalculationInputImplementation(1, 10000);
+
+ mocks.ReplayAll();
+
+ var activity = new TargetProbabilityCalculationActivity("Name of activity", "hlcdDirectory", "ringId", HydraRingTimeIntegrationSchemeType.FBC, HydraRingUncertaintiesType.All, targetProbabilityCalculationInputImplementation, output => { count++; }, hydraRingCalculationService);
+
+ // Call
+ activity.Finish();
+
+ // Assert
+ Assert.AreEqual(1, count);
+ }
+
+ private class TargetProbabilityCalculationInputImplementation : TargetProbabilityCalculationInput
+ {
+ public TargetProbabilityCalculationInputImplementation(int hydraulicBoundaryLocationId, double norm) : base(hydraulicBoundaryLocationId, norm) {}
+
+ public override HydraRingFailureMechanismType FailureMechanismType
+ {
+ get
+ {
+ return HydraRingFailureMechanismType.QVariant;
+ }
+ }
+
+ public override HydraRingDikeSection DikeSection
+ {
+ get
+ {
+ return new HydraRingDikeSection(1, "Name", 2.2, 3.3, 4.4, 5.5, 6.6, 7.7);
+ }
+ }
+ }
+ }
+}
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Integration/HydraRingConfigurationServiceIntegrationTest.cs
===================================================================
diff -u -r938e3cf3c4fb8d0f64f21ef4b0d6f5b45feb23bb -r67100b9ae4581855aa4b6e1675c3fdf550614c7a
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Integration/HydraRingConfigurationServiceIntegrationTest.cs (.../HydraRingConfigurationServiceIntegrationTest.cs) (revision 938e3cf3c4fb8d0f64f21ef4b0d6f5b45feb23bb)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Integration/HydraRingConfigurationServiceIntegrationTest.cs (.../HydraRingConfigurationServiceIntegrationTest.cs) (revision 67100b9ae4581855aa4b6e1675c3fdf550614c7a)
@@ -23,7 +23,7 @@
using NUnit.Framework;
using Ringtoets.HydraRing.Calculation.Data;
using Ringtoets.HydraRing.Calculation.Data.Input.Hydraulics;
-using Ringtoets.HydraRing.Calculation.Service;
+using Ringtoets.HydraRing.Calculation.Services;
namespace Ringtoets.HydraRing.Calculation.Test.Integration
{
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Ringtoets.HydraRing.Calculation.Test.csproj
===================================================================
diff -u -r5acab76606f99e1ce397803e7fcaaa1cc42aa3eb -r67100b9ae4581855aa4b6e1675c3fdf550614c7a
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Ringtoets.HydraRing.Calculation.Test.csproj (.../Ringtoets.HydraRing.Calculation.Test.csproj) (revision 5acab76606f99e1ce397803e7fcaaa1cc42aa3eb)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Ringtoets.HydraRing.Calculation.Test.csproj (.../Ringtoets.HydraRing.Calculation.Test.csproj) (revision 67100b9ae4581855aa4b6e1675c3fdf550614c7a)
@@ -59,7 +59,7 @@
-
+
@@ -81,9 +81,9 @@
-
-
-
+
+
+
Fisheye: Tag 67100b9ae4581855aa4b6e1675c3fdf550614c7a refers to a dead (removed) revision in file `Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/HydraRingConfigurationServiceTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 67100b9ae4581855aa4b6e1675c3fdf550614c7a refers to a dead (removed) revision in file `Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/HydraRingInitializationServiceTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 67100b9ae4581855aa4b6e1675c3fdf550614c7a refers to a dead (removed) revision in file `Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/HydraRingProcessFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 67100b9ae4581855aa4b6e1675c3fdf550614c7a refers to a dead (removed) revision in file `Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/TargetProbabilityCalculationActivityTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Services/HydraRingConfigurationServiceTest.cs
===================================================================
diff -u
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Services/HydraRingConfigurationServiceTest.cs (revision 0)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Services/HydraRingConfigurationServiceTest.cs (revision 67100b9ae4581855aa4b6e1675c3fdf550614c7a)
@@ -0,0 +1,313 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using Ringtoets.HydraRing.Calculation.Data;
+using Ringtoets.HydraRing.Calculation.Data.Input;
+using Ringtoets.HydraRing.Calculation.Services;
+
+namespace Ringtoets.HydraRing.Calculation.Test.Services
+{
+ [TestFixture]
+ public class HydraRingConfigurationServiceTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var hydraRingConfigurationService = new HydraRingConfigurationService("34-1", HydraRingTimeIntegrationSchemeType.NTI, HydraRingUncertaintiesType.Model);
+
+ // Assert
+ Assert.AreEqual("34-1", hydraRingConfigurationService.RingId);
+ Assert.AreEqual(HydraRingTimeIntegrationSchemeType.NTI, hydraRingConfigurationService.TimeIntegrationSchemeType);
+ Assert.AreEqual(HydraRingUncertaintiesType.Model, hydraRingConfigurationService.UncertaintiesType);
+ }
+
+ [Test]
+ public void GenerateDataBaseCreationScript_SingleHydraRingCalculationInputAddedToConfiguration_ReturnsExpectedCreationScript()
+ {
+ // Setup
+ var hydraRingConfigurationService = new HydraRingConfigurationService("34-1", HydraRingTimeIntegrationSchemeType.NTI, HydraRingUncertaintiesType.Model);
+
+ hydraRingConfigurationService.AddHydraRingCalculationInput(new HydraRingCalculationInputImplementation(1, 700004));
+
+ var expectedCreationScript = "DELETE FROM [HydraulicModels];" + Environment.NewLine +
+ "INSERT INTO [HydraulicModels] VALUES (3, 2, 'WTI 2017');" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Sections];" + Environment.NewLine +
+ "INSERT INTO [Sections] VALUES (1, 1, 1, 'LocationName', 'LocationName', 2.2, 3.3, 5.5, 6.6, 700004, 700004, 100, 7.7, 4.4);" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [DesignTables];" + Environment.NewLine +
+ "INSERT INTO [DesignTables] VALUES (1, 1, 1, 1, 4, 26, 0, 0, 0, 0, 0, 50, 1.1);" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Numerics];" + Environment.NewLine +
+ "INSERT INTO [Numerics] VALUES (1, 1, 1, 1, 1, 1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 1, 20000, 100000, 0.1, -6, 6, 25);" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [VariableDatas];" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 2.2, 0, 0, 0, 0, 0, 0, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 22.2, 0, 0, 0, 0, 0, 1, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 2, 333.3, 444.4, 0, 0, 0, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 2, 3333.3, 0, 0, 0, 1, 4444.4, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 4, 33333.3, 44444.4, 55555.5, 0, 0, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 4, 333333.3, 0, 555555.5, 0, 1, 444444.4, 300);" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [CalculationProfiles];" + Environment.NewLine +
+ "INSERT INTO [CalculationProfiles] VALUES (1, 1, 1.1, 2.2, 3.3);" + Environment.NewLine +
+ "INSERT INTO [CalculationProfiles] VALUES (1, 2, 11.1, 22.2, 33.3);" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [SectionFaultTreeModels];" + Environment.NewLine +
+ "INSERT INTO [SectionFaultTreeModels] VALUES (1, 1, 1, 1, 1);" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [SectionSubMechanismModels];" + Environment.NewLine +
+ "INSERT INTO [SectionSubMechanismModels] VALUES (1, 1, 1, 1, 1, 1234);" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Fetches];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [AreaPoints];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [PresentationSections];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Profiles];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [ForelandModels];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Forelands];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [ProbabilityAlternatives];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [SetUpHeights];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [CalcWindDirections];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Swells];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [WaveReductions];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Areas];" + Environment.NewLine +
+ "INSERT INTO [Areas] VALUES (1, '1', 'Nederland');" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Projects];" + Environment.NewLine +
+ "INSERT INTO [Projects] VALUES (1, 'WTI 2017', 'Ringtoets calculation');" + Environment.NewLine;
+
+ // Call
+ var creationScript = hydraRingConfigurationService.GenerateDataBaseCreationScript();
+
+ // Assert
+ Assert.AreEqual(expectedCreationScript, creationScript);
+ }
+
+ [Test]
+ public void GenerateDataBaseCreationScript_MultipleHydraRingCalculationInputsAddedToConfiguration_ReturnsExpectedCreationScript()
+ {
+ // Setup
+ var hydraRingConfigurationService = new HydraRingConfigurationService("34-1", HydraRingTimeIntegrationSchemeType.NTI, HydraRingUncertaintiesType.Model);
+
+ hydraRingConfigurationService.AddHydraRingCalculationInput(new HydraRingCalculationInputImplementation(1, 700004));
+ hydraRingConfigurationService.AddHydraRingCalculationInput(new HydraRingCalculationInputImplementation(2, 700005));
+ hydraRingConfigurationService.AddHydraRingCalculationInput(new HydraRingCalculationInputImplementation(3, 700006));
+
+ var expectedCreationScript = "DELETE FROM [HydraulicModels];" + Environment.NewLine +
+ "INSERT INTO [HydraulicModels] VALUES (3, 2, 'WTI 2017');" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Sections];" + Environment.NewLine +
+ "INSERT INTO [Sections] VALUES (1, 1, 1, 'LocationName', 'LocationName', 2.2, 3.3, 5.5, 6.6, 700004, 700004, 100, 7.7, 4.4);" + Environment.NewLine +
+ "INSERT INTO [Sections] VALUES (2, 1, 1, 'LocationName', 'LocationName', 2.2, 3.3, 5.5, 6.6, 700005, 700005, 100, 7.7, 4.4);" + Environment.NewLine +
+ "INSERT INTO [Sections] VALUES (3, 1, 1, 'LocationName', 'LocationName', 2.2, 3.3, 5.5, 6.6, 700006, 700006, 100, 7.7, 4.4);" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [DesignTables];" + Environment.NewLine +
+ "INSERT INTO [DesignTables] VALUES (1, 1, 1, 1, 4, 26, 0, 0, 0, 0, 0, 50, 1.1);" + Environment.NewLine +
+ "INSERT INTO [DesignTables] VALUES (2, 1, 1, 1, 4, 26, 0, 0, 0, 0, 0, 50, 1.1);" + Environment.NewLine +
+ "INSERT INTO [DesignTables] VALUES (3, 1, 1, 1, 4, 26, 0, 0, 0, 0, 0, 50, 1.1);" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Numerics];" + Environment.NewLine +
+ "INSERT INTO [Numerics] VALUES (1, 1, 1, 1, 1, 1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 1, 20000, 100000, 0.1, -6, 6, 25);" + Environment.NewLine +
+ "INSERT INTO [Numerics] VALUES (2, 1, 1, 1, 1, 1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 1, 20000, 100000, 0.1, -6, 6, 25);" + Environment.NewLine +
+ "INSERT INTO [Numerics] VALUES (3, 1, 1, 1, 1, 1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 1, 20000, 100000, 0.1, -6, 6, 25);" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [VariableDatas];" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 2.2, 0, 0, 0, 0, 0, 0, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 22.2, 0, 0, 0, 0, 0, 1, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 2, 333.3, 444.4, 0, 0, 0, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 2, 3333.3, 0, 0, 0, 1, 4444.4, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 4, 33333.3, 44444.4, 55555.5, 0, 0, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 4, 333333.3, 0, 555555.5, 0, 1, 444444.4, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (2, 1, 1, 1, 26, 2.2, 0, 0, 0, 0, 0, 0, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (2, 1, 1, 1, 26, 22.2, 0, 0, 0, 0, 0, 1, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (2, 1, 1, 1, 26, 0, 2, 333.3, 444.4, 0, 0, 0, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (2, 1, 1, 1, 26, 0, 2, 3333.3, 0, 0, 0, 1, 4444.4, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (2, 1, 1, 1, 26, 0, 4, 33333.3, 44444.4, 55555.5, 0, 0, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (2, 1, 1, 1, 26, 0, 4, 333333.3, 0, 555555.5, 0, 1, 444444.4, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (3, 1, 1, 1, 26, 2.2, 0, 0, 0, 0, 0, 0, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (3, 1, 1, 1, 26, 22.2, 0, 0, 0, 0, 0, 1, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (3, 1, 1, 1, 26, 0, 2, 333.3, 444.4, 0, 0, 0, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (3, 1, 1, 1, 26, 0, 2, 3333.3, 0, 0, 0, 1, 4444.4, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (3, 1, 1, 1, 26, 0, 4, 33333.3, 44444.4, 55555.5, 0, 0, 0, 300);" + Environment.NewLine +
+ "INSERT INTO [VariableDatas] VALUES (3, 1, 1, 1, 26, 0, 4, 333333.3, 0, 555555.5, 0, 1, 444444.4, 300);" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [CalculationProfiles];" + Environment.NewLine +
+ "INSERT INTO [CalculationProfiles] VALUES (1, 1, 1.1, 2.2, 3.3);" + Environment.NewLine +
+ "INSERT INTO [CalculationProfiles] VALUES (1, 2, 11.1, 22.2, 33.3);" + Environment.NewLine +
+ "INSERT INTO [CalculationProfiles] VALUES (2, 1, 1.1, 2.2, 3.3);" + Environment.NewLine +
+ "INSERT INTO [CalculationProfiles] VALUES (2, 2, 11.1, 22.2, 33.3);" + Environment.NewLine +
+ "INSERT INTO [CalculationProfiles] VALUES (3, 1, 1.1, 2.2, 3.3);" + Environment.NewLine +
+ "INSERT INTO [CalculationProfiles] VALUES (3, 2, 11.1, 22.2, 33.3);" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [SectionFaultTreeModels];" + Environment.NewLine +
+ "INSERT INTO [SectionFaultTreeModels] VALUES (1, 1, 1, 1, 1);" + Environment.NewLine +
+ "INSERT INTO [SectionFaultTreeModels] VALUES (2, 1, 1, 1, 1);" + Environment.NewLine +
+ "INSERT INTO [SectionFaultTreeModels] VALUES (3, 1, 1, 1, 1);" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [SectionSubMechanismModels];" + Environment.NewLine +
+ "INSERT INTO [SectionSubMechanismModels] VALUES (1, 1, 1, 1, 1, 1234);" + Environment.NewLine +
+ "INSERT INTO [SectionSubMechanismModels] VALUES (2, 1, 1, 1, 1, 1234);" + Environment.NewLine +
+ "INSERT INTO [SectionSubMechanismModels] VALUES (3, 1, 1, 1, 1, 1234);" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Fetches];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [AreaPoints];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [PresentationSections];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Profiles];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [ForelandModels];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Forelands];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [ProbabilityAlternatives];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [SetUpHeights];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [CalcWindDirections];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Swells];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [WaveReductions];" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Areas];" + Environment.NewLine +
+ "INSERT INTO [Areas] VALUES (1, '1', 'Nederland');" + Environment.NewLine +
+ Environment.NewLine +
+ "DELETE FROM [Projects];" + Environment.NewLine +
+ "INSERT INTO [Projects] VALUES (1, 'WTI 2017', 'Ringtoets calculation');" + Environment.NewLine;
+
+ // Call
+ var creationScript = hydraRingConfigurationService.GenerateDataBaseCreationScript();
+
+ // Assert
+ Assert.AreEqual(expectedCreationScript, creationScript);
+ }
+
+ private class HydraRingCalculationInputImplementation : HydraRingCalculationInput
+ {
+ private readonly int sectionId;
+
+ public HydraRingCalculationInputImplementation(int sectionId, int hydraulicBoundaryLocationId) : base(hydraulicBoundaryLocationId)
+ {
+ this.sectionId = sectionId;
+ }
+
+ public override HydraRingFailureMechanismType FailureMechanismType
+ {
+ get
+ {
+ return HydraRingFailureMechanismType.AssessmentLevel;
+ }
+ }
+
+ public override int CalculationTypeId
+ {
+ get
+ {
+ return 4;
+ }
+ }
+
+ public override HydraRingDikeSection DikeSection
+ {
+ get
+ {
+ return new HydraRingDikeSection(sectionId, "LocationName", 2.2, 3.3, 4.4, 5.5, 6.6, 7.7);
+ }
+ }
+
+ public override IEnumerable Variables
+ {
+ get
+ {
+ yield return new HydraRingVariableImplementation(26, HydraRingDistributionType.Deterministic, 2.2, HydraRingDeviationType.Standard, 3.3, 4.4, 5.5);
+ yield return new HydraRingVariableImplementation(26, HydraRingDistributionType.Deterministic, 22.2, HydraRingDeviationType.Variation, 33.3, 44.4, 55.5);
+ yield return new HydraRingVariableImplementation(26, HydraRingDistributionType.Normal, 222.2, HydraRingDeviationType.Standard, 333.3, 444.4, 555.5);
+ yield return new HydraRingVariableImplementation(26, HydraRingDistributionType.Normal, 2222.2, HydraRingDeviationType.Variation, 3333.3, 4444.4, 5555.5);
+ yield return new HydraRingVariableImplementation(26, HydraRingDistributionType.LogNormal, 22222.2, HydraRingDeviationType.Standard, 33333.3, 44444.4, 55555.5);
+ yield return new HydraRingVariableImplementation(26, HydraRingDistributionType.LogNormal, 222222.2, HydraRingDeviationType.Variation, 333333.3, 444444.4, 555555.5);
+ }
+ }
+
+ public override IEnumerable ProfilePoints
+ {
+ get
+ {
+ yield return new HydraRingProfilePointDerivative(1.1, 2.2, 3.3);
+ yield return new HydraRingProfilePointDerivative(11.1, 22.2, 33.3);
+ }
+ }
+
+ public override double Beta
+ {
+ get
+ {
+ return 1.1;
+ }
+ }
+
+ public override int? GetSubMechanismModelId(int subMechanismId)
+ {
+ return 1234;
+ }
+ }
+
+ private class HydraRingVariableImplementation : HydraRingVariable
+ {
+ public HydraRingVariableImplementation(int variableId, HydraRingDistributionType distributionType, double value, HydraRingDeviationType deviationType, double mean, double variability, double shift)
+ : base(variableId, distributionType, value, deviationType, mean, variability, shift) {}
+ }
+
+ private class HydraRingProfilePointDerivative : HydraRingProfilePoint
+ {
+ private readonly double roughness;
+
+ public HydraRingProfilePointDerivative(double x, double z, double roughness) : base(x, z)
+ {
+ this.roughness = roughness;
+ }
+
+ public override double Roughness
+ {
+ get
+ {
+ return roughness;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Services/HydraRingInitializationServiceTest.cs
===================================================================
diff -u
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Services/HydraRingInitializationServiceTest.cs (revision 0)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Services/HydraRingInitializationServiceTest.cs (revision 67100b9ae4581855aa4b6e1675c3fdf550614c7a)
@@ -0,0 +1,79 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.IO;
+using System.Reflection;
+using NUnit.Framework;
+using Ringtoets.HydraRing.Calculation.Data;
+using Ringtoets.HydraRing.Calculation.Services;
+
+namespace Ringtoets.HydraRing.Calculation.Test.Services
+{
+ [TestFixture]
+ public class HydraRingInitializationServiceTest
+ {
+ [Test]
+ public void ParameteredConstructor_ExpectedValues()
+ {
+ // Call
+ var hydraRingInitializationService = new HydraRingInitializationService(HydraRingFailureMechanismType.DikesPiping, 700001, "D:\\hlcd", "D:\\work");
+
+ // Assert
+ Assert.AreEqual("D:\\work\\700001.ini", hydraRingInitializationService.IniFilePath);
+ Assert.AreEqual("D:\\work\\700001.sql", hydraRingInitializationService.DataBaseCreationScriptFilePath);
+ Assert.AreEqual("D:\\work\\700001.log", hydraRingInitializationService.LogFilePath);
+ Assert.AreEqual("D:\\work\\designTable.txt", hydraRingInitializationService.OutputFilePath);
+ Assert.AreEqual("D:\\work\\temp.sqlite", hydraRingInitializationService.OutputDataBasePath);
+ Assert.AreEqual("D:\\hlcd\\HLCD.sqlite", hydraRingInitializationService.HlcdFilePath);
+
+ var hydraRingDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"HydraRing");
+ Assert.AreEqual(Path.Combine(hydraRingDirectory, "MechanismComputation.exe"), hydraRingInitializationService.MechanismComputationExeFilePath);
+ }
+
+ [Test]
+ public void GenerateInitializationScript_ReturnsExpectedInitializationScript()
+ {
+ // Setup
+ var hydraRingInitializationService = new HydraRingInitializationService(HydraRingFailureMechanismType.DikesPiping, 700001, "D:\\hlcd", "D:\\work");
+ var hydraRingDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"HydraRing");
+ var configurationDatabaseFilePath = Path.Combine(hydraRingDirectory, "config.sqlite");
+
+ var expectedInitializationScript = "section = 700001" + Environment.NewLine +
+ "mechanism = 103" + Environment.NewLine +
+ "alternative = 1" + Environment.NewLine +
+ "layer = 1" + Environment.NewLine +
+ "logfile = 700001.log" + Environment.NewLine +
+ "outputverbosity = basic" + Environment.NewLine +
+ "outputtofile = file" + Environment.NewLine +
+ "projectdbfilename = 700001.sql" + Environment.NewLine +
+ "outputfilename = designTable.txt" + Environment.NewLine +
+ "configdbfilename = " + configurationDatabaseFilePath + Environment.NewLine +
+ "hydraulicdbfilename = D:\\hlcd\\HLCD.sqlite";
+
+ // Call
+ var initializationScript = hydraRingInitializationService.GenerateInitializationScript();
+
+ // Assert
+ Assert.AreEqual(expectedInitializationScript, initializationScript);
+ }
+ }
+}
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Services/HydraRingProcessFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Services/HydraRingProcessFactoryTest.cs (revision 0)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Services/HydraRingProcessFactoryTest.cs (revision 67100b9ae4581855aa4b6e1675c3fdf550614c7a)
@@ -0,0 +1,51 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using NUnit.Framework;
+using Ringtoets.HydraRing.Calculation.Services;
+
+namespace Ringtoets.HydraRing.Calculation.Test.Services
+{
+ [TestFixture]
+ public class HydraRingProcessFactoryTest
+ {
+ [Test]
+ public void Create_ReturnsExpectedProcess()
+ {
+ // Call
+ var iniFilePath = "D:\\iniFile.text";
+ var workingDirectory = "D:\\workingDirectory";
+ var mechanismComputationExeFilePath = "D:\\mechanismComputation.exe";
+
+ var process = HydraRingProcessFactory.Create(mechanismComputationExeFilePath, iniFilePath, workingDirectory);
+
+ // Assert
+ Assert.AreEqual(mechanismComputationExeFilePath, process.StartInfo.FileName);
+ Assert.AreEqual(iniFilePath, process.StartInfo.Arguments);
+ Assert.AreEqual(workingDirectory, process.StartInfo.WorkingDirectory);
+ Assert.IsFalse(process.StartInfo.UseShellExecute);
+ Assert.IsTrue(process.StartInfo.CreateNoWindow);
+ Assert.IsTrue(process.StartInfo.RedirectStandardInput);
+ Assert.IsTrue(process.StartInfo.RedirectStandardOutput);
+ Assert.IsTrue(process.StartInfo.RedirectStandardError);
+ }
+ }
+}
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs
===================================================================
diff -u -r938e3cf3c4fb8d0f64f21ef4b0d6f5b45feb23bb -r67100b9ae4581855aa4b6e1675c3fdf550614c7a
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 938e3cf3c4fb8d0f64f21ef4b0d6f5b45feb23bb)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 67100b9ae4581855aa4b6e1675c3fdf550614c7a)
@@ -38,9 +38,9 @@
using Ringtoets.Common.Data.Contribution;
using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.Common.Placeholder;
+using Ringtoets.HydraRing.Calculation.Activities;
using Ringtoets.HydraRing.Calculation.Data;
using Ringtoets.HydraRing.Calculation.Data.Input.Hydraulics;
-using Ringtoets.HydraRing.Calculation.Service;
using Ringtoets.Integration.Data.Placeholders;
using Ringtoets.Integration.Forms.PresentationObjects;
using Ringtoets.Integration.Forms.PropertyClasses;