Sunday, December 29, 2024

SWMM5 Delphi GUI Dinflows.pas Summary

 Below is an overview of Dinflows.pas, a Delphi unit from SWMM 5.2 that provides a form (TInflowsForm) for editing user-supplied external inflows to nodes in a drainage network.


1. Purpose and Context

This unit implements the Inflow Editor dialog, which lets you define external inflows at a SWMM node. These inflows can be:

  1. Direct (time series-based) inflows
  2. Dry Weather Flows (DWF)
  3. RDII (rainfall-dependent I/I) inflows

The form displays these three inflow categories on separate tab pages. Each inflow category is handled differently, but shares the same goal: store additional inflow data that augments or overrides flows calculated via hydraulic routing.


2. Key Components of the Form

The TInflowsForm has a TPageControl with three TTabSheet pages:

  • TimeSeriesPage (for Direct inflows)
  • DryWeatherPage (for DWF)
  • RDIIPage (for rainfall-dependent infiltration/inflow)

Several controls on each page let the user pick or edit input data relevant to that page’s inflow type (time series names, patterns, baseline flow, etc.).

2.1 Hidden Data Grids

Two hidden TStringGrid controls store inflow data internally:

  1. DxInflowDataGrid

    • For “Direct inflow” properties.
    • Each column represents one constituent (Flow + Pollutants).
    • Each row represents a different property (e.g., time series, baseline value, time pattern, etc.).
  2. DwInflowDataGrid

    • For “Dry Weather inflow” properties.
    • Each column again represents one constituent.
    • Rows store average DWF values and up to 4 time patterns.

These grids are invisible to the user but serve as an internal data structure for:

  • Retrieving existing inflow data from the project.
  • Storing new or updated inflow properties when the user edits the form.

2.2 Direct Inflow Controls

  • DxParamCombo: Selects which parameter (Flow or pollutant) the user is editing on the Direct Inflow page.
  • DxSeriesCombo: Name of a time series that defines how the inflow changes over time.
  • DxSFactorEdit: A scaling factor applied to the time series flow/concentration.
  • DxBaseEdit: Baseline inflow value (constant).
  • DxPatCombo: A time pattern ID used to scale the baseline inflow.
  • DxTypeCombo and DxCFactorEdit: For pollutants only; define the type of inflow (“FLOW” vs. “CONCEN”) and a units conversion factor.

2.3 Dry Weather Flow Controls

  • DwParamCombo: Selects which parameter (Flow or pollutant) is being edited for DWF.
  • DwAvgEdit: Average inflow value for that parameter.
  • DwPatCombo1..DwPatCombo4: Up to four time patterns that adjust the average inflow by time of day, day of week, etc.

2.4 RDII Controls

  • UHGroupCombo: Name of the Unit Hydrograph Group used for RDII at this node.
  • SewerAreaEdit: The contributing sewer area for RDII flows at this node.

3. Event Handlers and Flow of Operation

3.1 FormCreate

  • Sets up default properties and hides the data grids (DxInflowDataGrid, DwInflowDataGrid).
  • Populates combo boxes (time series, time patterns, unit hydrograph groups) from the main project data structures (Project.Lists[...]).
  • Sets button glyphs using images from the main form’s project image list.

3.2 FormShow

  • Initializes the currently edited Direct inflow parameter (DxParamIndex = 0) and Dry Weather parameter (DwParamIndex = 0).
  • Calls UpdateDxInflowPage and UpdateDwInflowPage to display existing data for these parameters on their respective pages.
  • Activates the TimeSeriesPage (Direct inflow) as the default visible tab.

3.3 SetData / GetData

SetData(NodeType, NodeIndex)

  • Fills the hidden data grids with a node’s existing external inflow properties:
    1. Direct inflows go to DxInflowDataGrid.
    2. Dry Weather inflows go to DwInflowDataGrid.
    3. RDII data (unit hydrograph name, sewer area) are put into UHGroupCombo and SewerAreaEdit.
  • The user sees these values immediately on the appropriate tab pages.

GetData(NodeType, NodeIndex)

  • Reads data from the hidden data grids and the RDII controls.
  • Updates the node’s inflow properties accordingly in the project data structure.

3.4 User Interaction: Direct Inflows

  1. Choose a constituent (Flow or pollutant) in DxParamCombo.
  2. Edit baseline (DxBaseEdit), baseline pattern (DxPatCombo), a time series (DxSeriesCombo), or scaling factor (DxSFactorEdit).
  3. For pollutants: set DxTypeCombo (“CONCEN” or “FLOW”) and DxCFactorEdit (units conversion factor).

As the user edits these controls, event handlers like DxParamComboChange or DxBaseDelBtnClick update the hidden grid or clear fields.

Double-clicking the DxSeriesCombo or clicking TseriesBtn1 opens the Time Series Editor, letting the user edit or add a time series on the fly.

3.5 User Interaction: Dry Weather Flows

  1. Pick a constituent in DwParamCombo.
  2. Edit the average inflow (DwAvgEdit).
  3. Optionally add time patterns (DwPatCombo1..DwPatCombo4).

Events such as DwParamComboChange or clicking the pattern edit buttons cause updates to the hidden DwInflowDataGrid. Double-clicking a pattern combo box or clicking the edit button opens the Pattern Editor.

3.6 User Interaction: RDII

  1. Select a Unit Hydrograph Group from UHGroupCombo.
  2. Enter the sewer area contributing to RDII in SewerAreaEdit.

Double-clicking UHGroupCombo or the button next to it opens the Unit Hydrograph Editor for that group.

3.7 Data Synchronization

When a user switches constituents or leaves a tab, the code calls:

  • UpdateDxInflowDataGrid (for Direct inflows) or
  • UpdateDwInflowDataGrid (for DWF)

to ensure the hidden data grid is always up to date before a new parameter is displayed.

3.8 OK / Cancel / Help

  • OK: Finalizes changes by calling UpdateDxInflowDataGrid & UpdateDwInflowDataGrid to store the latest user edits, and then closes the form.
  • Cancel: Closes the form without saving new changes.
  • Help: Calls Application.HelpCommand with context-sensitive help IDs depending on which tab is active.

4. Summary of Operation

  1. Loading: SetData populates hidden grids and the visible controls with any existing inflow data for the node.
  2. Editing: The user manipulates direct inflow, DWF, or RDII fields on each tab.
  3. Validation: As items change, HasChanged is set to True to record that modifications have been made.
  4. Saving: Clicking OK writes the form controls back into the hidden grids, then GetData extracts these grids and updates the node object in Project.

This approach keeps user input and stored data consistent while letting the user seamlessly edit multiple inflow types at once. By splitting the data into separate grids and pages, TInflowsForm provides a straightforward user experience for external inflows—time series flows, dry weather flows, and RDII parameters—without clutter or confusion.

No comments:

A comprehensive explanation of how minimum travel distance relates to link length in InfoSewer

In hydraulic modeling of sewer networks, the minimum travel distance is a fundamental parameter that affects how accurately the model can si...