Merge pull request #84 from AngelaMarchi/ChangingRuleBased

Changing rule based
This commit is contained in:
Elad Salomons
2016-09-23 14:00:34 +03:00
committed by GitHub
8 changed files with 726 additions and 48 deletions

View File

@@ -79,6 +79,7 @@ Global Const EN_LINKCOUNT = 2
Global Const EN_PATCOUNT = 3
Global Const EN_CURVECOUNT = 4
Global Const EN_CONTROLCOUNT = 5
Global Const EN_RULECOUNT = 6
Global Const EN_JUNCTION = 0 ' Node types
Global Const EN_RESERVOIR = 1
@@ -231,4 +232,17 @@ Global Const EN_CUSTOM = 2 ' user-defined custom curve
Declare Function ENgetcurvevalue Lib "epanet2.dll" (ByVal Index As Long, ByVal Ptn As Long, X As Single, Y As Single) As Long
Declare Function ENsetcurvevalue Lib "epanet2.dll" (ByVal Index As Long, ByVal Ptn As Long, ByVal X As Single, ByVal Y As Single) As Long
Declare Function ENsetcurve Lib "epanet2.dll" (ByVal Index As Long, X As Any, Y As Any, ByVal N As Long) As Long
Declare Function ENaddcurve Lib "epanet2.dll" (ByVal ID As String) As Long
Declare Function ENaddcurve Lib "epanet2.dll" (ByVal ID As String) As Long
Declare Function ENgetrule Lib "epanet2.dll" (ByVal index As Long, nPremises As Long, nTrueActions As Long, nFalseActions As Long, priority As Double) As Long
Declare Function ENsetrulepriority Lib "epanet2.dll" (ByVal index As Long, ByVal priority As Double) As Long
Declare Function ENgetpremise Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexPremise As Long, logop As Long, object As Long, indexObj As Long, variable As Long, relop As Long, status As Long, value As Double) As Long
Declare Function ENsetpremise Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexPremise As Long, ByVal logop As Long, ByVal object As Long, ByVal indexObj As Long, ByVal variable As Long, ByVal relop As Long, ByVal status As Long, ByVal value As Double) As Long
Declare Function ENsetpremiseindex Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexPremise As Long, ByVal indexObj As Long) As Long
Declare Function ENsetpremisestatus Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexPremise As Long, ByVal status As Long) As Long
Declare Function ENsetpremisevalue Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexPremise As Long, ByVal value As Double) As Long
Declare Function ENgettrueaction Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexAction As Long, indexLink As Long, status As Long, setting As Double) As Long
Declare Function ENsettrueaction Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexAction As Long, ByVal indexLink As Long, ByVal status As Long, ByVal setting As Double) As Long
Decalre FUnction ENgetfalseaction Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexAction As Long, indexLink As Long, status As Long, setting As Double) As Long
Declare Function ENsetfalseaction Lib "epanet2.dll" (ByVal indexRule As Long, ByVal indexAction As Long, ByVal indexLink As Long, ByVal status As Long, ByVal setting As Double) As Long
Declare Function ENgetruleID Lib "epanet2.dll" (ByVal indexRule As Long, ByVal id As String) As Long

View File

@@ -145,7 +145,8 @@ typedef enum {
EN_LINKCOUNT = 2, /**< Number of Links (Pipes + Pumps + Valves) */
EN_PATCOUNT = 3, /**< Number of Time Patterns */
EN_CURVECOUNT = 4, /**< Number of Curves */
EN_CONTROLCOUNT = 5 /**< Number of Control Statements */
EN_CONTROLCOUNT = 5, /**< Number of Control Statements */
EN_RULECOUNT = 6 /**< Number of Rule-based Control Statements */
} EN_CountType;
typedef enum {
@@ -904,6 +905,136 @@ extern "C" {
*/
int DLLEXPORT ENaddcurve(char *id);
/**
@brief Gets the number of premises, true actions, and false actions and the priority of an existing rule-based control.
@param index The index of a rule-based control.
@param nPremises The number of conditions in a rule-based control.
@param nTrueActions The number of actions that are executed when the conditions in the rule-based control are met.
@param nFalseActions The number of actions that are executed when the conditions in the rule-based control are not met.
@param priority The priority of a rule-based control.
@return Error code.
*/
int DLLEXPORT ENgetrule(int index, int *nPremises, int *nTrueActions, int *nFalseActions, double *priority);
/**
@brief Sets the priority of the existing rule-based control.
@param index The index of a rule-based control.
@param priority The priority to be set in the rule-based control.
@return Error code.
*/
int DLLEXPORT ENsetrulepriority(int index, double priority);
/**
@brief Gets the components of a premise/condition in an existing rule-based control.
@param indexRule The index of a rule-based control.
@param indexPremise The index of the premise.
@param logop The logiv operator (IF/AND/OR) in the premise
@param object The object (e.g. TANK) the premise is looking at.
@param indexObj The index of the object (e.g. the index of the tank).
@param variable The variable to be checked (e.g. level).
@param relop The relashionship operator (e.g. LARGER THAN) in the premise.
@param status The status of the object to be checked (e.g. CLOSED)
@param value The value of the variable to be checked (e.g. 5.5)
@return Error code.
*/
int DLLEXPORT ENgetpremise(int indexRule, int indexPremise, int *logop, int *object, int *indexObj, int *variable, int *relop, int *status, double *value);
/**
@brief Sets the components of a premise/condition in an existing rule-based control.
@param indexRule The index of a rule-based control.
@param indexPremise The index of the premise.
@param logop The logiv operator (IF/AND/OR) in the premise
@param object The object (e.g. TANK) the premise is looking at.
@param indexObj The index of the object (e.g. the index of the tank).
@param variable The variable to be checked (e.g. level).
@param relop The relashionship operator (e.g. LARGER THAN) in the premise.
@param status The status of the object to be checked (e.g. CLOSED)
@param value The value of the variable to be checked (e.g. 5.5)
@return Error code.
*/
int DLLEXPORT ENsetpremise(int indexRule, int indexPremise, int logop, int object, int indexObj, int variable, int relop, int status, double value);
/**
@brief Sets the index of an object in a premise of an existing rule-based control.
@param indexRule The index of a rule-based control.
@param indexPremise The index of the premise.
@param indexObj The index of the object (e.g. the index of the tank).
@return Error code.
*/
int DLLEXPORT ENsetpremiseindex(int indexRule, int indexPremise, int indexObj);
/**
@brief Sets the status in a premise of an existing rule-based control.
@param indexRule The index of a rule-based control.
@param indexPremise The index of the premise.
@param status The status of the object to be checked (e.g. CLOSED)
@return Error code.
*/
int DLLEXPORT ENsetpremisestatus(int indexRule, int indexPremise, int status);
/**
@brief Sets the value in a premise of an existing rule-based control.
@param indexRule The index of a rule-based control.
@param indexPremise The index of the premise.
@param value The value of the variable to be checked (e.g. 5.5)
@return Error code.
*/
int DLLEXPORT ENsetpremisevalue(int indexRule, int indexPremise, double value);
/**
@brief Gets the components of a true-action in an existing rule-based control.
@param indexRule The index of a rule-based control.
@param indexAction The index of the action when the conditions in the rule are met.
@param indexLink The index of the link in the action (e.g. index of Pump 1)
@param status The status of the link (e.g. CLOSED)
@param setting The value of the link (e.g. pump speed 0.9)
@return Error code.
*/
int DLLEXPORT ENgettrueaction(int indexRule, int indexAction, int *indexLink, int *status, double *setting);
/**
@brief Sets the components of a true-action in an existing rule-based control.
@param indexRule The index of a rule-based control.
@param indexAction The index of the action when the conditions in the rule are met.
@param indexLink The index of the link in the action (e.g. index of Pump 1)
@param status The status of the link (e.g. CLOSED)
@param setting The value of the link (e.g. pump speed 0.9)
@return Error code.
*/
int DLLEXPORT ENsettrueaction(int indexRule, int indexAction, int indexLink, int status, double setting);
/**
@brief Gets the components of a false-action in an existing rule-based control.
@param indexRule The index of a rule-based control.
@param indexAction The index of the action when the conditions in the rule are not met.
@param indexLink The index of the link in the action (e.g. index of Pump 1)
@param status The status of the link (e.g. CLOSED)
@param setting The value of the link (e.g. pump speed 0.9)
@return Error code.
*/
int DLLEXPORT ENgetfalseaction(int indexRule, int indexAction, int *indexLink, int *status, double *setting);
/**
@brief Sets the components of a false-action in an existing rule-based control.
@param indexRule The index of a rule-based control.
@param indexAction The index of the action when the conditions in the rule are not met.
@param indexLink The index of the link in the action (e.g. index of Pump 1)
@param status The status of the link (e.g. CLOSED)
@param setting The value of the link (e.g. pump speed 0.9)
@return Error code.
*/
int DLLEXPORT ENsetfalseaction(int indexRule, int indexAction, int indexLink, int status,double setting);
/**
@brief Returns the ID of a rule.
@param indexRule The index of a rule-based control.
@param id The ID of the rule
@return Error code.
*/
int DLLEXPORT ENgetruleID(int indexRule, char* id);
#if defined(__cplusplus)
}
#endif

View File

@@ -76,6 +76,7 @@ Public Const EN_LINKCOUNT = 2
Public Const EN_PATCOUNT = 3
Public Const EN_CURVECOUNT = 4
Public Const EN_CONTROLCOUNT = 5
Public Const EN_RULECOUNT = 6
Public Const EN_JUNCTION = 0 ' Node types
Public Const EN_RESERVOIR = 1
@@ -225,5 +226,22 @@ Public Const EN_CUSTOM = 2 ' user-defined custom curve
Declare Function ENsetcurvevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Pnt As Int32, ByVal X As Single, ByVal Y As Single) As Int32
Declare Function ENsetcurve Lib "epanet2.dll" (ByVal Index as Int32, ByRef X as Single, ByRef Y as Single, ByVal N as Int32) as Int32
Declare Function ENaddcurve Lib "epanet2.dll" (ByVal ID As String) As Int32
Declare Function ENaddcurve Lib "epanet2.dll" (ByVal ID As String) As Long
Declare Function ENgetrule Lib "epanet2.dll" (ByVal index As Int32, ByRef nPremises As Int32, ByRef nTrueActions As Int32, ByRef nFalseActions As Int32, ByRef priority As Double) As Int32
Declare Function ENsetrulepriority Lib "epanet2.dll" (ByVal index As Int32, ByVal priority As Double) As Int32
Declare Function ENgetpremise Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexPremise As Int32, ByRef logop As Int32, ByRef object As Int32, ByRef indexObj As Int32, ByRef variable As Int32, ByRef relop As Int32, ByRef status As Int32, ByRef value As Double) As Int32
Declare Function ENsetpremise Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexPremise As Int32, ByVal logop As Int32, ByVal object As Int32, ByVal indexObj As Int32, ByVal variable As Int32, ByVal relop As Int32, ByVal status As Int32, ByVal value As Double) As Int32
Declare Function ENsetpremiseindex Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexPremise As Int32, ByVal indexObj As Int32) As Int32
Declare Function ENsetpremisestatus Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexPremise As Int32, ByVal status As Int32) As Int32
Declare Function ENsetpremisevalue Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexPremise As Int32, ByVal value As Double) As Int32
Declare Function ENgettrueaction Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexAction As Int32, ByRef indexLink As Int32, ByRef status As Int32, ByRef setting As Double) As Int32
Declare Function ENsettrueaction Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexAction As Int32, ByVal indexLink As Int32, ByVal status As Int32, ByVal setting As Double) As Int32
Decalre FUnction ENgetfalseaction Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexAction As Int32, ByRef indexLink As Int32, ByRef status As Int32, ByRef setting As Double) As Int32
Declare Function ENsetfalseaction Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal indexAction As Int32, ByVal indexLink As Int32, ByVal status As Int32, ByVal setting As Double) As Int32
Declare Function ENgetruleID Lib "epanet2.dll" (ByVal indexRule As Int32, ByVal id As StringBuilder) As Int32
End Module