Index: dam engine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStability/DamMacroStabilityOutput.cs =================================================================== diff -u --- dam engine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStability/DamMacroStabilityOutput.cs (revision 0) +++ dam engine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStability/DamMacroStabilityOutput.cs (revision 543) @@ -0,0 +1,8 @@ +using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces; + +namespace Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStability +{ + public class DamMacroStabilityOutput : IKernelDataOutput + { + } +} Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/DamMacroStabilityTests.cs =================================================================== diff -u --- dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/DamMacroStabilityTests.cs (revision 0) +++ dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/DamMacroStabilityTests.cs (revision 543) @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using System.Data; +using Deltares.DamEngine.Calculators.KernelWrappers.Common; +using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStability; +using Deltares.DamEngine.Data.General.Results; +using Deltares.DamEngine.Data.Standard.Logging; +using NUnit.Framework; + +namespace Deltares.DamEngine.Calculators.Tests +{ + [TestFixture] + public class DamMacroStabilityTests + { + [Test] + public void TestFullCalculation() + { + const double diff = 0.0001; + + // ToDo zant Fill input + var damKernelInput = new DamKernelInput(); + + var kernelWrapper = new DamMacroStabilityKernelWrapper(); + + // Prepare the wrapper. Result is input for the calculation dll + var damStabilityInput = kernelWrapper.Prepare(damKernelInput); + + // Validate the input + List messages; + kernelWrapper.Validate(damStabilityInput, out messages); +// Assert.AreEqual(0, messages.Count); + + // Run the dll +// DamMacroStabilityOutput output = (DamMacroStabilityOutput)kernelWrapper.Execute(damStabilityInput, out messages); +// Assert.AreEqual(0, messages.Count); + // ToDo zant specify output + // Assert.AreEqual(0.0, output.xxx, diff); + + // Fill the design results +// DesignResult result; +// kernelWrapper.PostProcess(output, out result); + // ToDo zant specify output +// Assert.AreEqual(0.0, result.StabilityDesignResults.SafetyFactor, diff); + } + + [Test] + public void TestValidate() + { + var kernelWrapper = new DamMacroStabilityKernelWrapper(); + + // Validate without setting values. Expected error messages. + var damStabilityInput = new DamMacroStabilityInput(); + List messages; + //ToDo zant Validate is not implemented yet + // kernelWrapper.Validate(damStabilityInput, out messages); + // Assert.IsTrue(messages.Count > 0); + + // Validate the input when valid input is provided. Expected no messages. + damStabilityInput = new DamMacroStabilityInput + { + // ToDo zant Fill input + }; +// messages.Clear(); + kernelWrapper.Validate(damStabilityInput, out messages); + Assert.AreEqual(0, messages.Count); + } + + [Test] + public void TestPostProcess() + { + var kernelWrapper = new DamMacroStabilityKernelWrapper(); + + DamMacroStabilityOutput output = new DamMacroStabilityOutput(); + // ToDo zant specify output +// output.xxx = 1.1; +// output.yyy = 2.2; + + DesignResult result; + kernelWrapper.PostProcess(output, out result); + // ToDo zant specify output +// Assert.AreEqual(output.xxx, result.StabilityDesignResults.SafetyFactor); + } + + [Test] + [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen invoer object gedefinieerd voor Macrostabiliteit")] + [SetUICulture("nl-NL")] + public void TestLanguageNLThrowsExceptionWhenInputIsNull() + { + DamMacroStabilityKernelWrapper.StabilityCalculator(null); + } + + [Test] + [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "No input object defined for Macro Stability")] + [SetUICulture("en-US")] + public void TestLanguageENThrowsExceptionWhenInputIsNull() + { + DamMacroStabilityKernelWrapper.StabilityCalculator(null); + } + + [Test] + [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen uitvoer object gedefinieerd voor Macrostabiliteit")] + [SetUICulture("nl-NL")] + public void TestThrowsExceptionWhenOutputIsNull() + { + var kernelWrapper = new DamMacroStabilityKernelWrapper(); + DesignResult result; + kernelWrapper.PostProcess(null, out result); + } + } +} Index: dam engine/trunk/lib/FailureMechanisms/DamMacroStability/Deltares.DamMacroStability.Calculator.pdb =================================================================== diff -u Binary files differ Index: dam engine/trunk/lib/FailureMechanisms/DamMacroStability/Deltares.DamMacroStability.Calculator.dll =================================================================== diff -u Binary files differ Index: dam engine/trunk/src/Deltares.DamEngine.Calculators/Properties/AssemblyInfo.cs.svn =================================================================== diff -u -r492 -r543 --- dam engine/trunk/src/Deltares.DamEngine.Calculators/Properties/AssemblyInfo.cs.svn (.../AssemblyInfo.cs.svn) (revision 492) +++ dam engine/trunk/src/Deltares.DamEngine.Calculators/Properties/AssemblyInfo.cs.svn (.../AssemblyInfo.cs.svn) (revision 543) @@ -1,5 +1,6 @@ using System.Reflection; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; [assembly: AssemblyTitle("Deltares.DamEngine.Calculators")] [assembly: AssemblyDescription("")] @@ -11,3 +12,4 @@ [assembly: AssemblyVersion("17.1.0.SVNREV")] [assembly: AssemblyFileVersion("17.1.0.SVNREV")] +[assembly: InternalsVisibleTo("Deltares.DamEngine.Calculators.Tests")] Index: dam engine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStability/DamMacroStabilityInput.cs =================================================================== diff -u --- dam engine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStability/DamMacroStabilityInput.cs (revision 0) +++ dam engine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStability/DamMacroStabilityInput.cs (revision 543) @@ -0,0 +1,8 @@ +using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces; + +namespace Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStability +{ + public class DamMacroStabilityInput : IKernelDataInput + { + } +} Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj =================================================================== diff -u -r515 -r543 --- dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 515) +++ dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 543) @@ -31,13 +31,18 @@ MinimumRecommendedRules.ruleset + + False + ..\..\lib\FailureMechanisms\DamMacroStability\Deltares.DamMacroStability.Calculator.dll + ..\..\lib\NUnit\nunit.framework.dll + Index: dam engine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStability/DamMacroStabilityKernelWrapper.cs =================================================================== diff -u --- dam engine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStability/DamMacroStabilityKernelWrapper.cs (revision 0) +++ dam engine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStability/DamMacroStabilityKernelWrapper.cs (revision 543) @@ -0,0 +1,134 @@ +using System.Collections.Generic; +using System.Data; +using System.Xml.Linq; +using Deltares.DamEngine.Calculators.KernelWrappers.Common; +using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces; +using Deltares.DamEngine.Calculators.Properties; +using Deltares.DamEngine.Data.Design; +using Deltares.DamEngine.Data.General; +using Deltares.DamEngine.Data.General.Results; +using Deltares.DamEngine.Data.Geotechnics; +using Deltares.DamEngine.Data.Standard.Logging; +using Deltares.DamMacroStability.Calculator; + +namespace Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStability +{ + public class DamMacroStabilityKernelWrapper : IKernelWrapper + { + /// + /// Prepares the specified dam kernel input. + /// + /// The dam kernel input. + /// + public IKernelDataInput Prepare(DamKernelInput damKernelInput) + { + // TODO: this is just fake data + return new DamMacroStabilityInput() + { + // ToDo + }; + } + + /// + /// Validates the specified kernel data input. + /// + /// The kernel data input. + /// The return messages. + /// + public int Validate(IKernelDataInput kernelDataInput, out List messages) + { + var calculator = StabilityCalculator(kernelDataInput); + //ToDo zant calculator has no Validate. +// List kernelMessages = calculator.Validate(); + messages = new List(); +// foreach (string stringMessage in kernelMessages) +// { +// messages.Add(new LogMessage() { Message = stringMessage, MessageType = LogMessageType.Error }); +// } + return messages.Count; + } + + /// + /// Executes the kernel. + /// + /// The kernel data input. + /// The return messages. + /// + public IKernelDataOutput Execute(IKernelDataInput kernelDataInput, out List messages) + { + // ToDo zant Question: write sti file in prepare or in execute? + +// // ToDo zant Fake data +// var stabilityProjectFilename = "testproject"; +// var scenario = new DesignScenario(); +// var soilProfile = new SoilProfile1D(); +// var soilGeometry2DName = "testgeom2D"; +// var riverLevel = 1.1; +// var mstabDesignEmbankment = new MStabDesignEmbankment(); +// var surfaceLine = new SurfaceLine2(); +// var trafficLoad = 2.2; +// var requiredSafetyFactor = 1.2; +// List errorMessages; +// +// XDocument mstabXML = MStabXmlDoc.CreateMStabXmlDoc(stabilityProjectFilename, scenario, soilProfile, soilGeometry2DName, +// riverLevel, mstabDesignEmbankment, surfaceLine, trafficLoad, requiredSafetyFactor, out errorMessages); +// +// mstabXML.Save(stabilityProjectFilename + ".xml"); + // + // stabilityServiceAgent.CreateProjectFile(mstabXML.ToString()); + // stabilityServiceAgent.CalculateMStabProject(stabilityProjectFilename); + + // start calculation + var calculator = StabilityCalculator(kernelDataInput); + calculator.Calculate(); + var damMacroStabilityOutput = new DamMacroStabilityOutput(); + // ToDo zant +// damMacroStabilityOutput.FoSp = calculator.FoSp; + messages = new List(); + return damMacroStabilityOutput; + } + + internal static StabilityCalculator StabilityCalculator(IKernelDataInput kernelDataInput) + { + DamMacroStabilityInput damPipingInput = kernelDataInput as DamMacroStabilityInput; + if (damPipingInput == null) + { + throw new NoNullAllowedException(Resources.DamMacroStabilityKernelWrapper_StabilityCalculator_NoInputObjectDefinedForMacroStability); + } + var calculator = new StabilityCalculator + { + // ToDo + }; + return calculator; + } + + /// + /// Fills the design results with the kernel output. + /// + /// The kernel data output. + /// The design result. + /// + public void PostProcess(IKernelDataOutput kernelDataOutput, out DesignResult designResult) + { + DamMacroStabilityOutput damPipingOutput = kernelDataOutput as DamMacroStabilityOutput; + if (damPipingOutput == null) + { + throw new NoNullAllowedException(Resources.DamMacroStabilityKernelWrapper_PostProcess_NoOutputObjectDefinedForSellmeijer4Forces); + } + + // TODO: this is just fake data + string id = "id"; + string soilProfile2DName = "soilProfile2DName"; + var d = new DamFailureMechanismeCalculationSpecification(); + var s = new DesignScenario(); + s.Location = new Location(); + var p = new SoilProfile1D(); + designResult = new DesignResult(id, d, s, p, soilProfile2DName, AnalysisType.NoAdaption, 0); + + var stabilityDesignResults = new StabilityDesignResults(); + // ToDo zant +// stabilityDesignResults.SafetyFactor = damPipingOutput.; + designResult.StabilityDesignResults = stabilityDesignResults; + } + } +} Index: dam engine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.Designer.cs =================================================================== diff -u -r510 -r543 --- dam engine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 510) +++ dam engine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 543) @@ -61,6 +61,26 @@ } /// + /// Looks up a localized string similar to No output object defined for Macro Stability. + /// + internal static string DamMacroStabilityKernelWrapper_PostProcess_NoOutputObjectDefinedForSellmeijer4Forces { + get { + return ResourceManager.GetString("DamMacroStabilityKernelWrapper_PostProcess_NoOutputObjectDefinedForSellmeijer4For" + + "ces", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No input object defined for Macro Stability. + /// + internal static string DamMacroStabilityKernelWrapper_StabilityCalculator_NoInputObjectDefinedForMacroStability { + get { + return ResourceManager.GetString("DamMacroStabilityKernelWrapper_StabilityCalculator_NoInputObjectDefinedForMacroSt" + + "ability", resourceCulture); + } + } + + /// /// Looks up a localized string similar to No input object defined for Sellmeijer 4 Forces. /// internal static string DamPipingSellmeijer4ForcesKernelWrapper_PipingCalculatorSellmeijer4Forces_NoInputObjectDefinedForSellmeijer4Forces { Index: dam engine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.nl-NL.resx =================================================================== diff -u -r510 -r543 --- dam engine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.nl-NL.resx (.../Resources.nl-NL.resx) (revision 510) +++ dam engine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.nl-NL.resx (.../Resources.nl-NL.resx) (revision 543) @@ -117,6 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Geen uitvoer object gedefinieerd voor Macrostabiliteit + + + Geen invoer object gedefinieerd voor Macrostabiliteit + Geen invoer object gedefinieerd voor Sellmeijer 4 Krachten Index: dam engine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.resx =================================================================== diff -u -r510 -r543 --- dam engine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.resx (.../Resources.resx) (revision 510) +++ dam engine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.resx (.../Resources.resx) (revision 543) @@ -1,107 +1,132 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + No input object defined for Sellmeijer 4 Forces No output object defined for Sellmeijer 4 Forces + + No input object defined for Macro Stability + + + No output object defined for Macro Stability + \ No newline at end of file Index: dam engine/trunk/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj =================================================================== diff -u -r510 -r543 --- dam engine/trunk/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj (.../Deltares.DamEngine.Calculators.csproj) (revision 510) +++ dam engine/trunk/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj (.../Deltares.DamEngine.Calculators.csproj) (revision 543) @@ -32,6 +32,9 @@ MinimumRecommendedRules.ruleset + + ..\..\lib\FailureMechanisms\DamMacroStability\Deltares.DamMacroStability.Calculator.dll + ..\..\lib\FailureMechanisms\DamPiping\Deltares.DamPiping.BlighCalculator.dll @@ -83,6 +86,9 @@ + + +