def read_all(cls, output): """ Read all items of this class from the output file into a dictionary. Intended to be called only in the constructor of the output file object. Args output (OutputObject): object that has already opened the desired output file. Returns (dictionary): Python dictionary of all objects of this type, keyed by name. """ items = {} item_count = output._call_int(_lib.ENR_getNetSize, cls._count_flag) ctypes_name = _lib.String((_lib.MAXID + 1) * '\0') for index in range(1, item_count + 1): _lib.ENR_getElementName(output.ptrapi, cls._elementType, index, ctypes_name) name = str(ctypes_name) items[name] = cls(name, index) return items
##ENR_LinkAttribute; from Externals.epanet.outputapi.outputapi import ENR_flow, ENR_velocity, ENR_headloss, ENR_avgQuality from Externals.epanet.outputapi.outputapi import ENR_status, ENR_setting, ENR_rxRate, ENR_frctnFctr ENR_LinkAttributes = (ENR_flow, ENR_velocity, ENR_headloss, ENR_avgQuality, ENR_status, ENR_setting, ENR_rxRate, ENR_frctnFctr) ENR_LinkAttributeNames = ('Flow', 'Velocity', 'Unit Headloss', 'Quality', 'Status', 'Setting', 'Reaction Rate', 'Friction Factor') ENR_LinkAttributeUnits = (('CFS', 'LPS'), ('fps', 'm/s'), ('ft/Kft', 'm/km'), ('mg/L', 'mg/L'), ('', ''), ('', ''), ('mg/L/d', 'mg/L/d'), ('', '')) ENR_UnitsUS = 0 ENR_UnitsSI = 1 #--------------------------------------------------------------------------------------------- label = _lib.String((_lib.MAXID + 1) * '\0') errmsg = _lib.String((_lib.MAXMSG + 1) * '\0') cint = c_int() class OutputObject(object): def __init__(self, binfile): """ 1) Initializes the opaque pointer to enrapi struct. 2) Opens the output file. """ self.enrapi = c_void_p() ret = _lib.ENR_open(byref(self.enrapi), str(binfile)) if ret != 0: self.RaiseError(ret) self._get_Units()