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
-
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.
-
TStringList (
PropList
)- Stores the numeric values (mass per area) for each pollutant.
- These correspond to the rows of the
PropEdit1
control.
-
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.
-
Buttons: OK, Cancel, Help
- OKBtn: Validates the numeric inputs (via
PropEdit1.IsValid
) and, if valid, returns withmrOK
. - HelpBtn: Opens context-sensitive help.
- CancelBtn: Closes the form without saving new changes.
- OKBtn: Validates the numeric inputs (via
-
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:
- Sets
HintLabel.Caption
to show which subcatchment is being edited. - For each pollutant in
Project.Lists[POLLUTANT]
, retrieves any existing initial loading fromaSubcatch.Loadings
. - Stores these values in
PropList
, matching row order withPropRecd
. - As a result,
PropEdit1
is populated with pollutant names (fromPropRecd[]
) and their values (fromPropList
).
- Sets
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, otherwisemrOK
closes the form.
3.5 GetData(aSubcatch: TSubcatch; var Count: Integer)
- Called externally after OK to store user inputs back into the subcatchment:
- Clear any existing
aSubcatch.Loadings
. - For each pollutant row, parse the string as a floating number.
- If it’s greater than 0, store it in
aSubcatch.Loadings
withpollutant=loading
. - Keep track of how many nonzero loadings were found in
Count
.
- Clear any existing
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 throughPropEdit1.Modified
. - This helps the main application know if anything in the subcatchment changed after leaving the dialog.
- Set to
5. Summary
Dloads.pas provides a straightforward, tabular approach to initial pollutant loadings in SWMM 5.2:
- PropEdit displays each pollutant and a single numeric field for its initial buildup.
- SetData loads existing loadings from the subcatchment’s
Loadings
property. - GetData writes the user’s final changes back to that subcatchment.
- 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:
Post a Comment