OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm_controls.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
31
32#ifndef OPENSWMM_CONTROLS_H
33#define OPENSWMM_CONTROLS_H
34
35#include "openswmm_engine.h"
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/* =========================================================================
42 * Control rules
43 * ========================================================================= */
44
70SWMM_ENGINE_API int swmm_control_add_rule(SWMM_Engine engine, const char* rule_text);
71
78
87SWMM_ENGINE_API int swmm_control_get_rule(SWMM_Engine engine, int idx, char* buf, int buflen);
88
105SWMM_ENGINE_API int swmm_control_get_id(SWMM_Engine engine, int idx, char* buf, int buflen);
106
113
125
145 const char* object_name,
146 int* rule_indices_out,
147 int* n_inout);
148
186 const char* rule_text,
187 char* errbuf, int buflen,
188 int* line_out);
189
190/* =========================================================================
191 * Direct control actions (without rules)
192 * ========================================================================= */
193
205SWMM_ENGINE_API int swmm_control_set_link_setting(SWMM_Engine engine, int link_idx, double setting);
206
217SWMM_ENGINE_API int swmm_control_set_link_status(SWMM_Engine engine, int link_idx, int status);
218
219#ifdef __cplusplus
220} /* extern "C" */
221#endif
222
223#endif /* OPENSWMM_CONTROLS_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
SWMM_ENGINE_API int swmm_control_validate_rule(SWMM_Engine engine, const char *rule_text, char *errbuf, int buflen, int *line_out)
Validate a control-rule text block without storing it.
Definition openswmm_controls_impl.cpp:220
SWMM_ENGINE_API int swmm_control_find_references(SWMM_Engine engine, const char *object_name, int *rule_indices_out, int *n_inout)
Find control rules whose text references an object by name.
Definition openswmm_controls_impl.cpp:202
SWMM_ENGINE_API int swmm_control_remove_rule(SWMM_Engine engine, int idx)
Remove one control rule by index.
Definition openswmm_controls_impl.cpp:192
SWMM_ENGINE_API int swmm_control_set_link_setting(SWMM_Engine engine, int link_idx, double setting)
Directly set the control setting of a link.
Definition openswmm_controls_impl.cpp:257
SWMM_ENGINE_API int swmm_control_clear_rules(SWMM_Engine engine)
Remove all control rules from the model.
Definition openswmm_controls_impl.cpp:185
SWMM_ENGINE_API int swmm_control_get_rule(SWMM_Engine engine, int idx, char *buf, int buflen)
Get the text of a control rule by index.
Definition openswmm_controls_impl.cpp:155
SWMM_ENGINE_API int swmm_control_add_rule(SWMM_Engine engine, const char *rule_text)
Add a control rule from its text representation.
Definition openswmm_controls_impl.cpp:98
SWMM_ENGINE_API int swmm_control_set_link_status(SWMM_Engine engine, int link_idx, int status)
Directly set the open/close status of a link.
Definition openswmm_controls_impl.cpp:265
SWMM_ENGINE_API int swmm_control_count(SWMM_Engine engine)
Get the total number of control rules defined.
Definition openswmm_controls_impl.cpp:150
SWMM_ENGINE_API int swmm_control_get_id(SWMM_Engine engine, int idx, char *buf, int buflen)
Get the canonical name of a control rule by index.
Definition openswmm_controls_impl.cpp:169
OpenSWMM Engine — primary transparent C API (master header).