Index: DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/CommandOptions.cs =================================================================== diff -u --- DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/CommandOptions.cs (revision 0) +++ DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/CommandOptions.cs (revision 1538) @@ -0,0 +1,73 @@ +using System; +using CommandLine; +using CommandLine.Text; +using Deltares.Standard; +using Deltares.Standard.Reflection; + +namespace Deltares.Dam.Application.Live +{ + 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; } + + readonly AssemblyInfoHelper assemblyInfoHelper = new AssemblyInfoHelper(typeof(Program)); + private AssemblyInfoHelper ThisAssembly + { + get + { + return assemblyInfoHelper; + } + } + + [HelpOption] + public string GetUsage() + { + var help = new HelpText + { + Heading = new HeadingInfo(ThisAssembly.Title, ThisAssembly.AssemblyVersion), + Copyright = new CopyrightInfo(ThisAssembly.Company, 2012), + AdditionalNewLineAfterOption = true, + AddDashesToOption = true + }; + + this.HandleParsingErrorsInHelp(help); + + //help.AddPreOptionsLine("<>"); + help.AddPreOptionsLine("Usage: damlive[.exe] -d DamXInputFile -i InputTimeSeriesFileName -o OutputTimeSeriesFileName [-p CalculationParametersFileName] [-f LocationFilter(comma separated)"); + help.AddOptions(this); + + return help; + } + + void HandleParsingErrorsInHelp(HelpText help) + { + if (this.LastPostParsingState.Errors.Count > 0) + { + var 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/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Assemblers/CalculationParametersAssembler.cs =================================================================== diff -u --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Assemblers/CalculationParametersAssembler.cs (revision 0) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Assemblers/CalculationParametersAssembler.cs (revision 1538) @@ -0,0 +1,196 @@ +using System; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Xml; +using System.Xml.Linq; +using System.Xml.Schema; +using Deltares.Standard; + +namespace Deltares.Dam.Data.Assemblers +{ + using Standard.Extensions; + + /// + /// + /// + public class CalculationParametersAssembler : DtoAssembler + { + #region Constant declarations + + /// + /// Holds the common part of the path to the embedded resource + /// + private const string EmbeddedResourcePath = "Deltares.Dam.Data.Xsd"; + + public const string XmlCalculationModulesElementName = "CalculationModules"; + public const string XmlStabilityElementName = "Stability"; + public const string XmlStabilityOutsideElementName = "StabilityOutside"; + public const string XmlPipingWtiElementName = "PipingWti"; + public const string XmlPipingBlighElementName = "PipingBligh"; + public const string XmlPipingSellmeijerElementName = "PipingSellmeijer"; + public const string XmlPipingSellmeijerProbabilisticElementName = "PipingSellmeijerProbabilistic"; + public const string XmlPipingIJkdijkElementName = "PipingIJkdijk"; + public const string XmlOvertoppingElementName = "Overtopping"; + public const string XmlMStabParametersElementName = "MStabParameters"; + public const string XmlMStabIsCalculateAllStabilityProjectsAtOnceElementName = "IsCalculateAllStabilityProjectsAtOnce"; + public const string XmlMStabCalculationModelElementName = "CalculationModel"; + public const string XmlMStabShearStrengthElementName = "ShearStrength"; + public const string XmlMStabProbabilisticElementName = "Probabilistic"; + public const string XmlMStabSearchMethodElementName = "SearchMethod"; + public const string XmlMStabUseZonesElementName = "UseZones"; + public const string XmlMStabIsOverrulePLLineCreationMethodName = "IsOverrulePLLineCreationMethod"; + public const string XmlMStabPLLineCreationMethodname = "PLLineCreationMethod"; + + /// + /// Holds the xml element name + /// + private const string XmlElementName = "CalculationParameters"; + + /// + /// Holds the name of the xml schema + /// + private const string XmlSchemaName = "CalculationParametersDefinition"; + + /// + /// Holds the xml namespace + /// + private const string XmlElementNamespace = "http://deltares.nl/2008/" + XmlSchemaName; + + /// + /// Holds the xsd resource path + /// + private const string XsdEmbeddedResourcePath = EmbeddedResourcePath + "." + XmlSchemaName + ".xsd"; + + + #endregion + + /// + /// + /// + public CalculationParametersAssembler() + : base(XmlElementName, XmlElementNamespace, Assembly.GetExecutingAssembly().GetEmbeddedFile(XsdEmbeddedResourcePath)) + { + } + + public override CalculationParameters CreateDomainObject(XElement dtoObj) + { + + CalculationParameters calculationParameters = base.CreateDomainObject(dtoObj); + + // Calculation modules + XElement calculationModulesElement = dtoObj.Element(XmlCalculationModulesElementName); + if (calculationModulesElement != null) + { + CalculationModules calculationModules = new CalculationModules(); + + XElement element = calculationModulesElement.Element(CalculationParametersAssembler.XmlStabilityElementName); + if (element != null) + calculationModules.Stability = int.Parse(element.Value) != 0; + element = calculationModulesElement.Element(CalculationParametersAssembler.XmlStabilityOutsideElementName); + if (element != null) + calculationModules.StabilityOutside = int.Parse(element.Value) != 0; + element = calculationModulesElement.Element(CalculationParametersAssembler.XmlPipingWtiElementName); + if (element != null) + calculationModules.PipingWti = int.Parse(element.Value) != 0; + element = calculationModulesElement.Element(CalculationParametersAssembler.XmlPipingBlighElementName); + if (element != null) + calculationModules.PipingBligh = int.Parse(element.Value) != 0; + element = calculationModulesElement.Element(CalculationParametersAssembler.XmlPipingSellmeijerElementName); + if (element != null) + calculationModules.PipingSellmeijer = int.Parse(element.Value) != 0; + element = calculationModulesElement.Element(CalculationParametersAssembler.XmlPipingSellmeijerProbabilisticElementName); + if (element != null) + calculationModules.PipingSellmeijerProbabilistic = int.Parse(element.Value) != 0; + element = calculationModulesElement.Element(CalculationParametersAssembler.XmlPipingIJkdijkElementName); + if (element != null) + calculationModules.PipingIJkdijk = int.Parse(element.Value) != 0; + element = calculationModulesElement.Element(CalculationParametersAssembler.XmlOvertoppingElementName); + if (element != null) + calculationModules.Overtopping = int.Parse(element.Value) != 0; + + calculationParameters.CalculationModules = calculationModules;; + } + + + // MStab parameters + XElement mstabParametersElement = dtoObj.Element(XmlMStabParametersElementName); + if (mstabParametersElement != null) + { + MStabParameters mstabParameters = new MStabParameters(); + + XElement element; + + element = mstabParametersElement.Element( + CalculationParametersAssembler.XmlMStabIsCalculateAllStabilityProjectsAtOnceElementName); + if (element != null) + mstabParameters.IsCalculateAllStabilityProjectsAtOnce = int.Parse(element.Value) != 0; + + element = + mstabParametersElement.Element(CalculationParametersAssembler.XmlMStabCalculationModelElementName); + if (element != null) + mstabParameters.Model = (MStabModelType)Enum.Parse(typeof (MStabModelType), element.Value, true); + + element = mstabParametersElement.Element(CalculationParametersAssembler.XmlMStabShearStrengthElementName); + if (element != null) + mstabParameters.ShearStrength = (MStabShearStrength) + Enum.Parse(typeof (MStabShearStrength), element.Value, true); + + element = mstabParametersElement.Element(CalculationParametersAssembler.XmlMStabSearchMethodElementName); + if (element != null) + mstabParameters.SearchMethod = (MStabSearchMethod) + Enum.Parse(typeof (MStabSearchMethod), element.Value, true); + + element = mstabParametersElement.Element(CalculationParametersAssembler.XmlMStabProbabilisticElementName); + if (element != null) + mstabParameters.IsProbabilistic = int.Parse(element.Value) != 0; + + element = mstabParametersElement.Element(CalculationParametersAssembler.XmlMStabUseZonesElementName); + mstabParameters.CalculationOptions = new MStabCalculationOptions(); + mstabParameters.CalculationOptions.ZonesType = MStabZonesType.NoZones; + if (element != null) + { + int useZones = int.Parse(element.Value); + mstabParameters.CalculationOptions.ZonesType = (MStabZonesType) useZones; + } + + element = mstabParametersElement.Element( + CalculationParametersAssembler.XmlMStabIsOverrulePLLineCreationMethodName); + if (element != null) + mstabParameters.IsOverrulePLLineCreationMethod = int.Parse(element.Value) != 0; + + element = + mstabParametersElement.Element(CalculationParametersAssembler.XmlMStabPLLineCreationMethodname); + if (element != null) + mstabParameters.PLLineCreationMethod = (PLLineCreationMethod)Enum.Parse(typeof(PLLineCreationMethod), element.Value, true); + else + mstabParameters.PLLineCreationMethod = PLLineCreationMethod.None; + + calculationParameters.MStabParameters = mstabParameters; + } + + return calculationParameters; + } + + #region Schema Validator Method + + public bool ValidateSchema(XDocument doc, out string message) + { + bool result = true; + string errorMessage = String.Empty; + + XmlSchemaSet schemas = new XmlSchemaSet(); + + Stream xsdStream = Common.GetEmbeddedFile(Assembly.GetExecutingAssembly(), XsdEmbeddedResourcePath); + schemas.Add(XmlElementNamespace, XmlReader.Create(xsdStream)); + + doc.Validate(schemas, (o, e) => { result = false; errorMessage = e.Message; }, true); + + message = errorMessage; + + return result; + } + + #endregion + } +} \ No newline at end of file Index: DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Deltares.Dam.Application.Live.csproj =================================================================== diff -u --- DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Deltares.Dam.Application.Live.csproj (revision 0) +++ DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Deltares.Dam.Application.Live.csproj (revision 1538) @@ -0,0 +1,160 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {09DD9498-9259-44BC-A84E-DA6B7DEDB133} + Exe + Properties + Deltares.Dam.Application.Live + DamLive + v4.5 + + + 512 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + ..\..\ + true + + + x86 + true + full + false + ..\bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + ..\bin\Release\ + TRACE + prompt + 4 + false + + + + False + ..\..\lib\CommandLineParser\CommandLine.dll + + + False + ..\..\lib\Authorization\x86\Deltares.Authorization.dll + + + ..\..\lib\DSL-Geographic\Deltares.Geographic.dll + + + False + ..\..\lib\DSL-Core\Deltares.Standard.dll + + + ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll + + + + + + + + + + + + + + + + + True + True + Settings.settings + + + + + + + PreserveNewest + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + False + Microsoft .NET Framework 4 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 3.1 + true + + + + + {f1cd9620-15cf-41f8-af70-5ae004a50f60} + Deltares.Dam.Data + + + + + dauth.dll + PreserveNewest + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file Index: DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Properties/AssemblyInfo.cs =================================================================== diff -u --- DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Properties/AssemblyInfo.cs (revision 0) +++ DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Properties/AssemblyInfo.cs (revision 1538) @@ -0,0 +1,39 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("DamLive")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Deltares")] +[assembly: AssemblyProduct("DamLive")] +[assembly: AssemblyCopyright("Deltares Copyright � 2012-2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a43f4365-f535-4f3a-b927-2b8ae3014bae")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("17.1.0.1442")] +[assembly: AssemblyFileVersion("17.1.0.1442")] +[assembly: InternalsVisibleTo("Deltares.Dam.Application.Live.Tests")] +[assembly: InternalsVisibleTo("Deltares.Dam.IntegrationTests")] + Index: DamClients/DamLive/trunk/lib/CommandLineParser/readme.txt =================================================================== diff -u --- DamClients/DamLive/trunk/lib/CommandLineParser/readme.txt (revision 0) +++ DamClients/DamLive/trunk/lib/CommandLineParser/readme.txt (revision 1538) @@ -0,0 +1,48 @@ +Command Line Parser Library 1.9.3.19 Beta +----------------------------------------- +Giacomo Stelluti Scala +(gsscoder@gmail.com) + +Codeplex: http://commandline.codeplex.com/ +GitHub (Latest Sources, Updated Docs): https://github.com/gsscoder/commandline + +Upgrading from 1.8.* versions: +------------------------------ +The major API change is that all attributes that inherits from BaseOptionAttribute now +apply only to properties. Fields are no longer supported. + +Old Code: +--------- +class Options { + [Option("o", "my-option", HelpText="This is an option!")] + public int MyOption = 10; +} + +New Code: +--------- +class Options { + [Option("o", "my-option", DefaultValue=10, HelpText="This is an option!")] + public int MyOption { get; set; } +} + +As you can see I've added the new DefaultValue property to help you initialize properties. + +Shortcut for Help Screen +------------------------ +[HelpOption] +public string GetUsage() +{ + return HelpText.AutoBuild(this, + (HelpText current) => HelpText.DefaultParsingErrorsHandler(this, current)); +} + +Note: +----- +If you don't use mutually exclusive options, now there's a singleton built for common uses: + +if (CommandLineParser.Default.ParseArguments(args, options)) { + // consume values here +} + + +Have fun! \ No newline at end of file Index: DamClients/DamLive/trunk/src/DamLive.sln =================================================================== diff -u -r1527 -r1538 --- DamClients/DamLive/trunk/src/DamLive.sln (.../DamLive.sln) (revision 1527) +++ DamClients/DamLive/trunk/src/DamLive.sln (.../DamLive.sln) (revision 1538) @@ -33,6 +33,15 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deltares.DamClientsLibrary.Version", "DamClientsLibrary\Deltares.DamClientsLibrary.Version\Deltares.DamClientsLibrary.Version.csproj", "{48691761-637B-4EFF-A04C-2047E5FA9843}" 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}" + ProjectSection(ProjectDependencies) = postProject + {A40C9407-ED80-4438-9E0E-E7BED8353D3B} = {A40C9407-ED80-4438-9E0E-E7BED8353D3B} + {48691761-637B-4EFF-A04C-2047E5FA9843} = {48691761-637B-4EFF-A04C-2047E5FA9843} + {17F76A8E-C9F4-415F-8D4B-0E8A3B36E665} = {17F76A8E-C9F4-415F-8D4B-0E8A3B36E665} + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deltares.DamLive.Version", "Deltares.DamLive.Version\Deltares.DamLive.Version.csproj", "{A40C9407-ED80-4438-9E0E-E7BED8353D3B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 @@ -51,6 +60,14 @@ {48691761-637B-4EFF-A04C-2047E5FA9843}.Debug|x86.Build.0 = Debug|x86 {48691761-637B-4EFF-A04C-2047E5FA9843}.Release|x86.ActiveCfg = Release|x86 {48691761-637B-4EFF-A04C-2047E5FA9843}.Release|x86.Build.0 = Release|x86 + {09DD9498-9259-44BC-A84E-DA6B7DEDB133}.Debug|x86.ActiveCfg = Debug|x86 + {09DD9498-9259-44BC-A84E-DA6B7DEDB133}.Debug|x86.Build.0 = Debug|x86 + {09DD9498-9259-44BC-A84E-DA6B7DEDB133}.Release|x86.ActiveCfg = Release|x86 + {09DD9498-9259-44BC-A84E-DA6B7DEDB133}.Release|x86.Build.0 = Release|x86 + {A40C9407-ED80-4438-9E0E-E7BED8353D3B}.Debug|x86.ActiveCfg = Debug|x86 + {A40C9407-ED80-4438-9E0E-E7BED8353D3B}.Debug|x86.Build.0 = Debug|x86 + {A40C9407-ED80-4438-9E0E-E7BED8353D3B}.Release|x86.ActiveCfg = Release|x86 + {A40C9407-ED80-4438-9E0E-E7BED8353D3B}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -61,5 +78,7 @@ {F1CD9620-15CF-41F8-AF70-5AE004A50F60} = {F6A85256-50BA-4E97-8E3C-D8D488DFAF44} {F6A85256-50BA-4E97-8E3C-D8D488DFAF44} = {31A32A36-649A-41A8-9F43-6A6193C04770} {48691761-637B-4EFF-A04C-2047E5FA9843} = {F6A85256-50BA-4E97-8E3C-D8D488DFAF44} + {09DD9498-9259-44BC-A84E-DA6B7DEDB133} = {95699CCD-37A6-4F2E-9462-F2F474AD8AE8} + {A40C9407-ED80-4438-9E0E-E7BED8353D3B} = {31A32A36-649A-41A8-9F43-6A6193C04770} EndGlobalSection EndGlobal Index: DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/app.config =================================================================== diff -u --- DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/app.config (revision 0) +++ DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/app.config (revision 1538) @@ -0,0 +1,111 @@ + + + + +
+ +
+ + + + + True + + + .\DGeoStability.exe + + + .\mstabfiles\ + + + 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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Properties/Settings.settings =================================================================== diff -u --- DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Properties/Settings.settings (revision 0) +++ DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Properties/Settings.settings (revision 1538) @@ -0,0 +1,72 @@ + + + + + + True + + + .\DGeoStability.exe + + + .\mstabfiles\ + + + 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.Dam.Application.Live/SensorModelRunner.cs =================================================================== diff -u --- DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/SensorModelRunner.cs (revision 0) +++ DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/SensorModelRunner.cs (revision 1538) @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Deltares.Dam.Data; +using Deltares.Dam.Data.Sensors; +using Deltares.Standard; + +namespace Deltares.Dam.Application.Live +{ + // 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 override void Run() + { + var calcParams = CalculationParameters ?? new CalculationParameters(); + calcParams.StabilityExePath = StabilityExePath; + calcParams.WorkingPath = WorkingPath; + calcParams.StabilityWorkingPath = StabilityWorkingPath; + ReadUserSettingsSlipCircleDefinition(calcParams.MStabParameters.SlipCircleDefinition); + + List locations = ProjectData.Locations; + if (!string.IsNullOrWhiteSpace(Filter)) + { + var 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"); + } + } + // 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(); + } + + public void ReadUserSettingsSlipCircleDefinition(SlipCircleDefinition slipCircleDefinition) + { + if (slipCircleDefinition == null) + { + slipCircleDefinition = new SlipCircleDefinition(); + } + slipCircleDefinition.GridSizeDetermination = Properties.Settings.Default.SlipCircleGridSizeDetermination; + slipCircleDefinition.UpliftVanTangentLinesDefinition = Properties.Settings.Default.SlipCircleUpliftVanTangentLinesDefinition; + slipCircleDefinition.UpliftVanTangentLinesDistance = Properties.Settings.Default.SlipCircleUpliftVanTangentLinesDistance; + slipCircleDefinition.UpliftVanLeftGridVerticalPointCount = Properties.Settings.Default.SlipCircleUpliftVanLeftGridVerticalPointCount; + slipCircleDefinition.UpliftVanLeftGridVerticalPointDistance = Properties.Settings.Default.SlipCircleUpliftVanLeftGridVerticalPointDistance; + slipCircleDefinition.UpliftVanLeftGridHorizontalPointCount = Properties.Settings.Default.SlipCircleUpliftVanLeftGridHorizontalPointCount; + slipCircleDefinition.UpliftVanLeftGridHorizontalPointDistance = Properties.Settings.Default.SlipCircleUpliftVanLeftGridHorizontalPointDistance; + slipCircleDefinition.UpliftVanRightGridVerticalPointCount = Properties.Settings.Default.SlipCircleUpliftVanRightGridVerticalPointCount; + slipCircleDefinition.UpliftVanRightGridVerticalPointDistance = Properties.Settings.Default.SlipCircleUpliftVanRightGridVerticalPointDistance; + slipCircleDefinition.UpliftVanRightGridHorizontalPointCount = Properties.Settings.Default.SlipCircleUpliftVanRightGridHorizontalPointCount; + slipCircleDefinition.UpliftVanRightGridHorizontalPointDistance = Properties.Settings.Default.SlipCircleUpliftVanRightGridHorizontalPointDistance; + slipCircleDefinition.BishopTangentLinesDefinition = Properties.Settings.Default.SlipCircleBishopTangentLinesDefinition; + slipCircleDefinition.BishopTangentLinesDistance = Properties.Settings.Default.SlipCircleBishopTangentLinesDistance; + slipCircleDefinition.BishopGridVerticalPointCount = Properties.Settings.Default.SlipCircleBishopGridVerticalPointCount; + slipCircleDefinition.BishopGridVerticalPointDistance = Properties.Settings.Default.SlipCircleBishopGridVerticalPointDistance; + slipCircleDefinition.BishopGridHorizontalPointCount = Properties.Settings.Default.SlipCircleBishopGridHorizontalPointCount; + slipCircleDefinition.BishopGridHorizontalPointDistance = Properties.Settings.Default.SlipCircleBishopGridHorizontalPointDistance; + } + } +} \ No newline at end of file Index: DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Properties/Settings.Designer.cs =================================================================== diff -u --- DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Properties/Settings.Designer.cs (revision 0) +++ DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Properties/Settings.Designer.cs (revision 1538) @@ -0,0 +1,224 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Deltares.Dam.Application.Live.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.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("True")] + public bool UseMStabForCalculation { + get { + return ((bool)(this["UseMStabForCalculation"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(".\\DGeoStability.exe")] + public string MStabExePath { + get { + return ((string)(this["MStabExePath"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(".\\mstabfiles\\")] + 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("OnBoundaryLines")] + public global::Deltares.Dam.Data.TangentLinesDefinition SlipCircleBishopTangentLinesDefinition { + get { + return ((global::Deltares.Dam.Data.TangentLinesDefinition)(this["SlipCircleBishopTangentLinesDefinition"])); + } + } + + [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 SlipCircleGridSizeDetermination { + get { + return ((global::Deltares.Dam.Data.GridSizeDetermination)(this["SlipCircleGridSizeDetermination"])); + } + } + + [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/lib/CommandLineParser/CommandLine.dll =================================================================== diff -u Binary files differ Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Version/Properties/AssemblyInfo.cs =================================================================== diff -u --- DamClients/DamLive/trunk/src/Deltares.DamLive.Version/Properties/AssemblyInfo.cs (revision 0) +++ DamClients/DamLive/trunk/src/Deltares.DamLive.Version/Properties/AssemblyInfo.cs (revision 1538) @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Deltares.DamLive.Version")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Deltares.DamLive.Version")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a40c9407-ed80-4438-9e0e-e7bed8353d3b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] Index: DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/ModelRunner.cs =================================================================== diff -u --- DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/ModelRunner.cs (revision 0) +++ DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/ModelRunner.cs (revision 1538) @@ -0,0 +1,250 @@ +using System; +using System.IO; +using System.Xml.Linq; +using Deltares.Dam.Application.Live.Properties; +using Deltares.Dam.Data; +using Deltares.Dam.Data.Assemblers; +using Deltares.Standard.Application; + +namespace Deltares.Dam.Application.Live +{ + 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(); + + protected internal FileInfo DamXFile { get; set; } + protected internal FileInfo FewsInputFile { get; set; } + protected internal FileInfo FewsOutputFile { get; set; } + protected internal FileInfo ParametersFile { get; set; } + + /// + /// 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 string StabilityExePath { get; set; } + public bool UseMStabForCalculation { get; set; } + public double WaterLevelOffset { get; set; } + public string WorkingPath { get; set; } + public string Filter { get; set; } + + public IModelRunner RunnerDelegate { get; set; } + + public bool HasErrors + { + get { return Logger.HasLoggedExceptions; } + } + + public ModelRunner() + { + // WorkingPath will be extracted from file name if available + StabilityWorkingPath = Settings.Default.StabilityWorkingPath; + PipingWorkingPath = Settings.Default.PipingWorkingPath; + StabilityExePath = Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), Settings.Default.MStabExePath); + UseMStabForCalculation = Settings.Default.UseMStabForCalculation; + WaterLevelOffset = Settings.Default.WaterLevelOffset; + } + + /// + /// 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 + CalculationParameters = CalculationParameters.LoadFromFile(ParametersFile); + } + } + + /// + /// 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); + } + + /// + /// 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); + } + } + + /// + /// 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); + } + + /// + /// 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.StabilityExePath = StabilityExePath; + RunnerDelegate.PipingWorkingPath = PipingWorkingPath; + RunnerDelegate.UseMStabForCalculation = UseMStabForCalculation; + 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"); + } + } + + /// + /// 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); + } + } + } +} Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/CalculationParameters.cs =================================================================== diff -u --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/CalculationParameters.cs (revision 0) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/CalculationParameters.cs (revision 1538) @@ -0,0 +1,64 @@ +//----------------------------------------------------------------------- +// +// Copyright (c) 2010 Deltares. All rights reserved. +// +// B.S.T. The +// tom.the@deltares.nl +// 04-11-2010 +// n.a. +//----------------------------------------------------------------------- + +using System.IO; +using System.Xml.Linq; +using Deltares.Dam.Data.Assemblers; + +namespace Deltares.Dam.Data +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + + public class CalculationModules + { + public bool Stability { get; set; } + public bool StabilityOutside { get; set; } + public bool PipingWti { get; set; } + public bool PipingBligh { get; set; } + public bool PipingSellmeijer { get; set; } + public bool PipingSellmeijerProbabilistic { get; set; } + public bool PipingIJkdijk { get; set; } + public bool Overtopping { get; set; } + } + + public class CalculationParameters + { + public string WorkingPath { get; set; } + public string StabilityWorkingPath { get; set; } + public string PipingWorkingPath { get; set; } + public string StabilityExePath { get; set; } + + public bool CalculateAllAtOnce + { + get { return MStabParameters == null || MStabParameters.IsCalculateAllStabilityProjectsAtOnce; } + set { MStabParameters.IsCalculateAllStabilityProjectsAtOnce = value; } + } + + public static CalculationParameters LoadFromFile(FileInfo xmlFile) + { + return LoadFromFile(xmlFile.FullName); + } + + public static CalculationParameters LoadFromFile(string xmlFileName) + { + if (string.IsNullOrWhiteSpace(xmlFileName)) throw new ArgumentException("xmlFileName"); + + XDocument calculationParametersFileDocument = XDocument.Load(xmlFileName); + var assembler = new CalculationParametersAssembler(); + return assembler.CreateDomainObject(calculationParametersFileDocument); + } + + public CalculationModules CalculationModules { get; set; } + public MStabParameters MStabParameters { get; set; } + } +} Index: DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/packages.config =================================================================== diff -u --- DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/packages.config (revision 0) +++ DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/packages.config (revision 1538) @@ -0,0 +1,4 @@ + + + + \ No newline at end of file Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Version/Deltares.DamLive.Version.csproj =================================================================== diff -u --- DamClients/DamLive/trunk/src/Deltares.DamLive.Version/Deltares.DamLive.Version.csproj (revision 0) +++ DamClients/DamLive/trunk/src/Deltares.DamLive.Version/Deltares.DamLive.Version.csproj (revision 1538) @@ -0,0 +1,54 @@ + + + + + Debug + AnyCPU + {A40C9407-ED80-4438-9E0E-E7BED8353D3B} + Library + Properties + Deltares.DamLive.Version + Deltares.DamLive.Version + v4.5 + 512 + + + true + ..\bin\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + ..\bin\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + + + + + + + + + + + + + + + + + \ No newline at end of file Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Deltares.Dam.Data.csproj =================================================================== diff -u -r1534 -r1538 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Deltares.Dam.Data.csproj (.../Deltares.Dam.Data.csproj) (revision 1534) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Deltares.Dam.Data.csproj (.../Deltares.Dam.Data.csproj) (revision 1538) @@ -170,8 +170,10 @@ + + Index: DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/IModelRunner.cs =================================================================== diff -u --- DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/IModelRunner.cs (revision 0) +++ DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/IModelRunner.cs (revision 1538) @@ -0,0 +1,21 @@ +using Deltares.Dam.Data; + +namespace Deltares.Dam.Application.Live +{ + public interface IModelRunner + { + string StabilityWorkingPath { get; set; } + string PipingWorkingPath { get; set; } + string StabilityExePath { get; set; } + bool UseMStabForCalculation { 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.Dam.Application.Live/DamLiveTest.cmd =================================================================== diff -u --- DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/DamLiveTest.cmd (revision 0) +++ DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/DamLiveTest.cmd (revision 1538) @@ -0,0 +1,2 @@ +@echo off +DamLive.exe -d TestData\DamLive\Set1\Deltares.Dam.Application.Live.Tests.ProjectFile.damx -i TestData\DamLive\Set1\Deltares.Dam.Application.Live.Tests.InputFile.xml -o TestData\DamLive\Set1\Deltares.Dam.Application.Live.Tests.OutputFile.xml -p TestData\DamLive\Set1\Deltares.Dam.Application.Live.Tests.ParametersFile.xml \ No newline at end of file Index: DamClients/DamLive/trunk/lib/CommandLineParser/CommandLine.XML =================================================================== diff -u --- DamClients/DamLive/trunk/lib/CommandLineParser/CommandLine.XML (revision 0) +++ DamClients/DamLive/trunk/lib/CommandLineParser/CommandLine.XML (revision 1538) @@ -0,0 +1,868 @@ + + + + /home/giacomo/Projects/CommandLine/src/libcmdline/bin/Release/CommandLine + + + + + Provides base properties for creating an attribute, used to define rules for command line parsing. + + + + + Short name of this command line option. You can use only one character. + + + + + Long name of this command line option. This name is usually a single english word. + + + + + True if this command line option is required. + + + + + Gets or sets mapped property default value. + + + + + A short description of this command line option. Usually a sentence summary. + + + + + Indicates the instance method that must be invoked when it becomes necessary show your help screen. + The method signature is an instance method with no parameters and + return value. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class. + Allows you to define short and long option names. + + The short name of the option or null if not used. + The long name of the option or null if not used. + + + + Returns always false for this kind of option. + This behaviour can't be changed by design; if you try set + an will be thrown. + + + + + Models an option that can accept multiple values as separated arguments. + + + + + Initializes a new instance of the class. + + The short name of the option or null if not used. + The long name of the option or null if not used. + + + + Models an option specification. + + + + + Initializes a new instance of the class. + + The short name of the option or null if not used. + The long name of the option or null if not used. + + + + Gets or sets the option's mutually exclusive set. + + + + + Models an option that can accept multiple values. + Must be applied to a field compatible with an interface + of instances. + + + + + Initializes a new instance of the class. + + The short name of the option or null if not used. + The long name of the option or null if not used. + + + + Initializes a new instance of the class. + + The short name of the option or null if not used. + The long name of the option or null if not used. + Values separator character. + + + + Gets or sets the values separator character. + + + + + Models a list of command line arguments that are not options. + Must be applied to a field compatible with an interface + of instances. + + + + + Initializes a new instance of the class. + + A type that implements . + Thrown if is null. + + + + Gets or sets the maximum element allow for the list managed by type. + If lesser than 0, no upper bound is fixed. + If equal to 0, no elements are allowed. + + + + + Models a bad parsed option. + + + + + The short name of the option + + Returns the short name of the option. + + + + The long name of the option + + Returns the long name of the option. + + + + Models a parsing error. + + + + + Gets or a the bad parsed option. + + + The bad option. + + + + + Gets or sets a value indicating whether this violates required. + + + true if violates required; otherwise, false. + + + + + Gets or sets a value indicating whether this violates format. + + + true if violates format; otherwise, false. + + + + + Gets or sets a value indicating whether this violates mutual exclusiveness. + + + true if violates mutual exclusiveness; otherwise, false. + + + + + Models a type that records the parser state afeter parsing. + + + + + Gets a list of parsing errors. + + + Parsing errors. + + + + + Defines a basic interface to parse command line arguments. + + + + + Parses a array of command line arguments, setting values in + parameter instance's public fields decorated with appropriate attributes. + + A array of command line arguments. + An object's instance used to receive values. + Parsing rules are defined using derived types. + True if parsing process succeed. + Thrown if is null. + Thrown if is null. + + + + Parses a array of command line arguments, setting values in + parameter instance's public fields decorated with appropriate attributes. + This overload allows you to specify a derived instance for write text messages. + + A array of command line arguments. + An object's instance used to receive values. + Parsing rules are defined using derived types. + Any instance derived from , + usually . Setting this argument to null, will disable help screen. + True if parsing process succeed. + Thrown if is null. + Thrown if is null. + + + + Provides the abstract base class for a strongly typed options target. Used when you need to get parsing errors. + + + + + This exception is thrown when a generic parsing error occurs. + + + + + Specifies a set of features to configure a behavior. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class, + setting the case comparison behavior. + + If set to true, parsing will be case sensitive. + + + + Initializes a new instance of the class, + setting the used for help method output. + + Any instance derived from , + default . Setting this argument to null, will disable help screen. + + + + Initializes a new instance of the class, + setting case comparison and help output options. + + If set to true, parsing will be case sensitive. + Any instance derived from , + default . Setting this argument to null, will disable help screen. + + + + Initializes a new instance of the class, + setting case comparison and mutually exclusive behaviors. + + If set to true, parsing will be case sensitive. + If set to true, enable mutually exclusive behavior. + + + + Initializes a new instance of the class, + setting case comparison, mutually exclusive behavior and help output option. + + If set to true, parsing will be case sensitive. + If set to true, enable mutually exclusive behavior. + Any instance derived from , + default . Setting this argument to null, will disable help screen. + + + + Initializes a new instance of the class, + setting case comparison, mutually exclusive behavior and help output option. + + If set to true, parsing will be case sensitive. + If set to true, enable mutually exclusive behavior. + If set to true, allow the parser to skip unknown argument, otherwise return a parse failure + Any instance derived from , + default . Setting this argument to null, will disable help screen. + + + + Gets or sets the case comparison behavior. + Default is set to true. + + + + + Gets or sets the mutually exclusive behavior. + Default is set to false. + + + + + Gets or sets the used for help method output. + Setting this property to null, will disable help screen. + + + + + Gets or sets a value indicating if the parser shall move on to the next argument and ignore the given argument if it + encounter an unknown arguments + + + true to allow parsing the arguments with differents class options that do not have all the arguments. + + + This allows fragmented version class parsing, useful for project with addon where addons also requires command line arguments but + when these are unknown by the main program at build time. + + + + + Provides methods to parse command line arguments. + Default implementation for . + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class, + configurable with a object. + + The object is used to configure + aspects and behaviors of the parser. + + + + Singleton instance created with basic defaults. + + + + + Parses a array of command line arguments, setting values in + parameter instance's public fields decorated with appropriate attributes. + + A array of command line arguments. + An object's instance used to receive values. + Parsing rules are defined using derived types. + True if parsing process succeed. + Thrown if is null. + Thrown if is null. + + + + Parses a array of command line arguments, setting values in + parameter instance's public fields decorated with appropriate attributes. + This overload allows you to specify a derived instance for write text messages. + + A array of command line arguments. + An object's instance used to receive values. + Parsing rules are defined using derived types. + Any instance derived from , + usually . Setting this argument to null, will disable help screen. + True if parsing process succeed. + Thrown if is null. + Thrown if is null. + + + + Models an abstract sentence builder. + + + + + Gets a string containing word 'option'. + + + The word 'option'. + + + + + Gets a string containing the word 'and'. + + + The word 'and'. + + + + + Gets a string containing the sentence 'required option missing'. + + + The sentence 'required option missing'. + + + + + Gets a string containing the sentence 'violates format'. + + + The sentence 'violates format'. + + + + + Gets a string containing the sentence 'violates mutual exclusiveness'. + + + The sentence 'violates mutual exclusiveness'. + + + + + Gets a string containing the error heading text. + + + The error heading text. + + + + + Creates the built in sentence builder. + + + The built in sentence builder. + + + + + Models an english sentence builder, currently the default one. + + + + + Gets a string containing word 'option' in english. + + + The word 'option' in english. + + + + + Gets a string containing the word 'and' in english. + + + The word 'and' in english. + + + + + Gets a string containing the sentence 'required option missing' in english. + + + The sentence 'required option missing' in english. + + + + + Gets a string containing the sentence 'violates format' in english. + + + The sentence 'violates format' in english. + + + + + Gets a string containing the sentence 'violates mutual exclusiveness' in english. + + + The sentence 'violates mutual exclusiveness' in english. + + + + + Gets a string containing the error heading text in english. + + + The error heading text in english. + + + + + Models the copyright informations part of an help text. + You can assign it where you assign any instance. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class + specifying author and year. + + The company or person holding the copyright. + The year of coverage of copyright. + Thrown when parameter is null or empty string. + + + + Initializes a new instance of the class + specifying author and years. + + The company or person holding the copyright. + The years of coverage of copyright. + Thrown when parameter is null or empty string. + Thrown when parameter is not supplied. + + + + Initializes a new instance of the class + specifying symbol case, author and years. + + The case of the copyright symbol. + The company or person holding the copyright. + The years of coverage of copyright. + Thrown when parameter is null or empty string. + Thrown when parameter is not supplied. + + + + When overridden in a derived class, allows to specify a different copyright word. + + + + + Returns the copyright informations as a . + + The that contains the copyright informations. + + + + When overridden in a derived class, allows to specify a new algorithm to render copyright years + as a instance. + + A array of years. + A instance with copyright years. + + + + Converts the copyright informations to a . + + This instance. + The that contains the copyright informations. + + + + Models the heading informations part of an help text. + You can assign it where you assign any instance. + + + + + Initializes a new instance of the class + specifying program name. + + The name of the program. + Thrown when parameter is null or empty string. + + + + Initializes a new instance of the class + specifying program name and version. + + The name of the program. + The version of the program. + Thrown when parameter is null or empty string. + + + + Returns the heading informations as a . + + The that contains the heading informations. + + + + Writes out a string and a new line using the program name specified in the constructor + and parameter. + + The message to write. + The target derived type. + Thrown when parameter is null or empty string. + Thrown when parameter is null. + + + + Writes out a string and a new line using the program name specified in the constructor + and parameter to standard output stream. + + The message to write. + Thrown when parameter is null or empty string. + + + + Writes out a string and a new line using the program name specified in the constructor + and parameter to standard error stream. + + The message to write. + Thrown when parameter is null or empty string. + + + + Converts the heading informations to a . + + This instance. + The that contains the heading informations. + + + + Handle parsing errors delegate. + + + + + Provides data for the FormatOptionHelpText event. + + + + + Initializes a new instance of the class. + + Option to format. + + + + Gets the option to format. + + + + + Models an help text and collects related informations. + You can assign it in place of a instance. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class + specifying the sentence builder. + + + A instance. + + + + + Initializes a new instance of the class + specifying heading informations. + + A string with heading information or + an instance of . + Thrown when parameter is null or empty string. + + + + Initializes a new instance of the class + specifying the sentence builder and heading informations. + + + A instance. + + + A string with heading information or + an instance of . + + + + + Initializes a new instance of the class + specifying heading and copyright informations. + + A string with heading information or + an instance of . + A string with copyright information or + an instance of . + Thrown when one or more parameters are null or empty strings. + + + + Initializes a new instance of the class + specifying heading and copyright informations. + + A string with heading information or + an instance of . + A string with copyright information or + an instance of . + The instance that collected command line arguments parsed with class. + Thrown when one or more parameters are null or empty strings. + + + + Message type enumeration. + + + + + Parsing error due to a violation of the format of an option value. + + + + + Parsing error due to a violation of mandatory option. + + + + + Parsing error due to a violation of the mutual exclusiveness of two or more option. + + + + + Occurs when an option help text is formatted. + + + + + Sets the heading information string. + You can directly assign a instance. + + + + + Sets the copyright information string. + You can directly assign a instance. + + + + + Gets or sets the maximum width of the display. This determines word wrap when displaying the text. + + The maximum width of the display. + + + + Gets or sets the format of options for adding or removing dashes. + It modifies behavior of method. + + + + + Gets or sets whether to add an additional line after the description of the option. + + + + + Creates a new instance of the class using common defaults. + + + An instance of class. + + + The instance that collected command line arguments parsed with class. + + + + + Creates a new instance of the class using common defaults. + + + An instance of class. + + + The instance that collected command line arguments parsed with class. + + + A delegate used to customize the text block for reporting parsing errors. + + + + + Adds a text line after copyright and before options usage informations. + + A instance. + Thrown when parameter is null or empty string. + + + + Adds a text line at the bottom, after options usage informations. + + A instance. + Thrown when parameter is null or empty string. + + + + Adds a text block with options usage informations. + + The instance that collected command line arguments parsed with class. + Thrown when parameter is null. + + + + Adds a text block with options usage informations. + + The instance that collected command line arguments parsed with the class. + The word to use when the option is required. + Thrown when parameter is null. + Thrown when parameter is null or empty string. + + + + Adds a text block with options usage informations. + + The instance that collected command line arguments parsed with the class. + The word to use when the option is required. + The maximum length of the help documentation. + Thrown when parameter is null. + Thrown when parameter is null or empty string. + + + + Builds a string that contains a parsing error message. + + + An options target instance that collected command line arguments parsed with the class. + + + The that contains the parsing error message. + + + + + Returns the help informations as a . + + The that contains the help informations. + + + + Converts the help informations to a . + + This instance. + The that contains the help informations. + + + Index: DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Program.cs =================================================================== diff -u --- DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Program.cs (revision 0) +++ DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/Program.cs (revision 1538) @@ -0,0 +1,160 @@ +using System; +using System.IO; +using CommandLine; +using Deltares.Authorization; +using Deltares.Dam.Data; +using Deltares.Standard.Application; +using log4net.Config; + +namespace Deltares.Dam.Application.Live +{ + internal class Program + { + internal readonly static LogHelper Logger = LogHelper.Create("DamLive"); + + private static DAuthClient dAuthClient; + private const string dAuthFeature = "DGS_27_00"; + private const string dAuthVersion = "17.0"; + + static void Main(string[] args) + { + var damLicenseType = DamLicenseType.None; + + // new authorization client ? + dAuthClient = new DAuthClient(false, true); + if (dAuthClient.CheckOut(dAuthFeature, dAuthVersion)) + { + damLicenseType = DamLicenseType.LFM; + } + + XmlConfigurator.Configure(); + try + { + if (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); + } + + // check in license + if (dAuthClient != null) + { + dAuthClient.CheckIn(dAuthFeature); + dAuthClient.Dispose(); + dAuthClient = null; + } + + //Console.ReadKey(); + } + + 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)); + + program.StartCalculations( + commandLineArguments.DamXFileName, + commandLineArguments.TimeSeriesInputFileName, + commandLineArguments.TimeSeriesOutputFileName, + commandLineArguments.ParameterFileName, + commandLineArguments.Filter); + } + else + { + Console.WriteLine(); + Console.WriteLine(commandLineArguments.GetUsage()); + } + } + + private static void CreateOutputTimeSeriesFileIfNeeded(string fileName, string path) + { + var filePath = Path.Combine(path, Path.GetFileName(fileName)); + if (!File.Exists(filePath)) + { + using (var stream = File.CreateText(filePath)) + { + + var xml = + "" + Environment.NewLine + + "" + + Environment.NewLine + + "\t0 " + Environment.NewLine + + ""; + + stream.Write(xml); + + } + } + } + + /// + /// 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); + + var 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); + } + + + Logger.LogInfo("v1.0 - Deltares 2014"); + Logger.LogInfo("Model runner started"); + Console.WriteLine(); + + var modelRunner = new ModelRunner + { + ParametersFile = new FileInfo(calculationParametersFile), + FewsInputFile = new FileInfo(fewsInputFile), + FewsOutputFile = new FileInfo(fewsOutputFile), + DamXFile = new FileInfo(damXFile), + Filter = filter, + RunnerDelegate = new SensorModelRunner() + }; + + modelRunner.Run(); + + Logger.LogInfo("Model runner ended"); + + } + } +}