Below is an overview of Dinletusage.pas, a Delphi unit from SWMM 5.2 that provides a form (TInletUsageForm) to manage how a street Inlet is assigned to a conduit (link), and which node receives the intercepted flow. It allows users to choose an inlet design (created in Dinlet.pas) and specify usage properties (e.g., number of inlets, flow restriction, etc.).
1. Purpose and Context
In SWMM 5.2, each conduit (link) can optionally have an inlet assigned that intercepts gutter or overland flow. The Dinletusage form:
- Lets the user pick which inlet design to apply (from among those listed in the project's inlets).
- Defines the receiver node (a node where the inlet’s captured flow is routed).
- Sets additional properties specific to the application of that inlet (e.g., “percent clogged,” “flow restriction,” “depression geometry,” etc.).
This allows SWMM to model partial street flow interception along a conduit, sending the intercepted flow to a specified node in the drainage network.
2. Key Classes and Data
2.1 TInletUsageForm
- The main form with:
- A TPropEdit control (
PropEdit1
) that displays property names/values in a grid-like format. - A string list (
PropList
) that holds the textual property values corresponding to the TInletUsage object associated with the conduit. - Image, buttons (
OkBtn
,CancelBtn
,HelpBtn
), panels, and a label for hints.
- A TPropEdit control (
2.2 TInletUsage Object
- Each conduit may contain a TInletUsage reference (
TheLink.Inlet
) that stores:Inlet
: a reference to a TInlet design (see Dinlet.pas).InletNode
: the node that receives the captured flow.Data[]
: an array of strings holding numerical or text properties (number of inlets, % clogged, etc.).
2.3 Constants and Structures
-
PropNames[]
: The names of the properties displayed in the property editor, e.g.:- “Inlet Structure”
- “Capture Node”
- “Number of Inlets”
- “Percent Clogged”
- “Flow Restriction”
- “Depression Height”
- “Depression Width”
- “Inlet Placement”
-
PropHints[]
: Tooltips describing each property. -
PropEdit1
(aTPropEdit
) is configured so each row in the property grid corresponds to one item inPropNames[]
. -
DefaultProps
: A multiline string that initializes property defaults if an inlet usage doesn’t exist yet.
3. Form Lifecycle
3.1 FormCreate
- Sets up the property editor (
PropEdit1
) with column headings (e.g., “Property,” “Value”) and styling. - Creates a
TStringList
(PropList
) that will store property values. - Initializes each TPropRecord in
InletProps[]
, specifying:- Display name (from
PropNames[]
). - Style (e.g.,
esComboList
,esEdit
, etc.). - Allowed numeric or text masks.
- Display name (from
3.2 SetData
SetData(Index: Integer; InletDesigns: String);
- Called externally to populate the form with data for a particular conduit (
Index
) and the list of available inlet designs (InletDesigns
). - Looks up the conduit object (
TheLink
) inProject.Lists[CONDUIT]
. - If the conduit has no inlet usage yet, sets
PropList
to default property strings. Otherwise loads property values from the existingTInletUsage
object (TheUsedInlet
). - Updates the property record for “Inlet Structure” to list available inlet designs.
- Sets the form’s caption to “Inlet for Conduit [link ID]”.
3.3 FormShow
- Positions the form near the standard property editor form (
PropEditForm.Left
,PropEditForm.Top
). - Calls
PropEdit1.SetProps(InletProps, PropList)
so the property editor displays the property records with the current values fromPropList
. - Then calls
PropEdit1.Edit
to enter editing mode.
3.4 User Interaction
-
The user edits values in the property grid:
- “Inlet Structure” (pick from combo box).
- “Capture Node” (typed in or assigned via
SetReceiverNode
). - “Number of Inlets,” “Percent Clogged,” etc.
- “Inlet Placement” (ON_GRADE, ON_SAG, or AUTOMATIC).
-
The user may also close the form with OK (save changes) or Cancel.
3.5 FormClose and OkBtnClick
- OkBtnClick checks for:
- A valid inlet name (if provided).
- A valid capture node ID.
- If invalid, it shows an error dialog. Otherwise, it updates the underlying conduit’s inlet usage with
GetData
.
- FormClose updates the main interface (Browser, Map, etc.) to reflect any changes.
4. Data Synchronization
4.1 GetData(aNode: TNode): String
After the user clicks OK, the code calls GetData
to:
- Ensure the “Inlet Structure” field is not empty.
- If empty and the conduit had an inlet usage object, it frees it and sets
TheLink.Inlet
tonil
. - Otherwise, if an inlet usage object doesn’t exist yet, it creates a new TInletUsage.
- Looks up the chosen inlet design from
Project.Lists[INLET]
and assigns it toTheUsedInlet.Inlet
. - Sets
TheUsedInlet.InletNode
to the node object passed in. - Copies the property values from
PropList
intoTheUsedInlet.Data[]
. - Triggers a map redraw if needed (e.g., if a new inlet was added or removed).
The function returns 'YES'
if an inlet was assigned, or 'NO'
if it was cleared.
4.2 SetReceiverNode(ObjType: Integer; ObjIndex: Integer)
- Called when the user picks a node from somewhere else in the GUI (like on the map).
- Updates the Capture Node property in
PropList
and marks the form as modified.
5. Summary of Operation
- Loading:
SetData
is called to display existing inlet usage for a chosen conduit (or defaults if no inlet is assigned). - Editing: The user changes property values in
PropEdit1
, possibly assigning a new inlet structure or capture node. - Validation:
OkBtnClick
ensures the capture node is valid and finalizes the property editor. - Saving:
GetData
writes back to the underlying TInletUsage object, linking it to both an inlet design and a receiver node. The project is then updated accordingly. - Map Refresh: The map and browser are refreshed to display inlet usage status for the conduit.
Overall, Dinletusage.pas provides a concise, property-grid-based approach to assigning an inlet design to a conduit and specifying to which node (if any) the intercepted flow is diverted. This allows more fine-grained modeling of surface inlets and how they connect back into the larger drainage network.
No comments:
Post a Comment