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

Conversation

manuelgilm
Copy link

@manuelgilm manuelgilm commented May 12, 2021

def ENgetcontrol(self, cindex):#<------------
    """Retrieves the parameters of a simple control statement.
    Arguments:
       cindex:  control statement index
    
    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#<------------

I modified this function to return the control rule parameters, in this case I used the ctypes.byref method to pass the correct arguments to ENgetcontrol function, and returned them. Now the Python function only receives one parameter, the control rule index.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant