def __init__(self): """Initialize the sections of an EPANET input file. Any sections not initialized here will be handled by the generic core.project_base.Section class.""" self.title = Title() self.junctions = SectionAsList("[JUNCTIONS]") # (list of Junction) self.reservoirs = SectionAsList("[RESERVOIRS]") # (list of Reservoir) self.tanks = SectionAsList("[TANKS]") # (list of Tank) self.pipes = SectionAsList("[PIPES]") # (list of Pipe) self.pumps = SectionAsList("[PUMPS]") # (list of Pump) self.valves = SectionAsList("[VALVES]") # (list of Valve) # self.emitters = [(Junction, "emitter_coefficient")] self.patterns = SectionAsList("[PATTERNS]") # (list of Pattern) self.curves = SectionAsList("[CURVES]") # (list of Curve) self.energy = EnergyOptions() self.status = SectionAsList("[STATUS]") # (list of Status) self.controls = Control() self.rules = Rule() self.demands = SectionAsList("[DEMANDS]") # (list of Demand) self.reactions = Reactions() self.sources = SectionAsList("[SOURCES]") # (list of Source) # self.options = MapOptions, self.options = Options() self.times = TimesOptions() self.report = ReportOptions() self.labels = SectionAsList("[LABELS]") # (list of Label) self.backdrop = BackdropOptions() self.calibrations = SectionAsList( "[CALIBRATIONS]") # (list of Calibration) ProjectBase.__init__( self ) # Do this after setting attributes so they will all get added to sections[]
def read(new_text): energy_options = EnergyOptions() for line in new_text.splitlines(): try: line = SectionReader.set_comment_check_section(energy_options, line) fields = line.split() if len(fields) > 1: if fields[0].upper() == "PUMP": energy_options.pumps.append(PumpEnergyReader.read(line)) else: SectionReader.set_text_line(energy_options, line) except: print("BackdropOptions skipping input line: " + line) return energy_options
def __init__(self): """Initialize the sections of an EPANET input file. Any sections not initialized here will be handled by the generic core.project_base.Section class.""" ProjectBase.__init__(self) self.title = Title() self.backdrop = BackdropOptions() # BACKDROP bounding rectangle and file name of backdrop image self.map = MapOptions() # MAP map's bounding rectangle and units self.junctions = SectionAsList("[JUNCTIONS]") # (list of Junction) self.reservoirs = SectionAsList("[RESERVOIRS]") # (list of Reservoir) self.tanks = SectionAsList("[TANKS]") # (list of Tank) self.pipes = SectionAsList("[PIPES]") # (list of Pipe) self.pumps = SectionAsList("[PUMPS]") # (list of Pump) self.valves = SectionAsList("[VALVES]") # (list of Valve) # self.emitters = [(Junction, "emitter_coefficient")] self.patterns = SectionAsList("[PATTERNS]") # (list of Pattern) self.curves = SectionAsList("[CURVES]") # (list of Curve) self.energy = EnergyOptions() self.status = SectionAsList("[STATUS]") # (list of Status) self.controls = Control() self.rules = Rule() self.demands = SectionAsList("[DEMANDS]") # (list of Demand) self.reactions = Reactions() self.sources = SectionAsList("[SOURCES]") # (list of Source) # self.options = MapOptions, self.options = Options() self.times = TimesOptions() self.report = ReportOptions() self.labels = SectionAsList("[LABELS]") # (list of Label) self.backdrop = BackdropOptions() self.calibrations = SectionAsList("[CALIBRATIONS]") # (list of Calibration) self.sections = [ self.title, self.options, self.report, self.junctions, self.tanks, self.reservoirs, self.pipes, self.pumps, self.valves, self.controls, self.patterns, self.curves, self.backdrop, self.map, self.labels] # Start with a sensible order of sections. self.add_sections_from_attributes() # Add any sections not added in the line above, should not be any left.