// Copyright (C) Stichting Deltares 2019. 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; 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; /// /// 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; } /// /// 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; 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; } } } /// /// 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 } /// /// Returns a that represents this instance. /// /// /// A that represents this instance. /// public override string ToString() { string description = ""; 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; } } }