// Copyright (C) Stichting Deltares 2024. 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.Wti2017;
private Enum calculationModel;
///
/// Initializes a new instance of the class.
///
public DamFailureMechanismeCalculationSpecification()
{
//Todo interface
failureMechanismSystemType = FailureMechanismSystemType.StabilityInside;
FailureMechanismParametersMStab = new FailureMechanismParametersMStab();
CalculationModel = FailureMechanismParametersMStab.MStabParameters.Model;
FailureMechanismParametersMStab.MStabParameters.GridPosition = StabilityGridPosition.Right;
}
///
/// Gets or sets the failure mechanism parameters MStab.
///
///
/// The failure mechanism parameters for MStab.
///
public FailureMechanismParametersMStab FailureMechanismParametersMStab { get; set; }
///
/// 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.
PipingModelType oldPipingModelType = pipingModelType;
switch (failureMechanismSystemType)
{
case FailureMechanismSystemType.StabilityInside:
FailureMechanismParametersMStab.MStabParameters.GridPosition = StabilityGridPosition.Right;
break;
case FailureMechanismSystemType.StabilityOutside:
FailureMechanismParametersMStab.MStabParameters.GridPosition = StabilityGridPosition.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; set; }
///
/// 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 = (StabilityModelType) value;
}
}
}
///
/// Gets or sets the type of the stability model.
///
///
/// The type of the stability model.
///
public StabilityModelType 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)
{
FailureMechanismSystemType = damFailureMechanismeCalculation.failureMechanismSystemType;
FailureMechanismParametersMStab.Assign(damFailureMechanismeCalculation.FailureMechanismParametersMStab.Clone());
//assign interface
}
///
/// Returns a that represents this instance.
///
///
/// A that represents this instance.
///
public override string ToString()
{
var description = "";
description += $"{FailureMechanismSystemType}";
if ((FailureMechanismSystemType == FailureMechanismSystemType.StabilityInside) ||
(FailureMechanismSystemType == FailureMechanismSystemType.StabilityOutside))
{
//interface?
description += $" ({FailureMechanismParametersMStab.MStabParameters.Model})";
}
return description;
}
}