Source code for epanet_plus.epanet_wrapper

   1"""
   2This module contains a Python wrapper (incl. error handling) for EPANET and EPANET-MSX functions.
   3"""
   4import warnings
   5import epanet
   6
   7
[docs] 8class EpanetAPI(): 9 """ 10 Interface for EPANET and EPANET-MSX functions, incl. a proper error handling. 11 12 Parameters 13 ---------- 14 use_project : `bool`, optional 15 If True, projects will be used when calling EPANET functions (default in EPANET >= 2.2). 16 Note that this is incompatible with EPANET-MSX. Please set to False when using EPANET-MSX. 17 18 The default is False. 19 20 raise_on_error : `bool`, optional 21 True if an exception should be raised in the case of an error/warning, False otherwise. 22 23 The default is True. 24 warn_on_error : `bool`, optional 25 True if a warning should be generated in the case of an error/warning, False otherwise. 26 27 The default is False. 28 ignore_error_codes : `list[int]`, optional 29 List of error codes that should be ignored -- i.e., no exception or warning 30 will be generated. 31 32 The default is an empty list. 33 """ 34 def __init__(self, use_project: bool = False, raise_exception_on_error: bool = True, 35 warn_on_error: bool = False, ignore_error_codes: list[int] = []): 36 if not isinstance(use_project, bool): 37 raise TypeError("'use_project' must be an instance of 'bool' " + 38 f"but not of '{type(use_project)}'") 39 if not isinstance(raise_exception_on_error, bool): 40 raise TypeError("'raise_exception_on_error' must be an instance of 'bool' " + 41 f"but not of '{type(raise_exception_on_error)}'") 42 if not isinstance(warn_on_error, bool): 43 raise TypeError("'warn_on_error' must be an instance of 'bool' " + 44 f"but not of type '{type(warn_on_error)}'") 45 if not isinstance(ignore_error_codes, list): 46 raise TypeError("'ignore_error_codes' must be an instance of 'list[int]' " + 47 f"but not of '{type(ignore_error_codes)}'") 48 else: 49 if any(not isinstance(item, int) for item in ignore_error_codes): 50 raise TypeError("All items in 'ignore_error_codes' must be of type 'int'") 51 52 if raise_exception_on_error is True and warn_on_error is True: 53 raise ValueError("'raise_exception_on_error' and 'warn_on_error' can not be both True") 54 55 self._use_project = use_project 56 self._ph = None 57 self._raise_on_error = raise_exception_on_error 58 self._warn_on_error = warn_on_error 59 self._ignore_error_codes = ignore_error_codes 60 self._last_error_code = 0 61 self._last_error_desc = None 62
[docs] 63 def set_error_handling(self, raise_exception_on_error: bool, warn_on_error: bool, 64 ignore_error_codes: list[int] = []) -> None: 65 """ 66 Specifies the behavior in the case of an error/warning -- 67 i.e. should an exception or warning be raised or not? 68 69 Parameters 70 ---------- 71 raise_exception_on_error : `bool` 72 True if an exception should be raised, False otherwise. 73 warn_on_error : `bool` 74 True if a warning should be generated, False otherwise. 75 ignore_error_codes : `list[int]` 76 List of error codes that should be ignored -- i.e., no exception or 77 warning will be generated. 78 """ 79 self._raise_on_error = raise_exception_on_error 80 self._warn_on_error = warn_on_error 81 self._ignore_error_codes = ignore_error_codes
82
[docs] 83 def get_last_error_desc(self) -> str: 84 """ 85 Returns the description of the last EPANET-(MSX) error/warning (if any). 86 87 Returns 88 ------- 89 `str` 90 Description of the last error/warning. None, if there was no error/warning. 91 """ 92 return self._last_error_desc
93
[docs] 94 def get_last_error_code(self) -> int: 95 """ 96 Returns the code of the last EPANET-(MSX) error/warnning (if any). 97 98 Refer to the `EPANET documentation <http://wateranalytics.org/EPANET/group___warning_codes.html>`_ 99 for a list of all possible warning codes and their meanings. 100 101 Returns 102 ------- 103 `int` 104 Code of the last error/warning. 0, if there was no error/warning. 105 """ 106 return self._last_error_code
107
[docs] 108 def was_last_func_successful(self) -> bool: 109 """ 110 Checks if the last EPANET call was successful or not. 111 112 Parameters 113 ---------- 114 `bool` 115 True if the last EPANET call returned an error/warning, False otherwise. 116 """ 117 return self._last_error_desc is None
118 119 def _reset_error(self) -> None: 120 self._last_error_code = 0 121 self._last_error_desc = None 122 123 def _process_result(self, ret: tuple, msx_call: bool = False): 124 ret_other = None 125 if len(ret) == 1: 126 errcode = ret[0] 127 else: 128 errcode, *ret_other = ret 129 130 if errcode != 0: 131 self._last_error_code = errcode 132 if msx_call is False: 133 self._last_error_desc = self.geterror(errcode) 134 else: 135 self._last_error_desc = self.MSXgeterror(errcode) 136 137 if self._last_error_code not in self._ignore_error_codes: 138 if self._warn_on_error: 139 warnings.warn(self._last_error_desc, RuntimeWarning) 140 if self._raise_on_error: 141 raise RuntimeError(self._last_error_desc) 142 143 if ret_other is not None and len(ret_other) == 1: 144 return ret_other[0] 145 else: 146 return ret_other 147 148 @property 149 def use_project(self) -> bool: 150 """ 151 Returns whether EPANET projects are used or not. 152 153 Returns 154 ------- 155 `bool` 156 True, if EPANET projects are used, False otherwise. 157 """ 158 return self._use_project 159 160 @property 161 def ph(self) -> int: 162 """ 163 Returns a pointer (memory address) to the project structure. 164 165 Returns 166 ------- 167 `int` 168 Pointer to project structure -- please do not change or access the memory location! 169 """ 170 return self._ph 171
[docs] 172 def openfrombuffer(self, inpBuffer: str, inpFile: str, rptFile: str, outFile: str): 173 """ 174 EN_openfrombuffer -- extension of EPANET and part of EPANET-PLUS 175 176 Parameters 177 ---------- 178 inpBuffer : `str` 179 inpFile : `str` 180 rptFile : `str` 181 outFile : `str` 182 """ 183 if self._use_project is False: 184 return self._process_result(epanet.ENopenfrombuffer(inpBuffer, inpFile, rptFile, 185 outFile)) 186 else: 187 return self._process_result(epanet.EN_openfrombuffer(self._ph, inpBuffer, inpFile, 188 rptFile, outFile))
189
[docs] 190 def createproject(self): 191 """ 192 EN_createproject 193 """ 194 if self._use_project is False: 195 raise ValueError("Can not create project because of use_project=False") 196 else: 197 self._ph = self._process_result(epanet.EN_createproject())
198
[docs] 199 def deleteproject(self): 200 """ 201 EN_deleteproject 202 """ 203 if self._use_project is False: 204 raise ValueError("Can not delete project because of use_project=False") 205 else: 206 if self._ph is not None: 207 res = self._process_result(epanet.EN_deleteproject(self._ph)) 208 self._ph = None 209 210 return res
211
[docs] 212 def init(self, rptFile: str, outFile: str, unitsType: int, headLossType: int): 213 """ 214 EN_init 215 216 Parameters 217 ---------- 218 rptFile : `str` 219 outFile : `str` 220 unitsType : `int` 221 headLossType : `int` 222 """ 223 if self._use_project is False: 224 return self._process_result(epanet.ENinit(rptFile, outFile, unitsType, headLossType)) 225 else: 226 return self._process_result(epanet.EN_init(self._ph, rptFile, outFile, unitsType, 227 headLossType))
228
[docs] 229 def open(self, inpFile: str, rptFile: str, outFile: str): 230 """ 231 EN_open 232 233 Parameters 234 ---------- 235 inpFile : `str` 236 rptFile : `str` 237 outFile : `str` 238 """ 239 if self._use_project is False: 240 return self._process_result(epanet.ENopen(inpFile, rptFile, outFile)) 241 else: 242 return self._process_result(epanet.EN_open(self._ph, inpFile, rptFile, outFile))
243
[docs] 244 def openX(self, inpFile: str, rptFile: str, outFile: str): 245 """ 246 EN_openX 247 248 Parameters 249 ---------- 250 inpFile : `str` 251 rptFile : `str` 252 outFile : `str` 253 """ 254 if self._use_project is False: 255 return self._process_result(epanet.ENopenX(inpFile, rptFile, outFile)) 256 else: 257 return self._process_result(epanet.EN_openX(self._ph, inpFile, rptFile, outFile))
258
[docs] 259 def gettitle(self): 260 """ 261 EN_gettitle 262 """ 263 if self._use_project is False: 264 return self._process_result(epanet.ENgettitle()) 265 else: 266 return self._process_result(epanet.EN_gettitle(self._ph))
267
[docs] 268 def settitle(self, line1: str, line2: str, line3: str): 269 """ 270 EN_settitle 271 272 Parameters 273 ---------- 274 line1: str 275 line2: str 276 line3: str 277 """ 278 if self._use_project is False: 279 return self._process_result(epanet.ENsettitle(line1, line2, line3)) 280 else: 281 return self._process_result(epanet.EN_settitle(self._ph, line1, line2, line3))
282
[docs] 283 def getcomment(self, obj: int, index: int): 284 """ 285 EN_getcomment 286 287 Parameters 288 ---------- 289 obj : `int` 290 index : `int` 291 """ 292 if self._use_project is False: 293 return self._process_result(epanet.ENgetcomment(obj, index)) 294 else: 295 return self._process_result(epanet.EN_getcomment(self._ph, obj, index))
296
[docs] 297 def setcomment(self, obj: int, index: int, comment: str): 298 """ 299 EN_setcomment 300 301 Parameters 302 ---------- 303 obj : `int` 304 index : `int` 305 comment : `str` 306 """ 307 if self._use_project is False: 308 return self._process_result(epanet.ENsetcomment(obj, index, comment)) 309 else: 310 return self._process_result(epanet.EN_setcomment(self._ph, obj, index, comment))
311
[docs] 312 def getcount(self, obj: int): 313 """ 314 EN_getcount 315 316 Parameters 317 ---------- 318 obj : `int` 319 """ 320 if self._use_project is False: 321 return self._process_result(epanet.ENgetcount(obj)) 322 else: 323 return self._process_result(epanet.EN_getcount(self._ph, obj))
324
[docs] 325 def saveinpfile(self, filename: str): 326 """ 327 EN_saveinpfile 328 329 Parameters 330 ---------- 331 filename : `str` 332 """ 333 if self._use_project is False: 334 return self._process_result(epanet.ENsaveinpfile(filename)) 335 else: 336 return self._process_result(epanet.EN_saveinpfile(self._ph, filename))
337
[docs] 338 def close(self): 339 """ 340 EN_close 341 """ 342 if self._use_project is False: 343 return self._process_result(epanet.ENclose()) 344 else: 345 if self._ph is not None: 346 return self._process_result(epanet.EN_close(self._ph))
347
[docs] 348 def solveH(self): 349 """ 350 EN_solveH 351 """ 352 if self._use_project is False: 353 return self._process_result(epanet.ENsolveH()) 354 else: 355 return self._process_result(epanet.EN_solveH(self._ph))
356
[docs] 357 def usehydfile(self, filename: str): 358 """ 359 EN_usehydfile 360 361 Parameters 362 ---------- 363 filename : `str` 364 """ 365 if self._use_project is False: 366 return self._process_result(epanet.ENusehydfile(filename)) 367 else: 368 return self._process_result(epanet.EN_usehydfile(filename))
369
[docs] 370 def openH(self): 371 """ 372 EN_openH 373 """ 374 if self._use_project is False: 375 return self._process_result(epanet.ENopenH()) 376 else: 377 return self._process_result(epanet.EN_openH(self._ph))
378
[docs] 379 def initH(self, initFlag: int): 380 """ 381 EN_initH 382 383 Parameters 384 ---------- 385 initFlag : `int` 386 """ 387 if self._use_project is False: 388 return self._process_result(epanet.ENinitH(initFlag)) 389 else: 390 return self._process_result(epanet.EN_initH(self._ph, initFlag))
391
[docs] 392 def runH(self): 393 """ 394 EN_runH 395 """ 396 if self._use_project is False: 397 return self._process_result(epanet.ENrunH()) 398 else: 399 return self._process_result(epanet.EN_runH(self._ph))
400
[docs] 401 def nextH(self): 402 """ 403 EN_nextH 404 """ 405 if self._use_project is False: 406 return self._process_result(epanet.ENnextH()) 407 else: 408 return self._process_result(epanet.EN_nextH(self._ph))
409
[docs] 410 def saveH(self): 411 """ 412 EN_saveH 413 """ 414 if self._use_project is False: 415 return self._process_result(epanet.ENsaveH()) 416 else: 417 return self._process_result(epanet.EN_saveH(self._ph))
418
[docs] 419 def savehydfile(self, filename): 420 """ 421 EN_savehydfile 422 423 Parameters 424 ---------- 425 filename : `str` 426 """ 427 if self._use_project is False: 428 return self._process_result(epanet.ENsavehydfile(filename)) 429 else: 430 return self._process_result(epanet.EN_savehydfile(self._ph, filename))
431
[docs] 432 def closeH(self): 433 """ 434 EN_closeH 435 """ 436 if self._use_project is False: 437 return self._process_result(epanet.ENcloseH()) 438 else: 439 return self._process_result(epanet.EN_closeH(self._ph))
440
[docs] 441 def solveQ(self): 442 """ 443 EN_solveQ 444 """ 445 if self._use_project is False: 446 return self._process_result(epanet.ENsolveQ()) 447 else: 448 return self._process_result(epanet.EN_solveQ(self._ph))
449
[docs] 450 def openQ(self): 451 """ 452 EN_openQ 453 """ 454 if self._use_project is False: 455 return self._process_result(epanet.ENopenQ()) 456 else: 457 return self._process_result(epanet.EN_openQ(self._ph))
458
[docs] 459 def initQ(self, save_flag: int): 460 """ 461 EN_initQ 462 463 Parameters 464 ---------- 465 save_flag : `int` 466 """ 467 if self._use_project is False: 468 return self._process_result(epanet.ENinitQ(save_flag)) 469 else: 470 return self._process_result(epanet.EN_initQ(self._ph, save_flag))
471
[docs] 472 def runQ(self): 473 """ 474 EN_runQ 475 """ 476 if self._use_project is False: 477 return self._process_result(epanet.ENrunQ()) 478 else: 479 return self._process_result(epanet.EN_runQ(self._ph))
480
[docs] 481 def nextQ(self): 482 """ 483 EN_nextQ 484 """ 485 if self._use_project is False: 486 return self._process_result(epanet.ENnextQ()) 487 else: 488 return self._process_result(epanet.EN_nextQ(self._ph))
489
[docs] 490 def stepQ(self): 491 """ 492 EN_stepQ 493 """ 494 if self._use_project is False: 495 return self._process_result(epanet.ENstepQ()) 496 else: 497 return self._process_result(epanet.EN_stepQ(self._ph))
498
[docs] 499 def closeQ(self): 500 """ 501 EN_closeQ 502 """ 503 if self._use_project is False: 504 return self._process_result(epanet.ENcloseQ()) 505 else: 506 return self._process_result(epanet.EN_closeQ(self._ph))
507
[docs] 508 def writeline(self, line: str): 509 """ 510 EN_writeline 511 512 Parameters 513 ---------- 514 line : `str` 515 """ 516 if self._use_project is False: 517 return self._process_result(epanet.ENwriteline(line)) 518 else: 519 return self._process_result(epanet.EN_writeline(self._ph, line))
520
[docs] 521 def report(self): 522 """ 523 EN_report 524 """ 525 if self._use_project is False: 526 return self._process_result(epanet.ENreport()) 527 else: 528 return self._process_result(epanet.EN_report(self._ph))
529
[docs] 530 def copyreport(self): 531 """ 532 EN_copyreport 533 """ 534 if self._use_project is False: 535 return self._process_result(epanet.ENcopyreport()) 536 else: 537 return self._process_result(epanet.EN_copyreport(self._ph))
538
[docs] 539 def clearreport(self): 540 """ 541 EN_clearreport 542 """ 543 if self._use_project is False: 544 return self._process_result(epanet.ENclearreport()) 545 else: 546 return self._process_result(epanet.EN_clearreport(self._ph))
547
[docs] 548 def resetreport(self): 549 """ 550 EN_resetreport 551 """ 552 if self._use_project is False: 553 return self._process_result(epanet.ENresetreport()) 554 else: 555 return self._process_result(epanet.EN_resetreport(self._ph))
556
[docs] 557 def setreport(self, format_desc: str): 558 """ 559 EN_setreport 560 561 Parameters 562 ---------- 563 format_desc : `str` 564 """ 565 if self._use_project is False: 566 return self._process_result(epanet.ENsetreport(format_desc)) 567 else: 568 return self._process_result(epanet.EN_setreport(self._ph, format_desc))
569
[docs] 570 def setstatusreport(self, level: int): 571 """ 572 EN_setstatusreport 573 574 Parameters 575 ---------- 576 level : `int` 577 """ 578 if self._use_project is False: 579 return self._process_result(epanet.ENsetstatusreport(level)) 580 else: 581 return self._process_result(epanet.EN_setstatusreport(self._ph, level))
582
[docs] 583 def getversion(self): 584 """ 585 EN_getversion 586 """ 587 if self._use_project is False: 588 return self._process_result(epanet.ENgetversion()) 589 else: 590 return self._process_result(epanet.EN_getversion())
591
[docs] 592 def geterror(self, error_code: int): 593 """ 594 EN_geterror 595 596 Parameters 597 ---------- 598 error_code : `int` 599 """ 600 if self._use_project is False: 601 err, err_msg = epanet.ENgeterror(error_code) 602 else: 603 err, err_msg = epanet.EN_geterror(error_code) 604 605 if err != 0: 606 raise RuntimeError("Failed to get error message") 607 608 return err_msg
609
[docs] 610 def getstatistic(self, stat_type: int): 611 """ 612 EN_getstatistic 613 614 Parameters 615 ---------- 616 stat_type : `int` 617 """ 618 if self._use_project is False: 619 return self._process_result(epanet.ENgetstatistic(stat_type)) 620 else: 621 return self._process_result(epanet.EN_getstatistic(self._ph, stat_type))
622
[docs] 623 def getresultindex(self, result_type: int, index: int): 624 """ 625 EN_getresultindex 626 627 Parameters 628 ---------- 629 result_type : `int` 630 index : `int` 631 """ 632 if self._use_project is False: 633 return self._process_result(epanet.ENgetresultindex(result_type, index)) 634 else: 635 return self._process_result(epanet.EN_getresultindex(self._ph, result_type, index))
636
[docs] 637 def getoption(self, option: int): 638 """ 639 EN_getoption 640 641 Parameters 642 ---------- 643 option : `int` 644 """ 645 if self._use_project is False: 646 return self._process_result(epanet.ENgetoption(option)) 647 else: 648 return self._process_result(epanet.EN_getoption(self._ph, option))
649
[docs] 650 def setoption(self, option: int, value: float): 651 """ 652 EN_setoption 653 654 Parameters 655 ---------- 656 option : `int` 657 value : `float` 658 """ 659 if self._use_project is False: 660 return self._process_result(epanet.ENsetoption(option, value)) 661 else: 662 return self._process_result(epanet.EN_setoption(self._ph, option, value))
663
[docs] 664 def getflowunits(self): 665 """ 666 EN_getflowunits 667 """ 668 if self._use_project is False: 669 return self._process_result(epanet.ENgetflowunits()) 670 else: 671 return self._process_result(epanet.EN_getflowunits(self._ph))
672
[docs] 673 def setflowunits(self, units: int): 674 """ 675 EN_setflowunits 676 677 Parameters 678 ---------- 679 units : `int` 680 """ 681 if self._use_project is False: 682 return self._process_result(epanet.ENsetflowunits(units)) 683 else: 684 return self._process_result(epanet.EN_setflowunits(self._ph, units))
685
[docs] 686 def gettimeparam(self, param: int): 687 """ 688 EN_gettimeparam 689 690 Parameters 691 ---------- 692 param : `int` 693 """ 694 if self._use_project is False: 695 return self._process_result(epanet.ENgettimeparam(param)) 696 else: 697 return self._process_result(epanet.EN_gettimeparam(self._ph, param))
698
[docs] 699 def settimeparam(self, param: int, value: int): 700 """ 701 EN_settimeparam 702 703 Parameters 704 ---------- 705 param : `int` 706 value : `int` 707 """ 708 if self._use_project is False: 709 return self._process_result(epanet.ENsettimeparam(param, value)) 710 else: 711 return self._process_result(epanet.EN_settimeparam(self._ph, param, value))
712
[docs] 713 def getqualinfo(self): 714 """ 715 EN_getqualinfo 716 """ 717 if self._use_project is False: 718 return self._process_result(epanet.ENgetqualinfo()) 719 else: 720 return self._process_result(epanet.EN_getqualinfo(self._ph))
721
[docs] 722 def getqualtype(self): 723 """ 724 EN_getqualtype 725 """ 726 if self._use_project is False: 727 return self._process_result(epanet.ENgetqualtype()) 728 else: 729 return self._process_result(epanet.EN_getqualtype(self._ph))
730
[docs] 731 def setqualtype(self, qual_type: int, chem_name: str, chem_units: str, trace_node_id: str): 732 """ 733 EN_setqualtype 734 735 Parameters 736 ---------- 737 qual_type : `int` 738 chem_name : `str` 739 chem_units : `str` 740 trace_node_id : `str` 741 """ 742 if self._use_project is False: 743 return self._process_result(epanet.ENsetqualtype(qual_type, chem_name, chem_units, 744 trace_node_id)) 745 else: 746 return self._process_result(epanet.EN_setqualtype(self._ph, qual_type, chem_name, 747 chem_units, trace_node_id))
748
[docs] 749 def addnode(self, node_id: str, node_type: int): 750 """ 751 EN_addnode 752 753 Parameters 754 ---------- 755 node_id : `str` 756 node_type : `int` 757 """ 758 if self._use_project is False: 759 return self._process_result(epanet.ENaddnode(node_id, node_type)) 760 else: 761 return self._process_result(epanet.EN_addnode(self._ph, node_id, node_type))
762
[docs] 763 def deletenode(self, index: int, action_code: int): 764 """ 765 EN_deletenode 766 767 Parameters 768 ---------- 769 index : `int` 770 action_code : `int` 771 """ 772 if self._use_project is False: 773 return self._process_result(epanet.ENdeletenode(index, action_code)) 774 else: 775 return self._process_result(epanet.EN_deletenode(self._ph, index, action_code))
776
[docs] 777 def getnodeindex(self, node_id: str): 778 """ 779 EN_getnodeindex 780 781 Parameters 782 ---------- 783 node_id : `str` 784 """ 785 if self._use_project is False: 786 return self._process_result(epanet.ENgetnodeindex(node_id)) 787 else: 788 return self._process_result(epanet.EN_getnodeindex(self._ph, node_id))
789
[docs] 790 def getnodeid(self, index: int): 791 """ 792 EN_getnodeid 793 794 Parameters 795 ---------- 796 index : `int` 797 """ 798 if self._use_project is False: 799 return self._process_result(epanet.ENgetnodeid(index)) 800 else: 801 return self._process_result(epanet.EN_getnodeid(self._ph, index))
802
[docs] 803 def setnodeid(self, index: int, new_id: str): 804 """ 805 EN_setnodeid 806 807 Parameters 808 ---------- 809 index : `int` 810 new_id : `str` 811 """ 812 if self._use_project is False: 813 return self._process_result(epanet.ENsetnodeid(index, new_id)) 814 else: 815 return self._process_result(epanet.EN_setnodeid(self._ph, index, new_id))
816
[docs] 817 def getnodetype(self, index: int): 818 """ 819 EN_getnodetype 820 821 Parameters 822 ---------- 823 index : `int` 824 """ 825 if self._use_project is False: 826 return self._process_result(epanet.ENgetnodetype(index)) 827 else: 828 return self._process_result(epanet.EN_getnodetype(self._ph, index))
829
[docs] 830 def getnodevalue(self, index: int, node_property: int): 831 """ 832 EN_getnodevalue 833 834 Parameters 835 ---------- 836 index : `int` 837 node_property : `int` 838 """ 839 if self._use_project is False: 840 return self._process_result(epanet.ENgetnodevalue(index, node_property)) 841 else: 842 return self._process_result(epanet.EN_getnodevalue(self._ph, index, node_property))
843
[docs] 844 def setnodevalue(self, index: int, node_property: int, value: float): 845 """ 846 EN_setnodevalue 847 848 Parameters 849 ---------- 850 index : `int` 851 node_property : `int` 852 value : `float` 853 """ 854 if self._use_project is False: 855 return self._process_result(epanet.ENsetnodevalue(index, node_property, value)) 856 else: 857 return self._process_result(epanet.EN_setnodevalue(self._ph, index, node_property, 858 value))
859
[docs] 860 def setnodevaluse(self, node_property: int, values: list[float]): 861 """ 862 EN_setnodevalues 863 864 Parameters 865 ---------- 866 node_property : `int` 867 values : `list[float]` 868 """ 869 if self._use_project is False: 870 return self._process_result(epanet.ENsetnodevalues(node_property, values)) 871 else: 872 return self._process_result(epanet.EN_setnodevalues(self._ph, node_property, values))
873
[docs] 874 def setjuncdata(self, index: int, elev: float, dmnd: float, dmnd_pat: str): 875 """ 876 EN_setjuncdata 877 878 Parameters 879 ---------- 880 index : `int` 881 elev : `float` 882 dmnd : `float` 883 dmdn_pat : `float` 884 """ 885 if self._use_project is False: 886 return self._process_result(epanet.ENsetjuncdata(index, elev, dmnd, dmnd_pat)) 887 else: 888 return self._process_result(epanet.EN_setjuncdata(self._ph, index, elev, dmnd, 889 dmnd_pat))
890
[docs] 891 def settankdata(self, index: int, elev: float, initlvl: float, minlvl: float, maxlvl: float, 892 diam: float, minvol: float, volcurve: str): 893 """ 894 EN_settankdata 895 896 Parameters 897 ---------- 898 index : `int` 899 elev : `float` 900 initlvl : `float` 901 minlvl : `float` 902 maxlvl : `float` 903 diam : `float` 904 minvol : `float` 905 volcurve : `str` 906 """ 907 if self._use_project is False: 908 return self._process_result(epanet.ENsettankdata(index, elev, initlvl, minlvl, maxlvl, 909 diam, minvol, volcurve)) 910 else: 911 return self._process_result(epanet.EN_settankdata(self._ph, index, elev, initlvl, 912 minlvl, maxlvl, diam, minvol, 913 volcurve))
914
[docs] 915 def getcoord(self, index: int): 916 """ 917 EN_getcoord 918 919 Parameters 920 ---------- 921 index : `int` 922 """ 923 if self._use_project is False: 924 return self._process_result(epanet.ENgetcoord(index)) 925 else: 926 return self._process_result(epanet.EN_getcoord(self._ph, index))
927
[docs] 928 def setcoord(self, index: int, x: float, y: float): 929 """ 930 EN_setcoord 931 932 Parameters 933 ---------- 934 index : `int` 935 x : `float` 936 y : `float` 937 """ 938 if self._use_project is False: 939 return self._process_result(epanet.ENsetcoord(index, x, y)) 940 else: 941 return self._process_result(epanet.EN_setcoord(self._ph, index, x, y))
942
[docs] 943 def getdemandmodel(self): 944 """ 945 EN_getdemandmodel 946 """ 947 if self._use_project is False: 948 return self._process_result(epanet.ENgetdemandmodel()) 949 else: 950 return self._process_result(epanet.EN_getdemandmodel(self._ph))
951
[docs] 952 def setdemandmodel(self, demand_type: int, pmin: float, preq: float, pexp: float): 953 """ 954 EN_setdemandmodel 955 956 Parameters 957 ---------- 958 demand_type : `int` 959 pmin : `float` 960 preq : `float` 961 pexp : `float` 962 """ 963 if self._use_project is False: 964 return self._process_result(epanet.ENsetdemandmodel(demand_type, pmin, preq, pexp)) 965 else: 966 return self._process_result(epanet.EN_setdemandmodel(self._ph, demand_type, 967 pmin, preq, pexp))
968
[docs] 969 def adddemand(self, node_index: int, base_demand: float, demand_pattern: str, demand_name: str): 970 """ 971 EN_adddemand 972 973 node_index : `int` 974 base_demand : `float` 975 demand_pattern : `str` 976 demand_name : `str` 977 """ 978 if self._use_project is False: 979 return self._process_result(epanet.ENadddemand(node_index, base_demand, demand_pattern, 980 demand_name)) 981 else: 982 return self._process_result(epanet.EN_adddemand(self._ph, node_index, base_demand, 983 demand_pattern, demand_name))
984
[docs] 985 def deletedemand(self, node_index: int, demand_index: int): 986 """ 987 EN_deletedemand 988 989 Parameters 990 ---------- 991 node_index : `int` 992 demand_index : `int` 993 """ 994 if self._use_project is False: 995 return self._process_result(epanet.ENdeletedemand(node_index, demand_index)) 996 else: 997 return self._process_result(epanet.EN_deletedemand(self._ph, node_index, demand_index))
998
[docs] 999 def getdemandindex(self, node_index: int, demand_name: str): 1000 """ 1001 EN_getdemandindex 1002 1003 Parameters 1004 ---------- 1005 node_index : `int` 1006 demand_name : `str` 1007 """ 1008 if self._use_project is False: 1009 return self._process_result(epanet.ENgetdemandindex(node_index, demand_name)) 1010 else: 1011 return self._process_result(epanet.EN_getdemandindex(self._ph, node_index, demand_name))
1012
[docs] 1013 def getnumdemands(self, node_index: int): 1014 """ 1015 EN_getnumdemands 1016 1017 Parameters 1018 ---------- 1019 node_index : `int` 1020 """ 1021 if self._use_project is False: 1022 return self._process_result(epanet.ENgetnumdemands(node_index)) 1023 else: 1024 return self._process_result(epanet.EN_getnumdemands(self._ph, node_index))
1025
[docs] 1026 def getbasedemand(self, node_index: int, demand_index: int): 1027 """ 1028 EN_getbasedemand 1029 1030 Parameters 1031 ---------- 1032 node_index : `int` 1033 demand_index : `int` 1034 """ 1035 if self._use_project is False: 1036 return self._process_result(epanet.ENgetbasedemand(node_index, demand_index)) 1037 else: 1038 return self._process_result(epanet.EN_getbasedemand(self._ph, node_index, demand_index))
1039
[docs] 1040 def setbasedemand(self, node_index: int, demand_index: int, base_demand: float): 1041 """ 1042 EN_setbasedemand 1043 1044 Parameters 1045 ---------- 1046 node_index : `int` 1047 demand_index : `int` 1048 base_demand : `float` 1049 """ 1050 if self._use_project is False: 1051 return self._process_result(epanet.ENsetbasedemand(node_index, demand_index, 1052 base_demand)) 1053 else: 1054 return self._process_result(epanet.EN_setbasedemand(self._ph, node_index, demand_index, 1055 base_demand))
1056
[docs] 1057 def getdemandpattern(self, node_index: int, demand_index: int): 1058 """ 1059 EN_getdemandpattern 1060 1061 Parameters 1062 ---------- 1063 node_index : `int` 1064 demand_index : `int` 1065 """ 1066 if self._use_project is False: 1067 return self._process_result(epanet.ENgetdemandpattern(node_index, demand_index)) 1068 else: 1069 return self._process_result(epanet.EN_getdemandpattern(self._ph, node_index, 1070 demand_index))
1071
[docs] 1072 def setdemandpattern(self, node_index: int, demand_index: int, pat_index: int): 1073 """ 1074 EN_setdemandpattern 1075 1076 Parameters 1077 ---------- 1078 node_index : `int` 1079 demand_index : `int` 1080 pat_index : `int` 1081 """ 1082 if self._use_project is False: 1083 return self._process_result(epanet.ENsetdemandpattern(node_index, demand_index, 1084 pat_index)) 1085 else: 1086 return self._process_result(epanet.EN_setdemandpattern(self._ph, node_index, 1087 demand_index, pat_index))
1088
[docs] 1089 def getdemandname(self, node_index: int, demand_index: int): 1090 """ 1091 EN_getdemandname 1092 1093 Parameters 1094 ---------- 1095 node_index : `int` 1096 demand_index : `int` 1097 """ 1098 if self._use_project is False: 1099 return self._process_result(epanet.ENgetdemandname(node_index, demand_index)) 1100 else: 1101 return self._process_result(epanet.EN_getdemandname(self._ph, node_index, demand_index))
1102
[docs] 1103 def setdemandname(self, node_index: int, demand_index: int, demand_name: str): 1104 """ 1105 EN_setdemandname 1106 1107 Parameters 1108 ---------- 1109 node_index : `int` 1110 demand_index : `int` 1111 demand_name : `str` 1112 """ 1113 if self._use_project is False: 1114 return self._process_result(epanet.ENsetdemandname(node_index, demand_index, 1115 demand_name)) 1116 else: 1117 return self._process_result(epanet.EN_setdemandname(self._ph, node_index, demand_index, 1118 demand_name))
1119 1136 1150
[docs] 1151 def getlinkindex(self, link_id: str): 1152 """ 1153 EN_getlinkindex 1154 1155 Parameters 1156 ---------- 1157 link_id : `str` 1158 """ 1159 if self._use_project is False: 1160 return self._process_result(epanet.ENgetlinkindex(link_id)) 1161 else: 1162 return self._process_result(epanet.EN_getlinkindex(self._ph, link_id))
1163
[docs] 1164 def getlinkid(self, index: int): 1165 """ 1166 EN_getlinkid 1167 1168 Parameters 1169 ---------- 1170 index : `int` 1171 """ 1172 if self._use_project is False: 1173 return self._process_result(epanet.ENgetlinkid(index)) 1174 else: 1175 return self._process_result(epanet.EN_getlinkid(self._ph, index))
1176
[docs] 1177 def setlinkid(self, index: int, new_id: str): 1178 """ 1179 EN_setlinkid 1180 1181 Parameters 1182 ---------- 1183 index : `int` 1184 new_id : `str` 1185 """ 1186 if self._use_project is False: 1187 return self._process_result(epanet.ENsetlinkid(index, new_id)) 1188 else: 1189 return self._process_result(epanet.EN_setlinkid(self._ph, index, new_id))
1190
[docs] 1191 def getlinktype(self, index: int): 1192 """ 1193 EN_getlinktype 1194 1195 Parameters 1196 ---------- 1197 index : `int` 1198 """ 1199 if self._use_project is False: 1200 return self._process_result(epanet.ENgetlinktype(index)) 1201 else: 1202 return self._process_result(epanet.EN_getlinktype(self._ph, index))
1203
[docs] 1204 def setlinktype(self, index: int, link_type: int, action_code: int): 1205 """ 1206 EN_setlinktype 1207 1208 Parameters 1209 ---------- 1210 index : `int` 1211 link_type : `int` 1212 action_code : `int` 1213 """ 1214 if self._use_project is False: 1215 return self._process_result(epanet.ENsetlinktype(index, link_type, action_code)) 1216 else: 1217 return self._process_result(epanet.EN_setlinktype(self._ph, index, link_type, 1218 action_code))
1219
[docs] 1220 def getlinknodes(self, index: int): 1221 """ 1222 EN_getlinknodes 1223 1224 Parameters 1225 ---------- 1226 index : `int` 1227 """ 1228 if self._use_project is False: 1229 return self._process_result(epanet.ENgetlinknodes(index)) 1230 else: 1231 return self._process_result(epanet.EN_getlinknodes(self._ph, index))
1232
[docs] 1233 def setlinknodes(self, index: int, node1: int, node2: int): 1234 """ 1235 EN_setlinknodes 1236 1237 Parameters 1238 ---------- 1239 index : `int` 1240 node1 : `int` 1241 node2 : `int` 1242 """ 1243 if self._use_project is False: 1244 return self._process_result(epanet.ENsetlinknodes(index, node1, node2)) 1245 else: 1246 return self._process_result(epanet.EN_setlinknodes(self._ph, index, node1, node2))
1247
[docs] 1248 def getlinkvalue(self, index: int, property: int): 1249 """ 1250 EN_getlinkvalue 1251 1252 Parameters 1253 ---------- 1254 index : `int` 1255 property : `int` 1256 """ 1257 if self._use_project is False: 1258 return self._process_result(epanet.ENgetlinkvalue(index, property)) 1259 else: 1260 return self._process_result(epanet.EN_getlinkvalue(self._ph, index, property))
1261
[docs] 1262 def setlinkvalue(self, index: int, property: int, value: float): 1263 """ 1264 EN_setlinkvalue 1265 1266 Parameters 1267 ---------- 1268 index : `int` 1269 property : `int` 1270 value : `float` 1271 """ 1272 if self._use_project is False: 1273 return self._process_result(epanet.ENsetlinkvalue(index, property, value)) 1274 else: 1275 return self._process_result(epanet.EN_setlinkvalue(self._ph, index, property, value))
1276
[docs] 1277 def setpipedata(self, index: int, length: float, diam: float, rough: float, mloss: float): 1278 """ 1279 EN_setpipedata 1280 1281 Parameters 1282 ---------- 1283 index : `int` 1284 length : `float` 1285 diam : `float` 1286 rough : `float` 1287 mloss : `float` 1288 """ 1289 if self._use_project is False: 1290 return self._process_result(epanet.ENsetpipedata(index, length, diam, rough, mloss)) 1291 else: 1292 return self._process_result(epanet.EN_setpipedata(self._ph, index, length, diam, rough, 1293 mloss))
1294
[docs] 1295 def getvertexcount(self, index: int): 1296 """ 1297 EN_getvertexcount 1298 1299 Parameters 1300 ---------- 1301 index : `int` 1302 """ 1303 if self._use_project is False: 1304 return self._process_result(epanet.ENgetvertexcount(index)) 1305 else: 1306 return self._process_result(epanet.EN_getvertexcount(self._ph, index))
1307
[docs] 1308 def getvertex(self, index: int, vertex: int): 1309 """ 1310 EN_getvertex 1311 1312 Parameters 1313 ---------- 1314 index : `int` 1315 vertex : `int` 1316 """ 1317 if self._use_project is False: 1318 return self._process_result(epanet.ENgetvertex(index, vertex)) 1319 else: 1320 return self._process_result(epanet.EN_getvertex(self._ph, index, vertex))
1321
[docs] 1322 def setvertices(self, index: int, x: list[float], y: list[float], count: int): 1323 """ 1324 EN_setvertices 1325 1326 Parameters 1327 ---------- 1328 index : `int` 1329 x : `list[float]` 1330 y : `list[float]` 1331 count : `int` 1332 """ 1333 if self._use_project is False: 1334 return self._process_result(epanet.ENsetvertices(index, x, y, count)) 1335 else: 1336 return self._process_result(epanet.EN_setvertices(self._ph, index, x, y, count))
1337
[docs] 1338 def getpumptype(self, link_index: int): 1339 """ 1340 EN_getpumptype 1341 1342 Parameters 1343 ---------- 1344 link_index : `int` 1345 """ 1346 if self._use_project is False: 1347 return self._process_result(epanet.ENgetpumptype(link_index)) 1348 else: 1349 return self._process_result(epanet.EN_getpumptype(self._ph, link_index))
1350
[docs] 1351 def getheadcurveindex(self, link_index: int): 1352 """ 1353 EN_getheadcurveindex 1354 1355 Parameters 1356 ---------- 1357 link_index : `int` 1358 """ 1359 if self._use_project is False: 1360 return self._process_result(epanet.ENgetheadcurveindex(link_index)) 1361 else: 1362 return self._process_result(epanet.EN_getheadcurveindex(self._ph, link_index))
1363
[docs] 1364 def setheadcurveindex(self, link_index: int, curve_index: int): 1365 """ 1366 EN_setheadcurveindex 1367 1368 Parameters 1369 ---------- 1370 link_index : `int` 1371 curve_index : `int` 1372 """ 1373 if self._use_project is False: 1374 return self._process_result(epanet.ENsetheadcurveindex(link_index, curve_index)) 1375 else: 1376 return self._process_result(epanet.EN_setheadcurveindex(self._ph, link_index, 1377 curve_index))
1378
[docs] 1379 def addpattern(self, id: str): 1380 """ 1381 EN_addpattern 1382 1383 Parameters 1384 ---------- 1385 id : `str` 1386 """ 1387 if self._use_project is False: 1388 return self._process_result(epanet.ENaddpattern(id)) 1389 else: 1390 return self._process_result(epanet.EN_addpattern(self._ph, id))
1391
[docs] 1392 def deletepattern(self, index: int): 1393 """ 1394 EN_deletepattern 1395 1396 Parameters 1397 ---------- 1398 index : `int` 1399 """ 1400 if self._use_project is False: 1401 return self._process_result(epanet.ENdeletepattern(index)) 1402 else: 1403 return self._process_result(epanet.EN_deletepattern(self._ph, index))
1404
[docs] 1405 def getpatternindex(self, pattern_id: str): 1406 """ 1407 EN_getpatternindex 1408 1409 Parameters 1410 ---------- 1411 pattern_id : `str` 1412 """ 1413 if self._use_project is False: 1414 return self._process_result(epanet.ENgetpatternindex(pattern_id)) 1415 else: 1416 return self._process_result(epanet.EN_getpatternindex(self._ph, pattern_id))
1417
[docs] 1418 def getpatternid(self, index: int): 1419 """ 1420 EN_getpatternid 1421 1422 Parameters 1423 ---------- 1424 index : `int` 1425 """ 1426 if self._use_project is False: 1427 return self._process_result(epanet.ENgetpatternid(index)) 1428 else: 1429 return self._process_result(epanet.EN_getpatternid(self._ph, index))
1430
[docs] 1431 def setpatternid(self, index: int, id: str): 1432 """ 1433 EN_setpatternid 1434 1435 Parameters 1436 ---------- 1437 index : `int` 1438 id : `str` 1439 """ 1440 if self._use_project is False: 1441 return self._process_result(epanet.ENsetpatternid(index, id)) 1442 else: 1443 return self._process_result(epanet.EN_setpatternid(self._ph, index, id))
1444
[docs] 1445 def getpatternlen(self, index: int): 1446 """ 1447 EN_getpatternlen 1448 1449 Parameters 1450 ---------- 1451 index : `int` 1452 """ 1453 if self._use_project is False: 1454 return self._process_result(epanet.ENgetpatternlen(index)) 1455 else: 1456 return self._process_result(epanet.EN_getpatternlen(self._ph, index))
1457
[docs] 1458 def getpatternvalue(self, index: int, period: int): 1459 """ 1460 EN_getpatternvalue 1461 1462 Parameters 1463 ---------- 1464 index : `int` 1465 period : `int` 1466 """ 1467 if self._use_project is False: 1468 return self._process_result(epanet.ENgetpatternvalue(index, period)) 1469 else: 1470 return self._process_result(epanet.EN_getpatternvalue(self._ph, index, period))
1471
[docs] 1472 def setpatternvalue(self, index: int, period: int, value: float): 1473 """ 1474 EN_setpatternvalue 1475 1476 Parameters 1477 ---------- 1478 index : `int` 1479 period : `int` 1480 value : `float` 1481 """ 1482 if self._use_project is False: 1483 return self._process_result(epanet.ENsetpatternvalue(index, period, value)) 1484 else: 1485 return self._process_result(epanet.EN_setpatternvalue(self._ph, index, period, value))
1486
[docs] 1487 def getaveragepatternvalue(self, index: int): 1488 """ 1489 EN_getaveragepatternvalue 1490 1491 Parameters 1492 ---------- 1493 index : `int` 1494 """ 1495 if self._use_project is False: 1496 return self._process_result(epanet.ENgetaveragepatternvalue(index)) 1497 else: 1498 return self._process_result(epanet.EN_getaveragepatternvalue(self._ph, index))
1499
[docs] 1500 def setpattern(self, index: int, values: list[float], len: int): 1501 """ 1502 EN_setpattern 1503 1504 Parameters 1505 ---------- 1506 index : `int` 1507 values : `list[float]` 1508 len : `int` 1509 """ 1510 if self._use_project is False: 1511 return self._process_result(epanet.ENsetpattern(index, values, len)) 1512 else: 1513 return self._process_result(epanet.EN_setpattern(self._ph, index, values, len))
1514
[docs] 1515 def addcurve(self, id: str): 1516 """ 1517 EN_addcurve 1518 1519 Parameters 1520 ---------- 1521 id : `str` 1522 """ 1523 if self._use_project is False: 1524 return self._process_result(epanet.ENaddcurve(id)) 1525 else: 1526 return self._process_result(epanet.EN_addcurve(self._ph, id))
1527
[docs] 1528 def deletecurve(self, index: int): 1529 """ 1530 EN_deletecurve 1531 1532 Parameters 1533 ---------- 1534 index : `int` 1535 """ 1536 if self._use_project is False: 1537 return self._process_result(epanet.ENdeletecurve(index)) 1538 else: 1539 return self._process_result(epanet.EN_deletecurve(self._ph, index))
1540
[docs] 1541 def getcurveindex(self, id: str): 1542 """ 1543 EN_getcurveindex 1544 1545 Parameters 1546 ---------- 1547 id : `str` 1548 """ 1549 if self._use_project is False: 1550 return self._process_result(epanet.ENgetcurveindex(id)) 1551 else: 1552 return self._process_result(epanet.EN_getcurveindex(self._ph, id))
1553
[docs] 1554 def getcurveid(self, index: int): 1555 """ 1556 EN_getcurveid 1557 1558 Parameters 1559 ---------- 1560 index : `int` 1561 """ 1562 if self._use_project is False: 1563 return self._process_result(epanet.ENgetcurveid(index)) 1564 else: 1565 return self._process_result(epanet.EN_getcurveid(self._ph, index))
1566
[docs] 1567 def setcurveid(self, index: int, id: str): 1568 """ 1569 EN_setcurveid 1570 1571 Parameters 1572 ---------- 1573 index : `int` 1574 id : `str` 1575 """ 1576 if self._use_project is False: 1577 return self._process_result(epanet.ENsetcurveid(index, id)) 1578 else: 1579 return self._process_result(epanet.EN_setcurveid(self._ph, index, id))
1580
[docs] 1581 def getcurvelen(self, index: int): 1582 """ 1583 EN_getcurvelen 1584 1585 Parameters 1586 ---------- 1587 index : `int` 1588 """ 1589 if self._use_project is False: 1590 return self._process_result(epanet.ENgetcurvelen(index)) 1591 else: 1592 return self._process_result(epanet.EN_getcurvelen(self._ph, index))
1593
[docs] 1594 def getcurvetype(self, index: int): 1595 """ 1596 EN_getcurvetype 1597 1598 Parameters 1599 ---------- 1600 index : `int` 1601 """ 1602 if self._use_project is False: 1603 return self._process_result(epanet.ENgetcurvetype(index)) 1604 else: 1605 return self._process_result(epanet.EN_getcurvetype(self._ph, index))
1606
[docs] 1607 def getcurvevalue(self, curve_index: int, point_index: int): 1608 """ 1609 EN_getcurvevalue 1610 1611 Parameters 1612 ---------- 1613 curve_index : `int` 1614 point_index : `int` 1615 """ 1616 if self._use_project is False: 1617 return self._process_result(epanet.ENgetcurvevalue(curve_index, point_index)) 1618 else: 1619 return self._process_result(epanet.EN_getcurvevalue(self._ph, curve_index, point_index))
1620
[docs] 1621 def setcurvevalue(self, curve_index: int, point_index: int, x: float, y: float): 1622 """ 1623 EN_setcurvevalue 1624 1625 Parameters 1626 ---------- 1627 curve_index : `int` 1628 point_index : `int` 1629 x : `float` 1630 y : `float` 1631 """ 1632 if self._use_project is False: 1633 return self._process_result(epanet.ENsetcurvevalue(curve_index, point_index, x, y)) 1634 else: 1635 return self._process_result(epanet.EN_setcurvevalue(self._ph, curve_index, point_index, 1636 x, y))
1637
[docs] 1638 def getcurve(self, index: int): 1639 """ 1640 EN_getcurve 1641 1642 Parameters 1643 ---------- 1644 index : `int` 1645 """ 1646 if self._use_project is False: 1647 return self._process_result(epanet.ENgetcurve(index)) 1648 else: 1649 return self._process_result(epanet.EN_getcurve(self._ph, index))
1650
[docs] 1651 def setcurve(self, index: int, x_values: list[float], y_values: list[float], n_points: int): 1652 """ 1653 EN_setcurve 1654 1655 Parameters 1656 ---------- 1657 index : `int` 1658 x_values : `list[float]` 1659 y_values : `list[float]` 1660 n_points : `int` 1661 """ 1662 if self._use_project is False: 1663 return self._process_result(epanet.ENsetcurve(index, x_values, y_values, n_points)) 1664 else: 1665 return self._process_result(epanet.EN_setcurve(self._ph, index, x_values, y_values, 1666 n_points))
1667
[docs] 1668 def addcontrol(self, type: int, link_index: int, setting: float, node_index: int, level: float): 1669 """ 1670 EN_addcontrol 1671 1672 Parameters 1673 ---------- 1674 type : `int` 1675 link_index : `int` 1676 setting : `float` 1677 node_index . `int` 1678 level : `float` 1679 """ 1680 if self._use_project is False: 1681 return self._process_result(epanet.ENaddcontrol(type, link_index, setting, node_index, 1682 level)) 1683 else: 1684 return self._process_result(epanet.EN_addcontrol(self._ph, type, link_index, setting, 1685 node_index, level))
1686
[docs] 1687 def deletecontrol(self, index: int): 1688 """ 1689 EN_deletecontrol 1690 1691 Parameters 1692 ---------- 1693 index : `int` 1694 """ 1695 if self._use_project is False: 1696 return self._process_result(epanet.ENdeletecontrol(index)) 1697 else: 1698 return self._process_result(epanet.EN_deletecontrol(self._ph, index))
1699
[docs] 1700 def getcontrol(self, index: int): 1701 """ 1702 EN_getcontrol 1703 1704 Parameters 1705 ---------- 1706 index : `int` 1707 """ 1708 if self._use_project is False: 1709 return self._process_result(epanet.ENgetcontrol(index)) 1710 else: 1711 return self._process_result(epanet.EN_getcontrol(self._ph, index))
1712
[docs] 1713 def setcontrol(self, index: int, type: int, link_index: int, setting: float, node_index: int, 1714 level: float): 1715 """ 1716 EN_setcontrol 1717 1718 Parameters 1719 ---------- 1720 index : `int` 1721 type : `int` 1722 link_index : `int` 1723 setting : `float` 1724 node_index : `int` 1725 level : `float` 1726 """ 1727 if self._use_project is False: 1728 return self._process_result(epanet.ENsetcontrol(index, type, link_index, setting, 1729 node_index, level)) 1730 else: 1731 return self._process_result(epanet.EN_setcontrol(self._ph, index, type, link_index, 1732 setting, node_index, level))
1733
[docs] 1734 def addrule(self, rule: str): 1735 """ 1736 EN_addrule 1737 1738 Parameters 1739 ---------- 1740 rule : `str` 1741 """ 1742 if self._use_project is False: 1743 return self._process_result(epanet.ENaddrule(rule)) 1744 else: 1745 return self._process_result(epanet.EN_addrule(self._ph, rule))
1746
[docs] 1747 def deleterule(self, index: int): 1748 """ 1749 EN_deleterule 1750 1751 Parameters 1752 ---------- 1753 index : `int` 1754 """ 1755 if self._use_project is False: 1756 return self._process_result(epanet.ENdeleterule(index)) 1757 else: 1758 return self._process_result(epanet.EN_deleterule(self.ph, index))
1759
[docs] 1760 def getrule(self, index: int): 1761 """ 1762 EN_getrule 1763 1764 Parameters 1765 ---------- 1766 index : `int` 1767 """ 1768 if self._use_project is False: 1769 return self._process_result(epanet.ENgetrule(index)) 1770 else: 1771 return self._process_result(epanet.EN_getrule(self._ph, index))
1772
[docs] 1773 def getruleid(self, index: int): 1774 """ 1775 EN_getruleID 1776 1777 Parameters 1778 ---------- 1779 index : `int` 1780 """ 1781 if self._use_project is False: 1782 return self._process_result(epanet.ENgetruleID(index)) 1783 else: 1784 return self._process_result(epanet.EN_getruleID(self._ph, index))
1785
[docs] 1786 def getpremise(self, rule_index: int, premise_index: int): 1787 """ 1788 EN_getpremise 1789 1790 Parameters 1791 ---------- 1792 rule_index : `int` 1793 premise_index : `int` 1794 """ 1795 if self._use_project is False: 1796 return self._process_result(epanet.ENgetpremise(rule_index, premise_index)) 1797 else: 1798 return self._process_result(epanet.EN_getpremise(self._ph, rule_index, premise_index))
1799
[docs] 1800 def setpremise(self, rule_index: int, premise_index: int, logop: int, object: int, 1801 obj_index: int, variable: int, relop: int, status: int, value: float): 1802 """ 1803 EN_setpremise 1804 1805 Parameters 1806 ---------- 1807 rule_index : `int` 1808 premise_index : `int` 1809 logop : `int` 1810 object : `int` 1811 obj_index : `int` 1812 variable : `int` 1813 relop : `int` 1814 status : `int` 1815 value : `float` 1816 """ 1817 if self._use_project is False: 1818 return self._process_result(epanet.ENsetpremise(rule_index, premise_index, logop, 1819 object, obj_index, variable, relop, 1820 status, value)) 1821 else: 1822 return self._process_result(epanet.EN_setpremise(self._ph, rule_index, premise_index, 1823 logop, object, obj_index, variable, 1824 relop, status, value))
1825
[docs] 1826 def setpremiseindex(self, rule_index: int, premise_index: int, obj_index: int): 1827 """ 1828 EN_setpremiseindex 1829 1830 Parameters 1831 ---------- 1832 rule_index : `int` 1833 premise_index : `int` 1834 obj_index : `int` 1835 """ 1836 if self._use_project is False: 1837 return self._process_result(epanet.ENsetpremiseindex(rule_index, premise_index, 1838 obj_index)) 1839 else: 1840 return self._process_result(epanet.EN_setpremiseindex(self._ph, rule_index, 1841 premise_index, obj_index))
1842
[docs] 1843 def setpremisestatus(self, rule_index: int, premise_index: int, status: int): 1844 """ 1845 EN_setpremisestatus 1846 1847 Parameters 1848 ---------- 1849 rule_index : `int` 1850 premise_index : `int` 1851 status : `int` 1852 """ 1853 if self._use_project is False: 1854 return self._process_result(epanet.ENsetpremisestatus(rule_index, premise_index, 1855 status)) 1856 else: 1857 return self._process_result(epanet.EN_setpremisestatus(self._ph, rule_index, 1858 premise_index, status))
1859
[docs] 1860 def setpremisevalue(self, rule_index: int, premise_index: int, value: float): 1861 """ 1862 EN_setpremisevalue 1863 1864 Parameters 1865 ---------- 1866 rule_index : `int` 1867 premise_index : `int` 1868 value : `float` 1869 """ 1870 if self._use_project is False: 1871 return self._process_result(epanet.ENsetpremisevalue(rule_index, premise_index, value)) 1872 else: 1873 return self._process_result(epanet.EN_setpremisevalue(self._ph, rule_index, premise_index, value))
1874
[docs] 1875 def getthenaction(self, rule_index: int, action_index: int): 1876 """ 1877 EN_getthenaction 1878 1879 Parameters 1880 ---------- 1881 rule_index : `int` 1882 action_index : `int` 1883 """ 1884 if self._use_project is False: 1885 return self._process_result(epanet.ENgetthenaction(rule_index, action_index)) 1886 else: 1887 return self._process_result(epanet.EN_getthenaction(self._ph, rule_index, action_index))
1888
[docs] 1889 def setthenaction(self, rule_index: int, action_index: int, link_index: int, status: int, 1890 setting: float): 1891 """ 1892 EN_setthenaction 1893 1894 Parameters 1895 ---------- 1896 rule_index : `int` 1897 action_index : `int` 1898 link_index : `int` 1899 status : `int` 1900 setting : `float` 1901 """ 1902 if self._use_project is False: 1903 return self._process_result(epanet.ENsetthenaction(rule_index, action_index, link_index, 1904 status, setting)) 1905 else: 1906 return self._process_result(epanet.EN_setthenaction(self._ph, rule_index, action_index, 1907 link_index, status, setting))
1908
[docs] 1909 def getelseaction(self, rule_index: int, action_index: int): 1910 """ 1911 EN_getelseaction 1912 1913 Parameters 1914 ---------- 1915 rule_index : `int` 1916 action_index : `int` 1917 """ 1918 if self._use_project is False: 1919 return self._process_result(epanet.ENgetelseaction(rule_index, action_index)) 1920 else: 1921 return self._process_result(epanet.EN_getelseaction(self._ph, rule_index, action_index))
1922
[docs] 1923 def setelseaction(self, rule_index: int, action_index: int, link_index: int, status: int, 1924 setting: float): 1925 """ 1926 EN_setelseaction 1927 1928 Parameters 1929 ---------- 1930 rule_index : `int` 1931 action_index : `int` 1932 link_index : `int` 1933 status : `int` 1934 setting : `float` 1935 """ 1936 if self._use_project is False: 1937 return self._process_result(epanet.ENsetelseaction(rule_index, action_index, link_index, 1938 status, setting)) 1939 else: 1940 return self._process_result(epanet.EN_setelseaction(self._ph, rule_index, action_index, 1941 link_index, status, setting))
1942
[docs] 1943 def setrulepriority(self, index: int, priority: float): 1944 """ 1945 EN_setrulepriority 1946 1947 Parameters 1948 ---------- 1949 index : `int` 1950 priority : `float` 1951 """ 1952 if self._use_project is False: 1953 return self._process_result(epanet.ENsetrulepriority(index, priority)) 1954 else: 1955 return self._process_result(epanet.EN_setrulepriority(self._ph, index, priority))
1956
[docs] 1957 def gettag(self, obj_type: int, obj_idx: int): 1958 """ 1959 EN_gettag 1960 1961 Parameters 1962 ---------- 1963 obj_type : `int` 1964 obj_idx : `int` 1965 """ 1966 if self._use_project is False: 1967 return self._process_result(epanet.ENgettag(obj_type, obj_idx)) 1968 else: 1969 return self._process_result(epanet.EN_gettag(self._ph, obj_type, obj_idx))
1970
[docs] 1971 def settag(self, obj_type: int, obj_idx: int, tag: str): 1972 """ 1973 EN_settag 1974 1975 Parameters 1976 ---------- 1977 obj_type : `int` 1978 obj_idx : `int` 1979 tag : `str` 1980 """ 1981 if self._use_project is False: 1982 return self._process_result(epanet.ENsettag(obj_type, obj_idx, tag)) 1983 else: 1984 return self._process_result(epanet.EN_settag(self._ph, obj_type, obj_idx, tag))
1985
[docs] 1986 def timetonextevent(self): 1987 """ 1988 EN_timetonextevent 1989 """ 1990 if self._use_project is False: 1991 return self._process_result(epanet.ENtimetonextevent()) 1992 else: 1993 return self._process_result(epanet.EN_timetonextevent(self._ph))
1994
[docs] 1995 def getnodevalues(self, property: int): 1996 """ 1997 EN_getnodevalues 1998 1999 Parameters 2000 ---------- 2001 property : `int` 2002 """ 2003 if self._use_project is False: 2004 return self._process_result(epanet.ENgetnodevalues(property)) 2005 else: 2006 return self._process_result(epanet.EN_getnodevalues(self._ph, property))
2007
[docs] 2008 def getlinkvalues(self, property: int): 2009 """ 2010 EN_getlinkvalues 2011 2012 Parameters 2013 ---------- 2014 property : `int` 2015 """ 2016 if self._use_project is False: 2017 return self._process_result(epanet.ENgetlinkvalues(property)) 2018 else: 2019 return self._process_result(epanet.EN_getlinkvalues(self._ph, property))
2020
[docs] 2021 def setvertex(self, link_idx: int, vertex_idx: int, x: float, y: float): 2022 """ 2023 EN_setvertex 2024 2025 Parameters 2026 ---------- 2027 link_idx : `int` 2028 vertex_idx : `int` 2029 x : `float` 2030 y : `float` 2031 """ 2032 if self._use_project is False: 2033 return self._process_result(epanet.ENsetvertex(link_idx, vertex_idx, x, y)) 2034 else: 2035 return self._process_result(epanet.EN_setvertex(self._ph, link_idx, vertex_idx, x, y))
2036
[docs] 2037 def loadpatternfile(self, filename: str, id: str): 2038 """ 2039 EN_loadpatternfile 2040 2041 Parameters 2042 ---------- 2043 filename : `str` 2044 id : `str` 2045 """ 2046 if self._use_project is False: 2047 return self._process_result(epanet.ENloadpatternfile(filename, id)) 2048 else: 2049 return self._process_result(epanet.EN_loadpatternfile(self._ph, filename, id))
2050
[docs] 2051 def setcurvetype(self, curve_idx: int, curve_type: int): 2052 """ 2053 EN_setcurvetype 2054 2055 Parameters 2056 ---------- 2057 curve_idx : `int` 2058 curve_type : `int` 2059 """ 2060 if self._use_project is False: 2061 return self._process_result(epanet.ENsetcurvetype(curve_idx, curve_type)) 2062 else: 2063 return self._process_result(epanet.EN_setcurvetype(self._ph, curve_idx, curve_type))
2064
[docs] 2065 def getcontrolenabled(self, control_idx: int): 2066 """ 2067 EN_getcontrolenabled 2068 2069 Parameters 2070 ---------- 2071 control_idx : `int` 2072 """ 2073 if self._use_project is False: 2074 return self._process_result(epanet.ENgetcontrolenabled(control_idx)) 2075 else: 2076 return self._process_result(epanet.EN_getcontrolenabled(self._ph, control_idx))
2077
[docs] 2078 def setcontrolenabled(self, control_idx: int, enabled: int): 2079 """ 2080 EN_setcontrolenabled 2081 2082 Parameters 2083 ---------- 2084 control_idx : `int` 2085 enabled : `int` 2086 """ 2087 if self._use_project is False: 2088 return self._process_result(epanet.ENsetcontrolenabled(control_idx, enabled)) 2089 else: 2090 return self._process_result(epanet.EN_setcontrolenabled(self._ph, control_idx, enabled))
2091
[docs] 2092 def getruleenabled(self, rule_idx: int): 2093 """ 2094 EN_getruleenabled 2095 2096 Parameters 2097 ---------- 2098 rule_idx : `int` 2099 """ 2100 if self._use_project is False: 2101 return self._process_result(epanet.ENgetruleenabled(rule_idx)) 2102 else: 2103 return self._process_result(epanet.EN_getruleenabled(self._ph, rule_idx))
2104
[docs] 2105 def setruleenabled(self, rule_idx: int, enabled: int): 2106 """ 2107 EN_setruleenabled 2108 2109 Parameters 2110 ---------- 2111 rule_idx : `int` 2112 enabled : `int` 2113 """ 2114 if self._use_project is False: 2115 return self._process_result(epanet.ENsetruleenabled(rule_idx, enabled)) 2116 else: 2117 return self._process_result(epanet.EN_setruleenabled(self._ph, rule_idx, enabled))
2118
[docs] 2119 def MSXENopen(self, inp_file: str, rpt_file: str, out_file: str): 2120 """ 2121 MSXENopen 2122 2123 Parameters 2124 ---------- 2125 inp_file : `str` 2126 rpt_file : `str` 2127 out_file : `str` 2128 """ 2129 return self._process_result(epanet.MSXENopen(inp_file, rpt_file, out_file), msx_call=True)
2130
[docs] 2131 def MSXopen(self, fname: str): 2132 """ 2133 MSXopen 2134 2135 Parameters 2136 ---------- 2137 fname : `str` 2138 """ 2139 return self._process_result(epanet.MSXopen(fname), msx_call=True)
2140
[docs] 2141 def MSXsolveH(self): 2142 """ 2143 MSXsolveH 2144 """ 2145 return self._process_result(epanet.MSXsolveH(), msx_call=True)
2146
[docs] 2147 def MSXusehydfile(self, fname: str): 2148 """ 2149 MSXusehydfile 2150 2151 Parameters 2152 ---------- 2153 fname : `str` 2154 """ 2155 return self._process_result(epanet.MSXusehydfile(fname), msx_call=True)
2156
[docs] 2157 def MSXsolveQ(self): 2158 """ 2159 MSXsolveQ 2160 """ 2161 return self._process_result(epanet.MSXsolveQ(), msx_call=True)
2162
[docs] 2163 def MSXinit(self, save_flag: int): 2164 """ 2165 MSXinit 2166 2167 Parameters 2168 ---------- 2169 save_flag : `int` 2170 """ 2171 return self._process_result(epanet.MSXinit(save_flag), msx_call=True)
2172
[docs] 2173 def MSXstep(self): 2174 """ 2175 MSXstep 2176 """ 2177 return self._process_result(epanet.MSXstep(), msx_call=True)
2178
[docs] 2179 def MSXsaveoutfile(self, fname: str): 2180 """ 2181 MSXsaveoutfile 2182 2183 Parameters 2184 ---------- 2185 fname : `str` 2186 """ 2187 return self._process_result(epanet.MSXsaveoutfile(fname), msx_call=True)
2188
[docs] 2189 def MSXsavemsxfile(self, fname: str): 2190 """ 2191 MSXsavemsxfile 2192 2193 Parameters 2194 ---------- 2195 fname : `str` 2196 """ 2197 return self._process_result(epanet.MSXsavemsxfile(fname), msx_call=True)
2198
[docs] 2199 def MSXreport(self): 2200 """ 2201 MSXreport 2202 """ 2203 return self._process_result(epanet.MSXreport(), msx_call=True)
2204
[docs] 2205 def MSXclose(self): 2206 """ 2207 MSXclose 2208 """ 2209 return self._process_result(epanet.MSXclose(), msx_call=True)
2210
[docs] 2211 def MSXENclose(self): 2212 """ 2213 MSXENclose 2214 """ 2215 return self._process_result(epanet.MSXENclose(), msx_call=True)
2216
[docs] 2217 def MSXgetindex(self, item_type: int, id: str): 2218 """ 2219 MSXgetindex 2220 2221 Parameters 2222 ---------- 2223 item_type : `int` 2224 id : `str` 2225 """ 2226 return self._process_result(epanet.MSXgetindex(item_type, id), msx_call=True)
2227
[docs] 2228 def MSXgetIDlen(self, item_type: int, index: int): 2229 """ 2230 MSXgetIDlen 2231 2232 Parameters 2233 ---------- 2234 item_type : `int` 2235 index : `int` 2236 """ 2237 return self._process_result(epanet.MSXgetIDlen(item_type, index), msx_call=True)
2238
[docs] 2239 def MSXgetID(self, item_type: int, index: int): 2240 """ 2241 MSXgetID 2242 2243 Parameters 2244 ---------- 2245 item_type : `int` 2246 index : `int` 2247 """ 2248 return self._process_result(epanet.MSXgetID(item_type, index), msx_call=True)
2249
[docs] 2250 def MSXgetcount(self, item_type: int): 2251 """ 2252 MSXgetcount 2253 2254 Parameters 2255 ---------- 2256 item_type : `int` 2257 """ 2258 return self._process_result(epanet.MSXgetcount(item_type), msx_call=True)
2259
[docs] 2260 def MSXgetspecies(self, index: int): 2261 """ 2262 MSXgetspecies 2263 2264 Parameters 2265 ---------- 2266 index : `int` 2267 """ 2268 return self._process_result(epanet.MSXgetspecies(index), msx_call=True)
2269
[docs] 2270 def MSXgetconstant(self, index: int): 2271 """ 2272 MSXgetconstant 2273 2274 Parameters 2275 ---------- 2276 index : `int` 2277 """ 2278 return self._process_result(epanet.MSXgetconstant(index), msx_call=True)
2279
[docs] 2280 def MSXgetparameter(self, item_type: int, index: int, param: int): 2281 """ 2282 MSXgetparameter 2283 2284 Parameters 2285 ---------- 2286 item_type : `int` 2287 index : `int` 2288 param : `int` 2289 """ 2290 return self._process_result(epanet.MSXgetparameter(item_type, index, param), msx_call=True)
2291
[docs] 2292 def MSXgetsource(self, node: int, species: int): 2293 """ 2294 MSXgetsource 2295 2296 Parameters 2297 ---------- 2298 node : `int` 2299 species : `int` 2300 """ 2301 return self._process_result(epanet.MSXgetsource(node, species), msx_call=True)
2302
[docs] 2303 def MSXgetpatternlen(self, pat: int): 2304 """ 2305 MSXgetpatternlen 2306 2307 Parameters 2308 ---------- 2309 pat : `int` 2310 """ 2311 return self._process_result(epanet.MSXgetpatternlen(pat), msx_call=True)
2312
[docs] 2313 def MSXgetpatternvalue(self, pat: int, period: int): 2314 """ 2315 MSXgetpatternvalue 2316 2317 Parameters 2318 ---------- 2319 pat : `int` 2320 period : `int` 2321 """ 2322 return self._process_result(epanet.MSXgetpatternvalue(pat, period), msx_call=True)
2323
[docs] 2324 def MSXgetinitqual(self, item_type: int, index: int, species: int): 2325 """ 2326 MSXgetinitqual 2327 2328 Parameters 2329 ---------- 2330 item_type : `int` 2331 index : `int` 2332 species : `int` 2333 """ 2334 return self._process_result(epanet.MSXgetinitqual(item_type, index, species), msx_call=True)
2335
[docs] 2336 def MSXgetqual(self, item_type: int, index: int, species: int): 2337 """ 2338 MSXgetqual 2339 2340 Parameters 2341 ---------- 2342 item_type : `int` 2343 index : `int` 2344 species : `int` 2345 """ 2346 return self._process_result(epanet.MSXgetqual(item_type, index, species), msx_call=True)
2347
[docs] 2348 def MSXgeterror(self, err_code: int): 2349 """ 2350 MSXgeterror 2351 2352 Parameters 2353 ---------- 2354 err_code : `int` 2355 """ 2356 err, msg = epanet.MSXgeterror(err_code) 2357 if err != 0: 2358 raise RuntimeError("Failed to get error message") 2359 else: 2360 return msg
2361
[docs] 2362 def MSXsetconstant(self, index: int, value: float): 2363 """ 2364 MSXsetconstant 2365 2366 Parameters 2367 ---------- 2368 index : `int` 2369 value : `float` 2370 """ 2371 return self._process_result(epanet.MSXsetconstant(index, value))
2372
[docs] 2373 def MSXsetparameter(self, item_type: int, index: int, param: int, value: float): 2374 """ 2375 MSXsetparameter 2376 2377 Parameters 2378 ---------- 2379 item_type : `int` 2380 index : `int` 2381 param : `int` 2382 value : `float` 2383 """ 2384 return self._process_result(epanet.MSXsetparameter(item_type, index, param, value), 2385 msx_call=True)
2386
[docs] 2387 def MSXsetinitqual(self, item_type: int, index: int, species: int, value: float): 2388 """ 2389 MSXsetinitqual 2390 2391 Parameters 2392 ---------- 2393 item_type : `int` 2394 index : `int` 2395 species : `int` 2396 value : `float` 2397 """ 2398 return self._process_result(epanet.MSXsetinitqual(item_type, index, species, value), 2399 msx_call=True)
2400
[docs] 2401 def MSXsetsource(self, node: int, species: int, item_type: int, level: float, pat: int): 2402 """ 2403 MSXsetsource 2404 2405 Parameters 2406 ---------- 2407 node : `int` 2408 species : `int` 2409 item_type : `int` 2410 level : `float` 2411 pat : `int` 2412 """ 2413 return self._process_result(epanet.MSXsetsource(node, species, item_type, level, pat), 2414 msx_call=True)
2415
[docs] 2416 def MSXsetpatternvalue(self, pat: int, period: int, value: float): 2417 """ 2418 MSXsetpatternvalue 2419 2420 Parameters 2421 ---------- 2422 pat : `int` 2423 period : `int` 2424 value : `float` 2425 """ 2426 return self._process_result(epanet.MSXsetpatternvalue(pat, period, value), msx_call=True)
2427
[docs] 2428 def MSXsetpattern(self, pat: int, mult: list[float], len: int): 2429 """ 2430 MSXsetpattern 2431 2432 Parameters 2433 ---------- 2434 pat : `int` 2435 mult : `list[float]` 2436 len : `int` 2437 """ 2438 return self._process_result(epanet.MSXsetpattern(pat, mult, len), msx_call=True)
2439
[docs] 2440 def MSXaddpattern(self, id: str): 2441 """ 2442 MSXaddpattern 2443 2444 Parameters 2445 ---------- 2446 id : `str` 2447 """ 2448 return self._process_result(epanet.MSXaddpattern(id), msx_call=True)