Extended Summary of Uglobals.pas
This unit, Uglobals.pas
, serves as a central module for the SWMM application, defining global (i.e., application-wide) constants, types, and variables. Many other units rely on these definitions. Below is an in-depth explanation of the unit’s contents and how they are used.
1. Purpose and Scope
Uglobals.pas
defines:
- Object categories and ID ranges used in SWMM (e.g.,
SUBCATCHMENTS
,NODES
,LINKS
, etc.). - Map and graphical display constants (e.g., for colors, cursors, legend indexes).
- Basic data structures:
- : for storing the intervals and type of the color legend on the map.
- : user preferences for plot displays (e.g., line colors, axis fonts, 3D layout).
- : user preferences for profile plots.
- : structure describing a table or plot selection.
- And others for storing user preferences (e.g.,
PageLayout
,TCalibData
,TRunStatus
, etc.).
- Global variables used throughout SWMM**:**
- Program-level preferences (e.g.,
StyleName
,Blinking
,AutoLength
,ShowStartPage
). - Paths / directories in use (
ProjectDir
,TempDir
, etc.). - The main SWMM
Project
instance (with references to all objects). - Simulation results summary info (
Nperiods
,RunFlag
, etc.).
- Program-level preferences (e.g.,
2. Key Sections
2.1 Object Category and SWMM Version Ranges
- The integer constants
VERSIONID1 = 51000
andVERSIONID2 = 52004
define the earliest and latest SWMM 5 version formats the program can parse without error. TXT_SUBCATCH
,TXT_NODE
,TXT_LINK
,TXT_SYS
are textual labels for certain object categories.
2.2 Global Constants
- File names:
INIFILE
,HLPFILE
, etc. - Map appearance: typical color sets, symbol sizes, arrow style enumerations, etc.
- Measurement units: arrays for flow units (US vs. SI), mass units, temperature units, etc.
- Default geometry or numeric tolerances: e.g.
FLOWTOL = 0.005
for zero-flow tolerance,MISSING = -1.0e10
as a missing-value sentinel, etc.
2.3 Data Structures
2.3.1 TMapLegend
- Keeps track of color intervals for subcatchment, node, or link color displays on the map.
- Has an array
Intervals[0..MAXINTERVALS]
for color intervals and the number of intervals used, plus references to “ViewVar” (the SWMM variable being visualized) and “Ltype” (subcatch, node, link).
2.3.2 TGraphOptions
- A record capturing user preferences for generating time-series plots (line colors, thickness, styles, background color, 3D display, legend styles, etc.).
2.3.3 TProfileOptions
- Used for profile plots.
- Holds colors for water fill, conduit line, labels, etc.
2.3.4 TReportSelection
- Describes how data will be reported in tables/plots, which variables are selected, date range, list of items, etc.
2.3.5 TPageLayout
- Tracks printed page layout: margins, orientation, page size, etc.
2.4 Global Variables
-
GUI Preferences
Blinking
: Are map hilighters blinking?FlyOvers
: Show map “flyover” tips.AutoLength
: Whether pipe lengths are auto-computed from node coordinates.BoldFonts
,LargeFonts
,StyleName
: affect the UI theme.
-
Project Database
Project
(typeTProject
): the main container for all SWMM objects.CurrentObject
: the category currently selected in the UI.UnitSystem
(e.g.,usUS
orusSI
).FlowUnits
: the textual representation of flow (CFS, CMS, etc.).
-
File Paths
HomeDir
,ProjectDir
,TempDir
,IniFileDir
, etc.InputFileName
,TempInputFile
,TempReportFile
,TempOutputFile
.
-
Analysis Results
RunFlag
: indicates if a successful run is loaded.Nperiods
: total number of time steps in output.Zsubcatch
,Znode
,Zlink
: arrays storing the current color-coded variable values for subcatchments, nodes, and links.FlowDir
: array for flow directions.
-
Calibration Data
CalibData[1..12]
: Holds info about any calibration data files, referencing the 12 possible measurement types (rainfall, flow, depth, etc.).
-
Program Startup
StartupFile
,StartupAction
,MRUList
: the “most recently used” file list, the file to open on startup, etc.
2.5 Key Procedures/Functions
-
GetStartupAction
- Shows a “Welcome” form so the user can select an action (e.g., “New Project,” “Open Project,” etc.).
- The form sets
StartupAction
andStartupFile
.
-
ReadCmdLine
- Checks for command-line switches like
/f
, meaning “open the specified file at startup,” or/s
to override the directory for storing the.ini
settings.
- Checks for command-line switches like
-
GetObject(ObjType, S)
- From an object category (
SUBCATCHMENTS
,NODES
,LINKS
, etc.) and an ID string, returns the matching SWMM object instance in theProject
.
- From an object category (
-
GetObjVarNames(ObjType, VarIndex, ObjName, VarName, VarUnits)
- Given an object type and variable index (like “FLOW” for a link), it sets out parameters describing object type name, variable name, and measurement units.
-
RegisterCalibData
- Reads each calibration data file path from
CalibData[]
and attempts to parse the known “location” IDs inside it.
- Reads each calibration data file path from
-
SetDirectories
,SetFormatSettings
- Initialize various directory paths (where the
.ini
or.exe
is located) and numeric/time format properties so that SWMM uses consistent date/time/decimal formats.
- Initialize various directory paths (where the
-
SetMapBackColors
- Provides a series of default background color choices for the study area map.
-
GetPeriod
- Given a “date index” (days from start), returns the reporting period integer for that date.
3. Typical Usage by Other Units
Fmain.pas
referencesUglobals
extensively for checking/updating the globalProject
, and to read/write to the same global variables controlling program settings.Fmap.pas
and others rely onZsubcatch
,Znode
,Zlink
,FlowDir
to color and animate the map.Uinlet.pas
,Uclipbrd.pas
, etc. also rely onProject
,UnitSystem
,MapLegend
, orTempDir
.
4. Conclusion
Uglobals.pas
is the foundation of SWMM’s data orchestration, holding:
- All constants describing categories, measurement units, maximum sizes, etc.
- Data structures for user options, plotting, legends, and more.
- Global variables that other modules rely on for status, file paths, or references to the main
TProject
.
Because these variables and types are used across almost all modules, Uglobals
is typically included in every major SWMM unit.
No comments:
Post a Comment