Skip to content

Commit 761199b

Browse files
eladsalmilad-ghiami
andcommitted
Added ENgetcurvetype API
Also update curve type on EN_setheadcurveindex. Co-Authored-By: milad ghiami <[email protected]>
1 parent 634651d commit 761199b

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

include/epanet2.bas

+1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ Public Const EN_G_CURVE = 4 ' General\default curve
229229
Declare Function ENgetcurve Lib "epanet2.dll" (ByVal curveIndex As Long, ByVal CurveID As String, nValues As Long, xValues As Any, yValues As Any) As Long
230230
Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal pumpIndex As Long, curveIndex As Long) As Long
231231
Declare Function ENgetpumptype Lib "epanet2.dll" (ByVal index As Long, PumpType As Long) As Long
232+
Declare Function ENgetcurvetype Lib "epanet2.dll" (ByVal curveindex As Long, CurveType As Long) As Long
232233

233234
Declare Function ENgetversion Lib "epanet2.dll" (value As Long) As Long
234235

include/epanet2.h

+12-2
Original file line numberDiff line numberDiff line change
@@ -763,10 +763,19 @@ extern "C" {
763763
@param linkIndex The index of the pump element
764764
@param[out] outType The integer-typed pump curve type signifier (output parameter)
765765
@return Error code
766-
@see EN_CurveType
766+
@see EN_PumpType
767767
*/
768768
int DLLEXPORT ENgetpumptype(int linkIndex, int *outType);
769-
769+
770+
/**
771+
@brief Get the type of a curve
772+
@param curveIndex The index of the curve element
773+
@param[out] outType The integer-typed curve curve type signifier (output parameter)
774+
@return Error code
775+
@see EN_CurveType
776+
*/
777+
int DLLEXPORT ENgetcurvetype(int curveIndex, int *outType);
778+
770779
/**
771780
@brief Get the version number. This number is to be interpreted with implied decimals, i.e., "20100" == "2(.)01(.)00"
772781
@param[out] version The version of EPANET
@@ -1189,6 +1198,7 @@ extern "C" {
11891198
int DLLEXPORT EN_getheadcurveindex(EN_Project *p, int pumpIndex, int *curveIndex);
11901199
int DLLEXPORT EN_setheadcurveindex(EN_Project *p, int pumpIndex, int curveIndex);
11911200
int DLLEXPORT EN_getpumptype(EN_Project *p, int linkIndex, int *outType);
1201+
int DLLEXPORT EN_getcurvetype(EN_Project *p, int curveIndex, int *outType);
11921202
int DLLEXPORT EN_getversion(int *version);
11931203
int DLLEXPORT EN_setcontrol(EN_Project *p, int cindex, int ctype, int lindex, EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level);
11941204
int DLLEXPORT EN_setnodevalue(EN_Project *p, int index, int code, EN_API_FLOAT_TYPE v);

src/epanet.c

+18-1
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,10 @@ int DLLEXPORT ENgetpumptype(int index, int *type) {
435435
return EN_getpumptype(_defaultModel, index, type);
436436
}
437437

438+
int DLLEXPORT ENgetcurvetype(int curveindex, int *type) {
439+
return EN_getcurvetype(_defaultModel, curveindex, type);
440+
}
441+
438442
int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands) {
439443
return EN_getnumdemands(_defaultModel, nodeIndex, numDemands);
440444
}
@@ -3349,7 +3353,8 @@ int DLLEXPORT EN_setheadcurveindex(EN_Project *p, int index, int curveindex) {
33493353
pump->Q0 /= Ucf[FLOW];
33503354
pump->Qmax /= Ucf[FLOW];
33513355
pump->Hmax /= Ucf[HEAD];
3352-
3356+
3357+
p->network.Curve[curveindex].Type = P_CURVE;
33533358
return (0);
33543359
}
33553360

@@ -3370,6 +3375,18 @@ int DLLEXPORT EN_getpumptype(EN_Project *p, int index, int *type) {
33703375
return (0);
33713376
}
33723377

3378+
int DLLEXPORT EN_getcurvetype(EN_Project *p, int curveindex, int *type) {
3379+
3380+
EN_Network *net = &p->network;
3381+
3382+
if (!p->Openflag)
3383+
return (102);
3384+
if (curveindex < 1 || curveindex > net->Ncurves)
3385+
return (206);
3386+
*type = net->Curve[curveindex].Type;
3387+
return (0);
3388+
}
3389+
33733390
/*
33743391
----------------------------------------------------------------
33753392
Functions for opening files

win_build/WinSDK/epanet2.def

+2-1
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,5 @@ EXPORTS
9292
ENaddlink = _ENaddlink@16
9393
ENdeletelink = _ENdeletelink@4
9494
ENdeletenode = _ENdeletenode@4
95-
ENsetlinktype = _ENsetlinktype@8
95+
ENsetlinktype = _ENsetlinktype@8
96+
ENgetcurvetype = _ENgetcurvetype@8

0 commit comments

Comments
 (0)