Merge branch 'dev' into contributor-lr

This commit is contained in:
Michael Tryby
2018-08-24 16:09:21 -04:00
committed by GitHub
11 changed files with 467 additions and 47 deletions

View File

@@ -449,6 +449,10 @@ int DLLEXPORT ENgetpumptype(int index, int *type) {
return EN_getpumptype(_defaultModel, index, type);
}
int DLLEXPORT ENgetcurvetype(int curveindex, int *type) {
return EN_getcurvetype(_defaultModel, curveindex, type);
}
int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands) {
return EN_getnumdemands(_defaultModel, nodeIndex, numDemands);
}
@@ -2046,6 +2050,7 @@ int DLLEXPORT EN_getlinknodes(EN_Project *p, int index, int *node1,
int DLLEXPORT EN_getlinkvalue(EN_Project *p, int index, EN_LinkProperty code, EN_API_FLOAT_TYPE *value) {
double a, h, q, v = 0.0;
int returnValue = 0;
int pmp;
EN_Network *net = &p->network;
hydraulics_t *hyd = &p->hydraulics;
@@ -2059,8 +2064,6 @@ int DLLEXPORT EN_getlinkvalue(EN_Project *p, int index, EN_LinkProperty code, EN
double *LinkFlows = hyd->LinkFlows;
double *LinkSetting = hyd->LinkSetting;
/* Check for valid arguments */
*value = 0.0;
if (!p->Openflag)
@@ -2176,6 +2179,38 @@ int DLLEXPORT EN_getlinkvalue(EN_Project *p, int index, EN_LinkProperty code, EN
else
v = 1.0;
break;
case EN_STATE:
v = hyd->LinkStatus[index];
if (Link[index].Type == EN_PUMP) {
pmp = findpump(net, index);
if (hyd->LinkStatus[index] >= OPEN) {
if (hyd->LinkFlows[index] > hyd->LinkSetting[index] * Pump[pmp].Qmax)
v = XFLOW;
if (hyd->LinkFlows[index] < 0.0)
v = XHEAD;
}
}
break;
case EN_CONST_POWER:
v = 0;
if (Link[index].Type == EN_PUMP) {
pmp = findpump(net, index);
if (Pump[pmp].Ptype == CONST_HP) {
v = Link[index].Km; // Power in HP
}
}
break;
case EN_SPEED:
v = 0;
if (Link[index].Type == EN_PUMP) {
pmp = findpump(net, index);
v = Link[index].Kc;
}
break;
case EN_SETTING:
if (Link[index].Type == EN_PIPE || Link[index].Type == EN_CVPIPE) {
@@ -2985,7 +3020,7 @@ int DLLEXPORT EN_addcurve(EN_Project *p, char *id) {
strcpy(tmpCur[n].ID, id);
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].Y = (double *)calloc(tmpCur[n].Npts, sizeof(double));
if (tmpCur[n].X == NULL)
@@ -3026,9 +3061,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) {
EN_Network *net = &p->network;
Scurve *Curve = net->Curve;
Scurve *Curve = net->Curve;
int j;
/* Check for valid arguments */
@@ -3059,12 +3092,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) {
EN_Network *net = &p->network;
Scurve *Curve = net->Curve;
const int Ncurves = net->Ncurves;
if (!p->Openflag)
return (102);
if (index <= 0 || index > Ncurves)
@@ -3375,7 +3405,8 @@ int DLLEXPORT EN_setheadcurveindex(EN_Project *p, int index, int curveindex) {
pump->Q0 /= Ucf[FLOW];
pump->Qmax /= Ucf[FLOW];
pump->Hmax /= Ucf[HEAD];
p->network.Curve[curveindex].Type = P_CURVE;
return (0);
}
@@ -3396,6 +3427,18 @@ int DLLEXPORT EN_getpumptype(EN_Project *p, int index, int *type) {
return (0);
}
int DLLEXPORT EN_getcurvetype(EN_Project *p, int curveindex, int *type) {
EN_Network *net = &p->network;
if (!p->Openflag)
return (102);
if (curveindex < 1 || curveindex > net->Ncurves)
return (206);
*type = net->Curve[curveindex].Type;
return (0);
}
/*
----------------------------------------------------------------
Functions for opening files
@@ -3765,7 +3808,7 @@ int allocdata(EN_Project *p)
}
for (n = 0; n <= par->MaxCurves; n++) {
net->Curve[n].Npts = 0;
net->Curve[n].Type = -1;
net->Curve[n].Type = G_CURVE;
net->Curve[n].X = NULL;
net->Curve[n].Y = NULL;
}

View File

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