// 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 Deltares.DamEngine.Data.General.Sensors; using Deltares.DamEngine.Data.Standard.Validation; namespace Deltares.DamEngine.Data.General { /// /// /// public class DamFailureMechanismeCalculationSpecification { private FailureMechanismSystemType failureMechanismSystemType; private PipingModelType pipingModelType = PipingModelType.Sellmeijer4Forces; private Enum calculationModel; private FailureMechanismParametersMStab failureMechanismParametersMStab; private static DamProjectType damProjectType; private StabilityKernelType stabilityKernelType = StabilityKernelType.DamClassic; private RegionalAssessmentScenarioJobSettings regionalAssessmentScenarioJobSettings; /// /// Initializes a new instance of the class. /// public DamFailureMechanismeCalculationSpecification() { //Todo interface failureMechanismSystemType = FailureMechanismSystemType.StabilityInside; failureMechanismParametersMStab = new FailureMechanismParametersMStab(); CalculationModel = failureMechanismParametersMStab.MStabParameters.Model; FailureMechanismParametersMStab.MStabParameters.GridPosition = MStabGridPosition.Right; regionalAssessmentScenarioJobSettings = new RegionalAssessmentScenarioJobSettings(); } /// /// Gets or sets the failure mechanism parameters MStab. /// /// /// The failure mechanism parameters for MStab. /// public FailureMechanismParametersMStab FailureMechanismParametersMStab { get { return failureMechanismParametersMStab; } set { failureMechanismParametersMStab = value; } } /// /// Gets or sets the type of the failure mechanism system. /// /// /// The type of the failure mechanism system. /// public FailureMechanismSystemType FailureMechanismSystemType { get { return failureMechanismSystemType; } set { if (failureMechanismSystemType != value) { failureMechanismSystemType = value; // To solve MWDAM-592, remember the current pipingmodeltype as this gets reset by setting the // calculationmodel. Only switch it back when needed. var oldPipingModelType = pipingModelType; // foreach (Enum possibleModel in this.GetDomain("CalculationModel")) // { // this.CalculationModel = possibleModel; // break; // } #Bka: I think this is only needed for the UI. switch (failureMechanismSystemType) { case FailureMechanismSystemType.StabilityInside: failureMechanismParametersMStab.MStabParameters.GridPosition = MStabGridPosition.Right; break; case FailureMechanismSystemType.StabilityOutside: failureMechanismParametersMStab.MStabParameters.GridPosition = MStabGridPosition.Left; break; case FailureMechanismSystemType.Piping: PipingModelType = oldPipingModelType; break; } } } } /// /// Gets or sets the type of the piping model. /// /// /// The type of the piping model. /// public PipingModelType PipingModelType { get { return pipingModelType; } set { pipingModelType = value; if (failureMechanismSystemType == FailureMechanismSystemType.Piping) { CalculationModel = pipingModelType; } } } /// /// Gets or sets the type of the dam project. /// /// /// The type of the dam project. /// public static DamProjectType DamProjectType { get { return damProjectType; } set { damProjectType = value; } } /// /// The calculationmodel is only needed to support the selection of the modeltype in the UI. The dropdownlist /// in the UI depends on this. This set can be filled with any proper types (for piping, stabilty etc) for any /// mechanisme instead of the fixed types per mechanisme. /// public Enum CalculationModel { get { return calculationModel; } set { calculationModel = value; if (value is PipingModelType) { pipingModelType = (PipingModelType) value; } else { failureMechanismParametersMStab.MStabParameters.Model = (MStabModelType)value; } } } /// /// Gets or sets the type of the stability model. /// /// /// The type of the stability model. /// public MStabModelType StabilityModelType { get { return failureMechanismParametersMStab.MStabParameters.Model; } set { failureMechanismParametersMStab.MStabParameters.Model = value; if (failureMechanismSystemType != FailureMechanismSystemType.Piping) { CalculationModel = value; } } } /// /// Gets or sets the type of the stability kernel. /// /// /// The type of the stability kernel. /// public StabilityKernelType StabilityKernelType { get { return stabilityKernelType; } set { stabilityKernelType = value; } } /// /// Gets or sets the assessment scenario job settings. /// /// /// The assessment scenario job settings. /// public RegionalAssessmentScenarioJobSettings AssessmentScenarioJobSettings { get { return regionalAssessmentScenarioJobSettings; } set { regionalAssessmentScenarioJobSettings = value; } } /// /// Assigns the specified dam failure mechanisme calculation. /// /// The dam failure mechanisme calculation. public void Assign(DamFailureMechanismeCalculationSpecification damFailureMechanismeCalculation) { this.FailureMechanismSystemType = damFailureMechanismeCalculation.failureMechanismSystemType; this.FailureMechanismParametersMStab.Assign(damFailureMechanismeCalculation.FailureMechanismParametersMStab.Clone()); //assign interface } /// /// Clones this instance. /// /// public DamFailureMechanismeCalculationSpecification Clone() { DamFailureMechanismeCalculationSpecification damFailureMechanismeCalculation = new DamFailureMechanismeCalculationSpecification(); damFailureMechanismeCalculation.Assign(this); return damFailureMechanismeCalculation; } /// /// Returns a that represents this instance. /// /// /// A that represents this instance. /// public override string ToString() { string description = ""; description += String.Format("{0}", StabilityKernelType); description += String.Format("{0}", this.FailureMechanismSystemType); if ((this.FailureMechanismSystemType == FailureMechanismSystemType.StabilityInside) || (this.FailureMechanismSystemType == FailureMechanismSystemType.StabilityOutside)) { //interface? description += String.Format(" ({0})", this.FailureMechanismParametersMStab.MStabParameters.Model); } return description; } /// /// Determines whether slip circle definition is undefined. /// /// /// true if [is slip circle definition undefined]; otherwise, false. /// public bool IsSlipCircleDefinitionUndefined() { bool isSlipCircleDefinitionUndefined = (failureMechanismParametersMStab.MStabParameters.SlipCircleDefinition == null); if (!isSlipCircleDefinitionUndefined) { isSlipCircleDefinitionUndefined = (failureMechanismParametersMStab.MStabParameters.SlipCircleDefinition.UpliftVanLeftGridHorizontalPointCount == 0); } return isSlipCircleDefinitionUndefined; } } }