public SlopedFacilityWorksheet(SlopedFacility facility)
        {
            InitializeComponent();

              _facility = facility;

              this.slopedFacilityBindingSource.DataSource = _facility;
              this.segmentsBindingSource.DataSource = _facility.Segments;
        }
Example #2
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            try
              {
            //Create a new segment
            SlopedFacilitySegment segment = new SlopedFacilitySegment();

            //Assign values to segment. All segments have these fields:
            segment.SegmentLengthFt = 10;
            segment.CheckDamLengthFt = 2;
            segment.SlopeRatio = 0.02;
            segment.SideSlopeRightRatio = 4;
            segment.SideSlopeLeftRatio = 4;
            segment.DownstreamDepthIn = 9;
            segment.LandscapeWidthFt = 2;

            segment.RockStorageWidthFt = 4; //Only facility types with rock galleries use this field; see parameter matrix for details

            //Create a catchment, no change for sloped facilities
            Catchment catchment = new Catchment("Test Catchment");

            //Create a SlopedFacility object, constructed the same way as a standard facility
            SlopedFacility facility = new SlopedFacility(FacilityType.Swale, FacilityConfiguration.A, catchment);

            //Segments can be added or deleted from the sloped facility.
            facility.AddSegment(segment);

            facility.DeleteSegment(segment);

            PerformCalculations();
              }
              catch (Exception ex)
              {
            MessageBox.Show("Error: " + ex.Message);
              }
        }
Example #3
0
 /// <summary>
 /// Constructor for a sloped facility
 /// </summary>
 /// <param name="type">The FacilityType; should be Swale or SlopedPlanter</param>
 /// <param name="configuration">The Configuration of the facility</param>
 /// <param name="catchment">The catchment for the facility</param>
 /// <param name="segments">A list of Segments to load the facility with</param>
 public SlopedFacility(FacilityType type, FacilityConfiguration configuration, Catchment catchment, List<SlopedFacilitySegment> segments)
     : base(type, configuration, catchment)
 {
     _segments = segments;
       SlopedFacility._this = this;
 }
Example #4
0
 /// <summary>
 /// Executes the calculator and returns a PacResults. Supports Category 4 facilities.
 /// </summary>
 /// <param name="catchment">A catchment object defining the hydrologic parameters of the catchment area to be evaluated.</param>
 /// <param name="preCatchment">A catchment object defining the hydrologic parameters of the pre-developed catchment area to be evaluated.</param>
 /// <param name="slopedFacility">A SlopedFacility object defining the stormwater management facility to be evaluated.</param>
 /// <param name="category">Identifies the Hierarchy Category the proposed facility will be evaluated against. Must be an integer from 1 to 4.</param>
 /// <returns>A PacResults object containing the results of the calculation.</returns>
 public static PacResults PerformCalculations(Catchment catchment, Catchment preCatchment, SlopedFacility slopedFacility, int category)
 {
     return(PerformCalculations(catchment, preCatchment, (Facility)slopedFacility, category, 'A'));
 }
 /// <summary>
 /// Constructor for a sloped facility segment.
 /// Assigns segment to current sloped facility pointer.
 /// </summary>
 public SlopedFacilitySegment()
 {
     _facility = SlopedFacility.GetSlopedFacility();
 }
        private SlopedFacility _facility; // Parent

        /// <summary>
        /// Constructor for a sloped facility segment
        /// </summary>
        public SlopedFacilitySegment(SlopedFacility facility)
        {
            _facility = facility;
        }
 /// <summary>
 /// Constructor for a sloped facility segment.
 /// Assigns segment to current sloped facility pointer.
 /// </summary>
 public SlopedFacilitySegment()
 {
     _facility = SlopedFacility.GetSlopedFacility();
 }
 /// <summary>
 /// Constructor for a sloped facility segment
 /// </summary>
 public SlopedFacilitySegment(SlopedFacility facility)
 {
     _facility = facility;
 }
Example #9
0
        /// <summary>
        /// Performs checks to determine whether a Facility has required parameters assigned, and that
        /// all parameters are valid.
        /// </summary>
        /// <param name="facility">The Facility to validate</param>
        /// <param name="category">The Hierarchy Category the facility will be validated against</param>
        /// <param name="message">A message indicating the first error found in an invalid facility,
        /// or "Valid Configuration" if the facility is valid.</param>
        /// <returns>True if the facility parameters are valid, otherwise false</returns>
        public static bool Validate(Facility facility, int category, out string message)
        {
            facility._validConfiguration = true;

            switch (category)
            {
            case 1:
                if (facility._configuration != FacilityConfiguration.A &&
                    facility._configuration != FacilityConfiguration.B)
                {
                    message = "Only Configuration A or B may be used for Category 1";
                    facility._validConfiguration = false;
                    return(false);
                }
                break;

            case 2:
                break;

            case 3:
                if (facility._configuration == FacilityConfiguration.E ||
                    facility._configuration == FacilityConfiguration.F)
                {
                    message = "Configuration E and F may not be used for Category 3";
                    facility._validConfiguration = false;
                    return(false);
                }
                break;

            case 4:
                if (facility._configuration == FacilityConfiguration.E ||
                    facility._configuration == FacilityConfiguration.F)
                {
                    message = "Configuration E and F may not be used for Category 4";
                    facility._validConfiguration = false;
                    return(false);
                }
                break;

            default:
                message = "Unknown configuration, unable to validate facility";
                facility._validConfiguration = false;
                return(false);
            }

            Stack <string> invalidated = new Stack <string>();

            switch (facility.Type)
            {
            case FacilityType.Basin:
            {
                switch (facility.Shape)
                {
                case FacilityShape.Rectangle:
                    if (facility.BottomWidthFt < 0)
                    {
                        invalidated.Push("Bottom Width must be greater than or equal to zero.");
                    }
                    if (facility.SideSlopeRatio < 0)
                    {
                        invalidated.Push("Side Slope Ratio must be greater than or equal to zero.");
                    }
                    if (facility.FreeboardIn < 0)
                    {
                        invalidated.Push("Freeboard must be greater than or equal to zero.");
                    }
                    break;

                case FacilityShape.Amoeba:
                    if (facility.BottomPerimeterLengthFt < Math.Sqrt(4 * facility.BottomAreaSqFt * Math.PI))
                    {
                        invalidated.Push("Bottom Perimeter Length must be greater than or equal to the circumference of a circle with area equal to bottom area.");
                    }
                    if (facility.SideSlopeRatio < 0)
                    {
                        invalidated.Push("Side Slope Ratio must be greater than or equal to zero.");
                    }
                    if (facility.FreeboardIn < 0)
                    {
                        invalidated.Push("Freeboard must be greater than or equal to zero.");
                    }
                    break;

                case FacilityShape.UserDefined:
                    if (facility.SurfaceAreaAtStorageDepth1SqFt < facility.BottomAreaSqFt)
                    {
                        invalidated.Push("Surface Area at Storage Depth 1 must be greater than or equal to the Bottom Area.");
                    }
                    if (facility.HasSecondaryOverflow && (facility.SurfaceAreaAtStorageDepth2SqFt < facility.SurfaceAreaAtStorageDepth1SqFt))
                    {
                        invalidated.Push("Surface Area at Storage Depth 2 must be greater than or equal to the Surface Area at Storage Depth 1.");
                    }
                    break;

                default:
                    break;
                }

                if (facility.BottomAreaSqFt < 0)
                {
                    invalidated.Push("Bottom Area must be greater than or equal to zero.");
                }
                if (facility.StorageDepth1In <= 0)
                {
                    invalidated.Push("Storage Depth 1 must be greater than zero.");
                }

                if (facility.HasRockStorage && (facility.RockStorageBottomAreaSqFt <= 0))
                {
                    invalidated.Push("Rock Storage Bottom Area must be greater than zero.");
                }

                if (facility.HasSecondaryOverflow && (facility.StorageDepth2In <= facility.StorageDepth1In))
                {
                    invalidated.Push("Storage Depth 2 must be greater than or equal to Storage Depth 1.");
                }
                break;
            }

            case FacilityType.PlanterFlat:
            {
                if (facility.BottomAreaSqFt <= 0)
                {
                    invalidated.Push("Bottom Area must be greater than zero.");
                }
                if (facility.StorageDepth1In <= 0)
                {
                    invalidated.Push("Storage Depth 1 must be greater than zero.");
                }

                if (facility.HasRockStorage && (facility.RockStorageBottomAreaSqFt < 0))
                {
                    invalidated.Push("Rock Storage Bottom Area must be greater than or equal to zero.");
                }

                if (facility.HasSecondaryOverflow && (facility.StorageDepth2In <= facility.StorageDepth1In))
                {
                    invalidated.Push("Storage Depth 2 must be greater than Storage Depth 1.");
                }
                break;
            }

            case FacilityType.PlanterSloped:
            case FacilityType.Swale:
            {
                if (facility is SlopedFacility)
                {
                    SlopedFacility slopedFacility = facility as SlopedFacility;
                    foreach (SlopedFacilitySegment segment in slopedFacility.Segments)
                    {
                        if (segment.SegmentLengthFt <= 0)
                        {
                            invalidated.Push("Segment " + (slopedFacility.Segments.IndexOf(segment) + 1).ToString()
                                             + " Segment Length must be greater than zero.");
                        }
                        if (segment.CheckDamLengthFt < 0)
                        {
                            invalidated.Push("Segment " + (slopedFacility.Segments.IndexOf(segment) + 1).ToString()
                                             + " Check Dam Length must be greater than or equal to zero.");
                        }
                        if (segment.SlopeRatio < 0)
                        {
                            invalidated.Push("Segment #" + (slopedFacility.Segments.IndexOf(segment) + 1).ToString()
                                             + " Slope must be greater than or equal to zero.");
                        }
                        if (segment.BottomWidthFt < 0)
                        {
                            invalidated.Push("Segment #" + (slopedFacility.Segments.IndexOf(segment) + 1).ToString()
                                             + " Bottom Width must be greater than or equal to zero.");
                        }
                        if (segment.SideSlopeRightRatio < 0)
                        {
                            invalidated.Push("Segment #" + (slopedFacility.Segments.IndexOf(segment) + 1).ToString()
                                             + " Side Slope Ratio Right must be greater than or equal to zero.");
                        }
                        if (segment.SideSlopeLeftRatio < 0)
                        {
                            invalidated.Push("Segment #" + (slopedFacility.Segments.IndexOf(segment) + 1).ToString()
                                             + " Side Slope Ratio Left must be greater than or equal to zero.");
                        }
                        if (segment.DownstreamDepthIn <= 0)
                        {
                            invalidated.Push("Segment #" + (slopedFacility.Segments.IndexOf(segment) + 1).ToString()
                                             + " Downstream Depth must be greater than zero.");
                        }
                        if (segment.LandscapeWidthFt < segment.DownstreamTopWidthFt)
                        {
                            invalidated.Push("Segment #" + (slopedFacility.Segments.IndexOf(segment) + 1).ToString()
                                             + " Landscape Width must contain facility segment at Downstream Depth.");
                        }
                        if (facility.HasRockStorage && (segment.RockStorageWidthFt <= 0))
                        {
                            invalidated.Push("Segment #" + (slopedFacility.Segments.IndexOf(segment) + 1).ToString()
                                             + " Rock Storage Width must be greater than zero.");
                        }
                    }

                    if (facility.HasSecondaryOverflow && (facility.StorageDepth2In <= slopedFacility.Segments.Last().DownstreamDepthIn))
                    {
                        invalidated.Push("Storage Depth 2 must be greater than the Downstream Depth of the final facility segment.");
                    }
                }
                break;
            }

            default:
                break;
            }

            if (facility.GrowingMediumDepthIn <= 0)
            {
                invalidated.Push("Growing Medium Depth must be greater than zero.");
            }

            if (facility.HasRockStorage)
            {
                if (facility.RockStorageDepthIn <= 0)
                {
                    invalidated.Push("Rock Storage Depth must be greater than zero.");
                }
                if (facility.RockVoidRatio <= 0 || facility.RockVoidRatio >= 1)
                {
                    invalidated.Push("Rock Porosity must be between zero and one.");
                }
            }

            if ((facility.Configuration == FacilityConfiguration.F ||
                 facility.Configuration == FacilityConfiguration.C) &&
                ((facility.StorageDepth3In < 0) || (facility.StorageDepth3In > facility._rockStorageDepthIn)))
            {
                invalidated.Push("Storage Depth 3 must be greater than or equal to zero and less than or equal to the Rock Storage Depth.");
            }
            if (facility.Catchment.DesignInfiltrationNativeInchesPerHour < 0)
            {
                invalidated.Push("Native Infiltration must be greater than or equal to zero.");
            }
            if (facility.Catchment.ImportedMediumInfiltrationInchesPerHour < 0)
            {
                invalidated.Push("Imported Medium Infiltration must be greater than or equal to zero.");
            }


            if (invalidated.Count() > 0)
            {
                message = string.Empty;
                while (invalidated.Count() > 0)
                {
                    message += invalidated.Pop();
                    if (invalidated.Count != 0)
                    {
                        message += System.Environment.NewLine;
                    }
                }
                facility._validConfiguration = false;
                return(false);
            }
            message = "Valid configuration.";

            return(facility._validConfiguration);
        }
Example #10
0
 /// <summary>
 /// Executes the calculator and returns a PacResults. Supports Category 4 facilities.
 /// </summary>
 /// <param name="catchment">A catchment object defining the hydrologic parameters of the catchment area to be evaluated.</param>
 /// <param name="preCatchment">A catchment object defining the hydrologic parameters of the pre-developed catchment area to be evaluated.</param>
 /// <param name="slopedFacility">A SlopedFacility object defining the stormwater management facility to be evaluated.</param>
 /// <param name="category">Identifies the Hierarchy Category the proposed facility will be evaluated against. Must be an integer from 1 to 4.</param>
 /// <returns>A PacResults object containing the results of the calculation.</returns>
 public static PacResults PerformCalculations(Catchment catchment, Catchment preCatchment, SlopedFacility slopedFacility, int category)
 {
     return PerformCalculations(catchment, preCatchment, (Facility)slopedFacility, category, 'A');
 }
Example #11
0
        private Facility ValidateFacility(string hierarchy, string facilityType, string configuration)
        {
            try
              {
              //Read catchment parameters to local variables
              double imperviousArea = Convert.ToDouble(txtImperviousArea.Text);
              double curveNumber = Convert.ToDouble(txtCurveNumber.Text);
              double preCurveNumber = Convert.ToDouble(txtPreCurveNumber.Text);
              double timeOfConcentration = Convert.ToDouble(txtTimeOfConcentration.Text);
              double nativeInfiltrationRate = Convert.ToDouble(txtNativeSoilInfiltrationRate.Text);
              InfiltrationTestType infiltrationTestType;

              switch (cmbInfiltrationProcedure.SelectedIndex)
              {
              case (0):
                  infiltrationTestType = InfiltrationTestType.OpenPitFallingHead;
                  break;
              case (1):
                  infiltrationTestType = InfiltrationTestType.EncasedFallingHead;
                  break;
              case (2):
                  infiltrationTestType = InfiltrationTestType.DoubleRingInfiltometer;
                  break;
              default:
                  infiltrationTestType = InfiltrationTestType.OpenPitFallingHead;
                  break;
              }

              //Create catchment object local variables
              Catchment catchment = new Catchment("Catchment A")
              {
              ImperviousAreaSquareFeet = imperviousArea,
              AcceptableSeparationFromGroundwater = chkMeetsGroundwaterRequirements.Checked,
              CurveNumber = curveNumber,
              TimeOfConcentrationMinutes = timeOfConcentration,
              TestedInfiltrationRateInchesPerHour = nativeInfiltrationRate,
              InfiltrationTestType = infiltrationTestType
              };

              //Read facility parameters to local variables
              double bottomArea = Convert.ToDouble(txtBottomArea.Text);
              double bottomWidth = Convert.ToDouble(txtBottomWidth.Text);
              double sideSlope = Convert.ToDouble(txtSideSlope.Text);
              double storageDepth1 = Convert.ToDouble(txtStorageDepth1.Text);
              double storageDepth2 = Convert.ToDouble(txtStorageDepth2.Text);
              double storageDepth3 = Convert.ToDouble(txtStorageDepth3.Text);
              double growingMediumDepth = Convert.ToDouble(txtGrowingMediumDepth.Text);
              double freeboardDepth = Convert.ToDouble(txtFreeboardDepth.Text);
              double rockStorageDepth = Convert.ToDouble(txtRockStorageDepth.Text);
              double rockStorageVoidRatio = Convert.ToDouble(txtRockVoidRatio.Text);
              double rockStorageBottomArea = Convert.ToDouble(txtRockStorageBottomArea.Text);
              double surfaceAreaAtStorageDepth1 = Convert.ToDouble(txtSurfaceAreaAtDepth1.Text);
              double bottomPerimiterLength = Convert.ToDouble(txtBottomPerimeterLength.Text);
              double surfaceAreaAtStorageDepth2 = Convert.ToDouble(txtSurfaceAreaAtDepth2.Text);
              FacilityShape shape = GetFacilityShape(cmbFacilityShape.Text);

              FacilityConfiguration config;
              config = (FacilityConfiguration)cmbFacilityConfiguration.Text[0];
              FacilityType type = GetFacilityType(cmbFacilityType.Text);

              Facility facility;

              if (type == FacilityType.Basin || type == FacilityType.PlanterFlat)
              {
              facility = new Facility(type, config, catchment)
              {
                  BottomAreaSqFt = bottomArea,
                  BottomWidthFt = bottomWidth,
                  SideSlopeRatio = sideSlope,
                  StorageDepth1In = storageDepth1,
                  StorageDepth2In = storageDepth2,
                  StorageDepth3In = storageDepth3,
                  GrowingMediumDepthIn = growingMediumDepth,
                  FreeboardIn = freeboardDepth,
                  RockStorageDepthIn = rockStorageDepth,
                  RockVoidRatio = rockStorageVoidRatio,
                  RockStorageBottomAreaSqFt = rockStorageBottomArea,
                  SurfaceAreaAtStorageDepth1SqFt = surfaceAreaAtStorageDepth1,
                  BottomPerimeterLengthFt = bottomPerimiterLength,
                  SurfaceAreaAtStorageDepth2SqFt = surfaceAreaAtStorageDepth2,
                  Shape = shape
              };
              }
              else //Write sloped facility parameters from UI to facility object and verify results
              {
              //ShowSlopedFacilityWS();
              List<SlopedFacilitySegment> segments;
              if (_sfws != null)
              {
                  if (_sfws.Segments != null)
                      segments = _sfws.Segments;
                  else
                      segments = new List<SlopedFacilitySegment>();
              }
              else
                  segments = new List<SlopedFacilitySegment>();

              facility = new SlopedFacility(type, config, catchment, segments)
              {
                  BottomAreaSqFt = bottomArea,
                  BottomWidthFt = bottomWidth,
                  SideSlopeRatio = sideSlope,
                  StorageDepth1In = storageDepth1,
                  StorageDepth2In = storageDepth2,
                  StorageDepth3In = storageDepth3,
                  GrowingMediumDepthIn = growingMediumDepth,
                  FreeboardIn = freeboardDepth,
                  RockStorageDepthIn = rockStorageDepth,
                  RockVoidRatio = rockStorageVoidRatio,
                  RockStorageBottomAreaSqFt = rockStorageBottomArea,
                  SurfaceAreaAtStorageDepth1SqFt = surfaceAreaAtStorageDepth1,
                  Shape = shape
              };
              }

            int hierarchyNumber = Convert.ToInt32(hierarchy);
            HierarchyCategory hierarchyCategory = (HierarchyCategory)hierarchyNumber;

            string message;
            _validFacility = Facility.Validate(facility, hierarchyNumber, out message);

            ToggleUIParameters(facility);
            if (!_validFacility)
            DisableUI(message);

            return facility;
              }
              catch (Exception ex)
              {
            MessageBox.Show("Error with facility parameters: " + ex.Message);
            return null;
              }
        }
Example #12
0
        private void ShowSlopedFacilityWS()
        {
            double storageDepth2 = Convert.ToDouble(txtStorageDepth2.Text);
              double storageDepth3 = Convert.ToDouble(txtStorageDepth3.Text);
              double growingMediumDepth = Convert.ToDouble(txtGrowingMediumDepth.Text);
              double freeboardDepth = Convert.ToDouble(txtFreeboardDepth.Text);
              double rockStorageDepth = Convert.ToDouble(txtRockStorageDepth.Text);
              double rockStorageVoidRatio = Convert.ToDouble(txtRockVoidRatio.Text);
              FacilityShape shape = GetFacilityShape(cmbFacilityShape.Text);
              FacilityConfiguration config = (FacilityConfiguration)cmbFacilityConfiguration.Text[0];
              FacilityType type = GetFacilityType(cmbFacilityType.Text);

              List<SlopedFacilitySegment> segments = new List<SlopedFacilitySegment>();

              SlopedFacility facility = new SlopedFacility(type, config, new Catchment("test catchment"), segments)
            {
              StorageDepth2In = storageDepth2,
              StorageDepth3In = storageDepth3,
              GrowingMediumDepthIn = growingMediumDepth,
              FreeboardIn = freeboardDepth,
              RockStorageDepthIn = rockStorageDepth,
              RockVoidRatio = rockStorageVoidRatio,
              Shape = shape
            };

              if (_sfws == null || _sfws.Disposing)
            _sfws = new SlopedFacilityWorksheet(facility);
              else
              {
            facility.Segments = _sfws.Segments; // connect new facility object to existing segments.
            _sfws.Facility = facility; // change worksheet object to new facility object.
              }

              try
              {
            _sfws.ShowDialog();
              }
              catch (Exception ex)
              {
            MessageBox.Show(ex.Message);
              }
        }
Example #13
0
 /// <summary>
 /// Constructor for a sloped facility
 /// </summary>
 /// <param name="type">The FacilityType; should be Swale or SlopedPlanter</param>
 /// <param name="configuration">The Configuration of the facility</param>
 /// <param name="catchment">The catchment for the facility</param>
 /// <param name="segments">A list of Segments to load the facility with</param>
 public SlopedFacility(FacilityType type, FacilityConfiguration configuration, Catchment catchment, List <SlopedFacilitySegment> segments)
     : base(type, configuration, catchment)
 {
     _segments            = segments;
     SlopedFacility._this = this;
 }