OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
Global Control Rule Methods

Global control rules methods. More...

Collaboration diagram for Global Control Rule Methods:

Functions

void controls_init (void)
 Initializes the control rule system.
 
void controls_addToCount (char *s)
 Updates the number of named variables or math expressions used by control rules.
 
int controls_create (int n)
 Creates an array of control rules.
 
void controls_delete (void)
 Deletes all control rules.
 
int controls_addVariable (char *tok[], int nToks)
 Adds a named variable to the control rule system from a tokenized line of input with formats:
 
int controls_addExpression (char *tok[], int nToks)
 Adds a math expression to the control rule system from a a tokenized line of input with format: EXPRESSION name = math expression containing VARIABLE names
 
int controls_addRuleClause (int r, int keyword, char *tok[], int nToks)
 Adds a new clause to a control rule.
 
int controls_evaluate (DateTime currentTime, DateTime elapsedTime, double tStep)
 Evaluates all control rules at the current time of the simulation.
 

Detailed Description

Global control rules methods.

Function Documentation

◆ controls_addExpression()

int controls_addExpression ( char * tok[],
int nToks )

Adds a math expression to the control rule system from a a tokenized line of input with format: EXPRESSION name = math expression containing VARIABLE names

Parameters
[in]tokArray of string tokens
[in]nToksNumber of tokens
Returns
Error code

Adds a math expression to the control rule system from a a tokenized line of input with format: EXPRESSION name = math expression containing VARIABLE names

Implementation arguments
  • tok (in): Borrowed nToks-element token array; expression tokens begin at index three.
  • nToks (in): Token count, at least four; corresponds to canonical ntoks.
Note
CurrentExpression advances before validation. Copies a bounded expression string and owns the compiled MathExpr on success; returns a parser error on invalid expression.
Here is the call graph for this function:

◆ controls_addRuleClause()

int controls_addRuleClause ( int r,
int keyword,
char * tok[],
int nToks )

Adds a new clause to a control rule.

Parameters
[in]rRule index
[in]keywordClause's keyword code (IF, THEN, etc.)
[in]tokArray of string tokens that comprises the clause
[in]nToksNumber of tokens
Returns
Error code

Adds a new clause to a control rule.

Implementation arguments
  • r (in): Valid preallocated rule index; canonical declaration calls this rule.
  • keyword (in): r_RULE, r_IF, r_AND, r_OR, r_THEN, r_ELSE or r_PRIORITY code.
  • tok (in): Borrowed clause-token array; canonical declaration calls this Tok.
  • nToks (in): Available token count; canonical declaration calls this nTokens.
Note
Mutates parser state and premise/action lists as each clause is accepted. Uses engine-global rule storage and is not reentrant; returns zero or an input-rule error.
Here is the call graph for this function:

◆ controls_addToCount()

void controls_addToCount ( char * s)

Updates the number of named variables or math expressions used by control rules.

Parameters
[in]sString containing either "VARIABLE" or "EXPRESSION"
See also
Declaration contract for controls_addToCount().
Here is the call graph for this function:

◆ controls_addVariable()

int controls_addVariable ( char * tok[],
int nToks )

Adds a named variable to the control rule system from a tokenized line of input with formats:

Accepted records are VARIABLE name = Object id attribute or VARIABLE name = SIMULATION attribute.

Parameters
[in]tokArray of string tokens
[in]nToksNumber of tokens
Returns
Error code

Adds a named variable to the control rule system from a tokenized line of input with formats:

Implementation arguments
  • tok (in): Borrowed nToks-element token array for VARIABLE name = object attribute.
  • nToks (in): Available token count, at least five (six for nonsimulation variables).
Note
Corresponds to canonical ntoks. CurrentVariable advances before validation; rejected input does not roll that counter back. No token storage is retained.
Here is the call graph for this function:

◆ controls_create()

int controls_create ( int n)

Creates an array of control rules.

Parameters
[in]nTotal number of control rules
Returns
Error code
See also
Declaration contract for controls_create().

◆ controls_delete()

void controls_delete ( void )

Deletes all control rules.

See also
Declaration contract for controls_delete().
Here is the call graph for this function:

◆ controls_evaluate()

int controls_evaluate ( DateTime currentTime,
DateTime elapsedTime,
double tStep )

Evaluates all control rules at the current time of the simulation.

Parameters
[in]currentTimeCurrent simulation date/time
[in]elapsedTimeDecimal days since start of simulation
[in]tStepSimulation time step (days)
Returns
Number of new actions taken
See also
Declaration contract for controls_evaluate().
Here is the call graph for this function:

◆ controls_init()

void controls_init ( void )

Initializes the control rule system.

Here is the caller graph for this function: