Fix PumpType and CurveType enums

Also adds a general \default curve type. Fixes #208.
This commit is contained in:
Elad Salomons
2018-08-15 07:37:19 +03:00
parent 528e99a791
commit 4e48c31147
4 changed files with 20 additions and 18 deletions

View File

@@ -154,6 +154,13 @@ Public Const EN_INITFLOW = 10 ' Re-initialize flow flag
Public Const EN_CONST_HP = 0 ' constant horsepower Public Const EN_CONST_HP = 0 ' constant horsepower
Public Const EN_POWER_FUNC = 1 ' power function Public Const EN_POWER_FUNC = 1 ' power function
Public Const EN_CUSTOM = 2 ' user-defined custom curve Public Const EN_CUSTOM = 2 ' user-defined custom curve
Public Const EN_NOCURVE = 3 ' no curve
Public Const EN_V_CURVE = 0 ' volume curve
Public Const EN_P_CURVE = 1 ' pump curve
Public Const EN_E_CURVE = 2 ' efficiency curve
Public Const EN_H_CURVE = 3 ' head loss curve
Public Const EN_G_CURVE = 4 ' General\default curve
'These are the external functions that comprise the DLL 'These are the external functions that comprise the DLL

View File

@@ -224,8 +224,6 @@ typedef enum {
EN_TIMEOFDAY = 3 EN_TIMEOFDAY = 3
} EN_ControlType; } EN_ControlType;
typedef enum { typedef enum {
EN_AVERAGE = 1, /* Time statistic types. */ EN_AVERAGE = 1, /* Time statistic types. */
EN_MINIMUM = 2, /* See TstatType in TYPES.H */ EN_MINIMUM = 2, /* See TstatType in TYPES.H */
@@ -233,8 +231,6 @@ typedef enum {
EN_RANGE = 4 EN_RANGE = 4
} EN_StatisticType; } EN_StatisticType;
typedef enum { typedef enum {
EN_MIX1 = 0, /* Tank mixing models */ EN_MIX1 = 0, /* Tank mixing models */
EN_MIX2 = 1, EN_MIX2 = 1,
@@ -242,8 +238,6 @@ typedef enum {
EN_LIFO = 3 EN_LIFO = 3
} EN_MixingModel; } EN_MixingModel;
typedef enum { typedef enum {
EN_NOSAVE = 0, EN_NOSAVE = 0,
EN_SAVE = 1, EN_SAVE = 1,
@@ -251,8 +245,6 @@ typedef enum {
EN_SAVE_AND_INIT = 11 EN_SAVE_AND_INIT = 11
} EN_SaveOption; } EN_SaveOption;
typedef enum { typedef enum {
EN_CONST_HP = 0, /* constant horsepower */ EN_CONST_HP = 0, /* constant horsepower */
EN_POWER_FUNC = 1, /* power function */ EN_POWER_FUNC = 1, /* power function */
@@ -260,6 +252,13 @@ typedef enum {
} EN_CurveType; } EN_CurveType;
typedef enum {
EN_V_CURVE = 0, /* volume curve */
EN_P_CURVE = 1, /* pump curve */
EN_E_CURVE = 2, /* efficiency curve */
EN_H_CURVE = 3, /* head loss curve */
EN_G_CURVE = 4 /* General\default curve */
} EN_CurveType;
// --- Declare the EPANET toolkit functions // --- Declare the EPANET toolkit functions
#if defined(__cplusplus) #if defined(__cplusplus)

View File

@@ -2933,7 +2933,7 @@ int DLLEXPORT EN_addcurve(EN_Project *p, char *id) {
strcpy(tmpCur[n].ID, id); strcpy(tmpCur[n].ID, id);
tmpCur[n].Npts = 1; tmpCur[n].Npts = 1;
tmpCur[n].Type = -1; tmpCur[n].Type = G_CURVE;
tmpCur[n].X = (double *)calloc(tmpCur[n].Npts, sizeof(double)); tmpCur[n].X = (double *)calloc(tmpCur[n].Npts, sizeof(double));
tmpCur[n].Y = (double *)calloc(tmpCur[n].Npts, sizeof(double)); tmpCur[n].Y = (double *)calloc(tmpCur[n].Npts, sizeof(double));
if (tmpCur[n].X == NULL) if (tmpCur[n].X == NULL)
@@ -2974,9 +2974,7 @@ int DLLEXPORT EN_addcurve(EN_Project *p, char *id) {
int DLLEXPORT EN_setcurve(EN_Project *p, int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y, int n) { int DLLEXPORT EN_setcurve(EN_Project *p, int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y, int n) {
EN_Network *net = &p->network; EN_Network *net = &p->network;
Scurve *Curve = net->Curve; Scurve *Curve = net->Curve;
int j; int j;
/* Check for valid arguments */ /* Check for valid arguments */
@@ -3007,12 +3005,9 @@ int DLLEXPORT EN_setcurve(EN_Project *p, int index, EN_API_FLOAT_TYPE *x, EN_API
int DLLEXPORT EN_setcurvevalue(EN_Project *p, int index, int pnt, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y) { int DLLEXPORT EN_setcurvevalue(EN_Project *p, int index, int pnt, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y) {
EN_Network *net = &p->network; EN_Network *net = &p->network;
Scurve *Curve = net->Curve; Scurve *Curve = net->Curve;
const int Ncurves = net->Ncurves; const int Ncurves = net->Ncurves;
if (!p->Openflag) if (!p->Openflag)
return (102); return (102);
if (index <= 0 || index > Ncurves) if (index <= 0 || index > Ncurves)
@@ -3713,7 +3708,7 @@ int allocdata(EN_Project *p)
} }
for (n = 0; n <= par->MaxCurves; n++) { for (n = 0; n <= par->MaxCurves; n++) {
net->Curve[n].Npts = 0; net->Curve[n].Npts = 0;
net->Curve[n].Type = -1; net->Curve[n].Type = G_CURVE;
net->Curve[n].X = NULL; net->Curve[n].X = NULL;
net->Curve[n].Y = NULL; net->Curve[n].Y = NULL;
} }

View File

@@ -151,8 +151,9 @@ typedef enum {
V_CURVE, /* volume curve */ V_CURVE, /* volume curve */
P_CURVE, /* pump curve */ P_CURVE, /* pump curve */
E_CURVE, /* efficiency curve */ E_CURVE, /* efficiency curve */
H_CURVE H_CURVE, /* head loss curve */
} CurveType; /* head loss curve */ G_CURVE /* General\default curve */
} CurveType;
typedef enum { typedef enum {
CONST_HP, /* constant horsepower */ CONST_HP, /* constant horsepower */