C API implementation — control rules and direct link control actions.
More...
C API implementation — control rules and direct link control actions.
- See also
- include/openswmm/engine/openswmm_controls.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_control_add_rule()
Add a control rule from its text representation.
The rule text follows the standard SWMM control rule syntax (e.g., "RULE R1\\nIF NODE J1 DEPTH > 5\\nTHEN PUMP P1 STATUS = ON"). Lines are separated by newline characters within the string.
- Parameters
-
| engine | Engine handle. |
| rule_text | Null-terminated string containing the full rule text. |
- Returns
- SWMM_OK on success, or an error code.
◆ swmm_control_clear_rules()
Remove all control rules from the model.
- Parameters
-
- Returns
- SWMM_OK on success, or an error code.
◆ swmm_control_count()
Get the total number of control rules defined.
- Parameters
-
- Returns
- Number of control rules, or -1 on error.
◆ swmm_control_get_rule()
Get the text of a control rule by index.
- Parameters
-
| engine | Engine handle. |
| idx | Zero-based rule index. |
| buf | Caller-allocated buffer to receive the rule text. |
| buflen | Size of buf in bytes. |
- Returns
- SWMM_OK on success, or an error code.
◆ swmm_control_set_link_setting()
Directly set the control setting of a link.
Bypasses the control rule engine. For pumps: 0.0=off, 1.0=full. For orifices/weirs: fractional opening [0, 1].
- Parameters
-
| engine | Engine handle (RUNNING state). |
| link_idx | Zero-based link index. |
| setting | Setting value. |
- Returns
- SWMM_OK on success, or an error code.
◆ swmm_control_set_link_status()
Directly set the open/close status of a link.
Bypasses the control rule engine. Status: 0=closed, 1=open.
- Parameters
-
| engine | Engine handle (RUNNING state). |
| link_idx | Zero-based link index. |
| status | 0 for closed, non-zero for open. |
- Returns
- SWMM_OK on success, or an error code.