Index: DamEngine/trunk/src/Deltares.DamEngine.Data/General/LocationJob.cs
===================================================================
diff -u -r1289 -r1290
--- DamEngine/trunk/src/Deltares.DamEngine.Data/General/LocationJob.cs (.../LocationJob.cs) (revision 1289)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/General/LocationJob.cs (.../LocationJob.cs) (revision 1290)
@@ -19,54 +19,70 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System;
using System.Collections.Generic;
using System.Linq;
-using Deltares.DamEngine.Data.Design;
using Deltares.DamEngine.Data.General.Results;
using Deltares.DamEngine.Data.General.TimeSeries;
using Deltares.DamEngine.Data.RegionalAssessmentResults;
-using Deltares.DamEngine.Data.Standard.Calculation;
using Deltares.DamEngine.Data.Standard.Validation;
namespace Deltares.DamEngine.Data.General
{
+ ///
+ /// Interface for location job
+ ///
public interface ILocationJob
{
Location Location { get; }
IEnumerable RegionalScenarioResults { get; }
bool HasRegionalScenarioResults { get; }
}
+ ///
+ /// Class holding LocationJob data
+ ///
+ ///
+ ///
public class LocationJob : DamJob, ILocationJob
{
private TimeSerie waterLevelTimeSerie = new TimeSerie();
private LocationResult locationResult = new LocationResult();
-
- private static ScenarioType currentScenarioType = ScenarioType.Scenario01;
- private static DateTime currentTime = DateTime.Today;
private static DamProjectType damProjectType = DamProjectType.Operational;
-
- private double designRequiredFactor = 0.0;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The subject.
public LocationJob(object subject)
: base(subject)
{
}
+ ///
+ /// Gets or sets the location.
+ ///
+ ///
+ /// The location.
+ ///
[Validate]
public Location Location
{
get
{
- return this.Subject as Location;
+ return Subject as Location;
}
set
{
- this.Subject = value;
+ Subject = value;
}
}
+ ///
+ /// Gets or sets the water level time serie.
+ ///
+ ///
+ /// The water level time serie.
+ ///
public TimeSerie WaterLevelTimeSerie
{
get { return waterLevelTimeSerie; }
@@ -76,22 +92,40 @@
}
}
+ ///
+ /// Gets the regional scenario results.
+ ///
+ ///
+ /// The regional scenario results.
+ ///
public virtual IEnumerable RegionalScenarioResults
{
get
{
- return !this.HasRegionalScenarioResults ?
- new List() : this.locationResult.RegionalScenariosResult.RegionalScenarioResults;
+ return !HasRegionalScenarioResults ?
+ new List() : locationResult.RegionalScenariosResult.RegionalScenarioResults;
}
}
+ ///
+ /// Gets a value indicating whether this instance has regional scenario results.
+ ///
+ ///
+ /// true if this instance has regional scenario results; otherwise, false.
+ ///
public bool HasRegionalScenarioResults
{
- get { return this.locationResult != null && this.locationResult.RegionalScenariosResult != null &&
- this.locationResult.RegionalScenariosResult.RegionalScenarioResults.Any();
+ get { return locationResult != null && locationResult.RegionalScenariosResult != null &&
+ locationResult.RegionalScenariosResult.RegionalScenarioResults.Any();
}
}
+ ///
+ /// Gets or sets the location result.
+ ///
+ ///
+ /// The location result.
+ ///
public virtual LocationResult LocationResult
{
get { return locationResult; }
@@ -101,236 +135,27 @@
}
}
- private bool HasUsableStabilityTimeSerieEntries()
- {
- var res = false;
- foreach (var timeSerieEntry in locationResult.StabilityTimeSerie.Entries)
- {
- if (timeSerieEntry.Value != Double.NaN)
- {
- res = true;
- break;
- }
- }
- return res;
- }
-
- public bool HasTimeSeriesLocationResults
- {
- get
- {
- if (locationResult == null)
- return false;
- return ((locationResult.PipingTimeSerie != null && locationResult.PipingTimeSerie.Entries.Count > 0) ||
- (locationResult.StabilityTimeSerie != null &&
- locationResult.StabilityTimeSerie.Entries.Count > 0 && HasUsableStabilityTimeSerieEntries()));
- }
- }
-
///
- /// Return the result of the profile with highest probability of occurrence
+ /// Gets or sets the type of the dam project.
///
- ///
- ///
- /// Return result with the lowest safetyfactor
- ///
- ///
- ///
- ///
- public RegionalScenarioProfileResult GetRWScenarioResultWithLowestSafetyFactor(ScenarioType scenarioType)
- {
- if (this.HasRegionalScenarioResults)
- {
- var scenarioResult = this.LocationResult.RegionalScenariosResult.GetScenarioResult(scenarioType);
- if (scenarioResult != null && scenarioResult.RegionalScenarioProfileResults.Count > 0)
- {
- RegionalScenarioProfileResult rwScenarioProfileResult = scenarioResult.RegionalScenarioProfileResults[0];
- for (int i = 1; i < scenarioResult.RegionalScenarioProfileResults.Count; i++)
- {
- if (scenarioResult.RegionalScenarioProfileResults[i].SafetyFactor < rwScenarioProfileResult.SafetyFactor)
- {
- rwScenarioProfileResult = scenarioResult.RegionalScenarioProfileResults[i];
- }
- }
- return rwScenarioProfileResult;
- }
- }
- return null;
- }
-
- public bool HasScenarioResults
- {
- get
- {
- List scenarios = Location.Scenarios;
- foreach (var scenario in scenarios)
- {
- foreach (var calculationResult in scenario.CalculationResults)
- {
- if ((calculationResult.SafetyFactor != null) || (calculationResult.CalculationResult == CalculationResult.UnexpectedError) )
- {
- return true;
- }
- }
- }
- return false;
- }
- }
-
- ///
- /// Get lowest safetyfactor of all scenarios
- ///
- ///
- private double GetLowestRealSafetyFactorFromScenarios()
- {
- var res = double.MaxValue;
- List scenarios = Location.Scenarios;
- foreach (var scenario in scenarios)
- {
- foreach (var calculationResult in scenario.CalculationResults)
- {
- if (calculationResult.CalculationResult == CalculationResult.UnexpectedError)
- {
- res = -1;
- }
- if (calculationResult.SafetyFactor != null)
- {
- if (calculationResult.SafetyFactor.Value < res)
- {
- res = calculationResult.SafetyFactor.Value;
-// if (calculationResult.RequiredSafetyFactor != null) #Bka should come from input, not results
-// {
-// designRequiredFactor = calculationResult.RequiredSafetyFactor.Value;
-// }
- }
- }
- }
- }
- if (res == double.MaxValue) res = DamGlobalConstants.NoRunValue;
- return res;
- }
-
- public double SafetyFactor
- {
- get
- {
- if (DamProjectType == DamProjectType.Operational)
- {
- if (this.HasTimeSeriesLocationResults)
- {
- TimeSerie timeSerie = this.LocationResult.StabilityTimeSerie;
- return timeSerie.GetValue(CurrentTime);
- }
- else
- {
- return DamGlobalConstants.NoRunValue;
- }
- }
- else if (DamProjectType == DamProjectType.AssessmentRegional)
- {
- if (this.HasRegionalScenarioResults && GetRWScenarioResultWithLowestSafetyFactor(currentScenarioType) != null)
- {
- return GetRWScenarioResultWithLowestSafetyFactor(currentScenarioType).SafetyFactor;
- }
- else
- {
- if (this.locationResult.RegionalScenariosResult != null &&
- this.locationResult.RegionalScenariosResult.CalculationResult == CalculationResult.RunFailed)
- {
- // DamGlobalConstants.NoRunValue is the default result resulting in NoRun whereas the
- // status must be failed. So when failed set to -1.
- return -1;
- }
- else
- {
- return DamGlobalConstants.NoRunValue;
- }
- }
- }
- else if (DamProjectType == DamProjectType.Design)
- {
- return GetLowestRealSafetyFactorFromScenarios();
- }
- else
- {
- return DamGlobalConstants.NoRunValue;
- }
- }
- }
-
- public double DetrimentFactor
- {
- get
- {
- if (DamProjectType == DamProjectType.Design)
- {
- return designRequiredFactor;
- }
- else
- {
- // For Piping in Assesment projects, ignore the given detriment factor and use the required safety for Piping
- if (DamProjectType == DamProjectType.AssessmentRegional && (currentScenarioType == ScenarioType.Scenario10 || currentScenarioType == ScenarioType.Scenario11))
- {
- return DamGlobalConstants.RequiredSafetyPipingForAssessment;
- }
- return this.Location.DetrimentFactor;
- }
- }
- }
-
- public bool AreRWScenarioResultsMixed(ScenarioType scenarioType)
- {
- if (this.HasRegionalScenarioResults)
- {
- var scenarioResult = this.LocationResult.RegionalScenariosResult.GetScenarioResult(scenarioType);
- if (scenarioResult != null && scenarioResult.RegionalScenarioProfileResults.Count > 0)
- {
- var aboveRequiredSafety = false;
- var belowRequiredSafety = false;
- for (int i = 0; i < scenarioResult.RegionalScenarioProfileResults.Count; i++)
- {
- if (!aboveRequiredSafety)
- {
- aboveRequiredSafety = scenarioResult.RegionalScenarioProfileResults[i].SafetyFactor >= DetrimentFactor;
- }
- if (!belowRequiredSafety)
- {
- belowRequiredSafety = scenarioResult.RegionalScenarioProfileResults[i].SafetyFactor < DetrimentFactor;
- }
- }
- return aboveRequiredSafety && belowRequiredSafety;
- }
- }
- return false;
- }
-
- public JobResult Result
- {
- get
- {
- if (DamProjectType == DamProjectType.AssessmentRegional && AreRWScenarioResultsMixed(currentScenarioType))
- {
- return JobResult.Mixed;
- }
- return JobResultInterpreter.GetJobResult(SafetyFactor, DetrimentFactor, true);
- }
- }
-
- public static DateTime CurrentTime
- {
- get { return currentTime; }
- set { currentTime = value; }
- }
-
+ ///
+ /// The type of the dam project.
+ ///
public static DamProjectType DamProjectType
{
get { return damProjectType; }
set { damProjectType = value; }
}
-
+
+ ///
+ /// Returns a that represents this instance.
+ ///
+ ///
+ /// A that represents this instance.
+ ///
public override string ToString()
{
- return this.Location != null ? this.Location.ToString() : "";
- }
+ return Location != null ? Location.ToString() : "";
+ }
}
}