SWMM5 Delphi GUI Dpollut.pas Summary

 Below is an overview of Dpollut.pas, a Delphi unit from SWMM 5.2 that provides a dialog (TPollutantForm) to create or edit the properties of a pollutant. A pollutant object in SWMM contains several parameters defining its concentration in various inflow streams, its first-order decay rate, and more.


1. Purpose and Context

In SWMM, pollutants represent chemical or biological constituents transported in runoff and sanitary flows. The TPollutantForm allows the user to edit:

  1. Pollutant Name and Units
  2. Concentrations in rainfall, groundwater, infiltration/inflow (I&I), dry weather flow, and the initial system concentration
  3. Decay Coefficient for a first-order decay process
  4. Whether buildup occurs only during snowfall
  5. Co-pollutant relationships (where pollutant concentration can be derived as a fraction of another pollutant’s concentration)

These properties are then used by SWMM’s water quality analysis routines.


2. Main Form: TPollutantForm

2.1 Visual Components

  1. Property Editor (TPropEdit, referenced as PropEdit1):

    • Displays each pollutant parameter in a name/value grid.
    • Allows the user to edit numeric or text values.
    • Provides events for validation (OnValidate) and hint messages (OnRowSelect).
  2. Panels and Buttons:

    • OK, Cancel, Help at the bottom.
    • A HintLabel in Panel3 that shows context-sensitive help when the user highlights a property row in the property editor.

2.2 Pollutant Properties and Hints

PollutProps (an array of TPropRecord) enumerates each pollutant property’s editing style, input mask, default text, etc.:

  1. Name (string, no spaces)
  2. Units (combo list: mg/L, µg/L, #/L, etc.)
  3. Rain Concen.
  4. GW Concen. (groundwater)
  5. I&I Concen.
  6. DWF Concen. (dry weather flow)
  7. Init. Concen. (initial system concentration)
  8. Decay Coeff.
  9. Snow Only (combo: NO/YES)
  10. Co-Pollutant
  11. Co-Fraction (fraction relating current pollutant to co-pollutant’s runoff concentration)

These are matched with a set of hints (PollutHint[]) explaining each property, displayed in HintLabel upon row selection.


3. Data Flow

3.1 SetData(Index, Pollut: TPollutant)

  • Called by the main application to load data from an existing pollutant (or a new one) into the form:
    1. PollutIndex records which item of Project.Lists[POLLUTANT] we’re editing (or -1 if new).
    2. If Index < 0, uses DefaultProps as the property values.
    3. Otherwise:
      • Property 0 is the pollutant’s name from Project.Lists[POLLUTANT].Strings[Index].
      • Properties 1..10 come from Pollut.Data[].
    4. Copies these values into PropList, which the PropEdit1 control will display.

3.2 FormShow

  • Calls PropEdit1.SetProps(PollutProps, PropList), linking the TPropRecord definitions to the string list of values.
  • Calls PropEdit1.Edit to enter interactive editing mode in the property grid.

3.3 User Edits

  • The user modifies each property in the property editor.
  • If the user changes rows, OnRowSelect -> ShowPropertyHint updates HintLabel.Caption.
  • OnValidate -> ValidateEntry ensures certain fields are not left blank (e.g., concentration fields).

3.4 OKBtnClick and Validation

  1. OKBtnClick triggers:
    • PropEdit1.IsValid: ensures each property passes OnValidate.
    • ValidateName: ensures the pollutant name is not blank or duplicated in Project.Lists[POLLUTANT].
    • If any check fails, the form remains open and displays an error message.
  2. If all checks pass, the form sets ModalResult := mrOK.

3.5 GetData(var S: String; Pollut: TPollutant)

  • Called after OK, storing the user’s final entries:
    1. S := PropList[0] for the pollutant’s name.
    2. For properties 1..10, Pollut.Data[k-1] := PropList[k].
  • The main calling code then uses the new name (S) and updated Pollut.Data[] to overwrite the old pollutant object in Project.Lists[POLLUTANT].

4. Validation Methods

  • ValidateEntry (OnValidate): For properties #2..#6, ensures the field cannot be empty. Displays an error message if blank.
  • ValidateName: Checks that PropList[0] (the name) is neither empty nor duplicated among existing pollutants.

5. Summary

Dpollut.pas defines a user-friendly form for editing pollutant properties in SWMM. By combining a property editor grid with validation logic, it ensures every pollutant has a unique name, valid numeric concentrations, optional co-pollutant relationships, and correct decay and “snow only” settings. Once the user confirms, these changes are transferred back into the SWMM project’s pollutant database for use in water quality modeling.