OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm_tables.h File Reference

OpenSWMM Engine — Tables (Time Series & Curves) and Patterns C API. More...

#include "openswmm_engine.h"
Include dependency graph for openswmm_tables.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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.
 

Detailed Description

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
License\n MIT License

Function Documentation

◆ swmm_curve_add()

SWMM_ENGINE_API int swmm_curve_add ( SWMM_Engine  engine,
const char *  id,
int  type 
)

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
engineEngine handle (SWMM_STATE_BUILDING).
idUnique null-terminated identifier.
typeCurve type code.
Returns
SWMM_OK on success, or an error code.

◆ swmm_pattern_add()

SWMM_ENGINE_API int swmm_pattern_add ( SWMM_Engine  engine,
const char *  id,
int  type 
)

Add a new time pattern to the model.

Pattern types: 0=MONTHLY, 1=DAILY, 2=HOURLY, 3=WEEKEND.

Parameters
engineEngine handle (SWMM_STATE_BUILDING).
idUnique null-terminated identifier.
typePattern type code.
Returns
SWMM_OK on success, or an error code.

◆ swmm_pattern_count()

SWMM_ENGINE_API int swmm_pattern_count ( SWMM_Engine  engine)

Get the total number of time patterns in the model.

Parameters
engineEngine handle.
Returns
Number of patterns, or -1 on error.

◆ swmm_pattern_set_factors()

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.

Parameters
engineEngine handle.
idxZero-based pattern index.
factorsArray of multiplier values.
countNumber of factors (e.g., 12 for MONTHLY, 24 for HOURLY).
Returns
SWMM_OK on success, or an error code.

◆ swmm_table_add_point()

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.

For time series, x is in decimal days; for curves, x depends on the curve type (e.g., depth for storage curves).

Parameters
engineEngine handle.
idxZero-based table index.
xX value (independent variable).
yY value (dependent variable).
Returns
SWMM_OK on success, or an error code.

◆ swmm_table_clear()

SWMM_ENGINE_API int swmm_table_clear ( SWMM_Engine  engine,
int  idx 
)

Remove all data points from a table.

Parameters
engineEngine handle.
idxZero-based table index.
Returns
SWMM_OK on success, or an error code.

◆ swmm_table_count()

SWMM_ENGINE_API int swmm_table_count ( SWMM_Engine  engine)

Get the total number of tables (time series + curves) in the model.

Parameters
engineEngine handle.
Returns
Number of tables, or -1 on error.

◆ swmm_table_get_point()

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.

Parameters
engineEngine handle.
idxZero-based table index.
pt_idxZero-based point index within the table.
[out]xReceives the X value.
[out]yReceives the Y value.
Returns
SWMM_OK on success, or an error code.

◆ swmm_table_get_point_count()

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.

Parameters
engineEngine handle.
idxZero-based table index.
[out]countReceives the point count.
Returns
SWMM_OK on success, or an error code.

◆ swmm_table_id()

SWMM_ENGINE_API const char * swmm_table_id ( SWMM_Engine  engine,
int  idx 
)

Get the string identifier of a table by index.

Parameters
engineEngine handle.
idxZero-based table index.
Returns
Null-terminated string owned by the engine, or NULL on error.

◆ swmm_table_index()

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.

Parameters
engineEngine handle.
idNull-terminated table identifier.
Returns
Zero-based index, or -1 if not found.

◆ swmm_table_lookup()

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.

Uses cursor-based lookup for efficient sequential access (e.g., during time-stepping through a time series).

Parameters
engineEngine handle.
idxZero-based table index.
xX value to look up.
[out]yReceives the interpolated Y value.
Returns
SWMM_OK on success, or an error code.
Here is the call graph for this function:

◆ swmm_timeseries_add()

SWMM_ENGINE_API int swmm_timeseries_add ( SWMM_Engine  engine,
const char *  id 
)

Add a new time series to the model.

Parameters
engineEngine handle (SWMM_STATE_BUILDING).
idUnique null-terminated identifier.
Returns
SWMM_OK on success, or an error code.