OpenSWMM Engine — Tables (Time Series & Curves) and Patterns C API.
More...
Go to the source code of this file.
|
| SWMM_ENGINE_API int | swmm_table_count (SWMM_Engine engine) |
| | Get the total number of tables (time series + curves) in the model.
|
| |
| SWMM_ENGINE_API int | swmm_table_index (SWMM_Engine engine, const char *id) |
| | Look up a table's zero-based index by its string identifier.
|
| |
| SWMM_ENGINE_API const char * | swmm_table_id (SWMM_Engine engine, int idx) |
| | Get the string identifier of a table by index.
|
| |
| SWMM_ENGINE_API int | swmm_timeseries_add (SWMM_Engine engine, const char *id) |
| | Add a new time series to the model.
|
| |
| SWMM_ENGINE_API int | swmm_curve_add (SWMM_Engine engine, const char *id, int type) |
| | Add a new curve to the model.
|
| |
| SWMM_ENGINE_API int | swmm_table_add_point (SWMM_Engine engine, int idx, double x, double y) |
| | Append a data point (x, y) to a table.
|
| |
| SWMM_ENGINE_API int | swmm_table_get_point_count (SWMM_Engine engine, int idx, int *count) |
| | Get the number of data points in a table.
|
| |
| SWMM_ENGINE_API int | swmm_table_get_point (SWMM_Engine engine, int idx, int pt_idx, double *x, double *y) |
| | Get a specific data point from a table.
|
| |
| SWMM_ENGINE_API int | swmm_table_clear (SWMM_Engine engine, int idx) |
| | Remove all data points from a table.
|
| |
| SWMM_ENGINE_API int | swmm_table_lookup (SWMM_Engine engine, int idx, double x, double *y) |
| | Interpolate a Y value from a table for a given X.
|
| |
| SWMM_ENGINE_API int | swmm_pattern_add (SWMM_Engine engine, const char *id, int type) |
| | Add a new time pattern to the model.
|
| |
| SWMM_ENGINE_API int | swmm_pattern_set_factors (SWMM_Engine engine, int idx, const double *factors, int count) |
| | Set the multiplier factors for a time pattern.
|
| |
| SWMM_ENGINE_API int | swmm_pattern_count (SWMM_Engine engine) |
| | Get the total number of time patterns in the model.
|
| |
OpenSWMM Engine — Tables (Time Series & Curves) and Patterns C API.
Table identity, creation, data point management, cursor-optimized lookup, and time pattern management.
- See also
- openswmm_engine.h
- Author
- Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
- Copyright
- Copyright (c) 2026 HydroCouple. All rights reserved.
- License\n MIT License
◆ swmm_curve_add()
Add a new curve to the model.
Curve types: 0=STORAGE, 1=DIVERSION, 2=TIDAL, 3=RATING, 4=CONTROL, 5=SHAPE, 6=PUMP1..PUMP4, etc.
- Parameters
-
| engine | Engine handle (SWMM_STATE_BUILDING). |
| id | Unique null-terminated identifier. |
| type | Curve type code. |
- Returns
- SWMM_OK on success, or an error code.
◆ swmm_pattern_add()
Add a new time pattern to the model.
Pattern types: 0=MONTHLY, 1=DAILY, 2=HOURLY, 3=WEEKEND.
- Parameters
-
| engine | Engine handle (SWMM_STATE_BUILDING). |
| id | Unique null-terminated identifier. |
| type | Pattern type code. |
- Returns
- SWMM_OK on success, or an error code.
◆ swmm_pattern_count()
Get the total number of time patterns in the model.
- Parameters
-
- Returns
- Number of patterns, or -1 on error.
◆ swmm_pattern_set_factors()
Set the multiplier factors for a time pattern.
- Parameters
-
| engine | Engine handle. |
| idx | Zero-based pattern index. |
| factors | Array of multiplier values. |
| count | Number of factors (e.g., 12 for MONTHLY, 24 for HOURLY). |
- Returns
- SWMM_OK on success, or an error code.
◆ swmm_table_add_point()
Append a data point (x, y) to a table.
For time series, x is in decimal days; for curves, x depends on the curve type (e.g., depth for storage curves).
- Parameters
-
| engine | Engine handle. |
| idx | Zero-based table index. |
| x | X value (independent variable). |
| y | Y value (dependent variable). |
- Returns
- SWMM_OK on success, or an error code.
◆ swmm_table_clear()
Remove all data points from a table.
- Parameters
-
| engine | Engine handle. |
| idx | Zero-based table index. |
- Returns
- SWMM_OK on success, or an error code.
◆ swmm_table_count()
Get the total number of tables (time series + curves) in the model.
- Parameters
-
- Returns
- Number of tables, or -1 on error.
◆ swmm_table_get_point()
Get a specific data point from a table.
- Parameters
-
| engine | Engine handle. |
| idx | Zero-based table index. |
| pt_idx | Zero-based point index within the table. |
| [out] | x | Receives the X value. |
| [out] | y | Receives the Y value. |
- Returns
- SWMM_OK on success, or an error code.
◆ swmm_table_get_point_count()
Get the number of data points in a table.
- Parameters
-
| engine | Engine handle. |
| idx | Zero-based table index. |
| [out] | count | Receives the point count. |
- Returns
- SWMM_OK on success, or an error code.
◆ swmm_table_id()
Get the string identifier of a table by index.
- Parameters
-
| engine | Engine handle. |
| idx | Zero-based table index. |
- Returns
- Null-terminated string owned by the engine, or NULL on error.
◆ swmm_table_index()
Look up a table's zero-based index by its string identifier.
- Parameters
-
| engine | Engine handle. |
| id | Null-terminated table identifier. |
- Returns
- Zero-based index, or -1 if not found.
◆ swmm_table_lookup()
Interpolate a Y value from a table for a given X.
Uses cursor-based lookup for efficient sequential access (e.g., during time-stepping through a time series).
- Parameters
-
| engine | Engine handle. |
| idx | Zero-based table index. |
| x | X value to look up. |
| [out] | y | Receives the interpolated Y value. |
- Returns
- SWMM_OK on success, or an error code.
◆ swmm_timeseries_add()
Add a new time series to the model.
- Parameters
-
| engine | Engine handle (SWMM_STATE_BUILDING). |
| id | Unique null-terminated identifier. |
- Returns
- SWMM_OK on success, or an error code.