Rewrite of EN_setlinktype function (#305)

- Complete rewrite of EN_setlinktype with link index argument passed by reference
- New unit test of EN_setlinktype added
- New function EN_setlinknodes added
This commit is contained in:
Lew Rossman
2018-10-28 16:58:43 -04:00
parent 7d021d8b82
commit 8514929622
6 changed files with 211 additions and 16 deletions

View File

@@ -288,7 +288,8 @@ Public Const EN_G_CURVE = 4 ' General\default curve
Declare Function ENinit Lib "epanet2.dll" (ByVal rptFile As String, ByVal binOutFile As String, ByVal UnitsType As Long, ByVal HeadlossFormula As Long) As Long
Declare Function ENsetheadcurveindex Lib "epanet2.dll" (ByVal pumpIndex As Long, ByVal curveIndex As Long) As Long
Declare Function ENsetlinktype Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long) As Long
Declare Function ENsetlinknodes Lib "epanet2.dll" (ByVal index As Long, ByVal node1 As Long, ByVal node2 As Long) As Long
Declare Function ENsetlinktype Lib "epanet2.dll" (index As Long, ByVal code As Long) As Long
Declare Function ENaddnode Lib "epanet2.dll" (ByVal id As String, ByVal nodeType As Long) As Long
Declare Function ENaddlink Lib "epanet2.dll" (ByVal id As String, ByVal linkType As Long, ByVal fromNode As String, ByVal toNode As String) As Long
Declare Function ENdeletelink Lib "epanet2.dll" (ByVal nodeIndex As Long) As Long

View File

@@ -743,12 +743,12 @@ extern "C" {
/**
@brief Set the link type code for a specified link
@param id The id of a link
@param type The type code of the link.
@param[in,out] index The index of a link before [in] and after [out] the type change.
@param code The new type code of the link.
@return Error code
@see EN_LinkType
*/
int DLLEXPORT ENsetlinktype(char *id, EN_LinkType type);
int DLLEXPORT ENsetlinktype(int *index, EN_LinkType code);
/**
@brief Get the indexes of a link's start- and end-nodes.
@@ -872,6 +872,16 @@ extern "C" {
*/
int DLLEXPORT ENsetlinkid(int index, char *newid);
/**
@brief Set the indexes of a link's start- and end-nodes.
@param index The index of a link (first link is index 1)
@param node1 The index of the link's start node (first node is index 1).
@param node2 The index of the link's end node (first node is index 1).
@return Error code
@see ENsetnodeid, ENsetlinkid
*/
int DLLEXPORT ENsetlinknodes(int index, int node1, int node2);
/**
@brief Set a property value for a link.
@param index The index of a link. First link is index 1.
@@ -1064,7 +1074,6 @@ extern "C" {
@see ENgetcurveindex ENsetcurve
*/
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.
@@ -1303,7 +1312,6 @@ extern "C" {
int DLLEXPORT EN_getlinkindex(EN_ProjectHandle ph, char *id, int *index);
int DLLEXPORT EN_getlinkid(EN_ProjectHandle ph, int index, char *id);
int DLLEXPORT EN_getlinktype(EN_ProjectHandle ph, int index, EN_LinkType *code);
int DLLEXPORT EN_setlinktype(EN_ProjectHandle ph, char *id, EN_LinkType type);
int DLLEXPORT EN_getlinknodes(EN_ProjectHandle ph, int index, int *node1, int *node2);
int DLLEXPORT EN_getlinkvalue(EN_ProjectHandle ph, int index, EN_LinkProperty code, EN_API_FLOAT_TYPE *value);
int DLLEXPORT EN_getcurve(EN_ProjectHandle ph, int curveIndex, char* id, int *nValues, EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues);
@@ -1319,6 +1327,8 @@ extern "C" {
int DLLEXPORT EN_setnodeid(EN_ProjectHandle ph, int index, char *newid);
int DLLEXPORT EN_setnodevalue(EN_ProjectHandle ph, int index, int code, EN_API_FLOAT_TYPE v);
int DLLEXPORT EN_setlinkid(EN_ProjectHandle ph, int index, char *newid);
int DLLEXPORT EN_setlinknodes(EN_ProjectHandle ph, int index, int node1, int node2);
int DLLEXPORT EN_setlinktype(EN_ProjectHandle ph, int *index, EN_LinkType code);
int DLLEXPORT EN_setlinkvalue(EN_ProjectHandle ph, int index, int code, EN_API_FLOAT_TYPE v);
int DLLEXPORT EN_addpattern(EN_ProjectHandle ph, char *id);
int DLLEXPORT EN_setpattern(EN_ProjectHandle ph, int index, EN_API_FLOAT_TYPE *f, int len);

View File

@@ -230,6 +230,8 @@ Public Const EN_CUSTOM = 2 ' user-defined custom curve
Declare Function ENsetnodeid Lib "epanet2.dll" (ByVal index As Int32, ByVal newid As String) As Int32
Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByVal Value As Single) As Int32
Declare Function ENsetlinkid Lib "epanet2.dll" (ByVal index As Int32, ByVal newid As String) As Int32
Declare Function ENsetlinknodes Lib "epanet2.dll" (ByVal index As Int32, ByVal node1 As Int32, ByVal node2 As Int32) As Int32
Declare Function ENsetlinktype Lib "epanet2.dll" (ByRef index As Int32, ByVal code As Int32) As Int32
Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByVal Value As Single) As Int32
Declare Function ENsetpattern Lib "epanet2.dll" (ByVal Index as Int32, ByRef F as Single, ByVal N as Int32) as Int32
Declare Function ENsetpatternvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Period As Int32, ByVal Value As Single) As Int32