Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Application/XmlConversionHelper.cs
===================================================================
diff -u
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Application/XmlConversionHelper.cs (revision 0)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Application/XmlConversionHelper.cs (revision 5844)
@@ -0,0 +1,91 @@
+// Copyright (C) Stichting Deltares 2023. All rights reserved.
+//
+// This file is part of the application DAM - Live.
+//
+// DAM - Live is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero 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.Collections.Generic;
+using Deltares.Dam.Data;
+using Deltares.DamLive.Io;
+
+namespace Deltares.DamLive.Application;
+
+public static class XmlConversionHelper
+{
+ public static MStabModelType ConvertToModelType(StabilityCalculationModel model)
+ {
+ var translationTable = new Dictionary
+ {
+ {
+ StabilityCalculationModel.Bishop, MStabModelType.Bishop
+ },
+ {
+ StabilityCalculationModel.UpliftVan, MStabModelType.UpliftVan
+ },
+ {
+ StabilityCalculationModel.BishopUpliftVan, MStabModelType.BishopUpliftVan
+ }
+ };
+ return translationTable[model];
+ }
+
+ public static StabilityCalculationModel ConvertToModelType(MStabModelType model)
+ {
+ var translationTable = new Dictionary
+ {
+ {
+ MStabModelType.Bishop, StabilityCalculationModel.Bishop
+ },
+ {
+ MStabModelType.UpliftVan, StabilityCalculationModel.UpliftVan
+ },
+ {
+ MStabModelType.BishopUpliftVan, StabilityCalculationModel.BishopUpliftVan
+ }
+ };
+ return translationTable[model];
+ }
+
+ public static MStabSearchMethod ConvertToSearchMethod(StabilitySearchMethod model)
+ {
+ var translationTable = new Dictionary
+ {
+ {
+ StabilitySearchMethod.Grid, MStabSearchMethod.Grid
+ },
+ {
+ StabilitySearchMethod.BeeSwarm, MStabSearchMethod.BeeSwarm
+ }
+ };
+ return translationTable[model];
+ }
+
+ public static StabilitySearchMethod ConvertToSearchMethod(MStabSearchMethod model)
+ {
+ var translationTable = new Dictionary
+ {
+ {
+ MStabSearchMethod.Grid, StabilitySearchMethod.Grid
+ },
+ {
+ MStabSearchMethod.BeeSwarm, StabilitySearchMethod.BeeSwarm
+ }
+ };
+ return translationTable[model];
+ }
+}
\ No newline at end of file
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Application/SensorModelRunner.cs
===================================================================
diff -u
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Application/SensorModelRunner.cs (revision 0)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Application/SensorModelRunner.cs (revision 5844)
@@ -0,0 +1,99 @@
+// Copyright (C) Stichting Deltares 2023. All rights reserved.
+//
+// This file is part of the application DAM - Live.
+//
+// DAM - Live is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero 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.Linq;
+using Deltares.Dam.Data;
+using Deltares.DamLive.Application.Properties;
+using Deltares.DamLive.Data;
+
+namespace Deltares.DamLive.Application;
+
+// TODO: this class is just passing its input to another class, see if this class can be removed from the design
+public class SensorModelRunner : ModelRunner
+{
+ public void ReadUserSettingsSlipCircleDefinition(SlipCircleDefinition slipCircleDefinition)
+ {
+ if (slipCircleDefinition == null)
+ {
+ slipCircleDefinition = new SlipCircleDefinition();
+ }
+
+ slipCircleDefinition.UpliftVanGridSizeDetermination = Settings.Default.SlipCircleUpliftVanGridSizeDetermination;
+ slipCircleDefinition.UpliftVanTangentLinesDefinition = Settings.Default.SlipCircleUpliftVanTangentLinesDefinition;
+ slipCircleDefinition.UpliftVanTangentLinesDistance = Settings.Default.SlipCircleUpliftVanTangentLinesDistance;
+ slipCircleDefinition.UpliftVanLeftGridVerticalPointCount = Settings.Default.SlipCircleUpliftVanLeftGridVerticalPointCount;
+ slipCircleDefinition.UpliftVanLeftGridVerticalPointDistance = Settings.Default.SlipCircleUpliftVanLeftGridVerticalPointDistance;
+ slipCircleDefinition.UpliftVanLeftGridHorizontalPointCount = Settings.Default.SlipCircleUpliftVanLeftGridHorizontalPointCount;
+ slipCircleDefinition.UpliftVanLeftGridHorizontalPointDistance = Settings.Default.SlipCircleUpliftVanLeftGridHorizontalPointDistance;
+ slipCircleDefinition.UpliftVanRightGridVerticalPointCount = Settings.Default.SlipCircleUpliftVanRightGridVerticalPointCount;
+ slipCircleDefinition.UpliftVanRightGridVerticalPointDistance = Settings.Default.SlipCircleUpliftVanRightGridVerticalPointDistance;
+ slipCircleDefinition.UpliftVanRightGridHorizontalPointCount = Settings.Default.SlipCircleUpliftVanRightGridHorizontalPointCount;
+ slipCircleDefinition.UpliftVanRightGridHorizontalPointDistance = Settings.Default.SlipCircleUpliftVanRightGridHorizontalPointDistance;
+ slipCircleDefinition.BishopSearchAreaDetermination = Settings.Default.SlipCircleBishopSearchAreaDetermination;
+ slipCircleDefinition.BishopTangentLinesDistance = Settings.Default.SlipCircleBishopTangentLinesDistance;
+ slipCircleDefinition.BishopGridVerticalPointCount = Settings.Default.SlipCircleBishopGridVerticalPointCount;
+ slipCircleDefinition.BishopGridVerticalPointDistance = Settings.Default.SlipCircleBishopGridVerticalPointDistance;
+ slipCircleDefinition.BishopGridHorizontalPointCount = Settings.Default.SlipCircleBishopGridHorizontalPointCount;
+ slipCircleDefinition.BishopGridHorizontalPointDistance = Settings.Default.SlipCircleBishopGridHorizontalPointDistance;
+ }
+
+ public override void Run()
+ {
+ CalculationParameters calcParams = CalculationParameters ?? new CalculationParameters();
+ calcParams.WorkingPath = WorkingPath;
+ calcParams.StabilityWorkingPath = StabilityWorkingPath;
+ ReadUserSettingsSlipCircleDefinition(calcParams.StabilityParameters.SlipCircleDefinition);
+
+ List locations = ProjectData.Locations;
+ if (!string.IsNullOrWhiteSpace(Filter))
+ {
+ string[] parsedLocations = Filter.Split(new[]
+ {
+ ','
+ }, StringSplitOptions.RemoveEmptyEntries);
+ locations = ProjectData.Locations.Where(l => parsedLocations.All(a => l.Name == a.Trim())).ToList();
+
+ if (locations.Count == 0)
+ {
+ Logger.LogWarning("No matching locations found with the specified filter");
+ }
+ }
+
+ // TODO: Here the connection should be made with the Dam Engine
+ // It will replace the following code:
+ // var processor = new SensorTimeSeriesProcessor
+ // {
+ // CalculationParameters = calcParams,
+ // InputTimeSeriesCollection = InputTimeSeriesCollection,
+ // OutputTimeSeriesCollection = OutputTimeSeriesCollection,
+ // Locations = locations
+ // };
+ //
+ // processor.Initialize();
+ // processor.Process();
+ //
+ // // sync back the processed data
+ // OutputTimeSeriesCollection = processor.OutputTimeSeriesCollection;
+ OutputTimeSeriesCollection = new TimeSerieCollection();
+ }
+}
\ No newline at end of file
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/StabilityInsideBishopGridTest.cs
===================================================================
diff -u -r5807 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/StabilityInsideBishopGridTest.cs (.../StabilityInsideBishopGridTest.cs) (revision 5807)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/StabilityInsideBishopGridTest.cs (.../StabilityInsideBishopGridTest.cs) (revision 5844)
@@ -23,7 +23,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
using Deltares.Dam.Data;
using Deltares.DamLive.TestHelper;
using NUnit.Framework;
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveGrebbedijkTest.cs
===================================================================
diff -u -r5807 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveGrebbedijkTest.cs (.../DamLiveGrebbedijkTest.cs) (revision 5807)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveGrebbedijkTest.cs (.../DamLiveGrebbedijkTest.cs) (revision 5844)
@@ -23,7 +23,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
using Deltares.Dam.Data;
using Deltares.DamLive.TestHelper;
using Deltares.Standard.IO;
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Application/DamEngineRunner.cs
===================================================================
diff -u
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Application/DamEngineRunner.cs (revision 0)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Application/DamEngineRunner.cs (revision 5844)
@@ -0,0 +1,400 @@
+// Copyright (C) Stichting Deltares 2023. All rights reserved.
+//
+// This file is part of the application DAM - Live.
+//
+// DAM - Live is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero 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.Xml.Linq;
+using Deltares.Dam.Data;
+using Deltares.Dam.Data.Assemblers;
+using Deltares.Dam.Data.DamEngineIo;
+using Deltares.DamEngine.Interface;
+using Deltares.DamEngine.Io;
+using Deltares.DamEngine.Io.XmlInput;
+using Deltares.DamEngine.Io.XmlOutput;
+using Deltares.DamLive.Application.Properties;
+using Deltares.DamLive.Io;
+using Deltares.Standard.Application;
+using Deltares.Standard.Logging;
+using Location = Deltares.Dam.Data.Location;
+using Deltares.DamLive.Data;
+
+namespace Deltares.DamLive.Application;
+
+public class DamEngineRunner
+{
+ internal const string NoDamxFile = "No .damx file set to load project data from.";
+ internal const string NoFewsInputFileAvailable = "No FEWS input file available to read the input time series from.";
+ internal const string NoFewsOutputFileAvailable = "No FEWS output file available to write the result to.";
+ internal const string ErrorExtractingWorkingFolder = "An error occured while trying to extract the path from the FEWS input file. This error can be solved by setting a working folder";
+ internal LogHelper Logger = LogHelper.Create();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public DamEngineRunner()
+ {
+ // WorkingPath will be extracted from file name if available
+ StabilityWorkingPath = Settings.Default.StabilityWorkingPath;
+ PipingWorkingPath = Settings.Default.PipingWorkingPath;
+ WaterLevelOffset = Settings.Default.WaterLevelOffset;
+ }
+
+ ///
+ /// Gets or sets the dam project data.
+ ///
+ ///
+ /// The dam project data.
+ ///
+ public DamProjectData DamProjectData { get; set; }
+
+ ///
+ /// Gets or sets the calculation parameters.
+ ///
+ ///
+ /// The calculation parameters.
+ ///
+ public CalculationParameters CalculationParameters { get; set; }
+
+ ///
+ /// Gets or sets the output time series collection.
+ ///
+ ///
+ /// The output time series collection.
+ ///
+ public TimeSerieCollection OutputTimeSeriesCollection { get; set; }
+
+ ///
+ /// Gets or sets the input time series collection.
+ ///
+ ///
+ /// The input time series collection.
+ ///
+ public TimeSerieCollection InputTimeSeriesCollection { get; set; }
+
+ ///
+ /// Gets or sets the stability working path.
+ ///
+ ///
+ /// The stability working path.
+ ///
+ public string StabilityWorkingPath { get; set; }
+
+ ///
+ /// Gets or sets the piping working path.
+ ///
+ ///
+ /// The piping working path.
+ ///
+ public string PipingWorkingPath { get; set; }
+
+ ///
+ /// Gets or sets the water level offset.
+ ///
+ ///
+ /// The water level offset.
+ ///
+ public double WaterLevelOffset { get; set; }
+
+ ///
+ /// Gets or sets the working path.
+ ///
+ ///
+ /// The working path.
+ ///
+ public string WorkingPath { get; set; }
+
+ ///
+ /// Gets or sets the maximum calculation cores.
+ ///
+ ///
+ /// The maximum calculation cores.
+ ///
+ public int MaxCalculationCores { get; set; } = 1;
+
+ ///
+ /// Gets or sets the filter.
+ ///
+ ///
+ /// The filter.
+ ///
+ public string Filter { get; set; }
+
+ public string TestFileName { get; set; }
+
+ ///
+ /// Gets a value indicating whether this instance has errors.
+ ///
+ ///
+ /// true if this instance has errors; otherwise, false.
+ ///
+ public bool HasErrors
+ {
+ get
+ {
+ return Logger.HasLoggedExceptions;
+ }
+ }
+
+ ///
+ /// Initializes this instance.
+ ///
+ ///
+ ///
+ public void Initialize()
+ {
+ LoadDataFromFiles();
+
+ AdaptDamProjectData();
+ }
+
+ // Wat te doen: debug input xml file (InputFile.xml in debug dir DamLive) oppakken en gebruiken in DamEngine via de aanstuurtruc van Tom en dan kijken wat daar gebeurt.
+
+ ///
+ /// Runs this instance.
+ ///
+ public void Run()
+ {
+ Initialize();
+ OutputTimeSeriesCollection.Series.Clear();
+ RunSelectedModels();
+ WriteResultsToFile(FewsOutputFile.FullName);
+ }
+
+ ///
+ /// Reads the user settings of the slip circle definition.
+ ///
+ /// The slip circle definition.
+ public void ReadUserSettingsSlipCircleDefinition(SlipCircleDefinition slipCircleDefinition)
+ {
+ if (slipCircleDefinition == null)
+ {
+ slipCircleDefinition = new SlipCircleDefinition();
+ }
+
+ slipCircleDefinition.UpliftVanGridSizeDetermination = Settings.Default.SlipCircleUpliftVanGridSizeDetermination;
+ slipCircleDefinition.UpliftVanTangentLinesDefinition = Settings.Default.SlipCircleUpliftVanTangentLinesDefinition;
+ slipCircleDefinition.UpliftVanTangentLinesDistance = Settings.Default.SlipCircleUpliftVanTangentLinesDistance;
+ slipCircleDefinition.UpliftVanLeftGridVerticalPointCount = Settings.Default.SlipCircleUpliftVanLeftGridVerticalPointCount;
+ slipCircleDefinition.UpliftVanLeftGridVerticalPointDistance = Settings.Default.SlipCircleUpliftVanLeftGridVerticalPointDistance;
+ slipCircleDefinition.UpliftVanLeftGridHorizontalPointCount = Settings.Default.SlipCircleUpliftVanLeftGridHorizontalPointCount;
+ slipCircleDefinition.UpliftVanLeftGridHorizontalPointDistance = Settings.Default.SlipCircleUpliftVanLeftGridHorizontalPointDistance;
+ slipCircleDefinition.UpliftVanRightGridVerticalPointCount = Settings.Default.SlipCircleUpliftVanRightGridVerticalPointCount;
+ slipCircleDefinition.UpliftVanRightGridVerticalPointDistance = Settings.Default.SlipCircleUpliftVanRightGridVerticalPointDistance;
+ slipCircleDefinition.UpliftVanRightGridHorizontalPointCount = Settings.Default.SlipCircleUpliftVanRightGridHorizontalPointCount;
+ slipCircleDefinition.UpliftVanRightGridHorizontalPointDistance = Settings.Default.SlipCircleUpliftVanRightGridHorizontalPointDistance;
+ slipCircleDefinition.BishopSearchAreaDetermination = Settings.Default.SlipCircleBishopSearchAreaDetermination;
+ slipCircleDefinition.BishopTangentLinesDistance = Settings.Default.SlipCircleBishopTangentLinesDistance;
+ slipCircleDefinition.BishopGridVerticalPointCount = Settings.Default.SlipCircleBishopGridVerticalPointCount;
+ slipCircleDefinition.BishopGridVerticalPointDistance = Settings.Default.SlipCircleBishopGridVerticalPointDistance;
+ slipCircleDefinition.BishopGridHorizontalPointCount = Settings.Default.SlipCircleBishopGridHorizontalPointCount;
+ slipCircleDefinition.BishopGridHorizontalPointDistance = Settings.Default.SlipCircleBishopGridHorizontalPointDistance;
+ }
+
+ protected internal FileInfo DamXFile { get; set; }
+ protected internal FileInfo FewsInputFile { get; set; }
+ protected internal FileInfo FewsOutputFile { get; set; }
+ protected internal FileInfo ParametersFile { get; set; }
+
+
+
+ protected void WriteResultsToFile(string fileName)
+ {
+ if (string.IsNullOrWhiteSpace(fileName))
+ {
+ throw new ArgumentNullException("fileName");
+ }
+
+ var timeSerieAssembler = new TimeSeriesAssembler();
+ XDocument doc = timeSerieAssembler.CreateDataTransferDocument(OutputTimeSeriesCollection);
+
+ try
+ {
+ doc.Save(fileName);
+ FileWriterUtil.RemoveThreeBytesFromXml(fileName);
+ }
+ catch (Exception e)
+ {
+ Logger.LogError("Could not export Fews xml file", e);
+ }
+ }
+
+ private void AdaptDamProjectData()
+ {
+ // Prepare DamProjetData for serializing to Dam Engine
+ DamProjectData.SelectedLocationJobs.Clear();
+ foreach (Location location in DamProjectData.Locations)
+ {
+ var locationJob = new LocationJob
+ {
+ Location = location,
+ Run = true
+ };
+ DamProjectData.LocationJobs.Add(locationJob);
+ }
+
+ DamProjectData.FillOverallSensorData();
+
+ // Add time series to DamProjectData
+ DamProjectData.InputTimeSerieCollection = InputTimeSeriesCollection;
+
+ // Set correct calculation settings
+ DamProjectData.DamProjectType = DamProjectType.Calamity;
+ }
+
+ private void LoadDataFromFiles()
+ {
+ if (DamProjectData == null)
+ {
+ if (DamXFile == null)
+ {
+ throw new InvalidOperationException(NoDamxFile);
+ }
+
+ DamProjectData = DamProject.LoadData(DamXFile.FullName);
+ WorkingPath = Path.ChangeExtension(DamXFile.FullName, ".Calc");
+ }
+
+ if (InputTimeSeriesCollection == null)
+ {
+ if (FewsInputFile == null)
+ {
+ throw new InvalidOperationException(NoFewsInputFileAvailable);
+ }
+
+ InputTimeSeriesCollection = TimeSerieCollection.LoadFromFile(FewsInputFile);
+ }
+
+ if (OutputTimeSeriesCollection == null)
+ {
+ if (FewsOutputFile == null)
+ {
+ throw new InvalidOperationException(NoFewsOutputFileAvailable);
+ }
+
+ OutputTimeSeriesCollection = InputTimeSeriesCollection.GetShallowCopy();
+ }
+
+ if (CalculationParameters == null && ParametersFile != null)
+ {
+ // Read calculation parameters, if available
+ XmlCalculationParameters xmlCalculationParameters = CalculationParametersXmlSerialization.LoadFromXmlFile(ParametersFile.FullName);
+ CalculationParameters = FillDomainFromXmlCalculationParameters.CreateCalculationParameters(xmlCalculationParameters);
+ }
+ }
+
+ private void RunSelectedModels()
+ {
+ if (CalculationParameters.CalculationModules.StabilityInside)
+ {
+ RunStability(FailureMechanismSystemType.StabilityInside);
+ }
+
+ if (CalculationParameters.CalculationModules.StabilityOutside)
+ {
+ RunStability(FailureMechanismSystemType.StabilityOutside);
+ }
+
+ if (CalculationParameters.CalculationModules.PipingBligh)
+ {
+ Logger.LogError("Calculation module PipingBligh not implemented yet");
+ }
+
+ if (CalculationParameters.CalculationModules.PipingWti)
+ {
+ RunPiping(FailureMechanismSystemType.Piping);
+ }
+ }
+
+ private void RunStability(FailureMechanismSystemType failureMechanismSystemType)
+ {
+ ReadUserSettingsSlipCircleDefinition(CalculationParameters.StabilityParameters.SlipCircleDefinition);
+ DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismSystemType = failureMechanismSystemType;
+ DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismeParamatersMStab.MStabParameters =
+ CalculationParameters.StabilityParameters;
+
+ CallDamEngine();
+ if (DamProjectData.OutputTimeSerieCollection != null && DamProjectData.OutputTimeSerieCollection.Series.Count > 0)
+ {
+ OutputTimeSeriesCollection.Series.AddRange(DamProjectData.OutputTimeSerieCollection.Series);
+ }
+ }
+
+ private void RunPiping(FailureMechanismSystemType failureMechanismSystemType)
+ {
+ DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismSystemType = failureMechanismSystemType;
+
+ CallDamEngine();
+ if (DamProjectData.OutputTimeSerieCollection != null && DamProjectData.OutputTimeSerieCollection.Series.Count > 0)
+ {
+ OutputTimeSeriesCollection.Series.AddRange(DamProjectData.OutputTimeSerieCollection.Series);
+ }
+ }
+
+ private void CallDamEngine()
+ {
+ DamProjectData.MaxCalculationCores = MaxCalculationCores;
+ try
+ {
+ Input input = FillXmlInputFromDamUi.CreateInput(DamProjectData);
+#if DEBUG
+ string inputFilename = TestFileName + "Input.xml";
+ DamXmlSerialization.SaveInputAsXmlFile(inputFilename, input);
+#endif
+ string inputXml = DamXmlSerialization.SaveInputAsXmlString(input);
+
+ var damEngineInterface = new EngineInterface(inputXml);
+ string validationMessages = damEngineInterface.Validate();
+ // now the validation messages should be deserialized. If any, they should be passed on to the Validator
+ // and checked for errors. If errors are found, then no calculation. When no messages or only warnings then
+ // do calculate. For now, just check length
+ if (string.IsNullOrEmpty(validationMessages))
+ {
+ string outputXml = damEngineInterface.Run();
+ Output output = DamXmlSerialization.LoadOutputFromXmlString(outputXml);
+ FillDamUiFromXmlOutput.AddOutputToDamProjectData(DamProjectData, output);
+#if DEBUG
+ string outputFilename = TestFileName + "Output.xml";
+ DamXmlSerialization.SaveOutputAsXmlFile(outputFilename, output);
+#endif
+ foreach (Message calculationMessage in output.Results.CalculationMessages)
+ {
+ switch (calculationMessage.MessageType)
+ {
+ case MessageMessageType.Info:
+ Logger.LogInfo(calculationMessage.Message1);
+ break;
+ case MessageMessageType.Warning:
+ Logger.LogWarning(calculationMessage.Message1);
+ break;
+ case MessageMessageType.Error:
+ Logger.LogError(calculationMessage.Message1);
+ break;
+ }
+ }
+ }
+ // Todo: handle validation messages
+ }
+ catch (Exception e)
+ {
+ LogManager.Add(new LogMessage(LogMessageType.FatalError, typeof(EngineInterface), $"{e.Message}"));
+ }
+ }
+}
\ No newline at end of file
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Application/IModelRunner.cs
===================================================================
diff -u
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Application/IModelRunner.cs (revision 0)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Application/IModelRunner.cs (revision 5844)
@@ -0,0 +1,40 @@
+// Copyright (C) Stichting Deltares 2023. All rights reserved.
+//
+// This file is part of the application DAM - Live.
+//
+// DAM - Live is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero 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 Deltares.Dam.Data;
+using Deltares.DamLive.Data;
+
+namespace Deltares.DamLive.Application;
+
+public interface IModelRunner
+{
+ string StabilityWorkingPath { get; set; }
+ string PipingWorkingPath { get; set; }
+ double WaterLevelOffset { get; set; }
+ string WorkingPath { get; set; }
+ CalculationParameters CalculationParameters { get; set; }
+ TimeSerieCollection OutputTimeSeriesCollection { get; set; }
+ TimeSerieCollection InputTimeSeriesCollection { get; set; }
+ DamProjectData ProjectData { get; set; }
+ string Filter { get; set; }
+
+ void Run();
+}
\ No newline at end of file
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/XmlConversionHelperTests.cs
===================================================================
diff -u -r5807 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/XmlConversionHelperTests.cs (.../XmlConversionHelperTests.cs) (revision 5807)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/XmlConversionHelperTests.cs (.../XmlConversionHelperTests.cs) (revision 5844)
@@ -19,7 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
using Deltares.Dam.Data;
using Deltares.DamLive.Io;
using NUnit.Framework;
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/StabilityInsideUpliftVanGridTest.cs
===================================================================
diff -u -r5807 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/StabilityInsideUpliftVanGridTest.cs (.../StabilityInsideUpliftVanGridTest.cs) (revision 5807)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/StabilityInsideUpliftVanGridTest.cs (.../StabilityInsideUpliftVanGridTest.cs) (revision 5844)
@@ -22,7 +22,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
using Deltares.Dam.Data;
using Deltares.DamLive.TestHelper;
using NUnit.Framework;
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Application/Program.cs
===================================================================
diff -u
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Application/Program.cs (revision 0)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Application/Program.cs (revision 5844)
@@ -0,0 +1,185 @@
+// Copyright (C) Stichting Deltares 2023. All rights reserved.
+//
+// This file is part of the application DAM - Live.
+//
+// DAM - Live is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero 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 CommandLine;
+using Deltares.Dam.Data;
+using Deltares.Dam.Data.License;
+using Deltares.Standard.Application;
+using Deltares.Standard.Reflection;
+using log4net.Config;
+
+namespace Deltares.DamLive.Application;
+
+internal class Program
+{
+ internal static readonly LogHelper Logger = LogHelper.Create("DamLive");
+
+ private const string dAuthFeature = "DGS_27_00";
+ static readonly AssemblyInfoHelper info = new AssemblyInfoHelper(typeof(Program));
+
+ ///
+ /// Starts the calculations.
+ ///
+ /// The path of the .damx file
+ /// The FEWS input file.
+ /// The FEWS output file.
+ /// Settings of calculation parameters
+ /// Filter to specify locations to handle
+ internal void StartCalculations(string damXFile, string fewsInputFile, string fewsOutputFile, string calculationParametersFile = "", string filter = "")
+ {
+ if (string.IsNullOrWhiteSpace(damXFile))
+ {
+ throw new ArgumentException("damXFile");
+ }
+
+ if (string.IsNullOrWhiteSpace(fewsInputFile))
+ {
+ throw new ArgumentException("fewsOutputFile");
+ }
+
+ if (string.IsNullOrWhiteSpace(fewsOutputFile))
+ {
+ throw new ArgumentException("fewsExportFile");
+ }
+
+ if (!File.Exists(damXFile))
+ {
+ throw new FileNotFoundException(damXFile);
+ }
+
+ string workDir = Path.GetDirectoryName(damXFile) ?? ".\\";
+ if (!File.Exists(fewsInputFile))
+ {
+ fewsInputFile = Path.Combine(workDir, fewsInputFile);
+ if (!File.Exists(fewsInputFile))
+ {
+ throw new FileNotFoundException(fewsInputFile);
+ }
+ }
+
+ if (!File.Exists(fewsOutputFile))
+ {
+ fewsOutputFile = Path.Combine(workDir, fewsOutputFile);
+ if (!File.Exists(fewsOutputFile))
+ {
+ throw new FileNotFoundException(fewsOutputFile);
+ }
+ }
+
+ if (!File.Exists(calculationParametersFile))
+ {
+ calculationParametersFile = Path.Combine(workDir, calculationParametersFile);
+ if (!File.Exists(calculationParametersFile))
+ {
+ throw new FileNotFoundException(calculationParametersFile);
+ }
+ }
+
+ var damEngineRunner = new DamEngineRunner
+ {
+ ParametersFile = new FileInfo(calculationParametersFile),
+ FewsInputFile = new FileInfo(fewsInputFile),
+ FewsOutputFile = new FileInfo(fewsOutputFile),
+ DamXFile = new FileInfo(damXFile),
+ Filter = filter
+ };
+ DamProject.SetTestProgramVersion("19.1");
+ damEngineRunner.Run();
+ }
+
+ static void Main(string[] args)
+ {
+ DamLicense.CheckoutLicense(dAuthFeature, info.AssemblyVersion);
+
+ XmlConfigurator.Configure();
+ try
+ {
+ if (DamLicense.DamLicenseType == DamLicenseType.None)
+ {
+ throw new Exception("No license found for DamLive");
+ }
+
+ Run(args);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine();
+ Logger.LogFatal("There was an unexpected error. Program terminated", e);
+ }
+
+ DamLicense.CheckinLicense();
+ }
+
+ static void Run(string[] args)
+ {
+ var commandLineArguments = new CommandOptions();
+ ICommandLineParser parser = new CommandLineParser();
+ bool success = parser.ParseArguments(args, commandLineArguments);
+ if (success)
+ {
+ var program = new Program();
+
+ CreateOutputTimeSeriesFileIfNeeded(
+ commandLineArguments.TimeSeriesOutputFileName,
+ Path.GetDirectoryName(commandLineArguments.TimeSeriesOutputFileName));
+
+ var thisAssembly = new AssemblyInfoHelper(typeof(Program));
+ Logger.LogInfo(thisAssembly.Title + " " + thisAssembly.AssemblyVersion);
+ Logger.LogInfo(thisAssembly.Copyright);
+ Logger.LogInfo("Model runner started");
+ Console.WriteLine();
+ program.StartCalculations(
+ commandLineArguments.DamXFileName,
+ commandLineArguments.TimeSeriesInputFileName,
+ commandLineArguments.TimeSeriesOutputFileName,
+ commandLineArguments.ParameterFileName,
+ commandLineArguments.Filter);
+ Console.WriteLine();
+ Logger.LogInfo("Model runner ended");
+ }
+ else
+ {
+ Console.WriteLine();
+ Console.WriteLine(commandLineArguments.GetUsage());
+ }
+ }
+
+ private static void CreateOutputTimeSeriesFileIfNeeded(string fileName, string path)
+ {
+ string filePath = Path.Combine(path, Path.GetFileName(fileName));
+ if (!File.Exists(filePath))
+ {
+ using (StreamWriter stream = File.CreateText(filePath))
+ {
+ string xml =
+ "" + Environment.NewLine +
+ "" +
+ Environment.NewLine +
+ "\t0 " + Environment.NewLine +
+ "";
+
+ stream.Write(xml);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Application/FillDomainFromXmlCalculationParameters.cs
===================================================================
diff -u
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Application/FillDomainFromXmlCalculationParameters.cs (revision 0)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Application/FillDomainFromXmlCalculationParameters.cs (revision 5844)
@@ -0,0 +1,86 @@
+// Copyright (C) Stichting Deltares 2023. All rights reserved.
+//
+// This file is part of the application DAM - Live.
+//
+// DAM - Live is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero 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 Deltares.Dam.Data;
+using Deltares.DamLive.Io;
+using Deltares.DamLive.Data;
+
+namespace Deltares.DamLive.Application;
+
+public static class FillDomainFromXmlCalculationParameters
+{
+ public static CalculationParameters CreateCalculationParameters(XmlCalculationParameters xmlCalculationParameters)
+ {
+ var calculationParameters = new CalculationParameters();
+ TransferCalculationModules(xmlCalculationParameters.CalculationModules, calculationParameters);
+ TransferStabilityParameters(xmlCalculationParameters.StabilityParameters, calculationParameters);
+ return calculationParameters;
+ }
+
+ private static void TransferCalculationModules(XmlCalculationParametersCalculationModules calculationModulesXml, CalculationParameters calculationParameters)
+ {
+ var calculationModules = new CalculationModules();
+ if (calculationModulesXml != null)
+ {
+ if (calculationModulesXml.PipingWtiSpecified)
+ {
+ calculationModules.PipingWti = calculationModulesXml.PipingWti;
+ }
+
+ if (calculationModulesXml.PipingBlighSpecified)
+ {
+ calculationModules.PipingBligh = calculationModulesXml.PipingBligh;
+ }
+
+ if (calculationModulesXml.StabilityInsideSpecified)
+ {
+ calculationModules.StabilityInside = calculationModulesXml.StabilityInside;
+ }
+
+ if (calculationModulesXml.StabilityOutsideSpecified)
+ {
+ calculationModules.StabilityOutside = calculationModulesXml.StabilityOutside;
+ }
+ }
+
+ calculationParameters.CalculationModules = calculationModules;
+ }
+
+ private static void TransferStabilityParameters(XmlCalculationParametersStabilityParameters stabilityParametersXml, CalculationParameters calculationParameters)
+ {
+ MStabParameters stabParameters = null;
+ if (stabilityParametersXml.SearchMethodSpecified || stabilityParametersXml.CalculationModelSpecified)
+ {
+ stabParameters = new MStabParameters();
+ if (stabilityParametersXml.CalculationModelSpecified)
+ {
+ stabParameters.Model = XmlConversionHelper.ConvertToModelType(stabilityParametersXml.CalculationModel);
+ }
+
+ if (stabilityParametersXml.SearchMethodSpecified)
+ {
+ stabParameters.SearchMethod = XmlConversionHelper.ConvertToSearchMethod(stabilityParametersXml.SearchMethod);
+ }
+ }
+
+ calculationParameters.StabilityParameters = stabParameters;
+ }
+}
\ No newline at end of file
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/ModelRunnerTest.cs
===================================================================
diff -u -r5807 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/ModelRunnerTest.cs (.../ModelRunnerTest.cs) (revision 5807)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/ModelRunnerTest.cs (.../ModelRunnerTest.cs) (revision 5844)
@@ -21,7 +21,7 @@
using System;
using System.IO;
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
using Deltares.Dam.Data;
using Deltares.DamLive.Io;
using Deltares.DamLive.Data;
@@ -159,10 +159,10 @@
[SetUp]
public void SetupFixture()
{
- paramFile = Path.Combine(TestDataFolder, "Deltares.Dam.Application.Live.Tests.ParametersFile.xml");
- inputFile = Path.Combine(TestDataFolder, "Deltares.Dam.Application.Live.Tests.InputFile.xml");
- outputFile = Path.Combine(TestDataFolder, "Deltares.Dam.Application.Live.Tests.OutputFile.xml");
- projectFile = Path.Combine(TestDataFolder, "Deltares.Dam.Application.Live.Tests.ProjectFile.damx");
+ paramFile = Path.Combine(TestDataFolder, "Deltares.DamLive.Application.Tests.ParametersFile.xml");
+ inputFile = Path.Combine(TestDataFolder, "Deltares.DamLive.Application.Tests.InputFile.xml");
+ outputFile = Path.Combine(TestDataFolder, "Deltares.DamLive.Application.Tests.OutputFile.xml");
+ projectFile = Path.Combine(TestDataFolder, "Deltares.DamLive.Application.Tests.ProjectFile.damx");
RemoveTestWorkingDirectory(); // to be sure no test directory exist from previous tests
Directory.CreateDirectory(TestWorkingFolder);
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLivePulauTekongMissingValuesTest.cs
===================================================================
diff -u -r5807 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLivePulauTekongMissingValuesTest.cs (.../DamLivePulauTekongMissingValuesTest.cs) (revision 5807)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLivePulauTekongMissingValuesTest.cs (.../DamLivePulauTekongMissingValuesTest.cs) (revision 5844)
@@ -23,7 +23,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
using Deltares.Dam.Data;
using Deltares.DamLive.TestHelper;
using Deltares.Standard.IO;
Index: DamClients/DamLive/trunk/src/DamLive.sln
===================================================================
diff -u -r5839 -r5844
--- DamClients/DamLive/trunk/src/DamLive.sln (.../DamLive.sln) (revision 5839)
+++ DamClients/DamLive/trunk/src/DamLive.sln (.../DamLive.sln) (revision 5844)
@@ -12,7 +12,7 @@
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DamClientsLibrary", "DamClientsLibrary", "{F6A85256-50BA-4E97-8E3C-D8D488DFAF44}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deltares.Dam.Application.Live", "Deltares.Dam.Application.Live\Deltares.Dam.Application.Live.csproj", "{09DD9498-9259-44BC-A84E-DA6B7DEDB133}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deltares.DamLive.Application", "Deltares.DamLive.Application\Deltares.DamLive.Application.csproj", "{09DD9498-9259-44BC-A84E-DA6B7DEDB133}"
ProjectSection(ProjectDependencies) = postProject
{17F76A8E-C9F4-415F-8D4B-0E8A3B36E665} = {17F76A8E-C9F4-415F-8D4B-0E8A3B36E665}
EndProjectSection
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Application/CommandOptions.cs
===================================================================
diff -u
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Application/CommandOptions.cs (revision 0)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Application/CommandOptions.cs (revision 5844)
@@ -0,0 +1,83 @@
+// Copyright (C) Stichting Deltares 2023. All rights reserved.
+//
+// This file is part of the application DAM - Live.
+//
+// DAM - Live is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero 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 CommandLine;
+using CommandLine.Text;
+using Deltares.Standard.Reflection;
+
+namespace Deltares.DamLive.Application;
+
+internal class CommandOptions : CommandLineOptionsBase
+{
+ public const string DefaultOutputTimeSeriesFileName = "live.OutputTimeSeries.xml";
+ public const string DefaultInputTimeSeriesFileName = "live.InputTimeSeries.xml";
+ public const string DefaultParamFileName = "live.ParametersFile.xml";
+
+ [Option("d", "damxFile", Required = true, HelpText = "Name and path of the input DAMX file")]
+ public string DamXFileName { get; set; }
+
+ [Option("i", "inTimeSeriesFile", Required = false, DefaultValue = DefaultInputTimeSeriesFileName, HelpText = "Name and path of the input time series file. Should contain all locations or sensors")]
+ public string TimeSeriesInputFileName { get; set; }
+
+ [Option("o", "outTimeSeriesFile", Required = false, DefaultValue = DefaultOutputTimeSeriesFileName, HelpText = "Name and path of the output time series file")]
+ public string TimeSeriesOutputFileName { get; set; }
+
+ [Option("p", "paramFile", Required = false, DefaultValue = DefaultParamFileName, HelpText = "Name and path of the calculation parameters file")]
+ public string ParameterFileName { get; set; }
+
+ [Option("f", "filter", Required = false, HelpText = "Filter to tell the runner only to handle the locations specified")]
+ public string Filter { get; set; }
+
+ [HelpOption]
+ public string GetUsage()
+ {
+ var help = new HelpText
+ {
+ Heading = new HeadingInfo(ThisAssembly.Title, ThisAssembly.AssemblyVersion),
+ Copyright = ThisAssembly.Copyright,
+ AdditionalNewLineAfterOption = true,
+ AddDashesToOption = true
+ };
+
+ HandleParsingErrorsInHelp(help);
+
+ help.AddPreOptionsLine("Usage: damlive[.exe] -d DamXInputFile -i InputTimeSeriesFileName -o OutputTimeSeriesFileName [-p CalculationParametersFileName] [-f LocationFilter(comma separated)");
+ help.AddOptions(this);
+
+ return help;
+ }
+
+ private AssemblyInfoHelper ThisAssembly { get; } = new AssemblyInfoHelper(typeof(Program));
+
+ void HandleParsingErrorsInHelp(HelpText help)
+ {
+ if (LastPostParsingState.Errors.Count > 0)
+ {
+ string errors = help.RenderParsingErrorsText(this, 2); // indent with two spaces
+ if (!string.IsNullOrEmpty(errors))
+ {
+ help.AddPreOptionsLine(string.Concat(Environment.NewLine, "ERROR(S):"));
+ help.AddPreOptionsLine(errors);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/Deltares.DamLive.Tests.csproj
===================================================================
diff -u -r5807 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/Deltares.DamLive.Tests.csproj (.../Deltares.DamLive.Tests.csproj) (revision 5807)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/Deltares.DamLive.Tests.csproj (.../Deltares.DamLive.Tests.csproj) (revision 5844)
@@ -22,7 +22,7 @@
-
+
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveUsingCompleteDataSetTest.cs
===================================================================
diff -u -r5807 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveUsingCompleteDataSetTest.cs (.../DamLiveUsingCompleteDataSetTest.cs) (revision 5807)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveUsingCompleteDataSetTest.cs (.../DamLiveUsingCompleteDataSetTest.cs) (revision 5844)
@@ -23,7 +23,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
using Deltares.Dam.Data;
using Deltares.DamLive.TestHelper;
using Deltares.Standard.IO;
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveIntegrationTest.cs
===================================================================
diff -u -r5807 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveIntegrationTest.cs (.../DamLiveIntegrationTest.cs) (revision 5807)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveIntegrationTest.cs (.../DamLiveIntegrationTest.cs) (revision 5844)
@@ -23,7 +23,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
using Deltares.Dam.Data;
using Deltares.Dam.Data.Sensors;
using Deltares.DamLive.Data;
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/FillDomainFromXmlCalculationParametersTests.cs
===================================================================
diff -u -r5840 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/FillDomainFromXmlCalculationParametersTests.cs (.../FillDomainFromXmlCalculationParametersTests.cs) (revision 5840)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/FillDomainFromXmlCalculationParametersTests.cs (.../FillDomainFromXmlCalculationParametersTests.cs) (revision 5844)
@@ -19,7 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
using Deltares.Dam.Data;
using Deltares.DamLive.Io;
using Deltares.DamLive.Data;
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveHHNKTests.cs
===================================================================
diff -u -r5828 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveHHNKTests.cs (.../DamLiveHHNKTests.cs) (revision 5828)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveHHNKTests.cs (.../DamLiveHHNKTests.cs) (revision 5844)
@@ -22,7 +22,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
using Deltares.Dam.Data;
using Deltares.DamLive.TestHelper;
using NUnit.Framework;
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/TestModelRunner.cs
===================================================================
diff -u -r4056 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/TestModelRunner.cs (.../TestModelRunner.cs) (revision 4056)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/TestModelRunner.cs (.../TestModelRunner.cs) (revision 5844)
@@ -20,7 +20,7 @@
// All rights reserved.
using System.IO;
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
namespace Deltares.DamLive.Tests;
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLivePulauTekongTests.cs
===================================================================
diff -u -r5828 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLivePulauTekongTests.cs (.../DamLivePulauTekongTests.cs) (revision 5828)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLivePulauTekongTests.cs (.../DamLivePulauTekongTests.cs) (revision 5844)
@@ -22,7 +22,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
using Deltares.Dam.Data;
using Deltares.DamLive.TestHelper;
using NUnit.Framework;
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/GeneralHelper.cs
===================================================================
diff -u -r5807 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/GeneralHelper.cs (.../GeneralHelper.cs) (revision 5807)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/GeneralHelper.cs (.../GeneralHelper.cs) (revision 5844)
@@ -22,7 +22,7 @@
using System;
using System.Collections.Generic;
using System.IO;
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
using Deltares.Dam.Data;
using Deltares.Standard.IO;
using NUnit.Framework;
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/PipingWtiInsideTest.cs
===================================================================
diff -u -r5721 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/PipingWtiInsideTest.cs (.../PipingWtiInsideTest.cs) (revision 5721)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/PipingWtiInsideTest.cs (.../PipingWtiInsideTest.cs) (revision 5844)
@@ -22,7 +22,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
using Deltares.Dam.Data;
using Deltares.DamLive.TestHelper;
using NUnit.Framework;
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Application/FillXmlCalculationParametersFromDomain.cs
===================================================================
diff -u
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Application/FillXmlCalculationParametersFromDomain.cs (revision 0)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Application/FillXmlCalculationParametersFromDomain.cs (revision 5844)
@@ -0,0 +1,73 @@
+// Copyright (C) Stichting Deltares 2023. All rights reserved.
+//
+// This file is part of the application DAM - Live.
+//
+// DAM - Live is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero 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 Deltares.Dam.Data;
+using Deltares.DamLive.Io;
+using Deltares.DamLive.Data;
+
+namespace Deltares.DamLive.Application;
+
+public static class FillXmlCalculationParametersFromDomain
+{
+ public static XmlCalculationParameters CreateCalculationParameters(CalculationParameters calculationParameters)
+ {
+ var calculationParametersXml = new XmlCalculationParameters();
+ TransferCalculationModules(calculationParameters.CalculationModules, calculationParametersXml);
+ TransferStabilityParameters(calculationParameters.StabilityParameters, calculationParametersXml);
+
+ return calculationParametersXml;
+ }
+
+ private static void TransferCalculationModules(CalculationModules calculationModules, XmlCalculationParameters calculationParametersXml)
+ {
+ var xmlCalculationParametersCalculationModules = new XmlCalculationParametersCalculationModules();
+
+ if (calculationModules != null)
+ {
+ xmlCalculationParametersCalculationModules.PipingWtiSpecified = true;
+ xmlCalculationParametersCalculationModules.PipingBlighSpecified = true;
+ xmlCalculationParametersCalculationModules.StabilityInsideSpecified = true;
+ xmlCalculationParametersCalculationModules.StabilityOutsideSpecified = true;
+
+ xmlCalculationParametersCalculationModules.PipingWti = calculationModules.PipingWti;
+ xmlCalculationParametersCalculationModules.PipingBligh = calculationModules.PipingBligh;
+ xmlCalculationParametersCalculationModules.StabilityInside = calculationModules.StabilityInside;
+ xmlCalculationParametersCalculationModules.StabilityOutside = calculationModules.StabilityOutside;
+ }
+
+ calculationParametersXml.CalculationModules = xmlCalculationParametersCalculationModules;
+ }
+
+ private static void TransferStabilityParameters(MStabParameters stabilityParameters, XmlCalculationParameters calculationParametersXml)
+ {
+ var xmlCalculationParametersStabilityParameters = new XmlCalculationParametersStabilityParameters();
+ if (stabilityParameters != null)
+ {
+ xmlCalculationParametersStabilityParameters.CalculationModelSpecified = true;
+ xmlCalculationParametersStabilityParameters.SearchMethodSpecified = true;
+
+ xmlCalculationParametersStabilityParameters.CalculationModel = XmlConversionHelper.ConvertToModelType(stabilityParameters.Model);
+ xmlCalculationParametersStabilityParameters.SearchMethod = XmlConversionHelper.ConvertToSearchMethod(stabilityParameters.SearchMethod);
+ }
+
+ calculationParametersXml.StabilityParameters = xmlCalculationParametersStabilityParameters;
+ }
+}
\ No newline at end of file
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Application/Properties/Settings.Designer.cs
===================================================================
diff -u
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Application/Properties/Settings.Designer.cs (revision 0)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Application/Properties/Settings.Designer.cs (revision 5844)
@@ -0,0 +1,205 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Deltares.DamLive.Application.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute(".\\stabilityfiles\\")]
+ public string StabilityWorkingPath {
+ get {
+ return ((string)(this["StabilityWorkingPath"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("2")]
+ public double WaterLevelOffset {
+ get {
+ return ((double)(this["WaterLevelOffset"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute(".\\pipingfiles\\")]
+ public string PipingWorkingPath {
+ get {
+ return ((string)(this["PipingWorkingPath"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("10")]
+ public int SlipCircleBishopGridVerticalPointCount {
+ get {
+ return ((int)(this["SlipCircleBishopGridVerticalPointCount"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("2.5")]
+ public double SlipCircleBishopGridVerticalPointDistance {
+ get {
+ return ((double)(this["SlipCircleBishopGridVerticalPointDistance"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("10")]
+ public int SlipCircleBishopGridHorizontalPointCount {
+ get {
+ return ((int)(this["SlipCircleBishopGridHorizontalPointCount"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("2.5")]
+ public double SlipCircleBishopGridHorizontalPointDistance {
+ get {
+ return ((double)(this["SlipCircleBishopGridHorizontalPointDistance"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0.25")]
+ public double SlipCircleBishopTangentLinesDistance {
+ get {
+ return ((double)(this["SlipCircleBishopTangentLinesDistance"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("Specified")]
+ public global::Deltares.Dam.Data.GridSizeDetermination SlipCircleBishopSearchAreaDetermination {
+ get {
+ return ((global::Deltares.Dam.Data.GridSizeDetermination)(this["SlipCircleBishopSearchAreaDetermination"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("Specified")]
+ public global::Deltares.Dam.Data.GridSizeDetermination SlipCircleUpliftVanGridSizeDetermination {
+ get {
+ return ((global::Deltares.Dam.Data.GridSizeDetermination)(this["SlipCircleUpliftVanGridSizeDetermination"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("10")]
+ public int SlipCircleUpliftVanLeftGridVerticalPointCount {
+ get {
+ return ((int)(this["SlipCircleUpliftVanLeftGridVerticalPointCount"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("2.5")]
+ public double SlipCircleUpliftVanLeftGridVerticalPointDistance {
+ get {
+ return ((double)(this["SlipCircleUpliftVanLeftGridVerticalPointDistance"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("10")]
+ public int SlipCircleUpliftVanLeftGridHorizontalPointCount {
+ get {
+ return ((int)(this["SlipCircleUpliftVanLeftGridHorizontalPointCount"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("2.5")]
+ public double SlipCircleUpliftVanLeftGridHorizontalPointDistance {
+ get {
+ return ((double)(this["SlipCircleUpliftVanLeftGridHorizontalPointDistance"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("3")]
+ public int SlipCircleUpliftVanRightGridVerticalPointCount {
+ get {
+ return ((int)(this["SlipCircleUpliftVanRightGridVerticalPointCount"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("2.5")]
+ public double SlipCircleUpliftVanRightGridVerticalPointDistance {
+ get {
+ return ((double)(this["SlipCircleUpliftVanRightGridVerticalPointDistance"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("6")]
+ public int SlipCircleUpliftVanRightGridHorizontalPointCount {
+ get {
+ return ((int)(this["SlipCircleUpliftVanRightGridHorizontalPointCount"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("2.5")]
+ public double SlipCircleUpliftVanRightGridHorizontalPointDistance {
+ get {
+ return ((double)(this["SlipCircleUpliftVanRightGridHorizontalPointDistance"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("OnBoundaryLines")]
+ public global::Deltares.Dam.Data.TangentLinesDefinition SlipCircleUpliftVanTangentLinesDefinition {
+ get {
+ return ((global::Deltares.Dam.Data.TangentLinesDefinition)(this["SlipCircleUpliftVanTangentLinesDefinition"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0.25")]
+ public double SlipCircleUpliftVanTangentLinesDistance {
+ get {
+ return ((double)(this["SlipCircleUpliftVanTangentLinesDistance"]));
+ }
+ }
+ }
+}
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Application/ModelRunner.cs
===================================================================
diff -u
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Application/ModelRunner.cs (revision 0)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Application/ModelRunner.cs (revision 5844)
@@ -0,0 +1,302 @@
+// Copyright (C) Stichting Deltares 2023. All rights reserved.
+//
+// This file is part of the application DAM - Live.
+//
+// DAM - Live is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero 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.Xml.Linq;
+using Deltares.Dam.Data;
+using Deltares.Dam.Data.Assemblers;
+using Deltares.DamLive.Application.Properties;
+using Deltares.Standard.Application;
+using Deltares.DamLive.Io;
+using Deltares.DamLive.Data;
+
+namespace Deltares.DamLive.Application;
+
+public class ModelRunner : IModelRunner
+{
+ internal const string NoDamxFile = "No .damx file set to load project data from.";
+ internal const string NoFewsInputFileAvailable = "No FEWS input file available to read the input time series from.";
+ internal const string NoFewsOutputFileAvailable = "No FEWS output file available to write the result to.";
+ internal const string ErrorExtractingWorkingFolder = "An error occured while trying to extract the path from the FEWS input file. This error can be solved by setting a working folder";
+
+ internal LogHelper Logger = LogHelper.Create();
+
+ public ModelRunner()
+ {
+ // WorkingPath will be extracted from file name if available
+ StabilityWorkingPath = Settings.Default.StabilityWorkingPath;
+ PipingWorkingPath = Settings.Default.PipingWorkingPath;
+ WaterLevelOffset = Settings.Default.WaterLevelOffset;
+ }
+
+ public IModelRunner RunnerDelegate { get; set; }
+
+ public bool HasErrors
+ {
+ get
+ {
+ return Logger.HasLoggedExceptions;
+ }
+ }
+
+ ///
+ /// Gets or sets the DAM project data used for stability calculations
+ ///
+ public DamProjectData ProjectData { get; set; }
+
+ public CalculationParameters CalculationParameters { get; set; }
+ public TimeSerieCollection OutputTimeSeriesCollection { get; set; }
+ public TimeSerieCollection InputTimeSeriesCollection { get; set; }
+
+ public string StabilityWorkingPath { get; set; }
+ public string PipingWorkingPath { get; set; }
+ public double WaterLevelOffset { get; set; }
+ public string WorkingPath { get; set; }
+ public string Filter { get; set; }
+
+ ///
+ /// Initializes this instance. Validates input files, deletes former project files,
+ /// creates working folders and prepares the in and output time series collections
+ ///
+ public virtual void Initialize()
+ {
+ if (ProjectData == null)
+ {
+ if (DamXFile == null)
+ {
+ throw new InvalidOperationException(NoDamxFile);
+ }
+
+ ProjectData = DamProject.LoadData(DamXFile.FullName);
+ WorkingPath = Path.ChangeExtension(DamXFile.FullName, ".Calc");
+ }
+
+ if (InputTimeSeriesCollection == null)
+ {
+ if (FewsInputFile == null)
+ {
+ throw new InvalidOperationException(NoFewsInputFileAvailable);
+ }
+
+ InputTimeSeriesCollection = TimeSerieCollection.LoadFromFile(FewsInputFile);
+ }
+
+ if (OutputTimeSeriesCollection == null)
+ {
+ if (FewsOutputFile == null)
+ {
+ throw new InvalidOperationException(NoFewsOutputFileAvailable);
+ }
+
+ OutputTimeSeriesCollection = InputTimeSeriesCollection.GetShallowCopy();
+ }
+
+ if (CalculationParameters == null && ParametersFile != null)
+ {
+ // Read calculation parameters, if available
+ XmlCalculationParameters xmlCalculationParameters = CalculationParametersXmlSerialization.LoadFromXmlFile(ParametersFile.FullName);
+ CalculationParameters = FillDomainFromXmlCalculationParameters.CreateCalculationParameters(xmlCalculationParameters);
+ }
+ }
+
+ ///
+ /// Creates and set's up the working directories. By default, the directory the output file
+ /// will be used if the working path is not set.
+ ///
+ public virtual void CreateAndSetWorkingDirectories()
+ {
+ string targetPath;
+ string defaultFolder = FewsOutputFile != null ? FewsOutputFile.DirectoryName : null;
+
+ if (!string.IsNullOrWhiteSpace(WorkingPath))
+ {
+ targetPath = WorkingPath;
+ }
+ else
+ {
+ if (defaultFolder == null)
+ {
+ throw new InvalidOperationException(ErrorExtractingWorkingFolder);
+ }
+
+ targetPath = string.IsNullOrWhiteSpace(defaultFolder) ? "." : defaultFolder;
+ }
+
+ CreateWorkingDirectory(targetPath);
+
+ // The following path's are sub folders of the main working path
+ StabilityWorkingPath = Path.Combine(targetPath, StabilityWorkingPath);
+ CreateWorkingDirectory(StabilityWorkingPath);
+
+ PipingWorkingPath = Path.Combine(targetPath, PipingWorkingPath);
+ CreateWorkingDirectory(PipingWorkingPath);
+ }
+
+ ///
+ /// Processes an output time series using the input time series collection
+ /// and the required project data.
+ ///
+ public virtual void Process()
+ {
+ if (ProjectData == null)
+ {
+ throw new InvalidOperationException("No DAM project data available.");
+ }
+
+ if (InputTimeSeriesCollection == null)
+ {
+ throw new InvalidOperationException("No input time series collection available.");
+ }
+
+ if (OutputTimeSeriesCollection == null)
+ {
+ throw new InvalidOperationException("No output time series collection available.");
+ }
+
+ if (RunnerDelegate != null)
+ {
+ RunnerDelegate.WorkingPath = WorkingPath;
+ RunnerDelegate.WaterLevelOffset = WaterLevelOffset;
+ RunnerDelegate.PipingWorkingPath = PipingWorkingPath;
+ RunnerDelegate.StabilityWorkingPath = StabilityWorkingPath;
+ RunnerDelegate.CalculationParameters = CalculationParameters;
+ RunnerDelegate.InputTimeSeriesCollection = InputTimeSeriesCollection;
+ RunnerDelegate.OutputTimeSeriesCollection = OutputTimeSeriesCollection;
+ RunnerDelegate.ProjectData = ProjectData;
+ RunnerDelegate.Filter = Filter;
+
+ RunnerDelegate.Run();
+
+ // sync back the processed data
+ OutputTimeSeriesCollection = RunnerDelegate.OutputTimeSeriesCollection;
+ }
+ else
+ {
+ Logger.LogWarning("No model runner set to delegate the processing of the time series to");
+ }
+ }
+
+ ///
+ /// Performs all the steps to transform the input time series collection to
+ /// the output time series collection with the calculated values
+ ///
+ public virtual void Run()
+ {
+ Initialize();
+ CreateAndSetWorkingDirectories();
+ DeleteFormerProjectFiles();
+ Process();
+ WriteResultsToFile(FewsOutputFile.FullName);
+ }
+
+ protected internal FileInfo DamXFile { get; set; }
+ protected internal FileInfo FewsInputFile { get; set; }
+ protected internal FileInfo FewsOutputFile { get; set; }
+ protected internal FileInfo ParametersFile { get; set; }
+
+ ///
+ /// Creates the working directory if they not exist.
+ ///
+ /// Name of the directory.
+ protected static void CreateWorkingDirectory(string directoryName)
+ {
+ if (string.IsNullOrWhiteSpace(directoryName))
+ {
+ throw new ArgumentNullException("directoryName");
+ }
+
+ if (!Directory.Exists(directoryName))
+ {
+ Directory.CreateDirectory(directoryName);
+ }
+ }
+
+ ///
+ /// Cleanup the working directory
+ ///
+ protected void DeleteFormerProjectFiles()
+ {
+ // remove known files for stability calculation
+ var di = new DirectoryInfo(StabilityWorkingPath);
+ FileInfo[] rgFiles = di.GetFiles("*.st?");
+ foreach (FileInfo fi in rgFiles)
+ {
+ File.Delete(fi.FullName);
+ }
+
+ rgFiles = di.GetFiles("*.sti.xml");
+ foreach (FileInfo fi in rgFiles)
+ {
+ File.Delete(fi.FullName);
+ }
+
+ rgFiles = di.GetFiles("*.wmf");
+ foreach (FileInfo fi in rgFiles)
+ {
+ File.Delete(fi.FullName);
+ }
+
+ rgFiles = di.GetFiles("*.err");
+ foreach (FileInfo fi in rgFiles)
+ {
+ File.Delete(fi.FullName);
+ }
+
+ foreach (FileInfo fi in rgFiles)
+ {
+ File.Delete(fi.FullName);
+ }
+
+ // remove known files for piping calculator
+ di = new DirectoryInfo(PipingWorkingPath);
+ rgFiles = di.GetFiles("*.txt");
+ foreach (FileInfo fi in rgFiles)
+ {
+ File.Delete(fi.FullName);
+ }
+ }
+
+ ///
+ /// Writes all the results in the output collection to the given file
+ ///
+ ///
+ protected void WriteResultsToFile(string fileName)
+ {
+ if (string.IsNullOrWhiteSpace(fileName))
+ {
+ throw new ArgumentNullException("fileName");
+ }
+
+ var timeSerieAssembler = new TimeSeriesAssembler();
+ XDocument doc = timeSerieAssembler.CreateDataTransferDocument(OutputTimeSeriesCollection);
+
+ try
+ {
+ doc.Save(fileName);
+ FileWriterUtil.RemoveThreeBytesFromXml(fileName);
+ }
+ catch (Exception e)
+ {
+ Logger.LogError("Could not export Fews xml file", e);
+ }
+ }
+}
\ No newline at end of file
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Application/app.config
===================================================================
diff -u
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Application/app.config (revision 0)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Application/app.config (revision 5844)
@@ -0,0 +1,141 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ .\stabilityfiles\
+
+
+ 2
+
+
+ .\pipingfiles\
+
+
+ 10
+
+
+ 2.5
+
+
+ 10
+
+
+ 2.5
+
+
+ OnBoundaryLines
+
+
+ 0.25
+
+
+ Specified
+
+
+ 10
+
+
+ 2.5
+
+
+ 10
+
+
+ 2.5
+
+
+ 3
+
+
+ 2.5
+
+
+ 6
+
+
+ 2.5
+
+
+ OnBoundaryLines
+
+
+ 0.25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/StabilityInsideUpliftVanBeeSwarmTest.cs
===================================================================
diff -u -r5807 -r5844
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/StabilityInsideUpliftVanBeeSwarmTest.cs (.../StabilityInsideUpliftVanBeeSwarmTest.cs) (revision 5807)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/StabilityInsideUpliftVanBeeSwarmTest.cs (.../StabilityInsideUpliftVanBeeSwarmTest.cs) (revision 5844)
@@ -25,7 +25,7 @@
using System.IO;
using System.Linq;
using System.Threading;
-using Deltares.Dam.Application.Live;
+using Deltares.DamLive.Application;
using Deltares.Dam.Data;
using Deltares.DamEngine.Interface;
using Deltares.DamEngine.Io;
Fisheye: Tag 5844 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/CommandOptions.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 5844 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Deltares.Dam.Application.Live.csproj'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 5844 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/app.config'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 5844 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Properties/Settings.settings'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 5844 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/SensorModelRunner.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 5844 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Properties/Settings.Designer.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 5844 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/ModelRunner.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 5844 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/IModelRunner.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 5844 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/DamLiveTest.cmd'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 5844 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Program.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 5844 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/DamEngineRunner.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 5844 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/FillDomainFromXmlCalculationParameters.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 5844 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/FillXmlCalculationParametersFromDomain.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 5844 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/XmlConversionHelper.cs'.
Fisheye: No comparison available. Pass `N' to diff?