Added curve GET functions
ENgetcurveindex, ENgetcurveid, ENgetcurvelen and ENgetcurvevalue. This is for issue #9
This commit is contained in:
@@ -67,4 +67,8 @@ EXPORTS
|
||||
ENsetbasedemand = _ENsetbasedemand@12
|
||||
ENgetaveragepatternvalue = _ENgetaveragepatternvalue@8
|
||||
ENgetheadcurve = _ENgetheadcurve@8
|
||||
ENgetpumptype = _ENgetpumptype@8
|
||||
ENgetpumptype = _ENgetpumptype@8
|
||||
ENgetcurveindex = _ENgetcurveindex@8
|
||||
ENgetcurveid = _ENgetcurveid@8
|
||||
ENgetcurvelen = _ENgetcurvelen@8
|
||||
ENgetcurvevalue = _ENgetcurvevalue@16
|
||||
@@ -219,3 +219,8 @@ Global Const EN_INITFLOW = 10 ' Re-initialize flow flag
|
||||
Declare Function ENsetqualtype Lib "epanet2.dll" (ByVal QualCode As Long, ByVal ChemName As String, ByVal ChemUnits As String, ByVal TraceNode As String) As Long
|
||||
Declare Function ENgetqualinfo Lib "epanet2.dll" (QualCode As Long, ChemName As String, ChemUnits As String, TraceNode As Long) As Long
|
||||
Declare Function ENsetbasedemand Lib "epanet2.dll" (ByVal NodeIndex As Long, ByVal DemandIndex As Long, ByVal BaseDemand As Single) As Long
|
||||
|
||||
Declare Function ENgetcurveindex Lib "epanet2.dll" (ByVal ID As String, Index As Long) As Long
|
||||
Declare Function ENgetcurveid Lib "epanet2.dll" (ByVal Index As Long, ByVal ID As String) As Long
|
||||
Declare Function ENgetcurvelen Lib "epanet2.dll" (ByVal Index As Long, L As Long) As Long
|
||||
Declare Function ENgetcurvevalue Lib "epanet2.dll" (ByVal Index As Long, ByVal Ptn As Long, X As Single, Y As Single) As Long
|
||||
@@ -271,7 +271,12 @@ extern "C" {
|
||||
int DLLEXPORT ENsetqualtype(int qualcode, char *chemname, char *chemunits, char *tracenode);
|
||||
int DLLEXPORT ENgetqualinfo(int *qualcode, char *chemname, char *chemunits, int *tracenode);
|
||||
int DLLEXPORT ENsetbasedemand(int nodeIndex, int demandIdx, EN_API_FLOAT_TYPE baseDemand);
|
||||
|
||||
|
||||
int DLLEXPORT ENgetcurveindex(char *id, int *index);
|
||||
int DLLEXPORT ENgetcurveid(int index, char *id);
|
||||
int DLLEXPORT ENgetcurvelen(int index, int *len);
|
||||
int DLLEXPORT ENgetcurvevalue(int index, int pnt, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -217,4 +217,9 @@ Public Const EN_CUSTOM = 2 ' user-defined custom curve
|
||||
|
||||
Declare Function ENaddpattern Lib "epanet2.dll" (ByVal ID As String) As Int32
|
||||
|
||||
Declare Function ENgetcurveindex Lib "epanet2.dll" (ByVal ID As String, ByRef Index As Int32) As Int32
|
||||
Declare Function ENgetcurveid Lib "epanet2.dll" (ByVal Index As Int32, ByVal ID As StringBuilder) As Int32
|
||||
Declare Function ENgetcurvelen Lib "epanet2.dll" (ByVal Index As Int32, ByRef L As Int32) As Int32
|
||||
Declare Function ENgetcurvevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Pnt As Int32, ByRef X As Single, ByRef Y As Single) As Int32
|
||||
|
||||
End Module
|
||||
|
||||
83
src/epanet.c
83
src/epanet.c
@@ -1137,6 +1137,89 @@ int DLLEXPORT ENgetpatternvalue(int index, int period, EN_API_FLOAT_TYPE *value)
|
||||
}
|
||||
|
||||
|
||||
int DLLEXPORT ENgetcurveindex(char *id, int *index)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: id = curve ID
|
||||
** Output: *index = index of curve in list of curves
|
||||
** Returns: error code
|
||||
** Purpose: retrieves index of curve with specific ID
|
||||
**----------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
int i;
|
||||
*index = 0;
|
||||
if (!Openflag) return(102);
|
||||
for (i=1; i<=Ncurves; i++)
|
||||
{
|
||||
if (strcmp(id, Curve[i].ID) == 0)
|
||||
{
|
||||
*index = i;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
*index = 0;
|
||||
return(206);
|
||||
}
|
||||
|
||||
|
||||
int DLLEXPORT ENgetcurveid(int index, char *id)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: index = index of curve
|
||||
** Output: id = curve ID
|
||||
** Returns: error code
|
||||
** Purpose: retrieves ID of a curve with specific index
|
||||
**
|
||||
** NOTE: 'id' must be able to hold MAXID characters
|
||||
**----------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
strcpy(id,"");
|
||||
if (!Openflag) return(102);
|
||||
if (index < 1 || index > Ncurves) return(206);
|
||||
strcpy(id,Curve[index].ID);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int DLLEXPORT ENgetcurvelen(int index, int *len)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: index = index of curve
|
||||
** Output: *len = curve length (number of points in curve)
|
||||
** Returns: error code
|
||||
** Purpose: retrieves number of points in a curve
|
||||
**----------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
if (!Openflag) return(102);
|
||||
if (index < 1 || index > Ncurves) return(206);
|
||||
*len = Curve[index].Npts;
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int DLLEXPORT ENgetcurvevalue(int index, int pnt, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: index = index of curve
|
||||
** pnt = curve's point number
|
||||
** Output: *x = curve x value
|
||||
** curve y value
|
||||
** Returns: error code
|
||||
** Purpose: retrieves x,y point for a specific point number
|
||||
** and curve
|
||||
**----------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
*x = 0.0;
|
||||
*y = 0.0;
|
||||
if (!Openflag) return(102);
|
||||
if (index < 1 || index > Ncurves) return(206);
|
||||
if (pnt < 1 || pnt > Curve[index].Npts) return(251);
|
||||
*x = (EN_API_FLOAT_TYPE)Curve[index].X[pnt-1];
|
||||
*y = (EN_API_FLOAT_TYPE)Curve[index].Y[pnt-1];
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int DLLEXPORT ENgetqualtype(int *qualcode, int *tracenode)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: none
|
||||
|
||||
Reference in New Issue
Block a user