Closed gustavods14 closed 2 years ago
Hello Gustavo, Add "ByRef" to the last parameter of the function "ENaddcontrol" Use zero instead of "EN_R_IS_CLOSED". Use one instead of "EN_R_IS_OPEN". "EN_R_IS_CLOSED" and "EN_R_IS_OPEN" Used for rules
Hi, @eladsal @LRossman With my friend Gustavo we have found, apparently, a bug in the simple control rules. After writing the lines of code:
ENopen(FileInput, "", "") ENaddcontrol(EN_TIMER, 13, 1340.75, 0, 3600, 3) ENaddcontrol(EN_TIMER, 13, 800.75, 0, 7200, 4) ENaddcontrol(EN_TIMER, 13, 1, 0, 10800, 5) ------> '1 = Open ENsaveinpfile(FileOutput) ENclose()
And generate an INP file, and after running a simulation, Epanet interprets the value of 1 as a setting when in fact the valve is asked to be open. Is it possible that it is an error?. If it is an error, I think a solution is to write "Open" instead of 1 and "Closed" instead of 0.
You can't use the ENaddcontrol
and ENsetcontrol
API functions to fix the status of a pressure or flow control valve to fully open or fully closed (thus making the valve non-active). Those functions can only adjust the valve's pressure or flow setting. This should have been explained more clearly in the Toolkit documentation.
Here are two ways to set a control valve's status to OPEN or CLOSED at a particular point in time (that corresponds to a whole number of hydraulic time steps):
ENaddrule ("RULE Link13_Timer\nIF SYSTEM TIME = 10800\nTHEN LINK 13 STATUS IS OPEN")
long t = 0, tstep;
do {
if (t == 10800) then
ENsetlinkvalue(13, EN_STATUS, EN_OPEN);
ENrunH(&t);
ENnextH(&tstep);
} while (tstep > 0);
Thanks @LRossman
Thanks @Ostoveni @LRossman !
closing as resolved
I want to add simple control from toolkit EPANET v 2.2 using VB.net. Bbut how i can add control valve closed or open?, for example: "LINK VALVE-1 CLOSED AT TIME 0" "LINK VALVE-1 OPEN AT TIME 1"
There is a constant (Rule status types) in Epanet2: EN_R_IS_OPEN = 1 and EN_R_IS_CLOSED=2 .... but, when i write the code:
... and Open the INP file, Controls looks like: "LINK VALVE-1 2.000 AT TIME 0" "LINK VALVE-1 1.000 AT TIME 1"