changed old RTX to "KF-DAL", the Kalman Filter Demand Allocation Library
git-svn-id: https://epanet.svn.sourceforge.net/svnroot/epanet/BASE/trunk@348 c320cabd-cc23-0410-96d8-e60fbf53ed7f
This commit is contained in:
65
src/epanet.c
65
src/epanet.c
@@ -1074,6 +1074,8 @@ int DLLEXPORT ENgetoption(int code, float *value)
|
||||
break;
|
||||
case EN_DEMANDMULT: v = Dmult;
|
||||
break;
|
||||
case EN_HALTFLAG: v = checkHaltFlag(); /* sh - 4.2010 */
|
||||
break; /* sh - 4.2010 */
|
||||
default: return(251);
|
||||
}
|
||||
*value = (float)v;
|
||||
@@ -1186,7 +1188,7 @@ int DLLEXPORT ENgetpatternlen(int index, int *len)
|
||||
}
|
||||
|
||||
|
||||
int DLLEXPORT ENgetpatternvalue(int index, int period, float *value)
|
||||
int DLLEXPORT ENgetpatternvalue(int index, int period, double *value)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: index = index of time pattern
|
||||
** period = pattern time period
|
||||
@@ -1200,7 +1202,7 @@ int DLLEXPORT ENgetpatternvalue(int index, int period, float *value)
|
||||
if (!Openflag) return(102);
|
||||
if (index < 1 || index > Npats) return(205);
|
||||
if (period < 1 || period > Pattern[index].Length) return(251);
|
||||
*value = (float)Pattern[index].F[period-1];
|
||||
*value = Pattern[index].F[period-1];
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -1314,7 +1316,7 @@ int DLLEXPORT ENgetnodetype(int index, int *code)
|
||||
}
|
||||
|
||||
|
||||
int DLLEXPORT ENgetnodevalue(int index, int code, float *value)
|
||||
int DLLEXPORT ENgetnodevalue(int index, int code, double *value)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: index = node index
|
||||
** code = node parameter code (see TOOLKIT.H)
|
||||
@@ -1330,6 +1332,15 @@ int DLLEXPORT ENgetnodevalue(int index, int code, float *value)
|
||||
|
||||
/* Check for valid arguments */
|
||||
*value = 0.0f;
|
||||
|
||||
// added ability to get system-wide demand // SH added 4.2010
|
||||
if (index == 0) {
|
||||
v = Dsystem;
|
||||
v *= Ucf[FLOW];
|
||||
*value = v;
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (!Openflag) return(102);
|
||||
if (index <= 0 || index > Nnodes) return(203);
|
||||
|
||||
@@ -1475,9 +1486,17 @@ int DLLEXPORT ENgetnodevalue(int index, int code, float *value)
|
||||
|
||||
/*** New parameter additions ends here. ***/ //(2.00.12 - LR)
|
||||
|
||||
/*** SH addition: retreive tank volume ***/
|
||||
case EN_TANKVOLUME:
|
||||
if (index <= Njuncs) return(251);
|
||||
v = Tank[index-Njuncs].V0;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
default: return(251);
|
||||
}
|
||||
*value = (float)v;
|
||||
*value = v;
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -1562,7 +1581,7 @@ int DLLEXPORT ENgetlinknodes(int index, int *node1, int *node2)
|
||||
}
|
||||
|
||||
|
||||
int DLLEXPORT ENgetlinkvalue(int index, int code, float *value)
|
||||
int DLLEXPORT ENgetlinkvalue(int index, int code, double *value)
|
||||
/*------------------------------------------------------------------
|
||||
** Input: index = link index
|
||||
** code = link parameter code (see TOOLKIT.H)
|
||||
@@ -1696,7 +1715,7 @@ int DLLEXPORT ENgetlinkvalue(int index, int code, float *value)
|
||||
|
||||
default: return(251);
|
||||
}
|
||||
*value = (float)v;
|
||||
*value = v;
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -1797,7 +1816,7 @@ int DLLEXPORT ENsetcontrol(int cindex, int ctype, int lindex,
|
||||
}
|
||||
|
||||
|
||||
int DLLEXPORT ENsetnodevalue(int index, int code, float v)
|
||||
int DLLEXPORT ENsetnodevalue(int index, int code, double v)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: index = node index
|
||||
** code = node parameter code (see TOOLKIT.H)
|
||||
@@ -1847,11 +1866,22 @@ int DLLEXPORT ENsetnodevalue(int index, int code, float v)
|
||||
j = ROUND(value);
|
||||
if (j < 0 || j > Npats) return(205);
|
||||
if (index <= Njuncs)
|
||||
{
|
||||
for (demand = Node[index].D; demand != NULL; demand = demand ->next)
|
||||
{
|
||||
if (demand->next == NULL) demand->Pat = j;
|
||||
}
|
||||
{
|
||||
if (j == 0) { // SH 3.2010
|
||||
// we are re-setting the pattern assignment if we set pattern index to 0. // SH 3.2010
|
||||
demand = Node[index].D; // SH 3.2010
|
||||
demand->next = NULL; // SH 3.2010
|
||||
demand->Pat = 0; // SH 3.2010
|
||||
} // SH 3.2010
|
||||
else { // SH 3.2010
|
||||
for (demand = Node[index].D; demand != NULL; demand = demand ->next)
|
||||
{
|
||||
if (demand->next == NULL) demand->Pat = j;
|
||||
}
|
||||
} // SH 3.2010
|
||||
|
||||
|
||||
|
||||
}
|
||||
else Tank[index-Njuncs].Pat = j;
|
||||
break;
|
||||
@@ -2006,7 +2036,7 @@ int DLLEXPORT ENsetnodevalue(int index, int code, float v)
|
||||
}
|
||||
|
||||
|
||||
int DLLEXPORT ENsetlinkvalue(int index, int code, float v)
|
||||
int DLLEXPORT ENsetlinkvalue(int index, int code, double v)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: index = link index
|
||||
** code = link parameter code (see TOOLKIT.H)
|
||||
@@ -2252,7 +2282,7 @@ int DLLEXPORT ENsettimeparam(int code, long value)
|
||||
*/
|
||||
{
|
||||
if (!Openflag) return(102);
|
||||
if (OpenHflag || OpenQflag) return(109);
|
||||
//if (OpenHflag || OpenQflag) return(109);
|
||||
if (value < 0) return(202);
|
||||
switch(code)
|
||||
{
|
||||
@@ -2289,13 +2319,15 @@ int DLLEXPORT ENsettimeparam(int code, long value)
|
||||
case EN_STATISTIC: if (value > RANGE) return(202);
|
||||
Tstatflag = (char)value;
|
||||
break;
|
||||
case EN_HTIME: Htime = value;
|
||||
break;
|
||||
default: return(251);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int DLLEXPORT ENsetoption(int code, float v)
|
||||
int DLLEXPORT ENsetoption(int code, double v)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: code = option code (see TOOLKIT.H)
|
||||
** v = option value
|
||||
@@ -2332,6 +2364,9 @@ int DLLEXPORT ENsetoption(int code, float v)
|
||||
break;
|
||||
case EN_DEMANDMULT: if (value <= 0.0) return(202);
|
||||
Dmult = value;
|
||||
break;
|
||||
case EN_HALTFLAG: if (value < 0.0) return(202);
|
||||
setHaltFlag((int)value);
|
||||
break;
|
||||
default: return(251);
|
||||
}
|
||||
|
||||
@@ -82,6 +82,13 @@ double RelaxFactor; /
|
||||
/* Function to find flow coeffs. through open/closed valves */ //(2.00.11 - LR)
|
||||
void valvecoeff(int k); //(2.00.11 - LR)
|
||||
|
||||
int checkHaltFlag() {
|
||||
return Haltflag;
|
||||
}
|
||||
int setHaltFlag(int value) {
|
||||
Haltflag = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int openhyd()
|
||||
/*
|
||||
@@ -786,7 +793,8 @@ void controltimestep(long *tstep)
|
||||
long t,t1,t2;
|
||||
|
||||
for (i=1; i<=Ncontrols; i++)
|
||||
{
|
||||
{
|
||||
if (Control[i].Link == 0) continue;
|
||||
t = 0;
|
||||
if ( (n = Control[i].Node) > 0) /* Node control: */
|
||||
{
|
||||
|
||||
@@ -59,6 +59,8 @@ AUTHOR: L. Rossman
|
||||
#define EN_MIXFRACTION 22
|
||||
#define EN_TANK_KBULK 23
|
||||
|
||||
#define EN_TANKVOLUME 24 /* SH added 4.2010 */
|
||||
|
||||
#define EN_DIAMETER 0 /* Link parameters */
|
||||
#define EN_LENGTH 1
|
||||
#define EN_ROUGHNESS 2
|
||||
@@ -84,6 +86,8 @@ AUTHOR: L. Rossman
|
||||
#define EN_RULESTEP 7
|
||||
#define EN_STATISTIC 8
|
||||
#define EN_PERIODS 9
|
||||
#define EN_HTIME 10
|
||||
#define EN_HALTFLAG 11 /* sh 4.2010 */
|
||||
|
||||
#define EN_NODECOUNT 0 /* Component counts */
|
||||
#define EN_TANKCOUNT 1
|
||||
@@ -194,31 +198,31 @@ AUTHOR: L. Rossman
|
||||
int DLLEXPORT ENgetpatternindex(char *, int *);
|
||||
int DLLEXPORT ENgetpatternid(int, char *);
|
||||
int DLLEXPORT ENgetpatternlen(int, int *);
|
||||
int DLLEXPORT ENgetpatternvalue(int, int, float *);
|
||||
int DLLEXPORT ENgetpatternvalue(int, int, double *);
|
||||
int DLLEXPORT ENgetqualtype(int *, int *);
|
||||
int DLLEXPORT ENgeterror(int, char *, int);
|
||||
|
||||
int DLLEXPORT ENgetnodeindex(char *, int *);
|
||||
int DLLEXPORT ENgetnodeid(int, char *);
|
||||
int DLLEXPORT ENgetnodetype(int, int *);
|
||||
int DLLEXPORT ENgetnodevalue(int, int, float *);
|
||||
int DLLEXPORT ENgetnodevalue(int, int, double *);
|
||||
|
||||
int DLLEXPORT ENgetlinkindex(char *, int *);
|
||||
int DLLEXPORT ENgetlinkid(int, char *);
|
||||
int DLLEXPORT ENgetlinktype(int, int *);
|
||||
int DLLEXPORT ENgetlinknodes(int, int *, int *);
|
||||
int DLLEXPORT ENgetlinkvalue(int, int, float *);
|
||||
int DLLEXPORT ENgetlinkvalue(int, int, double *);
|
||||
|
||||
int DLLEXPORT ENgetversion(int *);
|
||||
|
||||
int DLLEXPORT ENsetcontrol(int, int, int, float, int, float);
|
||||
int DLLEXPORT ENsetnodevalue(int, int, float);
|
||||
int DLLEXPORT ENsetlinkvalue(int, int, float);
|
||||
int DLLEXPORT ENsetnodevalue(int, int, double);
|
||||
int DLLEXPORT ENsetlinkvalue(int, int, double);
|
||||
int DLLEXPORT ENaddpattern(char *);
|
||||
int DLLEXPORT ENsetpattern(int, float *, int);
|
||||
int DLLEXPORT ENsetpatternvalue(int, int, float);
|
||||
int DLLEXPORT ENsettimeparam(int, long);
|
||||
int DLLEXPORT ENsetoption(int, float);
|
||||
int DLLEXPORT ENsetoption(int, double);
|
||||
int DLLEXPORT ENsetstatusreport(int);
|
||||
int DLLEXPORT ENsetqualtype(int, char *, char *, char *);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user