Merge pull request #873 from OpenWaterAnalytics/Fix_Set_InitSetting
Fix set EN_INITSETTING and EN_INITSTATUS
This commit is contained in:
@@ -4177,6 +4177,10 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
|
||||
{
|
||||
Link[index].Kc = value;
|
||||
Link[index].InitSetting = value;
|
||||
if (Link[index].Type > PUMP && Link[index].Type != GPV)
|
||||
{
|
||||
Link[index].InitStatus = ACTIVE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4338,8 +4342,12 @@ int DLLEXPORT EN_setpipedata(EN_Project p, int index, double length,
|
||||
if (p->hydraul.Formflag == DW) Link[index].Kc /= (1000.0 * Ucf[ELEV]);
|
||||
|
||||
// Update minor loss factor & pipe flow resistance
|
||||
if (p->hydraul.OpenHflag)
|
||||
{
|
||||
Link[index].Km = 0.02517 * mloss / SQR(Link[index].Diam) / SQR(Link[index].Diam);
|
||||
resistcoeff(p, index);
|
||||
}
|
||||
else Link[index].InitSetting = Link[index].Kc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ void tanklevels(Project *, long);
|
||||
void resetpumpflow(Project *, int);
|
||||
void getallpumpsenergy(Project *);
|
||||
|
||||
|
||||
int openhyd(Project *pr)
|
||||
/*
|
||||
*--------------------------------------------------------------
|
||||
@@ -126,19 +127,10 @@ void inithyd(Project *pr, int initflag)
|
||||
// Initialize status and setting
|
||||
hyd->LinkStatus[i] = link->InitStatus;
|
||||
hyd->LinkSetting[i] = link->InitSetting;
|
||||
|
||||
// Setting of non-ACTIVE FCV, PRV, PSV valves is "MISSING"
|
||||
switch (link->Type)
|
||||
if (link->Type > PUMP && link->Type != GPV && link->InitStatus != ACTIVE)
|
||||
{
|
||||
case FCV:
|
||||
case PRV:
|
||||
case PSV:
|
||||
if (link->InitStatus != ACTIVE)
|
||||
{
|
||||
link->Kc = MISSING;
|
||||
hyd->LinkSetting[i] = MISSING;
|
||||
}
|
||||
}
|
||||
|
||||
// Compute flow resistance
|
||||
resistcoeff(pr, i);
|
||||
@@ -146,7 +138,7 @@ void inithyd(Project *pr, int initflag)
|
||||
// Start active control valves in ACTIVE position
|
||||
if (
|
||||
(link->Type == PRV || link->Type == PSV
|
||||
|| link->Type == FCV) && (link->Kc != MISSING)
|
||||
|| link->Type == FCV) && (hyd->LinkSetting[i] != MISSING)
|
||||
) hyd->LinkStatus[i] = ACTIVE;
|
||||
|
||||
// Initialize flows if necessary
|
||||
@@ -475,7 +467,7 @@ void setlinksetting(Project *pr, int index, double value, StatusType *s,
|
||||
else
|
||||
{
|
||||
if (*k == MISSING && *s <= CLOSED) *s = OPEN;
|
||||
if (t == PCV) link->R = pcvlosscoeff(pr, index, link->Kc);
|
||||
if (t == PCV) link->R = pcvlosscoeff(pr, index, value);
|
||||
*k = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,6 +191,7 @@ void writelogo(Project *pr)
|
||||
int version;
|
||||
int major;
|
||||
int minor;
|
||||
int patch;
|
||||
char s[80];
|
||||
time_t timer; // time_t structure & functions time() &
|
||||
// ctime() are defined in time.h
|
||||
@@ -198,6 +199,7 @@ void writelogo(Project *pr)
|
||||
version = CODEVERSION;
|
||||
major = version / 10000;
|
||||
minor = (version % 10000) / 100;
|
||||
patch = version % 100;
|
||||
|
||||
time(&timer);
|
||||
strcpy(rpt->DateStamp, ctime(&timer));
|
||||
@@ -209,7 +211,7 @@ void writelogo(Project *pr)
|
||||
writeline(pr, LOGO2);
|
||||
writeline(pr, LOGO3);
|
||||
writeline(pr, LOGO4);
|
||||
sprintf(s, LOGO5, major, minor);
|
||||
sprintf(s, LOGO5, major, minor, patch);
|
||||
writeline(pr, s);
|
||||
writeline(pr, LOGO6);
|
||||
writeline(pr, "");
|
||||
|
||||
@@ -359,7 +359,7 @@
|
||||
#define LOGO4 \
|
||||
"* Analysis for Pipe Networks *"
|
||||
#define LOGO5 \
|
||||
"* Version %d.%d *"
|
||||
"* Version %d.%d.%02d *"
|
||||
#define LOGO6 \
|
||||
"******************************************************************"
|
||||
#define FMT02 "\n o Retrieving network data"
|
||||
|
||||
@@ -31,7 +31,7 @@ typedef int INT4;
|
||||
Various constants
|
||||
----------------------------------------------
|
||||
*/
|
||||
#define CODEVERSION 20300
|
||||
#define CODEVERSION 20301
|
||||
#define MAGICNUMBER 516114521
|
||||
#define ENGINE_VERSION 201 // Used for binary hydraulics file
|
||||
#define EOFMARK 0x1A // Use 0x04 for UNIX systems
|
||||
|
||||
Reference in New Issue
Block a user