Sunday, December 29, 2024

SWMM5 Delphi GUI Dloads.pas Summary

 Below is an overview of Dloads.pas, a Delphi unit from SWMM 5.2 that provides a dialog (TInitLoadingsForm) for editing initial pollutant loadings on a subcatchment. In SWMM, you can specify an initial buildup (mass per area) of each pollutant on a subcatchment at the start of a simulation. This form makes it easy to set these initial loads for all pollutants at once.


1. Purpose and Context

When setting up a subcatchment in SWMM, you might have initial pollutant buildup (e.g., sediments, nutrients) already present on the land surface. These initial loads affect the first-flush pollutant washoff. The TInitLoadingsForm dialog allows you to enter these loads for each pollutant in one place.


2. Main Components: TInitLoadingsForm

  1. Property Editor (PropEdit1)

    • A specialized grid-like control that displays the pollutant names and their respective initial loads side by side.
    • The first column shows pollutant names, the second shows initial buildup values.
    • Each property row has an esEdit style, meaning the user can type in a numeric value.
  2. TStringList (PropList)

    • Stores the numeric values (mass per area) for each pollutant.
    • These correspond to the rows of the PropEdit1 control.
  3. TPropRecord array (PropRecd)

    • An array of metadata describing each pollutant row (e.g., name, editing style, input mask).
    • SWMM uses these records to define how each row is displayed and validated in the property editor.
  4. Buttons: OK, Cancel, Help

    • OKBtn: Validates the numeric inputs (via PropEdit1.IsValid) and, if valid, returns with mrOK.
    • HelpBtn: Opens context-sensitive help.
    • CancelBtn: Closes the form without saving new changes.
  5. HintPanel / HintLabel

    • Displays a short message (e.g., “Enter initial buildup of pollutants on subcatchment X”).

3. Data Flow

3.1 SetData(aSubcatch: TSubcatch)

  • Called from outside (e.g., some main form or property editor) to load existing data into this form:
    1. Sets HintLabel.Caption to show which subcatchment is being edited.
    2. For each pollutant in Project.Lists[POLLUTANT], retrieves any existing initial loading from aSubcatch.Loadings.
    3. Stores these values in PropList, matching row order with PropRecd.
    4. As a result, PropEdit1 is populated with pollutant names (from PropRecd[]) and their values (from PropList).

3.2 FormShow

  • PropEdit1.SetProps(PropRecd, PropList) places the rows (one per pollutant) into the property editor.
  • Calls PropEdit1.Edit to set up the editing session.

3.3 User Edits

  • The user types numeric values in the second column for each pollutant.
  • If the user wants to discard changes, they press Cancel.
  • If they accept, they press OK.

3.4 OKBtnClick

  • Calls PropEdit1.IsValid to validate that each row has valid numeric input.
  • If invalid, ModalResult := mrNone keeps the form open, otherwise mrOK closes the form.

3.5 GetData(aSubcatch: TSubcatch; var Count: Integer)

  • Called externally after OK to store user inputs back into the subcatchment:
    1. Clear any existing aSubcatch.Loadings.
    2. For each pollutant row, parse the string as a floating number.
    3. If it’s greater than 0, store it in aSubcatch.Loadings with pollutant=loading.
    4. Keep track of how many nonzero loadings were found in Count.

4. Key Implementation Details

  • Unit System:
    • If SWMM is in US units, the column heading is “Initial Buildup (lbs/ac)”.
    • If in SI units, it’s “Initial Buildup (kg/ha)”.
  • Validation:
    • PropRecd[i].Mask := emPosNumber means the form only allows numeric input with optional decimal points.
    • Anything else triggers an error message if the user tries to press OK.
  • HasChanged:
    • Set to True if the user makes changes, tracked through PropEdit1.Modified.
    • This helps the main application know if anything in the subcatchment changed after leaving the dialog.

5. Summary

Dloads.pas provides a straightforward, tabular approach to initial pollutant loadings in SWMM 5.2:

  1. PropEdit displays each pollutant and a single numeric field for its initial buildup.
  2. SetData loads existing loadings from the subcatchment’s Loadings property.
  3. GetData writes the user’s final changes back to that subcatchment.
  4. The form ensures all inputs are valid numeric values before closing.

This dialog thus streamlines the process of setting or modifying the starting level of pollutant buildup on each subcatchment, which can be an important factor in first-flush pollutant washoff calculations during the simulation.

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...