using System; using System.ComponentModel; using System.Xml.Serialization; using Deltares.Geographic; using Deltares.Probabilistic; using Deltares.Standard; using Deltares.Standard.Attributes; using Deltares.Standard.EventPublisher; using Deltares.Standard.Language; using Deltares.Standard.Units; using Deltares.Standard.Validation; namespace Deltares.DeltaModel { /// /// Hydraulic Structures like gates, concrete defense walls, etc /// Structures are line objects and have a begin and endpoint (location points). /// Their line symbology in the map is different from the dike. /// They have a name, description, geometry, and other assessment specific properties. /// public class Structure : DikeCrossSection { private string description; private double offset = -1; private double orientation; /// /// Initializes a new instance of the class. /// public Structure() { base.Name = string.Empty; getErrorMessageForMissingBoundaryLink = () => String.Format(LocalizationManager.GetTranslatedText(this, "StructureNotLinkedMessage"), Name); GateHeightStochast = new Stochast { Owner = this, DistributionType = DistributionType.Normal, Deviation = 0.05 }; GateWidthStochast = new Stochast { Owner = this, DistributionType = DistributionType.Normal, Deviation = 0.05 }; GateThresholdStochast = new Stochast { Owner = this, DistributionType = DistributionType.LogNormal, DeviationType = StochastDeviationType.Relative, Variation = 0.15, Minimum = 0.1, Maximum = 10.0 }; } /// /// Gets or sets the description for the Structure. /// /// /// The description. /// [Data] [PropertyOrder(0, 1)] public string Description { get { return description; } set { DataEventPublisher.BeforeChange(this, "Description"); description = value; DataEventPublisher.AfterChange(this, "Description"); } } [Unit(UnitType.Depth)] [Format("F2")] [PropertyOrder(1, 6)] [XmlIgnore] public double GateHeight { get { return TransformerManager.GetTransformedValue(this, p => p.GateHeight, GateHeightStochast.Mean); } set { var measuredValue = TransformerManager.SetTransformedValue(this, s => s.GateHeight, value); if (GateHeightStochast.Mean != measuredValue) { DataEventPublisher.BeforeChange(this, "GateHeight"); GateHeightStochast.Mean = measuredValue; DataEventPublisher.AfterChange(this, "GateHeight"); } } } /// /// Gets or sets the Level of crest of structures /// TODO: Comment /// /// /// The Height (is a level, not the structure height) /// [Unit(UnitType.Depth)] [Format("F2")] [PropertyOrder(1, 7)] [Category("KernData")] [Stochast(AutoAssociatedProperty = true)] [Translation("GateHeight")] public Stochast GateHeightStochast { get; private set; } /// ///61 Orientation of the normal of the structure 0 (degree North) /// TODO: Comment /// [Unit(UnitType.Angle)] [Minimum(0.0, false)] [Maximum(360.0)] [Format("F2")] [PropertyOrder(1, 9)] [Category("KernData")] [Validate] public double Orientation { get { return orientation; } set { DataEventPublisher.BeforeChange(this, "Orientation"); orientation = value; DataEventPublisher.AfterChange(this, "Orientation"); } } [Unit(UnitType.Length)] [Format("F2")] [PropertyOrder(1, 10)] [Minimum(0.0, ValidationResultType.Warning, false)] [Validate] [XmlIgnore] public double GateWidth { get { return TransformerManager.GetTransformedValue(this, p => p.GateWidth, GateWidthStochast.Mean); } set { var measuredValue = TransformerManager.SetTransformedValue(this, s => s.GateWidth, value); if (GateWidthStochast.Mean != measuredValue) { DataEventPublisher.BeforeChange(this, "GateWidth"); GateWidthStochast.Mean = measuredValue; DataEventPublisher.AfterChange(this, "GateWidth"); } } } [Unit(UnitType.Length)] [Format("F2")] [PropertyOrder(1, 11)] [Minimum(0.0, ValidationResultType.Warning, false)] [Validate] [XmlIgnore] public double GateThreshold { get { return TransformerManager.GetTransformedValue(this, p => p.GateThreshold, GateThresholdStochast.Mean); } set { var measuredValue = TransformerManager.SetTransformedValue(this, s => s.GateThreshold, value); if (GateThresholdStochast.Mean != measuredValue) { DataEventPublisher.BeforeChange(this, "GateThreshold"); GateThresholdStochast.Mean = measuredValue; DataEventPublisher.AfterChange(this, "GateThreshold"); } } } /// /// Gets or sets the gate width of the Structure. /// 106 Width of flow apertures /// TODO: Comment /// /// /// The Width. /// [Unit(UnitType.Length)] [Format("F2")] [PropertyOrder(1, 11)] [XmlOldName("GateWidth")] [Category("KernData")] [Validate] [Stochast(AutoAssociatedProperty = true)] [Translation("GateWidth")] public Stochast GateWidthStochast { get; private set; } /// /// Gets or sets the gate width of the Structure. /// 106 Width of flow apertures /// TODO: Comment /// /// /// The Width. /// [Unit(UnitType.Length)] [Format("F2")] [PropertyOrder(1, 11)] [XmlOldName("GateWidth")] [Category("KernData")] [Validate] [Stochast(AutoAssociatedProperty = true)] [Translation("GateThreshold")] public Stochast GateThresholdStochast { get; private set; } /// /// Gets or sets the name of the Structure. /// /// /// The name. /// [Data] [PropertyOrder(0, 0)] public override string Name { get { return base.Name; } set { base.Name = value; } } /// /// Gets the offset of the Structure. /// /// /// The offset. /// [Unit(UnitType.Length)] [Format("F2")] [ReadOnly(true)] [PropertyOrder(1, 3)] public override double Offset { get { return base.Offset; } } /// /// Determines whether the specified property is visible. /// /// The property. /// true if property is part of Structure; otherwise, false. public override bool IsVisible(string property) { switch (property) { case "Name": case "Description": case "X": case "Y": case "DikeLine": case "IsAutoLinkedToHydraulicBoundary": case "HydraulicBoundary1": case "HydraulicBoundary2": case "HydraulicBoundaryPartitioning": case "Orientation": case "GateWidth": case "GateWidthStochast": return true; default: return false; } } /// /// Determines whether the specified property is enabled. /// /// The property. /// /// true if property is part of Structure; /// base.IsEnabled() for HydraulicBoundary or AssessmentLevel /// otherwise, false. /// public override bool IsEnabled(string property) { switch (property) { case "X": case "Y": return false; case "Name": case "Description": case "IsAutoLinkedToHydraulicBoundary": return true; case "HydraulicBoundary1": case "HydraulicBoundary2": case "HydraulicBoundaryPartitioning": case "AssessmentLevel": return base.IsEnabled(property); case "GateHeight": case "GateWidth": return false; case "GateHeightStochast": case "GateWidthStochast": case "Orientation": return true; default: return false; } } /// /// Gets the representive point. /// /// the representive point public override IGeographicPoint GetRepresentivePoint() { return this; } } }