Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting network controls #34

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions epynet/epanet2.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,24 +352,31 @@ def ENgetqualtype(self, qualcode):


#-------Retrieving other network information--------
def ENgetcontrol(self, cindex, ctype, lindex, setting, nindex, level ):
def ENgetcontrol(self, cindex):
"""Retrieves the parameters of a simple control statement.
Arguments:
cindex: control statement index
ctype: control type code EN_LOWLEVEL (Low Level Control)
EN_HILEVEL (High Level Control)
EN_TIMER (Timer Control)
EN_TIMEOFDAY (Time-of-Day Control)
lindex: index of link being controlled
setting: value of the control setting
nindex: index of controlling node
level: value of controlling water level or pressure for level controls
or of time of control action (in seconds) for time-based controls"""
#int ENgetcontrol(int cindex, int* ctype, int* lindex, float* setting, int* nindex, float* level )
ierr= self._lib.EN_getcontrol(self.ph, ctypes.c_int(cindex), ctypes.c_int(ctype),
ctypes.c_int(lindex), ctypes.c_float(setting),
ctypes.c_int(nindex), ctypes.c_float(level) )
if ierr!=0: raise ENtoolkitError(self, ierr)

returns ctype: control type code:
EN_LOWLEVEL (Low Level Control)
EN_HILEVEL (High Level Control)
EN_TIMER (Timer Control)
EN_TIMEOFDAY (Time-of-Day Control)
lindex: index of link being controlled
setting: value of the control setting
nindex: index of controlling node
level: value of controlling water level or pressure for level controls
or of time of control action (in seconds) for time-based controls
"""
type_ = ctypes.c_int()
lindex = ctypes.c_int()
setting = ctypes.c_float()
nindex = ctypes.c_int()
level = ctypes.c_float()
ierr = self._lib.EN_getcontrol(self.ph, ctypes.c_int(cindex), ctypes.byref(type_), ctypes.byref(lindex),
ctypes.byref(setting), ctypes.byref(nindex),ctypes.byref(level), ctypes.byref(level))
if ierr!=0: raise ENtoolkitError(self,ierr)
return type_.value,lindex.value, setting.value, nindex.value, level.value


def ENgetoption(self, optioncode):
Expand All @@ -381,7 +388,7 @@ def ENgetoption(self, optioncode):
EN_TOLERANCE
EN_EMITEXPON
EN_DEMANDMULT"""
j= ctypes.c_int()
j= ctypes.c_float() #<--- solved: c_int() changed to c_float()
ierr= self._lib.EN_getoption(self.ph, optioncode, ctypes.byref(j))
if ierr!=0: raise ENtoolkitError(self, ierr)
return j.value
Expand Down Expand Up @@ -617,7 +624,7 @@ def ENsettimeparam(self, paramcode, timevalue):
if ierr!=0: raise ENtoolkitError(self, ierr)


def ENsetoption(self, optioncode, value):
def ENsetoption(self, paramcode, value): #<------------- solved: optioncode changed to paramcode
"""Sets the value of a particular analysis option.

Arguments:
Expand Down