// Copyright (C) Stichting Deltares 2018. All rights reserved. // // This file is part of the Dam Engine. // // The Dam Engine 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 Deltares.DamEngine.Data.General.Results; using Deltares.DamEngine.Data.General.Sensors; using Deltares.DamEngine.Data.RegionalAssessmentResults; using Deltares.DamEngine.Data.Standard.Language; using Deltares.DamEngine.Data.Standard.Logging; using Deltares.DamEngine.Data.Standard.Validation; namespace Deltares.DamEngine.Data.General { public class DamProjectData { public readonly double MissValStabilitySafetyFactor = -1.0; // ##Bka Waterboard eruit werken en vanaf nu max 1 dike! private string description = ""; private IList segments; private Dike dike; private DamProjectCalculationSpecification damProjectCalculationSpecification; private DikeJob dikeJob; private DamProjectType damProjectType = DamProjectType.Operational; private ProgramType programType = ProgramType.MStab; private List jobs = new List(); private List designCalculations; /// /// Gets or sets the calculation messages. /// /// /// The calculation messages. /// public List CalculationMessages { get; set; } = null; private SensorData sensorData; private string calculationMap = ""; private string projectPath = ""; private int maxCalculationCores = 1; /// /// Constructor /// public DamProjectData() { dikeJob = null; damProjectCalculationSpecification = new DamProjectCalculationSpecification(); dike = new Dike(); segments = new List(); } public virtual string Name { get { return String.Format(LocalizationManager.GetTranslatedText(this, "WaterBoard")); } } public virtual string Description { get { return description; } set { description = value; } } public virtual IList Segments { get { return segments; } set { segments = value; } } /// /// Gets the dike. /// Is a helper property to be able to show the soil table. When more Dikes than one are allowed, /// this has to become a "real" property set by the onselectionchanged event. /// /// /// The selected dike. /// public Dike Dike { get { return dike; } set { dike = value; } } /// /// calculation specification for the project /// /// Composite relationship [Validate] public DamProjectCalculationSpecification DamProjectCalculationSpecification { get { return damProjectCalculationSpecification; } set { damProjectCalculationSpecification = value; } } public virtual DamJob DikeJob { get { if (dikeJob == null) { dikeJob = new DikeJob(dike); foreach (Location location in dike.Locations) { LocationJob locationJob = new LocationJob(location); dikeJob.Jobs.Add(locationJob); } } return dikeJob; } set { dikeJob = value as DikeJob; } } public virtual DamProjectType DamProjectType { get { return damProjectType; } set { bool modified = damProjectType != value; damProjectType = value; Location.DamProjectType = value; DamFailureMechanismeCalculationSpecification.DamProjectType = value; if (modified) { LocationJob.DamProjectType = damProjectType; } } } public List DesignCalculations { get { return designCalculations; } set { designCalculations = value; } } public List LocationJobs { get { if (jobs.Count == 0 && dikeJob != null) { foreach (LocationJob locationJob in dikeJob.Jobs) { jobs.Add(locationJob); } } return jobs; } set { jobs = value; } } [Validate] public List SelectedLocationJobs { get { List selectedLocationJobs = new List(); foreach (var locationJob in LocationJobs) { if (locationJob.Run.HasValue && locationJob.Run.Value) { selectedLocationJobs.Add(locationJob); } } return selectedLocationJobs; } } // TODO: FM this is failure mechanism specific code and should be moved to ..\KernelWrappers public ProgramType ProgramType { // For now, only MStab (= default value) allowed so ReadOnly. Add setter when needed. get { return programType; } } /// /// Gets or sets the project path. /// /// /// The project path. /// public string ProjectPath { get { return projectPath; } set { projectPath = value ?? ""; } } /// /// Gets or sets the calculation map. /// This does not include a full path but can include a relative path /// /// /// The calculation map. /// public string CalculationMap { get { return calculationMap; } set { calculationMap = value?? ""; } } /// /// Gets or sets the maximum calculation cores. /// /// /// The maximum calculation cores. /// public int MaxCalculationCores { get { return maxCalculationCores; } set { maxCalculationCores = value; } } /// /// Gets or sets the sensor data. /// /// /// The sensor data. /// public SensorData SensorData { get { return sensorData; } set { sensorData = value; } } public EvaluationJob GetEvaluationJob() { EvaluationJob evaluationJob = new EvaluationJob { DikeName = dike.Name }; foreach (var locationJob in LocationJobs) { if (locationJob.Run != null && locationJob.Run.Value) { if (dike.Locations.Contains(locationJob.Location)) { dike.UpdateLocation(locationJob.Location); break; } evaluationJob.Locations.Add(locationJob.Location); } } return evaluationJob; } public override string ToString() { return Name; } public void FillOverallSensorData() { if (sensorData != null) { sensorData.Sensors.Clear(); sensorData.SensorGroups.Clear(); sensorData.SensorLocations.Clear(); } else { sensorData = new SensorData(); } foreach (var location in dike.Locations) { var sd = location.SensorData; foreach (var sensor in sd.Sensors ) { if (sensorData.GetSensorById(sensor.ID) == null) { sensorData.Sensors.Add(sensor); } } if (sensorData.GetGroupById(sd.Group.ID) == null && sd.Group.ID >= 0) { sd.Group.PickSensors = sensorData.Sensors; sensorData.SensorGroups.Add(sd.Group); } if (sensorData.GetSensorLocationByLocationName(sd.LocationName) == null) { sensorData.SensorLocations.Add(sd); } } } } }