OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches

Controls file local functions. More...

Collaboration diagram for Controls File Functions:

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.
 

Detailed Description

Controls file local functions.

Function Documentation

◆ addAction()

int addAction ( int  r,
char *  tok[],
int  nToks 
)

Adds a new action to a control rule.

Adds a new action to a control rule.

Parameters
[in]rRule index
[in]tokArray of string tokens containing action statement
[in]nToksNumber of string tokens
Returns
Error code
Parameters
[in]rRule index
[in]tokArray of string tokens containing action statement
[in]nToksNumber of string tokens
Returns
Error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addPremise()

int addPremise ( int  r,
int  type,
char *  tok[],
int  nToks 
)

Adds a premise clause to a control rule.

Adds a premise clause to a control rule.

Parameters
[in]rRule index
[in]typePremise type
[in]TokArray of string tokens
[in]nToksNumber of tokens
Returns
Error code
Parameters
[in]rRule index
[in]typePremise type
[in]TokArray of string tokens
[in]nToksNumber of tokens
Returns
Error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearActionList()

void clearActionList ( void  )

Clears action list.

Clears the list of actions to be executed.

Here is the caller graph for this function:

◆ compareTimes()

int compareTimes ( double  lhsValue,
int  relation,
double  rhsValue,
double  halfStep 
)

Compares two times.

Evaluates the truth of a relation between two date/times.

Parameters
[in]lhsValueLeft hand side value
[in]relationRelation operator
[in]rhsValueRight hand side value
[in]halfStepHalf time step
Returns
TRUE if relation is true, FALSE if not
Parameters
[in]lhsValueDate/time value on left hand side of relation
[in]relationRelational operator code (see RuleRelation enumeration)
[in]rhsValueDate/time value on right hand side of relation
[in]halfStep1/2 the current time step (days)
Returns
TRUE if time relation is satisfied, FALSE otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ compareValues()

int compareValues ( double  lhsValue,
int  relation,
double  rhsValue 
)

Compares two values.

Evaluates the truth of a relation between two values.

Parameters
[in]lhsValueLeft hand side value
[in]relationRelation operator
[in]rhsValueRight hand side value
Returns
TRUE if relation is true, FALSE if not
Parameters
[in]lhsValueValue on left hand side of relation
[in]relationRelational operator code (see RuleRelation enumeration)
[in]rhsValueValue on right hand side of relation
Returns
TRUE if relation is satisfied, FALSE otherwise
Here is the caller graph for this function:

◆ deleteActionList()

void deleteActionList ( void  )

Deletes action list.

Frees the memory used to hold the list of actions to be executed.

Here is the caller graph for this function:

◆ deleteRules()

void deleteRules ( void  )

Deletes control rules.

Frees the memory used for all of the control rules.

Here is the caller graph for this function:

◆ evaluatePremise()

int evaluatePremise ( struct TPremise p,
double  tStep 
)

Evaluates premise clause of a control rule.

Evaluates the truth of a control rule premise condition.

Parameters
[in]pPremise structure to evaluate
[in]tStepTime step
Returns
TRUE if premise is true, FALSE if not
Parameters
[in]pControl rule premise condition
[in]tStepCurrent time step (days)
Returns
TRUE if the condition is true, FALSE otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ executeActionList()

int executeActionList ( DateTime  currentTime)

Executes action list.

Executes all actions required by fired control rules.

Parameters
[in]currentTimeCurrent time
Returns
Error code
Parameters
[in]currentTimeCurrent simulation date/time
Returns
Number of new actions taken
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findExactMatch()

int findExactMatch ( char *  s,
char *  keyword[] 
)

Finds the exact match between a string and an array of keyword strings.

Finds the exact match between a string and an array of keyword strings.

Parameters
[in]sCharacter string
[in]keywordArray of keyword strings
Returns
Index of keyword which matches s or -1 if no match found
Parameters
[in]sCharacter string
[in]keywordArray of keyword strings
Returns
Index of keyword which matches s or -1 if no match found
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getExpressionIndex()

int getExpressionIndex ( char *  exprName)

Gets expression index.

Gets expression index.

Parameters
[in]exprNameName of expression to find index of
Returns
Index of expression
Parameters
[in]exprNameName of expression to find index of
Returns
Index of expression
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getGageAttrib()

int getGageAttrib ( char *  token)

Determines the attribute code for a rain gage variable.

Determines the attribute code for a rain gage variable.

Parameters
[in]tokenString token
Returns
Attribute code or -1 if an error occurred
Note
A valid token is INTENSITY for current rainfall intensity (attribute code = 0) or nHR_PRECIP for total rain depth over past n hours (attribute code = n).
Parameters
[in]tokenString token
Returns
Attribute code or -1 if an error occurred
Note
A valid token is INTENSITY for current rainfall intensity (attribute code = 0) or nHR_PRECIP for total rain depth over past n hours (attribute code = n).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNamedVariableValue()

double getNamedVariableValue ( int  varIndex)

Gets named variable value.

Gets the value of a variable.

Parameters
[in]varIndexIndex of variable
Returns
Value of variable

Gets variable value.

Parameters
[in]vVariable structure
Returns
Value of variable
Parameters
[in]vVariable structure
Returns
Variable value
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPIDSetting()

double getPIDSetting ( struct TAction a,
double  dt 
)

Gets PID setting.

Computes a new setting for a link subject to a PID controller.

Parameters
[in]aAction structure
[in]dtTime step
Returns
Value of action
Parameters
[in]aAction object
[in]dtCurrent time step (days)
Returns
New link setting value
Note
  • a->kp = gain coefficient,
  • a->ki = integral time (minutes),
  • a->k2 = derivative time (minutes),
  • a->e1 = error from previous time step,
  • a->e2 = error from two time steps ago
Here is the caller graph for this function:

◆ getPremiseValue()

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.

Parses the numerical value of a particular node/link attribute in the premise clause of a control rule.

Parameters
[in]tokenString token
[in]attribIndex of a node/link attribute
[out]valueAttribute value
Returns
Error code
Parameters
[in]tokenString token
[in]attribIndex of a node/link attribute
[out]valueAttribute value
Returns
Error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPremiseVariable()

int getPremiseVariable ( char *  tok[],
int  nToks,
int *  k,
struct TVariable v 
)

Parses a variable (e.g., Node 123 Depth) used in a control rule.

Parses a variable (e.g., Node 123 Depth) used in a control rule.

Parameters
[in]tokArray of string tokens
[in]nToksNumber of tokens
[in]kIndex of current token
[in,out]vVariable structure
Returns
Error code; updates k to new current token and places identity of specified variable in v
Parameters
[in]tokArray of string tokens
[in]nToksNumber of tokens
[in]kIndex of current token
[in,out]vVariable structure
Returns
Error code; updates k to new current token and places identity of specified variable in v
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRainValue()

double getRainValue ( struct TVariable  v)

Gets rain value.

Retrieves the current or past rainfall amount for a rain gage.

Parameters
vVariable structure
[in]vRule premise variable for a rain gage
Returns
Current or past rainfall amount
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getVariableIndex()

int getVariableIndex ( char *  varName)

Gets variable index.

Parameters
[in]varNameName of variable to find index of
Returns
Index of variable
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getVariableValue()

double getVariableValue ( struct TVariable  v)

Gets the value of a variable.

Gets variable value.

Parameters
[in]vVariable structure
Returns
Value of variable
Parameters
[in]vVariable structure
Returns
Variable value
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setActionSetting()

int setActionSetting ( char *  tok[],
int  nToks,
int *  curve,
int *  tseries,
int *  attrib,
double  values[] 
)

Identifies how control actions settings are determined.

Parameters
[in]tokArray of string tokens containing action statement
[in]nToksNumber of string tokens
[in]curveIndex of controller curve
[in]tseriesIndex of controller time series
[in]attribr_PID if PID controller used
[out]valuesValues of control settings
Returns
Error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateActionList()

void updateActionList ( struct TAction a)

Updates action list.

Adds a new action to the list of actions to be taken.

Parameters
[in]aAction structure
Here is the caller graph for this function:

◆ updateActionValue()

void updateActionValue ( struct TAction a,
DateTime  currentTime,
double  dt 
)

Updates the value of a control action.

Updates the value of actions found from Curves or Time Series.

Parameters
[in]aAction structure
[in]currentTimeCurrent time
[in]dtTime step
[in]aAction structure
[in]currentTimeCurrent time of simulation in days (days)
[in]dtTime step (days)
Here is the call graph for this function:
Here is the caller graph for this function: