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
82SWMM_ENGINE_API const char* swmm_gage_id(SWMM_Engine engine, int idx);
83
84/* =========================================================================
85 * Creation (BUILDING or OPENED — "editable" states)
86 * ========================================================================= */
87
95SWMM_ENGINE_API int swmm_gage_add(SWMM_Engine engine, const char* id);
96
97/* =========================================================================
98 * Property setters (BUILDING or OPENED)
99 * ========================================================================= */
100
108SWMM_ENGINE_API int swmm_gage_set_rain_type(SWMM_Engine engine, int idx, int type);
109
117SWMM_ENGINE_API int swmm_gage_set_rain_interval(SWMM_Engine engine, int idx, double seconds);
118
126SWMM_ENGINE_API int swmm_gage_set_data_source(SWMM_Engine engine, int idx, int source);
127
135SWMM_ENGINE_API int swmm_gage_set_timeseries(SWMM_Engine engine, int idx, const char* ts_id);
136
154SWMM_ENGINE_API int swmm_gage_set_filename(SWMM_Engine engine, int idx, const char* path,
155 const char* station_id);
156
164SWMM_ENGINE_API int swmm_gage_set_station_id(SWMM_Engine engine, int idx, const char* station_id);
165
180SWMM_ENGINE_API int swmm_gage_set_file_column(SWMM_Engine engine, int idx, const char* column);
181
203SWMM_ENGINE_API int swmm_gage_set_file_format(SWMM_Engine engine, int idx, int format);
204
212SWMM_ENGINE_API int swmm_gage_set_snow_factor(SWMM_Engine engine, int idx, double factor);
213
221SWMM_ENGINE_API int swmm_gage_set_rain_units(SWMM_Engine engine, int idx, int units);
222
236SWMM_ENGINE_API int swmm_gage_set_scale_factor(SWMM_Engine engine, int idx, double factor);
237
238/* =========================================================================
239 * Property getters
240 * ========================================================================= */
241
249SWMM_ENGINE_API int swmm_gage_get_rain_type(SWMM_Engine engine, int idx, int* type);
250
258SWMM_ENGINE_API int swmm_gage_get_data_source(SWMM_Engine engine, int idx, int* source);
259
267SWMM_ENGINE_API int swmm_gage_get_scale_factor(SWMM_Engine engine, int idx, double* factor);
268
276SWMM_ENGINE_API int swmm_gage_get_rain_interval(SWMM_Engine engine, int idx, double* seconds);
277
285SWMM_ENGINE_API int swmm_gage_get_snow_factor(SWMM_Engine engine, int idx, double* factor);
286
296SWMM_ENGINE_API int swmm_gage_get_timeseries(SWMM_Engine engine, int idx, char* buf, int buflen);
297
307SWMM_ENGINE_API int swmm_gage_get_station_id(SWMM_Engine engine, int idx, char* buf, int buflen);
308
318SWMM_ENGINE_API int swmm_gage_get_file_column(SWMM_Engine engine, int idx, char* buf, int buflen);
319
330SWMM_ENGINE_API int swmm_gage_get_file_format(SWMM_Engine engine, int idx, int* format);
331
339SWMM_ENGINE_API int swmm_gage_get_rain_units(SWMM_Engine engine, int idx, int* units);
340
341/* =========================================================================
342 * State
343 * ========================================================================= */
344
346SWMM_ENGINE_API int swmm_gage_get_rainfall(SWMM_Engine engine, int idx, double* rainfall);
347
354SWMM_ENGINE_API int swmm_gage_set_rainfall(SWMM_Engine engine, int idx, double rainfall);
355
356/* =========================================================================
357 * Bulk access
358 * ========================================================================= */
359
367SWMM_ENGINE_API int swmm_gage_get_rainfall_bulk(SWMM_Engine engine, double* buf, int count);
368
372SWMM_ENGINE_API int swmm_gage_rename(SWMM_Engine engine, int idx, const char* newId);
373
374/* =========================================================================
375 * Resolved rainfall series
376 * ========================================================================= */
377
393 int* count);
394
427 double* times, double* values,
428 int count);
429
447
448#ifdef __cplusplus
449} /* extern "C" */
450#endif
451
452#endif /* OPENSWMM_GAGES_H */
#define SWMM_ENGINE_API
Definition openswmm_2d.h:53
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition openswmm_callbacks.h:51
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:62
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:399
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:273
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:282
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:432
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:290
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:205
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:227
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:127
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:41
SWMM_ENGINE_API int swmm_gage_get_rainfall(SWMM_Engine engine, int idx, double *rainfall)
Get current rainfall rate at a gage (project rate units).
Definition openswmm_gages_impl.cpp:344
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:114
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:96
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:314
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:256
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:86
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:240
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:46
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:105
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:323
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:153
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:51
SWMM_ENGINE_API int swmm_gage_set_rainfall(SWMM_Engine engine, int idx, double rainfall)
Override rainfall at a gage for the current timestep.
Definition openswmm_gages_impl.cpp:352
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:365
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:387
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:166
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:305
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:181
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:217
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:332
SWMM_ENGINE_API int swmm_gage_rename(SWMM_Engine engine, int idx, const char *newId)
Rename the rain gage at idx to newId. Returns SWMM_ERR_BADPARAM if newId is null, empty,...
Definition openswmm_gages_impl.cpp:374
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:248