OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm_gages.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
30
31#ifndef OPENSWMM_GAGES_H
32#define OPENSWMM_GAGES_H
33
34#include "openswmm_engine.h"
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
47
56
57/* =========================================================================
58 * Identity
59 * ========================================================================= */
60
67
74SWMM_ENGINE_API int swmm_gage_index(SWMM_Engine engine, const char* id);
75
86SWMM_ENGINE_API const char* swmm_gage_id(SWMM_Engine engine, int idx);
87
88/* =========================================================================
89 * Creation (BUILDING or OPENED — "editable" states)
90 * ========================================================================= */
91
104SWMM_ENGINE_API int swmm_gage_add(SWMM_Engine engine, const char* id);
105
106/* =========================================================================
107 * Property setters (BUILDING or OPENED)
108 * ========================================================================= */
109
121SWMM_ENGINE_API int swmm_gage_set_rain_type(SWMM_Engine engine, int idx, int type);
122
136SWMM_ENGINE_API int swmm_gage_set_rain_interval(SWMM_Engine engine, int idx, double seconds);
137
151SWMM_ENGINE_API int swmm_gage_set_data_source(SWMM_Engine engine, int idx, int source);
152
166SWMM_ENGINE_API int swmm_gage_set_timeseries(SWMM_Engine engine, int idx, const char* ts_id);
167
191SWMM_ENGINE_API int swmm_gage_set_filename(SWMM_Engine engine, int idx, const char* path,
192 const char* station_id);
193
206SWMM_ENGINE_API int swmm_gage_set_station_id(SWMM_Engine engine, int idx, const char* station_id);
207
227SWMM_ENGINE_API int swmm_gage_set_file_column(SWMM_Engine engine, int idx, const char* column);
228
254SWMM_ENGINE_API int swmm_gage_set_file_format(SWMM_Engine engine, int idx, int format);
255
268SWMM_ENGINE_API int swmm_gage_set_snow_factor(SWMM_Engine engine, int idx, double factor);
269
281SWMM_ENGINE_API int swmm_gage_set_rain_units(SWMM_Engine engine, int idx, int units);
282
301SWMM_ENGINE_API int swmm_gage_set_scale_factor(SWMM_Engine engine, int idx, double factor);
302
303/* =========================================================================
304 * Property getters
305 * ========================================================================= */
306
318SWMM_ENGINE_API int swmm_gage_get_rain_type(SWMM_Engine engine, int idx, int* type);
319
331SWMM_ENGINE_API int swmm_gage_get_data_source(SWMM_Engine engine, int idx, int* source);
332
344SWMM_ENGINE_API int swmm_gage_get_scale_factor(SWMM_Engine engine, int idx, double* factor);
345
357SWMM_ENGINE_API int swmm_gage_get_rain_interval(SWMM_Engine engine, int idx, double* seconds);
358
370SWMM_ENGINE_API int swmm_gage_get_snow_factor(SWMM_Engine engine, int idx, double* factor);
371
387SWMM_ENGINE_API int swmm_gage_get_timeseries(SWMM_Engine engine, int idx, char* buf, int buflen);
388
403SWMM_ENGINE_API int swmm_gage_get_station_id(SWMM_Engine engine, int idx, char* buf, int buflen);
404
419SWMM_ENGINE_API int swmm_gage_get_file_column(SWMM_Engine engine, int idx, char* buf, int buflen);
420
435SWMM_ENGINE_API int swmm_gage_get_file_format(SWMM_Engine engine, int idx, int* format);
436
448SWMM_ENGINE_API int swmm_gage_get_rain_units(SWMM_Engine engine, int idx, int* units);
449
450/* =========================================================================
451 * State
452 * ========================================================================= */
453
466SWMM_ENGINE_API int swmm_gage_get_rainfall(SWMM_Engine engine, int idx, double* rainfall);
467
482SWMM_ENGINE_API int swmm_gage_set_rainfall(SWMM_Engine engine, int idx, double rainfall);
483
484/* =========================================================================
485 * Bulk access
486 * ========================================================================= */
487
499SWMM_ENGINE_API int swmm_gage_get_rainfall_bulk(SWMM_Engine engine, double* buf, int count);
500
513SWMM_ENGINE_API int swmm_gage_rename(SWMM_Engine engine, int idx, const char* newId);
514
515/* =========================================================================
516 * Resolved rainfall series
517 * ========================================================================= */
518
539
579SWMM_ENGINE_API int swmm_gage_get_rainfall_series(SWMM_Engine engine, int idx, double* times,
580 double* values, int count);
581
605
606#ifdef __cplusplus
607} /* extern "C" */
608#endif
609
610#endif /* OPENSWMM_GAGES_H */
#define SWMM_ENGINE_API
Definition openswmm_2d.h:62
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition openswmm_callbacks.h:55
OpenSWMM Engine — primary transparent C API (master header).
SWMM_GageRainType
Rain gage rainfall data format.
Definition openswmm_gages.h:51
@ SWMM_RAIN_VOLUME
Definition openswmm_gages.h:53
@ SWMM_RAIN_CUMULATIVE
Definition openswmm_gages.h:54
@ SWMM_RAIN_INTENSITY
Definition openswmm_gages.h:52
SWMM_ENGINE_API int swmm_gage_add(SWMM_Engine engine, const char *id)
Add a new rain gage to the model.
Definition openswmm_gages_impl.cpp:67
SWMM_ENGINE_API int swmm_gage_get_rainfall_series(SWMM_Engine engine, int idx, double *times, double *values, int count)
Copy a gage's resolved rainfall series.
Definition openswmm_gages_impl.cpp:439
SWMM_ENGINE_API int swmm_gage_get_rain_interval(SWMM_Engine engine, int idx, double *seconds)
Get the rainfall recording interval for a gage.
Definition openswmm_gages_impl.cpp:302
SWMM_ENGINE_API int swmm_gage_get_snow_factor(SWMM_Engine engine, int idx, double *factor)
Get the snow-catch deficiency correction factor (SCF) for a gage.
Definition openswmm_gages_impl.cpp:311
SWMM_ENGINE_API int swmm_gage_reload_rain_files(SWMM_Engine engine)
Re-read every FILE-source rain gage's data from disk.
Definition openswmm_gages_impl.cpp:475
SWMM_ENGINE_API int swmm_gage_get_timeseries(SWMM_Engine engine, int idx, char *buf, int buflen)
Get the assigned time series id for a TIMESERIES-source gage.
Definition openswmm_gages_impl.cpp:320
SWMM_GageDataSource
Rain gage data source type.
Definition openswmm_gages.h:43
@ SWMM_GAGE_TIMESERIES
Definition openswmm_gages.h:44
@ SWMM_GAGE_FILE
Definition openswmm_gages.h:45
SWMM_ENGINE_API int swmm_gage_set_snow_factor(SWMM_Engine engine, int idx, double factor)
Set the snow-catch deficiency correction factor (SCF) for a gage.
Definition openswmm_gages_impl.cpp:217
SWMM_ENGINE_API int swmm_gage_set_scale_factor(SWMM_Engine engine, int idx, double factor)
Set the rainfall scaling factor for a gage.
Definition openswmm_gages_impl.cpp:241
SWMM_ENGINE_API int swmm_gage_set_filename(SWMM_Engine engine, int idx, const char *path, const char *station_id)
Assign an external rainfall file as the data source for a gage.
Definition openswmm_gages_impl.cpp:138
SWMM_ENGINE_API int swmm_gage_count(SWMM_Engine engine)
Get the total number of rain gages in the model.
Definition openswmm_gages_impl.cpp:42
SWMM_ENGINE_API int swmm_gage_get_rainfall(SWMM_Engine engine, int idx, double *rainfall)
Read the current gage rainfall intensity.
Definition openswmm_gages_impl.cpp:378
SWMM_ENGINE_API int swmm_gage_set_timeseries(SWMM_Engine engine, int idx, const char *ts_id)
Assign a time series as the data source for a gage.
Definition openswmm_gages_impl.cpp:123
SWMM_ENGINE_API int swmm_gage_set_rain_interval(SWMM_Engine engine, int idx, double seconds)
Set the rainfall recording interval for a gage.
Definition openswmm_gages_impl.cpp:105
SWMM_ENGINE_API int swmm_gage_get_file_column(SWMM_Engine engine, int idx, char *buf, int buflen)
Get the data column name for a multi-column rain-file gage.
Definition openswmm_gages_impl.cpp:346
SWMM_ENGINE_API int swmm_gage_get_scale_factor(SWMM_Engine engine, int idx, double *factor)
Get the rainfall scaling factor for a gage.
Definition openswmm_gages_impl.cpp:273
SWMM_ENGINE_API int swmm_gage_set_rain_type(SWMM_Engine engine, int idx, int type)
Set the rainfall data format for a gage.
Definition openswmm_gages_impl.cpp:94
SWMM_ENGINE_API int swmm_gage_get_rain_type(SWMM_Engine engine, int idx, int *type)
Get the rainfall data format for a gage.
Definition openswmm_gages_impl.cpp:255
SWMM_ENGINE_API int swmm_gage_index(SWMM_Engine engine, const char *id)
Look up a rain gage's zero-based index by its string identifier.
Definition openswmm_gages_impl.cpp:48
SWMM_ENGINE_API int swmm_gage_set_data_source(SWMM_Engine engine, int idx, int source)
Set the data source type for a gage.
Definition openswmm_gages_impl.cpp:114
SWMM_ENGINE_API int swmm_gage_get_file_format(SWMM_Engine engine, int idx, int *format)
Get the rain file format for a file-based gage.
Definition openswmm_gages_impl.cpp:356
SWMM_ENGINE_API int swmm_gage_set_station_id(SWMM_Engine engine, int idx, const char *station_id)
Set the station id for a file-based gage (standard SWMM rain file).
Definition openswmm_gages_impl.cpp:165
SWMM_ENGINE_API const char * swmm_gage_id(SWMM_Engine engine, int idx)
Get the string identifier of a rain gage by index.
Definition openswmm_gages_impl.cpp:54
SWMM_ENGINE_API int swmm_gage_set_rainfall(SWMM_Engine engine, int idx, double rainfall)
Prescribe nonnegative gage rainfall for the next physical step.
Definition openswmm_gages_impl.cpp:387
SWMM_ENGINE_API int swmm_gage_get_rainfall_bulk(SWMM_Engine engine, double *buf, int count)
Get current rainfall rates for all gages in a single call.
Definition openswmm_gages_impl.cpp:403
SWMM_ENGINE_API int swmm_gage_get_rainfall_series_count(SWMM_Engine engine, int idx, int *count)
Number of entries in a gage's resolved rainfall series.
Definition openswmm_gages_impl.cpp:427
SWMM_ENGINE_API int swmm_gage_set_file_column(SWMM_Engine engine, int idx, const char *column)
Set the data column name for a multi-column rain-file gage.
Definition openswmm_gages_impl.cpp:178
SWMM_ENGINE_API int swmm_gage_get_station_id(SWMM_Engine engine, int idx, char *buf, int buflen)
Get the station id for a file-based gage.
Definition openswmm_gages_impl.cpp:336
SWMM_ENGINE_API int swmm_gage_set_file_format(SWMM_Engine engine, int idx, int format)
Set the rain file format for a file-based gage.
Definition openswmm_gages_impl.cpp:193
SWMM_ENGINE_API int swmm_gage_set_rain_units(SWMM_Engine engine, int idx, int units)
Set the rain-depth units declared for a file-based gage.
Definition openswmm_gages_impl.cpp:230
SWMM_ENGINE_API int swmm_gage_get_rain_units(SWMM_Engine engine, int idx, int *units)
Get the rain-depth units declared for a file-based gage.
Definition openswmm_gages_impl.cpp:365
SWMM_ENGINE_API int swmm_gage_rename(SWMM_Engine engine, int idx, const char *newId)
Rename an editable gage in the model name index.
Definition openswmm_gages_impl.cpp:413
SWMM_ENGINE_API int swmm_gage_get_data_source(SWMM_Engine engine, int idx, int *source)
Get the data source type for a gage.
Definition openswmm_gages_impl.cpp:264