OWA-EPANET Toolkit  2.2
Rule-Based Control Functions

These functions are used for working with rule-based controls. More...

Functions

int EN_addrule (EN_Project ph, char *rule)
 Adds a new rule-based control to a project. More...
 
int EN_deleterule (EN_Project ph, int index)
 Deletes an existing rule-based control. More...
 
int EN_getrule (EN_Project ph, int index, int *nPremises, int *nThenActions, int *nElseActions, double *priority)
 Retrieves summary information about a rule-based control. More...
 
int EN_getruleID (EN_Project ph, int index, char *out_id)
 Gets the ID name of a rule-based control given its index. More...
 
int EN_getpremise (EN_Project ph, int ruleIndex, int premiseIndex, int *logop, int *object, int *objIndex, int *variable, int *relop, int *status, double *value)
 Gets the properties of a premise in a rule-based control. More...
 
int EN_setpremise (EN_Project ph, int ruleIndex, int premiseIndex, int logop, int object, int objIndex, int variable, int relop, int status, double value)
 Sets the properties of a premise in a rule-based control. More...
 
int EN_setpremiseindex (EN_Project ph, int ruleIndex, int premiseIndex, int objIndex)
 Sets the index of an object in a premise of a rule-based control. More...
 
int EN_setpremisestatus (EN_Project ph, int ruleIndex, int premiseIndex, int status)
 Sets the status being compared to in a premise of a rule-based control. More...
 
int EN_setpremisevalue (EN_Project ph, int ruleIndex, int premiseIndex, double value)
 Sets the value in a premise of a rule-based control. More...
 
int EN_getthenaction (EN_Project ph, int ruleIndex, int actionIndex, int *linkIndex, int *status, double *setting)
 Gets the properties of a THEN action in a rule-based control. More...
 
int EN_setthenaction (EN_Project ph, int ruleIndex, int actionIndex, int linkIndex, int status, double setting)
 Sets the properties of a THEN action in a rule-based control. More...
 
int EN_getelseaction (EN_Project ph, int ruleIndex, int actionIndex, int *linkIndex, int *status, double *setting)
 Gets the properties of an ELSE action in a rule-based control. More...
 
int EN_setelseaction (EN_Project ph, int ruleIndex, int actionIndex, int linkIndex, int status, double setting)
 Sets the properties of an ELSE action in a rule-based control. More...
 
int EN_setrulepriority (EN_Project ph, int index, double priority)
 Sets the priority of a rule-based control. More...
 

Overview

These functions are used for working with rule-based controls.

Function Documentation

◆ EN_addrule()

int EN_addrule ( EN_Project  ph,
char *  rule 
)

Adds a new rule-based control to a project.

Parameters
phan EPANET project handle.
ruletext of the rule following the format used in an EPANET input file.
Returns
an error code.

Consult the [RULES] section of the Input File topic to learn about a rule's format. Each clause of the rule must end with a newline character \n.

◆ EN_deleterule()

int EN_deleterule ( EN_Project  ph,
int  index 
)

Deletes an existing rule-based control.

Parameters
phan EPANET project handle.
indexthe index of the rule to be deleted (starting from 1).
Returns
an error code.

◆ EN_getelseaction()

int EN_getelseaction ( EN_Project  ph,
int  ruleIndex,
int  actionIndex,
int *  linkIndex,
int *  status,
double *  setting 
)

Gets the properties of an ELSE action in a rule-based control.

Parameters
phan EPANET project handle.
ruleIndexthe rule's index (starting from 1).
actionIndexthe index of the ELSE action to retrieve (starting from 1).
[out]linkIndexthe index of the link in the action.
[out]statusthe status assigned to the link (see EN_RuleStatus).
[out]settingthe value assigned to the link's setting.
Returns
an error code.

◆ EN_getpremise()

int EN_getpremise ( EN_Project  ph,
int  ruleIndex,
int  premiseIndex,
int *  logop,
int *  object,
int *  objIndex,
int *  variable,
int *  relop,
int *  status,
double *  value 
)

Gets the properties of a premise in a rule-based control.

Parameters
phan EPANET project handle.
ruleIndexthe rule's index (starting from 1).
premiseIndexthe position of the premise in the rule's list of premises (starting from 1).
[out]logopthe premise's logical operator ( IF = 1, AND = 2, OR = 3 ).
[out]objectthe type of object the premise refers to (see EN_RuleObject).
[out]objIndexthe index of the object (e.g. the index of a tank).
[out]variablethe object's variable being compared (see EN_RuleVariable).
[out]relopthe premise's comparison operator (see EN_RuleOperator).
[out]statusthe status that the object's status is compared to (see EN_RuleStatus).
[out]valuethe value that the object's variable is compared to.
Returns
an error code.

◆ EN_getrule()

int EN_getrule ( EN_Project  ph,
int  index,
int *  nPremises,
int *  nThenActions,
int *  nElseActions,
double *  priority 
)

Retrieves summary information about a rule-based control.

Parameters
phan EPANET project handle.
indexthe rule's index (starting from 1).
[out]nPremisesnumber of premises in the rule's IF section.
[out]nThenActionsnumber of actions in the rule's THEN section.
[out]nElseActionsnumber of actions in the rule's ELSE section.
[out]prioritythe rule's priority value.
Returns
an error code.

◆ EN_getruleID()

int EN_getruleID ( EN_Project  ph,
int  index,
char *  out_id 
)

Gets the ID name of a rule-based control given its index.

Parameters
phan EPANET project handle.
indexthe rule's index (starting from 1).
[out]out_idthe rule's ID name.
Returns
Error code.

The ID name must be sized to hold at least EN_MAXID characters.

◆ EN_getthenaction()

int EN_getthenaction ( EN_Project  ph,
int  ruleIndex,
int  actionIndex,
int *  linkIndex,
int *  status,
double *  setting 
)

Gets the properties of a THEN action in a rule-based control.

Parameters
phan EPANET project handle.
ruleIndexthe rule's index (starting from 1).
actionIndexthe index of the THEN action to retrieve (starting from 1).
[out]linkIndexthe index of the link in the action (starting from 1).
[out]statusthe status assigned to the link (see EN_RuleStatus)
[out]settingthe value assigned to the link's setting.
Returns
an error code.

◆ EN_setelseaction()

int EN_setelseaction ( EN_Project  ph,
int  ruleIndex,
int  actionIndex,
int  linkIndex,
int  status,
double  setting 
)

Sets the properties of an ELSE action in a rule-based control.

Parameters
phan EPANET project handle.
ruleIndexthe rule's index (starting from 1).
actionIndexthe index of the ELSE action being modified (starting from 1).
linkIndexthe index of the link in the action (starting from 1).
statusthe new status assigned to the link (see EN_RuleStatus)
settingthe new value assigned to the link's setting.
Returns
an error code.

◆ EN_setpremise()

int EN_setpremise ( EN_Project  ph,
int  ruleIndex,
int  premiseIndex,
int  logop,
int  object,
int  objIndex,
int  variable,
int  relop,
int  status,
double  value 
)

Sets the properties of a premise in a rule-based control.

Parameters
phan EPANET project handle.
ruleIndexthe rule's index (starting from 1).
premiseIndexthe position of the premise in the rule's list of premises.
logopthe premise's logical operator ( IF = 1, AND = 2, OR = 3 ).
objectthe type of object the premise refers to (see EN_RuleObject).
objIndexthe index of the object (e.g. the index of a tank).
variablethe object's variable being compared (see EN_RuleVariable).
relopthe premise's comparison operator (see EN_RuleOperator).
statusthe status that the object's status is compared to (see EN_RuleStatus).
valuethe value that the object's variable is compared to.
Returns
an error code.

◆ EN_setpremiseindex()

int EN_setpremiseindex ( EN_Project  ph,
int  ruleIndex,
int  premiseIndex,
int  objIndex 
)

Sets the index of an object in a premise of a rule-based control.

Parameters
phan EPANET project handle.
ruleIndexthe rule's index (starting from 1).
premiseIndexthe premise's index (starting from 1).
objIndexthe index of the premise's object (e.g. the index of a tank).
Returns
an error code.

◆ EN_setpremisestatus()

int EN_setpremisestatus ( EN_Project  ph,
int  ruleIndex,
int  premiseIndex,
int  status 
)

Sets the status being compared to in a premise of a rule-based control.

Parameters
phan EPANET project handle.
ruleIndexthe rule's index (starting from 1).
premiseIndexthe premise's index (starting from 1).
statusthe status that the premise's object status is compared to (see EN_RuleStatus).
Returns
an error code.

◆ EN_setpremisevalue()

int EN_setpremisevalue ( EN_Project  ph,
int  ruleIndex,
int  premiseIndex,
double  value 
)

Sets the value in a premise of a rule-based control.

Parameters
phan EPANET project handle.
ruleIndexthe rule's index (staring from 1).
premiseIndexthe premise's index (starting from 1).
valueThe value that the premise's variable is compared to.
Returns
an error code.

◆ EN_setrulepriority()

int EN_setrulepriority ( EN_Project  ph,
int  index,
double  priority 
)

Sets the priority of a rule-based control.

Parameters
phan EPANET project handle.
indexthe rule's index (starting from 1).
prioritythe priority value assigned to the rule.
Returns
an error code.

◆ EN_setthenaction()

int EN_setthenaction ( EN_Project  ph,
int  ruleIndex,
int  actionIndex,
int  linkIndex,
int  status,
double  setting 
)

Sets the properties of a THEN action in a rule-based control.

Parameters
phan EPANET project handle.
ruleIndexthe rule's index (starting from 1).
actionIndexthe index of the THEN action to modify (starting from 1).
linkIndexthe index of the link in the action.
statusthe new status assigned to the link (see EN_RuleStatus).
settingthe new value assigned to the link's setting.
Returns
an error code.