This commit is contained in:
Michael Tryby
2018-08-20 07:45:34 -04:00
3 changed files with 40 additions and 3 deletions

View File

@@ -56,6 +56,9 @@ Public Const EN_EFFICIENCY = 16
Public Const EN_HEADCURVE = 17
Public Const EN_EFFICIENCYCURVE = 18
Public Const EN_PRICEPATTERN = 19
Public Const EN_STATE = 20
Public Const EN_CONST_POWER = 21
Public Const EN_SPEED = 22
Public Const EN_DURATION = 0 ' Time parameters
Public Const EN_HYDSTEP = 1

View File

@@ -115,7 +115,10 @@ typedef enum {
EN_EFFICIENCY = 16,
EN_HEADCURVE = 17,
EN_EFFICIENCYCURVE = 18,
EN_PRICEPATTERN = 19
EN_PRICEPATTERN = 19,
EN_STATE = 20,
EN_CONST_POWER = 21,
EN_SPEED = 22
} EN_LinkProperty;
/// Time parameter codes

View File

@@ -1994,6 +1994,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;
@@ -2007,8 +2008,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)
@@ -2125,6 +2124,38 @@ int DLLEXPORT EN_getlinkvalue(EN_Project *p, int index, EN_LinkProperty code, EN
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) {
return (ENgetlinkvalue(index, EN_ROUGHNESS, value));