![]() |
OpenSWMM Engine
6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
|
Rule-based controls functions. More...
Classes | |
| struct | TVariable |
| Rule premise variable. More... | |
| struct | TNamedVariable |
| Rule premise named variable. More... | |
| struct | TExpression |
| Rule premise math expression. More... | |
| struct | TPremise |
| Rule premise clause. More... | |
| struct | TAction |
| Rule action clause. More... | |
| struct | TActionList |
| Linked list of control actions. More... | |
| struct | TRule |
| Control rule. More... | |
Macros | |
| #define | _CRT_SECURE_NO_DEPRECATE |
| Define to prevent deprecation warnings from MS Visual C++ compilers. | |
| #define | MAXVARNAME 32 |
| Maximum length of a variable name. | |
Enumerations | |
| enum | RuleState { r_RULE , r_IF , r_AND , r_OR , r_THEN , r_ELSE , r_PRIORITY , r_VARIABLE , r_EXPRESSION , r_ERROR } |
| Enumeration of rule interpreter states. More... | |
| enum | RuleObject { r_GAGE , r_NODE , r_LINK , r_CONDUIT , r_PUMP , r_ORIFICE , r_WEIR , r_OUTLET , r_SIMULATION } |
| Enumeration of rule object types. More... | |
| enum | RuleAttrib { r_DEPTH , r_MAXDEPTH , r_HEAD , r_VOLUME , r_INFLOW , r_FLOW , r_FULLFLOW , r_FULLDEPTH , r_STATUS , r_SETTING , r_LENGTH , r_SLOPE , r_VELOCITY , r_TIMEOPEN , r_TIMECLOSED , r_TIME , r_DATE , r_CLOCKTIME , r_DAYOFYEAR , r_DAY , r_MONTH } |
| Enumeration of rule attribute types. More... | |
| enum | RuleRelation { EQ , NE , LT , LE , GT , GE } |
| Enumeration of rule relational operators. More... | |
| enum | RuleSetting { r_CURVE , r_TIMESERIES , r_PID , r_NUMERIC } |
| Enumeration of rule setting types. More... | |
Functions | |
| int | addPremise (int r, int type, char *Tok[], int nToks) |
| Adds a premise clause to a control rule. | |
| int | getPremiseVariable (char *tok[], int nToks, int *k, struct TVariable *v) |
| Parses a variable (e.g., Node 123 Depth) used in a control rule. | |
| int | getPremiseValue (char *token, int attrib, double *value) |
| Parses the numerical value of a particular node/link attribute in the premise clause of a control rule. | |
| int | addAction (int r, char *Tok[], int nToks) |
| Adds a new action to a control rule. | |
| int | evaluatePremise (struct TPremise *p, double tStep) |
| Evaluates premise clause of a control rule. | |
| double | getVariableValue (struct TVariable v) |
| Gets the value of a variable. | |
| int | compareTimes (double lhsValue, int relation, double rhsValue, double halfStep) |
| Compares two times. | |
| int | compareValues (double lhsValue, int relation, double rhsValue) |
| Compares two values. | |
| void | updateActionList (struct TAction *a) |
| Updates action list. | |
| int | executeActionList (DateTime currentTime) |
| Executes action list. | |
| void | clearActionList (void) |
| Clears action list. | |
| void | deleteActionList (void) |
| Deletes action list. | |
| void | deleteRules (void) |
| Deletes control rules. | |
| int | findExactMatch (char *s, char *keyword[]) |
| Finds the exact match between a string and an array of keyword strings. | |
| int | setActionSetting (char *tok[], int nToks, int *curve, int *tseries, int *attrib, double value[]) |
| Identifies how control actions settings are determined. | |
| void | updateActionValue (struct TAction *a, DateTime currentTime, double dt) |
| Updates the value of a control action. | |
| double | getPIDSetting (struct TAction *a, double dt) |
| Gets PID setting. | |
| int | getVariableIndex (char *varName) |
| Gets variable index. | |
| double | getNamedVariableValue (int varIndex) |
| Gets named variable value. | |
| int | getExpressionIndex (char *exprName) |
| Gets expression index. | |
| int | getGageAttrib (char *token) |
| Determines the attribute code for a rain gage variable. | |
| double | getRainValue (struct TVariable v) |
| Gets rain value. | |
| void | controls_init () |
| Initializes the control rule system. | |
| void | controls_addToCount (char *s) |
| int | controls_create (int n) |
| void | controls_delete (void) |
| int | controls_addVariable (char *tok[], int nToks) |
| int | controls_addExpression (char *tok[], int nToks) |
| int | controls_addRuleClause (int r, int keyword, char *tok[], int nToks) |
| int | controls_evaluate (DateTime currentTime, DateTime elapsedTime, double tStep) |
Variables | |
| struct TRule * | Rules |
| Array of control rules. | |
| struct TActionList * | ActionList |
| Linked list of control actions. | |
| int | InputState |
| State of rule interpreter. | |
| int | RuleCount |
| Total number of rules. | |
| double | ControlValue |
| Value of controller variable. | |
| double | SetPoint |
| Value of controller setpoint. | |
| DateTime | CurrentDate |
| Current date in whole days. | |
| DateTime | CurrentTime |
| Current time of day (decimal). | |
| int | VariableCount |
| Number of named variables. | |
| int | ExpressionCount |
| Number of math expressions. | |
| int | CurrentVariable |
| Index of current named variable. | |
| int | CurrentExpression |
| Index of current math expression. | |
| struct TNamedVariable * | NamedVariable |
| Array of named variables. | |
| struct TExpression * | Expression |
| Array of math expressions. | |
Rule-based controls functions.
Control rules have the format: RULE name IF <premise> AND / OR <premise> etc. THEN <action> AND <action> etc. ELSE <action> AND <action> etc. PRIORITY
<premise> consists of: <variable> <relational operator> value / <variable> where <variable> is <object type> <id name> <attribute> E.g.: Node 123 Depth > 4.5 Node 456 Depth < Node 123 Depth
<action> consists of: <variable> = setting E.g.: Pump abc status = OFF Weir xyz setting = 0.5
Build 5.1.008:
| #define _CRT_SECURE_NO_DEPRECATE |
Define to prevent deprecation warnings from MS Visual C++ compilers.