Refactors the API's demand editing functions

This commit is contained in:
Lew Rossman
2019-05-09 10:26:40 -04:00
parent 52bda22833
commit 365ab00dcb
22 changed files with 449 additions and 1124 deletions

View File

@@ -307,6 +307,9 @@ Public Const EN_R_IS_ACTIVE = 3
'Nodal Demand Functions
Declare Function ENgetdemandmodel Lib "epanet2.dll" (type_ As Long, pmin As Single, preq As Single, pexp As Single) As Long
Declare Function ENsetdemandmodel Lib "epanet2.dll" (ByVal type_ As Long, ByVal pmin As Single, ByVal preq As Single, ByVal pexp As Single) As Long
Declare Function ENadddemand Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal baseDemand As Single, ByVal patternName As String, ByVal demandName As String) As Long
Declare Function ENdeletedemand Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long) As Long
Declare Function ENgetdemandindex Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandName As String, demandIndex As Long) As Long
Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal nodeIndex As Long, numDemands As Long) As Long
Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long, value As Single) As Long
Declare Function ENsetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long, ByVal BaseDemand As Single) As Long

View File

@@ -5,6 +5,7 @@ EXPORTS
ENaddcurve = _ENaddcurve@4
ENaddlink = _ENaddlink@20
ENaddnode = _ENaddnode@12
ENadddemand = _ENadddemand@16
ENaddpattern = _ENaddpattern@4
ENaddrule = _ENaddrule@4
ENclearreport = _ENclearreport@0
@@ -14,6 +15,7 @@ EXPORTS
ENcopyreport = _ENcopyreport@4
ENdeletecontrol = _ENdeletecontrol@4
ENdeletecurve = _ENdeletecurve@4
ENdeletedemand = _ENdeletedemand@8
ENdeletelink = _ENdeletelink@8
ENdeletenode = _ENdeletenode@8
ENdeletepattern = _ENdeletepattern@4
@@ -30,7 +32,8 @@ EXPORTS
ENgetcurveindex = _ENgetcurveindex@8
ENgetcurvelen = _ENgetcurvelen@8
ENgetcurvetype = _ENgetcurvetype@8
ENgetcurvevalue = _ENgetcurvevalue@16
ENgetcurvevalue = _ENgetcurvevalue@16
ENgetdemandindex = _ENgetdemandindex@12
ENgetdemandmodel = _ENgetdemandmodel@16
ENgetdemandname = _ENgetdemandname@12
ENgetdemandpattern = _ENgetdemandpattern@12

View File

@@ -230,8 +230,15 @@ extern "C" {
int DLLEXPORT ENsetdemandmodel(int model, EN_API_FLOAT_TYPE pmin,
EN_API_FLOAT_TYPE preq, EN_API_FLOAT_TYPE pexp);
int DLLEXPORT ENadddemand(int nodeIndex, EN_API_FLOAT_TYPE baseDemand,
char *demandPattern, char *demandName);
int DLLEXPORT ENdeletedemand(int nodeIndex, int demandIndex);
int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands);
int DLLEXPORT ENgetdemandindex(int nodeIndex, char *demandName, int *demandIndex);
int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIndex,
EN_API_FLOAT_TYPE *baseDemand);

View File

@@ -312,6 +312,9 @@ Public Const EN_R_IS_ACTIVE = 3
'Nodal Demand Functions
Declare Function ENgetdemandmodel Lib "epanet2.dll" (type_ As Int32, pmin As Single, preq As Single, pexp As Single) As Int32
Declare Function ENsetdemandmodel Lib "epanet2.dll" (ByVal type_ As Int32, ByVal pmin As Single, ByVal preq As Single, ByVal pexp As Single) As Int32
Declare Function ENadddemand Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal baseDemand As Single, ByVal patternName As String, ByVal demandName As String) As Int32
Declare Function ENdeletedemand Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32) As Int32
Declare Function ENgetdemandindex Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandName As String, demandIndex As Int32) As Int32
Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal nodeIndex As Int32, numDemands As Int32) As Int32
Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, value As Single) As Int32
Declare Function ENsetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, ByVal BaseDemand As Single) As Int32

View File

@@ -853,13 +853,6 @@ typedef struct Project *EN_Project;
int DLLEXPORT EN_setjuncdata(EN_Project ph, int index, double elev, double dmnd,
char *dmndpat);
int DLLEXPORT EN_adddemand(EN_Project p, int node_index, double demand,
char *demand_pattern, const char *category_name, int *demand_index);
int DLLEXPORT EN_removedemand(EN_Project p, int node_index, int demand_index);
/**
@brief Sets a group of properties for a tank node.
@param ph an EPANET project handle.
@@ -940,6 +933,41 @@ typedef struct Project *EN_Project;
int DLLEXPORT EN_setdemandmodel(EN_Project ph, int type, double pmin,
double preq, double pexp);
/**
@brief appends a new demand to a junction node demands list.
@param ph an EPANET project handle.
@param nodeIndex the index of a node (starting from 1).
@param baseDemand the demand's base value.
@param demandPattern the name of a time pattern used by the demand
@param demandName the name of the demand's category
@return an error code.
A NULL or blank string can be used for `demandPattern` and for `demandName` to indicate
that no time pattern or category name is associated with the demand.
*/
int DLLEXPORT EN_adddemand(EN_Project ph, int nodeIndex, double baseDemand,
char *demandPattern, char *demandName);
/**
@brief deletes a demand from a junction node.
@param ph an EPANET project handle.
@param nodeIndex the index of a node (starting from 1).
@param demandIndex the position of the demand in the node's demands list (starting from 1).
@return an error code.
*/
int DLLEXPORT EN_deletedemand(EN_Project ph, int nodeIndex, int demandIndex);
/**
@brief Retrieves the index of a node's named demand category
@param nodeIndex the index of a node (starting from 1)
@param demandName the name of a demand category for the node
@param[out] demandIndex the index of the demand being sought
@return an error code
*/
int DLLEXPORT EN_getdemandindex(EN_Project p, int nodeIndex, char *demandName,
int *demandIndex);
/**
@brief Retrieves the number of demand categories for a junction node.
@param ph an EPANET project handle.