Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Brennan1994 committed Oct 16, 2024
2 parents ea18d4a + 14fb368 commit 10584fe
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 130 deletions.
179 changes: 95 additions & 84 deletions HEC.FDA.Model/compute/ImpactAreaScenarioSimulation.cs

Large diffs are not rendered by default.

20 changes: 2 additions & 18 deletions HEC.FDA.Model/scenarios/Scenario.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,18 @@ namespace HEC.FDA.Model.scenarios
{
public class Scenario : IReportMessage
{
#region Fields
private readonly IList<ImpactAreaScenarioSimulation> _impactAreaSimulations;
#endregion
#region Properties
public IList<ImpactAreaScenarioSimulation> ImpactAreaSimulations
{
get
{
return _impactAreaSimulations;
}
}
public event MessageReportedEventHandler MessageReport;

public IList<ImpactAreaScenarioSimulation> ImpactAreas
{
get { return _impactAreaSimulations; }
}
#endregion
#region Constructors
internal Scenario()
{
_impactAreaSimulations = new List<ImpactAreaScenarioSimulation>();
_impactAreaSimulations = [];
}
public Scenario( IList<ImpactAreaScenarioSimulation> impactAreaSimulations)
{
_impactAreaSimulations = impactAreaSimulations;
}
#endregion

#region Methods
public ScenarioResults Compute(IProvideRandomNumbers randomProvider, ConvergenceCriteria convergenceCriteria)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<CheckBox
Grid.ColumnSpan="2"
Content="Calculate Default Threshold"
IsChecked="{Binding ScenarioReflectsWithoutProjCondition}"
IsChecked="{Binding CalculateDefaultThresholdChecked}"
IsEnabled="{Binding ScenarioReflectsEnabled}"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:HEC.FDA.View.ImpactAreaScenario.Results"
xmlns:utils="clr-namespace:HEC.FDA.View.Utilities"
mc:Ignorable="d"
xmlns:results="clr-namespace:HEC.FDA.ViewModel.ImpactAreaScenario.Results;assembly=HEC.FDA.ViewModel"
d:DataContext="{d:DesignInstance Type=results:SpecificIASResultVM}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<utils:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,6 @@ public ImpactAreaScenarioSimulation BuildSimulation()
return _SimulationBuilder.Build();
}

public void WithAdditionalThresholds(List<Threshold> additionalThresholds)
{
foreach (Threshold threshold in additionalThresholds)
{
_SimulationBuilder.WithAdditionalThreshold(threshold);
}
}
public void WithAdditionalThreshold(Threshold additionalThreshold)
{
_SimulationBuilder.WithAdditionalThreshold(additionalThreshold);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class SpecificIASEditorVM : BaseViewModel
private readonly Func<ChildElementComboItem> _SelectedStageDamage;
private bool _IsSufficientForCompute;
private string _IsSufficientForComputeTooltip;
private bool _ScenarioReflectsWithoutProjCondition = true;
private bool _calculateDefualtThresholdChecked = true;
private double _DefaultStage;
private bool _ScenarioReflectsEnabled;
private bool _HasNonFailureStageDamage;
Expand All @@ -62,10 +62,10 @@ public double DefaultStage
get { return _DefaultStage; }
set { _DefaultStage = value; NotifyPropertyChanged(); }
}
public bool ScenarioReflectsWithoutProjCondition
public bool CalculateDefaultThresholdChecked
{
get { return _ScenarioReflectsWithoutProjCondition; }
set { _ScenarioReflectsWithoutProjCondition = value; UpdateDefaultStageRequired(); NotifyPropertyChanged(); }
get { return _calculateDefualtThresholdChecked; }
set { _calculateDefualtThresholdChecked = value; UpdateDefaultStageRequired(); NotifyPropertyChanged(); }
}

public string IsSufficientForComputeTooltip
Expand Down Expand Up @@ -319,7 +319,7 @@ public static void UpdateElement(ObservableCollection<ChildElementComboItem> col

private void FillForm(SpecificIAS elem)
{
ScenarioReflectsWithoutProjCondition = elem.ScenarioReflectsWithoutProj;
CalculateDefaultThresholdChecked = elem.CalculateDefaultThreshold;
DefaultStage = elem.DefaultStage;
Thresholds.AddRange(elem.Thresholds);
//all the available elements have been loaded into this editor. We now want to select
Expand Down Expand Up @@ -715,7 +715,7 @@ public SpecificIAS CreateSpecificIAS()
List<ThresholdRowItem> thresholdRowItems = Thresholds;

SpecificIAS elementToSave = new(CurrentImpactArea.ID, flowFreqID, inflowOutID, ratingID, extIntID,
latStructID, stageDamID, thresholdRowItems, ScenarioReflectsWithoutProjCondition, DefaultStage,
latStructID, stageDamID, thresholdRowItems, CalculateDefaultThresholdChecked, DefaultStage,
HasNonFailureStageDamage, nonFailureStageDamID);
return elementToSave;
}
Expand Down Expand Up @@ -756,15 +756,15 @@ public bool HasLeveeSelected()
}
public void UpdateDefaultStageRequired()
{
DefaultStageRequired = !ScenarioReflectsWithoutProjCondition && !HasLeveeSelected();
DefaultStageRequired = !CalculateDefaultThresholdChecked && !HasLeveeSelected();
}
private void UpdateThresholdStageValue()
{
if (HasLeveeSelected())
{
DefaultStage = ((LateralStructureElement)SelectedLeveeFeatureElement.ChildElement).Elevation;
//disable the checkbox
ScenarioReflectsWithoutProjCondition = false;
CalculateDefaultThresholdChecked = false;
ScenarioReflectsEnabled = false;
}
else
Expand Down
29 changes: 18 additions & 11 deletions HEC.FDA.ViewModel/ImpactAreaScenario/SpecificIAS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public class SpecificIAS : BaseViewModel

public List<ThresholdRowItem> Thresholds { get; } = new List<ThresholdRowItem>();

public bool ScenarioReflectsWithoutProj {get;set;}
public double DefaultStage { get; set; }
public bool CalculateDefaultThreshold {get;set;}
public double DefaultStage { get; set; } = -999;
public bool HasNonFailureStageDamage { get; set; }
public int NonFailureStageDamageID { get; set; }

Expand All @@ -99,13 +99,13 @@ public class SpecificIAS : BaseViewModel
/// <param name="stageDamageID"></param>
/// <param name="thresholds"></param>
public SpecificIAS(int impactAreaID, int flowFreqID, int inflowOutflowID, int ratingID, int extIntID,
int leveeFailureID, int stageDamageID, List<ThresholdRowItem> thresholds, bool scenarioReflectsWithoutProj,
int leveeFailureID, int stageDamageID, List<ThresholdRowItem> thresholds, bool calculateDefaultThreshold,
double defaultStage, bool hasNonFailureStageDamage, int nonFailureStageDamageID) : base()
{
HasNonFailureStageDamage = hasNonFailureStageDamage;
NonFailureStageDamageID = nonFailureStageDamageID;
DefaultStage = defaultStage;
ScenarioReflectsWithoutProj = scenarioReflectsWithoutProj;
CalculateDefaultThreshold = calculateDefaultThreshold;
ImpactAreaID = impactAreaID;
FlowFreqID = flowFreqID;
InflowOutflowID = inflowOutflowID;
Expand Down Expand Up @@ -144,7 +144,7 @@ public SpecificIAS(XElement iasElem)
//check if new elements exist before reading
if (iasElem.Elements(SCENARIO_REFLECTS_WITHOUT_PROJ).Any())
{
ScenarioReflectsWithoutProj = Convert.ToBoolean(iasElem.Element(SCENARIO_REFLECTS_WITHOUT_PROJ).Attribute("value").Value);
CalculateDefaultThreshold = Convert.ToBoolean(iasElem.Element(SCENARIO_REFLECTS_WITHOUT_PROJ).Attribute("value").Value);
DefaultStage = double.Parse(iasElem.Element(DEFAULT_STAGE).Attribute("value").Value);
}
XElement thresholdElement = iasElem.Element(THRESHOLDS);
Expand Down Expand Up @@ -248,10 +248,17 @@ private SimulationCreator GetSimulationCreator()
AggregatedStageDamageElement stageDamageElem = (AggregatedStageDamageElement)StudyCache.GetChildElementOfType(typeof(AggregatedStageDamageElement), StageDamageID);
AggregatedStageDamageElement nonFailureStageDamageElem = (AggregatedStageDamageElement)StudyCache.GetChildElementOfType(typeof(AggregatedStageDamageElement), NonFailureStageDamageID);

SimulationCreator sc = new SimulationCreator(freqElem, inOutElem, ratElem, extIntElem, leveeElem, stageDamageElem, ImpactAreaID,
HasNonFailureStageDamage, nonFailureStageDamageElem);
SimulationCreator sc = new(freqElem, inOutElem, ratElem, extIntElem, leveeElem, stageDamageElem, ImpactAreaID, HasNonFailureStageDamage, nonFailureStageDamageElem);

int thresholdIndex = 1;
//otherwise we'll calculate it ourselves in the model.
if (!CalculateDefaultThreshold)
{
ConvergenceCriteria cc = StudyCache.GetStudyPropertiesElement().GetStudyConvergenceCriteria();
Threshold defaultThreshold = new(ImpactAreaScenarioSimulation.DEFAULT_THRESHOLD_ID, cc, ThresholdEnum.DefaultExteriorStage, DefaultStage);
sc.WithAdditionalThreshold(defaultThreshold);
}

int thresholdID = 1;
foreach (ThresholdRowItem thresholdRow in Thresholds)
{
double thresholdValue = 0;
Expand All @@ -260,9 +267,9 @@ private SimulationCreator GetSimulationCreator()
thresholdValue = thresholdRow.ThresholdValue.Value;
}
ConvergenceCriteria cc = StudyCache.GetStudyPropertiesElement().GetStudyConvergenceCriteria();
Threshold threshold = new Threshold(thresholdIndex, cc, thresholdRow.ThresholdType.Metric, thresholdValue);
Threshold threshold = new Threshold(thresholdID, cc, thresholdRow.ThresholdType.Metric, thresholdValue);
sc.WithAdditionalThreshold(threshold);
thresholdIndex++;
thresholdID++;
}

return sc;
Expand Down Expand Up @@ -320,7 +327,7 @@ public XElement WriteToXML()
iasElement.Add(stageDamageElem);

XElement scenarioReflectsWithoutProjElem = new XElement(SCENARIO_REFLECTS_WITHOUT_PROJ);
scenarioReflectsWithoutProjElem.SetAttributeValue("value", ScenarioReflectsWithoutProj);
scenarioReflectsWithoutProjElem.SetAttributeValue("value", CalculateDefaultThreshold);
iasElement.Add(scenarioReflectsWithoutProjElem);

XElement defaultStageElem = new XElement(DEFAULT_STAGE);
Expand Down

0 comments on commit 10584fe

Please sign in to comment.