1"""
2This module contains a Python wrapper (incl. error handling) for EPANET and EPANET-MSX functions.
3"""
4from typing import Any
5import warnings
6import numpy
7import epanet
8
9
[docs]
10class EpanetAPI():
11 """
12 Interface for EPANET and EPANET-MSX functions, incl. a proper error handling.
13
14 Parameters
15 ----------
16 use_project : `bool`, optional
17 If True, projects will be used when calling EPANET functions (default in EPANET >= 2.2).
18 Note that this is incompatible with EPANET-MSX. Please set to False when using EPANET-MSX.
19
20 The default is False.
21
22 raise_on_error : `bool`, optional
23 True if an exception should be raised in the case of an error/warning, False otherwise.
24
25 The default is True.
26 warn_on_error : `bool`, optional
27 True if a warning should be generated in the case of an error/warning, False otherwise.
28
29 The default is False.
30 ignore_error_codes : `list[int]`, optional
31 List of error codes that should be ignored -- i.e., no exception or warning
32 will be generated.
33
34 The default is an empty list.
35 """
36 def __init__(self, use_project: bool = False, raise_exception_on_error: bool = True,
37 warn_on_error: bool = False, ignore_error_codes: list[int] = []):
38 if not isinstance(use_project, bool):
39 raise TypeError("'use_project' must be an instance of 'bool' " +
40 f"but not of '{type(use_project)}'")
41 if not isinstance(raise_exception_on_error, bool):
42 raise TypeError("'raise_exception_on_error' must be an instance of 'bool' " +
43 f"but not of '{type(raise_exception_on_error)}'")
44 if not isinstance(warn_on_error, bool):
45 raise TypeError("'warn_on_error' must be an instance of 'bool' " +
46 f"but not of type '{type(warn_on_error)}'")
47 if not isinstance(ignore_error_codes, list):
48 raise TypeError("'ignore_error_codes' must be an instance of 'list[int]' " +
49 f"but not of '{type(ignore_error_codes)}'")
50 else:
51 if any(not isinstance(item, int) for item in ignore_error_codes):
52 raise TypeError("All items in 'ignore_error_codes' must be of type 'int'")
53
54 if raise_exception_on_error is True and warn_on_error is True:
55 raise ValueError("'raise_exception_on_error' and 'warn_on_error' can not be both True")
56
57 self._use_project = use_project
58 self._ph = None
59 self._raise_on_error = raise_exception_on_error
60 self._warn_on_error = warn_on_error
61 self._ignore_error_codes = ignore_error_codes
62 self._last_error_code = 0
63 self._last_error_desc = None
64
[docs]
65 def set_error_handling(self, raise_exception_on_error: bool, warn_on_error: bool,
66 ignore_error_codes: list[int] = []) -> None:
67 """
68 Specifies the behavior in the case of an error/warning --
69 i.e. should an exception or warning be raised or not?
70
71 Parameters
72 ----------
73 raise_exception_on_error : `bool`
74 True if an exception should be raised, False otherwise.
75 warn_on_error : `bool`
76 True if a warning should be generated, False otherwise.
77 ignore_error_codes : `list[int]`
78 List of error codes that should be ignored -- i.e., no exception or
79 warning will be generated.
80 """
81 self._raise_on_error = raise_exception_on_error
82 self._warn_on_error = warn_on_error
83 self._ignore_error_codes = ignore_error_codes
84
[docs]
85 def get_last_error_desc(self) -> str:
86 """
87 Returns the description of the last EPANET-(MSX) error/warning (if any).
88
89 Returns
90 -------
91 `str`
92 Description of the last error/warning. None, if there was no error/warning.
93 """
94 return self._last_error_desc
95
[docs]
96 def get_last_error_code(self) -> int:
97 """
98 Returns the code of the last EPANET-(MSX) error/warnning (if any).
99
100 Refer to the `EPANET documentation <http://wateranalytics.org/EPANET/group___warning_codes.html>`_
101 for a list of all possible warning codes and their meanings.
102
103 Returns
104 -------
105 `int`
106 Code of the last error/warning. 0, if there was no error/warning.
107 """
108 return self._last_error_code
109
[docs]
110 def was_last_func_successful(self) -> bool:
111 """
112 Checks if the last EPANET call was successful or not.
113
114 Parameters
115 ----------
116 `bool`
117 True if the last EPANET call returned an error/warning, False otherwise.
118 """
119 return self._last_error_desc is None
120
121 def _reset_error(self) -> None:
122 self._last_error_code = 0
123 self._last_error_desc = None
124
125 def _process_result(self, ret: tuple, msx_call: bool = False) -> Any:
126 ret_other = None
127 if len(ret) == 1:
128 errcode = ret[0]
129 else:
130 errcode, *ret_other = ret
131
132 if errcode != 0:
133 self._last_error_code = errcode
134 if msx_call is False:
135 self._last_error_desc = self.geterror(errcode)
136 else:
137 self._last_error_desc = self.MSXgeterror(errcode)
138
139 if self._last_error_code not in self._ignore_error_codes:
140 if self._warn_on_error:
141 warnings.warn(self._last_error_desc, RuntimeWarning)
142 if self._raise_on_error:
143 raise RuntimeError(self._last_error_desc)
144
145 if ret_other is not None and len(ret_other) == 1:
146 return ret_other[0]
147 else:
148 return ret_other
149
150 @property
151 def use_project(self) -> bool:
152 """
153 Returns whether EPANET projects are used or not.
154
155 Returns
156 -------
157 `bool`
158 True, if EPANET projects are used, False otherwise.
159 """
160 return self._use_project
161
162 @property
163 def ph(self) -> int:
164 """
165 Returns a pointer (memory address) to the project structure.
166
167 Returns
168 -------
169 `int`
170 Pointer to project structure -- please do not change or access the memory location!
171 """
172 return self._ph
173
[docs]
174 def openfrombuffer(self, inpBuffer: str, inpFile: str, rptFile: str, outFile: str) -> int:
175 """
176 EN_openfrombuffer -- extension of EPANET and part of EPANET-PLUS
177
178 Parameters
179 ----------
180 inpBuffer : `str`
181 inpFile : `str`
182 rptFile : `str`
183 outFile : `str`
184
185 Returns
186 -------
187 int
188 Error code returned by ENopenfrombuffer / EN_openfrombuffer.
189 The underlying C function returns a tuple containing a single
190 integer (the error code), which `_process_result` unwraps and
191 returns as a plain int.
192 """
193 if self._use_project is False:
194 return self._process_result(epanet.ENopenfrombuffer(inpBuffer, inpFile, rptFile,
195 outFile))
196 else:
197 return self._process_result(epanet.EN_openfrombuffer(self._ph, inpBuffer, inpFile,
198 rptFile, outFile))
199
[docs]
200 def createproject(self) -> int:
201 """
202 EN_createproject
203
204 Returns
205 -------
206 int
207 The project handle created by EN_createproject.
208 The underlying C function returns a tuple (errcode, handle),
209 which `_process_result` unwraps and returns only the handle.
210 """
211 if self._use_project is False:
212 raise ValueError("Can not create project because of use_project=False")
213 else:
214 self._ph = self._process_result(epanet.EN_createproject())
215
[docs]
216 def deleteproject(self) -> None:
217 """
218 EN_deleteproject
219
220 Returns
221 -------
222 None
223 The underlying C function returns a tuple containing only the
224 error code (errcode,), which `_process_result` unwraps and
225 returns as None. Raises RuntimeError on failure.
226 """
227 if self._use_project is False:
228 raise ValueError("Can not delete project because of use_project=False")
229 else:
230 if self._ph is not None:
231 res = self._process_result(epanet.EN_deleteproject(self._ph))
232 self._ph = None
233
234 return res
235
[docs]
236 def init(self, rptFile: str, outFile: str, unitsType: int, headLossType: int) -> None:
237 """
238 EN_init
239
240 Parameters
241 ----------
242 rptFile : `str`
243 outFile : `str`
244 unitsType : `int`
245 headLossType : `int`
246
247 Returns
248 -------
249 None
250 The underlying C function returns a tuple containing only the
251 error code (errcode,), which `_process_result` unwraps and
252 returns as None. Errors trigger warnings or exceptions depending
253 on configuration.
254 """
255 if self._use_project is False:
256 return self._process_result(epanet.ENinit(rptFile, outFile, unitsType, headLossType))
257 else:
258 return self._process_result(epanet.EN_init(self._ph, rptFile, outFile, unitsType,
259 headLossType))
260
[docs]
261 def open(self, inpFile: str, rptFile: str, outFile: str)-> None:
262 """
263 EN_open
264
265 Parameters
266 ----------
267 inpFile : `str`
268 rptFile : `str`
269 outFile : `str`
270
271 Returns
272 -------
273 None
274 The underlying C function returns a tuple containing only the
275 error code (errcode,), which `_process_result` unwraps and
276 returns as None. Errors trigger warnings or exceptions depending
277 on configuration.
278 """
279 if self._use_project is False:
280 return self._process_result(epanet.ENopen(inpFile, rptFile, outFile))
281 else:
282 return self._process_result(epanet.EN_open(self._ph, inpFile, rptFile, outFile))
283
[docs]
284 def openX(self, inpFile: str, rptFile: str, outFile: str) -> None:
285 """
286 EN_openX
287
288 Parameters
289 ----------
290 inpFile : `str`
291 rptFile : `str`
292 outFile : `str`
293
294 Returns
295 -------
296 None
297 The underlying C function returns a tuple containing only the
298 error code (errcode,), which `_process_result` unwraps and
299 returns as None. Errors trigger warnings or exceptions depending
300 on configuration.
301 """
302 if self._use_project is False:
303 return self._process_result(epanet.ENopenX(inpFile, rptFile, outFile))
304 else:
305 return self._process_result(epanet.EN_openX(self._ph, inpFile, rptFile, outFile))
306
[docs]
307 def gettitle(self) -> list[str]:
308 """
309 EN_gettitle
310
311 Returns
312 -------
313 list[str]
314 A list containing the three title lines of the EPANET project.
315 The underlying C function returns a tuple (errcode, line1, line2, line3),
316 which `_process_result` unwraps and returns as a list of three strings.
317 """
318 if self._use_project is False:
319 return self._process_result(epanet.ENgettitle())
320 else:
321 return self._process_result(epanet.EN_gettitle(self._ph))
322
[docs]
323 def settitle(self, line1: str, line2: str, line3: str) -> None:
324 """
325 EN_settitle
326
327 Parameters
328 ----------
329 line1: str
330 line2: str
331 line3: str
332
333 Returns
334 -------
335 None
336 The underlying C function returns a tuple containing only the
337 error code (errcode,), which `_process_result` unwraps and
338 returns as None. Errors trigger warnings or exceptions depending
339 on configuration.
340 """
341 if self._use_project is False:
342 return self._process_result(epanet.ENsettitle(line1, line2, line3))
343 else:
344 return self._process_result(epanet.EN_settitle(self._ph, line1, line2, line3))
345
366
389
[docs]
390 def getcount(self, obj: int) -> int:
391 """
392 EN_getcount
393
394 Parameters
395 ----------
396 obj : `int`
397
398 Returns
399 -------
400 int
401 The number of the objects of the given type. The underlying C
402 function returns a tuple (errcode, count), which `_process_result`
403 unwraps and returns as a plain integer
404 """
405 if self._use_project is False:
406 return self._process_result(epanet.ENgetcount(obj))
407 else:
408 return self._process_result(epanet.EN_getcount(self._ph, obj))
409
[docs]
410 def saveinpfile(self, filename: str) -> None:
411 """
412 EN_saveinpfile
413
414 Parameters
415 ----------
416 filename : `str`
417
418 Returns
419 -------
420 None
421 The underlying C function returns a tuple containing only the
422 error code (errcode,), which `_process_result` unwraps and
423 returns as None. Errors trigger warnings or exceptions depending
424 on configuration.
425 """
426 if self._use_project is False:
427 return self._process_result(epanet.ENsaveinpfile(filename))
428 else:
429 return self._process_result(epanet.EN_saveinpfile(self._ph, filename))
430
[docs]
431 def close(self) -> None:
432 """
433 EN_close
434
435 Returns
436 -------
437 None
438 The underlying C function returns a tuple containing only the
439 error code (errcode,), which `_process_result` unwraps and
440 returns as None. Errors trigger warnings or exceptions depending
441 on configuration.
442 """
443 if self._use_project is False:
444 return self._process_result(epanet.ENclose())
445 else:
446 if self._ph is not None:
447 return self._process_result(epanet.EN_close(self._ph))
448
[docs]
449 def solveH(self) -> None:
450 """
451 EN_solveH
452
453 Returns
454 -------
455 None
456 The underlying C function returns a tuple containing only the
457 error code (errcode,), which `_process_result` unwraps and
458 returns as None. Errors trigger warnings or exceptions depending
459 on configuration.
460 """
461 if self._use_project is False:
462 return self._process_result(epanet.ENsolveH())
463 else:
464 return self._process_result(epanet.EN_solveH(self._ph))
465
[docs]
466 def usehydfile(self, filename: str) -> None:
467 """
468 EN_usehydfile
469
470 Parameters
471 ----------
472 filename : `str`
473
474 Returns
475 -------
476 None
477 The underlying C function returns a tuple containing only the
478 error code (errcode,), which `_process_result` unwraps and
479 returns as None. Errors trigger warnings or exceptions depending
480 on configuration.
481 """
482 if self._use_project is False:
483 return self._process_result(epanet.ENusehydfile(filename))
484 else:
485 return self._process_result(epanet.EN_usehydfile(filename))
486
[docs]
487 def openH(self) -> None:
488 """
489 EN_openH
490
491 Returns
492 -------
493 None
494 The underlying C function returns a tuple containing only the
495 error code (errcode,), which `_process_result` unwraps and
496 returns as None. Errors trigger warnings or exceptions depending
497 on configuration.
498 """
499 if self._use_project is False:
500 return self._process_result(epanet.ENopenH())
501 else:
502 return self._process_result(epanet.EN_openH(self._ph))
503
[docs]
504 def initH(self, initFlag: int) -> None:
505 """
506 EN_initH
507
508 Parameters
509 ----------
510 initFlag : `int`
511
512 Returns
513 -------
514 None
515 The underlying C function returns a tuple containing only the
516 error code (errcode,), which `_process_result` unwraps and
517 returns as None. Errors trigger warnings or exceptions depending
518 on configuration.
519 """
520 if self._use_project is False:
521 return self._process_result(epanet.ENinitH(initFlag))
522 else:
523 return self._process_result(epanet.EN_initH(self._ph, initFlag))
524
[docs]
525 def runH(self) -> int:
526 """
527 EN_runH
528
529 Returns
530 -------
531 int
532 The current simulation time (in seconds). The underlying C
533 function returns a tuple (errcode, currentTime), which
534 `_process_result` unwraps and returns as a plain integer.
535 """
536 if self._use_project is False:
537 return self._process_result(epanet.ENrunH())
538 else:
539 return self._process_result(epanet.EN_runH(self._ph))
540
[docs]
541 def nextH(self) -> int:
542 """
543 EN_nextH
544
545 Returns
546 -------
547 int
548 The next hydraulic time step (in seconds). The underlying C
549 function returns a tuple (errcode, tStep), which `_process_result`
550 unwraps and returns as a plain integer.
551 """
552 if self._use_project is False:
553 return self._process_result(epanet.ENnextH())
554 else:
555 return self._process_result(epanet.EN_nextH(self._ph))
556
[docs]
557 def saveH(self) -> None:
558 """
559 EN_saveH
560
561 Returns
562 -------
563 None
564 The underlying C function returns a tuple containing only the
565 error code (errcode,), which `_process_result` unwraps and
566 returns as None. Errors trigger warnings or exceptions depending
567 on configuration.
568 """
569 if self._use_project is False:
570 return self._process_result(epanet.ENsaveH())
571 else:
572 return self._process_result(epanet.EN_saveH(self._ph))
573
[docs]
574 def savehydfile(self, filename) -> None:
575 """
576 EN_savehydfile
577
578 Parameters
579 ----------
580 filename : `str`
581
582 Returns
583 -------
584 None
585 The underlying C function returns a tuple containing only the
586 error code (errcode,), which `_process_result` unwraps and
587 returns as None. Errors trigger warnings or exceptions depending
588 on configuration.
589 """
590 if self._use_project is False:
591 return self._process_result(epanet.ENsavehydfile(filename))
592 else:
593 return self._process_result(epanet.EN_savehydfile(self._ph, filename))
594
[docs]
595 def closeH(self) -> None:
596 """
597 EN_closeH
598
599 Returns
600 -------
601 None
602 The underlying C function returns a tuple containing only the
603 error code (errcode,), which `_process_result` unwraps and
604 returns as None. Errors trigger warnings or exceptions depending
605 on configuration.
606 """
607 if self._use_project is False:
608 return self._process_result(epanet.ENcloseH())
609 else:
610 return self._process_result(epanet.EN_closeH(self._ph))
611
[docs]
612 def solveQ(self) -> None:
613 """
614 EN_solveQ
615
616 Returns
617 -------
618 None
619 The underlying C function returns a tuple containing only the
620 error code (errcode,), which `_process_result` unwraps and
621 returns as None. Errors trigger warnings or exceptions depending
622 on configuration.
623 """
624 if self._use_project is False:
625 return self._process_result(epanet.ENsolveQ())
626 else:
627 return self._process_result(epanet.EN_solveQ(self._ph))
628
[docs]
629 def openQ(self) -> None:
630 """
631 EN_openQ
632
633 Returns
634 -------
635 None
636 The underlying C function returns a tuple containing only the
637 error code (errcode,), which `_process_result` unwraps and
638 returns as None. Errors trigger warnings or exceptions depending
639 on configuration.
640 """
641 if self._use_project is False:
642 return self._process_result(epanet.ENopenQ())
643 else:
644 return self._process_result(epanet.EN_openQ(self._ph))
645
[docs]
646 def initQ(self, save_flag: int) -> None:
647 """
648 EN_initQ
649
650 Parameters
651 ----------
652 save_flag : `int`
653
654 Returns
655 -------
656 None
657 The underlying C function returns a tuple containing only the
658 error code (errcode,), which `_process_result` unwraps and
659 returns as None. Errors trigger warnings or exceptions depending
660 on configuration.
661 """
662 if self._use_project is False:
663 return self._process_result(epanet.ENinitQ(save_flag))
664 else:
665 return self._process_result(epanet.EN_initQ(self._ph, save_flag))
666
[docs]
667 def runQ(self) -> int:
668 """
669 EN_runQ
670
671 Returns
672 -------
673 int
674 The current water quality simulation time (in seconds). The
675 underlying C funtion returns a tuple (errcode, currentTime),
676 which `_process_result` unwraps and returns as a plain integer.
677 """
678 if self._use_project is False:
679 return self._process_result(epanet.ENrunQ())
680 else:
681 return self._process_result(epanet.EN_runQ(self._ph))
682
[docs]
683 def nextQ(self) -> int:
684 """
685 EN_nextQ
686
687 Returns
688 -------
689 int
690 The next water quality simulation time (in seconds). The
691 underlying C funtion returns a tuple (errcode, currentTime),
692 which `_process_result` unwraps and returns as a plain integer.
693 """
694 if self._use_project is False:
695 return self._process_result(epanet.ENnextQ())
696 else:
697 return self._process_result(epanet.EN_nextQ(self._ph))
698
[docs]
699 def stepQ(self) -> int:
700 """
701 EN_stepQ
702
703 Returns
704 -------
705 int
706 The remaining water quality simulation time (in seconds). The
707 underlying C funtion returns a tuple (errcode, currentTime),
708 which `_process_result` unwraps and returns as a plain integer.
709 """
710 if self._use_project is False:
711 return self._process_result(epanet.ENstepQ())
712 else:
713 return self._process_result(epanet.EN_stepQ(self._ph))
714
[docs]
715 def closeQ(self) -> None:
716 """
717 EN_closeQ
718
719 Returns
720 -------
721 None
722 The underlying C function returns a tuple containing only the
723 error code (errcode,), which `_process_result` unwraps and
724 returns as None. Errors trigger warnings or exceptions depending
725 on configuration.
726 """
727 if self._use_project is False:
728 return self._process_result(epanet.ENcloseQ())
729 else:
730 return self._process_result(epanet.EN_closeQ(self._ph))
731
[docs]
732 def writeline(self, line: str) -> None:
733 """
734 EN_writeline
735
736 Parameters
737 ----------
738 line : `str`
739
740 Returns
741 -------
742 None
743 The underlying C function returns a tuple containing only the
744 error code (errcode,), which `_process_result` unwraps and
745 returns as None. Errors trigger warnings or exceptions depending
746 on configuration.
747 """
748 if self._use_project is False:
749 return self._process_result(epanet.ENwriteline(line))
750 else:
751 return self._process_result(epanet.EN_writeline(self._ph, line))
752
[docs]
753 def report(self) -> None:
754 """
755 EN_report
756
757 Returns
758 -------
759 None
760 The underlying C function returns a tuple containing only the
761 error code (errcode,), which `_process_result` unwraps and
762 returns as None. Errors trigger warnings or exceptions depending
763 on configuration.
764 """
765 if self._use_project is False:
766 return self._process_result(epanet.ENreport())
767 else:
768 return self._process_result(epanet.EN_report(self._ph))
769
[docs]
770 def copyreport(self) -> None:
771 """
772 EN_copyreport
773
774 Returns
775 -------
776 None
777 The underlying C function returns a tuple containing only the
778 error code (errcode,), which `_process_result` unwraps and
779 returns as None. Errors trigger warnings or exceptions depending
780 on configuration.
781 """
782 if self._use_project is False:
783 return self._process_result(epanet.ENcopyreport())
784 else:
785 return self._process_result(epanet.EN_copyreport(self._ph))
786
[docs]
787 def clearreport(self) -> None:
788 """
789 EN_clearreport
790
791 Returns
792 -------
793 None
794 The underlying C function returns a tuple containing only the
795 error code (errcode,), which `_process_result` unwraps and
796 returns as None. Errors trigger warnings or exceptions depending
797 on configuration.
798 """
799 if self._use_project is False:
800 return self._process_result(epanet.ENclearreport())
801 else:
802 return self._process_result(epanet.EN_clearreport(self._ph))
803
[docs]
804 def resetreport(self) -> None:
805 """
806 EN_resetreport
807
808 Returns
809 -------
810 None
811 The underlying C function returns a tuple containing only the
812 error code (errcode,), which `_process_result` unwraps and
813 returns as None. Errors trigger warnings or exceptions depending
814 on configuration.
815 """
816 if self._use_project is False:
817 return self._process_result(epanet.ENresetreport())
818 else:
819 return self._process_result(epanet.EN_resetreport(self._ph))
820
[docs]
821 def setreport(self, format_desc: str) -> None:
822 """
823 EN_setreport
824
825 Parameters
826 ----------
827 format_desc : `str`
828
829 Returns
830 -------
831 None
832 The underlying C function returns a tuple containing only the
833 error code (errcode,), which `_process_result` unwraps and
834 returns as None. Errors trigger warnings or exceptions depending
835 on configuration.
836 """
837 if self._use_project is False:
838 return self._process_result(epanet.ENsetreport(format_desc))
839 else:
840 return self._process_result(epanet.EN_setreport(self._ph, format_desc))
841
[docs]
842 def setstatusreport(self, level: int) -> None:
843 """
844 EN_setstatusreport
845
846 Parameters
847 ----------
848 level : `int`
849
850 Returns
851 -------
852 None
853 The underlying C function returns a tuple containing only the
854 error code (errcode,), which `_process_result` unwraps and
855 returns as None. Errors trigger warnings or exceptions depending
856 on configuration.
857 """
858 if self._use_project is False:
859 return self._process_result(epanet.ENsetstatusreport(level))
860 else:
861 return self._process_result(epanet.EN_setstatusreport(self._ph, level))
862
[docs]
863 def getversion(self) -> int:
864 """
865 EN_getversion
866
867 Returns
868 -------
869 int
870 The EPANET version number. The underlying C function returns a
871 tuple (errcode, version), which `_process_result` unwraps and
872 returns as a plain integer.
873 """
874 if self._use_project is False:
875 return self._process_result(epanet.ENgetversion())
876 else:
877 return self._process_result(epanet.EN_getversion())
878
[docs]
879 def geterror(self, error_code: int) -> str:
880 """
881 EN_geterror
882
883 Parameters
884 ----------
885 error_code : `int`
886
887 Returns
888 -------
889 str
890 The descriptive error message associated with the given error
891 code. The underlying C function returns a tuple (errcode, errmsg).
892 If retrieving the message fails, a RuntimeError is raised.
893 """
894 if self._use_project is False:
895 err, err_msg = epanet.ENgeterror(error_code)
896 else:
897 err, err_msg = epanet.EN_geterror(error_code)
898
899 if err != 0:
900 raise RuntimeError("Failed to get error message")
901
902 return err_msg
903
[docs]
904 def getstatistic(self, stat_type: int) -> float:
905 """
906 EN_getstatistic
907
908 Parameters
909 ----------
910 stat_type : `int`
911
912 Returns
913 -------
914 float
915 The requested project statistic. The underlying C function
916 returns a tuple (errcode, value), which `_process_result`
917 unwraps and returns as a plain float.
918 """
919 if self._use_project is False:
920 return self._process_result(epanet.ENgetstatistic(stat_type))
921 else:
922 return self._process_result(epanet.EN_getstatistic(self._ph, stat_type))
923
[docs]
924 def getresultindex(self, result_type: int, index: int) -> int:
925 """
926 EN_getresultindex
927
928 Parameters
929 ----------
930 result_type : `int`
931 index : `int`
932
933 Returns
934 -------
935 int
936 The index of the requested result variable. The underlying C
937 function returns a tuple (errcode, value), which `process_result`
938 unwraps and returns as a plain integer.
939 """
940 if self._use_project is False:
941 return self._process_result(epanet.ENgetresultindex(result_type, index))
942 else:
943 return self._process_result(epanet.EN_getresultindex(self._ph, result_type, index))
944
[docs]
945 def getoption(self, option: int) -> float:
946 """
947 EN_getoption
948
949 Parameters
950 ----------
951 option : `int`
952
953 Returns
954 -------
955 float
956 The value of the specfied analysis option. The underlying C
957 function returns a tuple (errcode, value), which `_process_result`
958 unwraps and returns as a plain float.
959 """
960 if self._use_project is False:
961 return self._process_result(epanet.ENgetoption(option))
962 else:
963 return self._process_result(epanet.EN_getoption(self._ph, option))
964
[docs]
965 def setoption(self, option: int, value: float)-> None:
966 """
967 EN_setoption
968
969 Parameters
970 ----------
971 option : `int`
972 value : `float`
973
974 Returns
975 -------
976 None
977 The underlying C function returns a tuple containing only the
978 error code (errcode,), which `_process_result` unwraps and
979 returns as None. Errors trigger warnings or exceptions depending
980 on configuration.
981 """
982 if self._use_project is False:
983 return self._process_result(epanet.ENsetoption(option, value))
984 else:
985 return self._process_result(epanet.EN_setoption(self._ph, option, value))
986
[docs]
987 def getflowunits(self) -> int:
988 """
989 EN_getflowunits
990
991 Returns
992 -------
993 int
994 The flow units used in the project. The underlying C function
995 returns a tuple (errcode, units), which `_process_results` unwraps
996 and returns as a plain integer.
997 """
998 if self._use_project is False:
999 return self._process_result(epanet.ENgetflowunits())
1000 else:
1001 return self._process_result(epanet.EN_getflowunits(self._ph))
1002
[docs]
1003 def setflowunits(self, units: int) -> None:
1004 """
1005 EN_setflowunits
1006
1007 Parameters
1008 ----------
1009 units : `int`
1010
1011 Returns
1012 -------
1013 None
1014 The underlying C function returns a tuple containing only the
1015 error code (errcode,), which `_process_result` unwraps and
1016 returns as None. Errors trigger warnings or exceptions depending
1017 on configuration.
1018 """
1019 if self._use_project is False:
1020 return self._process_result(epanet.ENsetflowunits(units))
1021 else:
1022 return self._process_result(epanet.EN_setflowunits(self._ph, units))
1023
[docs]
1024 def gettimeparam(self, param: int) -> int:
1025 """
1026 EN_gettimeparam
1027
1028 Parameters
1029 ----------
1030 param : `int`
1031
1032 Returns
1033 -------
1034 int
1035 The requested time parameter (in seconds). The underlying C
1036 function returns a tuple (errcode, value), which `_process_result`
1037 unwraps and retruns as a plain integer.
1038 """
1039 if self._use_project is False:
1040 return self._process_result(epanet.ENgettimeparam(param))
1041 else:
1042 return self._process_result(epanet.EN_gettimeparam(self._ph, param))
1043
[docs]
1044 def settimeparam(self, param: int, value: int) -> None:
1045 """
1046 EN_settimeparam
1047
1048 Parameters
1049 ----------
1050 param : `int`
1051 value : `int`
1052
1053 Returns
1054 -------
1055 None
1056 The underlying C function returns a tuple containing only the
1057 error code (errcode,), which `_process_result` unwraps and
1058 returns as None. Errors trigger warnings or exceptions depending
1059 on configuration.
1060 """
1061 if self._use_project is False:
1062 return self._process_result(epanet.ENsettimeparam(param, value))
1063 else:
1064 return self._process_result(epanet.EN_settimeparam(self._ph, param, value))
1065
[docs]
1066 def getqualinfo(self)-> list:
1067 """
1068 EN_getqualinfo
1069
1070 Returns
1071 -------
1072 list
1073 A list containing: [qualType, chemName, chemUnits, traceNode].
1074 The underlying C function returns a tuple
1075 (errcode, qualType, chemName, chemUnits, traceNode), which
1076 `_process_result` unwraps and returns as a list of these values.
1077 """
1078 if self._use_project is False:
1079 return self._process_result(epanet.ENgetqualinfo())
1080 else:
1081 return self._process_result(epanet.EN_getqualinfo(self._ph))
1082
[docs]
1083 def getqualtype(self) -> list:
1084 """
1085 EN_getqualtype
1086
1087 Returns
1088 -------
1089 list
1090 A list containing: [qualType, traceNode].
1091 The underlying C function returns a tuple
1092 (errdcode, qualType, traceNode), which `_process_results` unwraps
1093 and returns a list of these values.
1094 """
1095 if self._use_project is False:
1096 return self._process_result(epanet.ENgetqualtype())
1097 else:
1098 return self._process_result(epanet.EN_getqualtype(self._ph))
1099
[docs]
1100 def setqualtype(self, qual_type: int, chem_name: str, chem_units: str, trace_node_id: str) -> None:
1101 """
1102 EN_setqualtype
1103
1104 Parameters
1105 ----------
1106 qual_type : `int`
1107 chem_name : `str`
1108 chem_units : `str`
1109 trace_node_id : `str`
1110
1111 Returns
1112 -------
1113 None
1114 The underlying C function returns a tuple containing only the
1115 error code (errcode,), which `_process_result` unwraps and
1116 returns as None. Errors trigger warnings or exceptions depending
1117 on configuration.
1118 """
1119 if self._use_project is False:
1120 return self._process_result(epanet.ENsetqualtype(qual_type, chem_name, chem_units,
1121 trace_node_id))
1122 else:
1123 return self._process_result(epanet.EN_setqualtype(self._ph, qual_type, chem_name,
1124 chem_units, trace_node_id))
1125
[docs]
1126 def addnode(self, node_id: str, node_type: int) -> int:
1127 """
1128 EN_addnode
1129
1130 Parameters
1131 ----------
1132 node_id : `str`
1133 node_type : `int`
1134
1135 Returns
1136 -------
1137 int
1138 The index of the newly added node. The underlying C function
1139 returns a tupel (errcode, index), which `_process_result` unwraps
1140 and returns as a plain integer.
1141 """
1142 if self._use_project is False:
1143 return self._process_result(epanet.ENaddnode(node_id, node_type))
1144 else:
1145 return self._process_result(epanet.EN_addnode(self._ph, node_id, node_type))
1146
[docs]
1147 def deletenode(self, index: int, action_code: int) -> None:
1148 """
1149 EN_deletenode
1150
1151 Parameters
1152 ----------
1153 index : `int`
1154 action_code : `int`
1155
1156 Returns
1157 -------
1158 None
1159 The underlying C function returns a tuple containing only the
1160 error code (errcode,), which `_process_result` unwraps and
1161 returns as None. Errors trigger warnings or exceptions depending
1162 on configuration.
1163 """
1164 if self._use_project is False:
1165 return self._process_result(epanet.ENdeletenode(index, action_code))
1166 else:
1167 return self._process_result(epanet.EN_deletenode(self._ph, index, action_code))
1168
[docs]
1169 def getnodeindex(self, node_id: str) -> int:
1170 """
1171 EN_getnodeindex
1172
1173 Parameters
1174 ----------
1175 node_id : `str`
1176
1177 Returns
1178 -------
1179 int
1180 The index of the node with the given ID. The underlying C
1181 function returns a tuple (errcode, index), which
1182 `_process_result` unwraps and returns as a plain integer.
1183 """
1184 if self._use_project is False:
1185 return self._process_result(epanet.ENgetnodeindex(node_id))
1186 else:
1187 return self._process_result(epanet.EN_getnodeindex(self._ph, node_id))
1188
[docs]
1189 def getnodeid(self, index: int) -> str:
1190 """
1191 EN_getnodeid
1192
1193 Parameters
1194 ----------
1195 index : `int`
1196
1197 Returns
1198 -------
1199 str
1200 The ID of the node at the given index. The underlying C function
1201 returns a tuple (errcode, id), which `_process_result`
1202 unwraps and returns as a plain string.
1203 """
1204 if self._use_project is False:
1205 return self._process_result(epanet.ENgetnodeid(index))
1206 else:
1207 return self._process_result(epanet.EN_getnodeid(self._ph, index))
1208
[docs]
1209 def setnodeid(self, index: int, new_id: str) -> None:
1210 """
1211 EN_setnodeid
1212
1213 Parameters
1214 ----------
1215 index : `int`
1216 new_id : `str`
1217
1218 Returns
1219 -------
1220 None
1221 The underlying C function returns a tuple containing only the
1222 error code (errcode,), which `_process_result` unwraps and
1223 returns as None. Errors trigger warnings or exceptions depending
1224 on configuration.
1225 """
1226 if self._use_project is False:
1227 return self._process_result(epanet.ENsetnodeid(index, new_id))
1228 else:
1229 return self._process_result(epanet.EN_setnodeid(self._ph, index, new_id))
1230
[docs]
1231 def getnodetype(self, index: int) -> int:
1232 """
1233 EN_getnodetype
1234
1235 Parameters
1236 ----------
1237 index : `int`
1238
1239 Returns
1240 -------
1241 int
1242 The type of the node at the given index. The underlying C
1243 function returns a tuple (errcode, nodeType), which
1244 `_process_result` unwraps and returns as a plain integer.
1245 """
1246 if self._use_project is False:
1247 return self._process_result(epanet.ENgetnodetype(index))
1248 else:
1249 return self._process_result(epanet.EN_getnodetype(self._ph, index))
1250
[docs]
1251 def getnodevalue(self, index: int, node_property: int) -> float:
1252 """
1253 EN_getnodevalue
1254
1255 Parameters
1256 ----------
1257 index : `int`
1258 node_property : `int`
1259
1260 Returns
1261 -------
1262 float
1263 The value of the specified node property. The underlying C
1264 function returns a tuple (errcode, value), which
1265 `_process_result` unwraps and returns as a plain float.
1266 """
1267 if self._use_project is False:
1268 return self._process_result(epanet.ENgetnodevalue(index, node_property))
1269 else:
1270 return self._process_result(epanet.EN_getnodevalue(self._ph, index, node_property))
1271
[docs]
1272 def setnodevalue(self, index: int, node_property: int, value: float) -> None:
1273 """
1274 EN_setnodevalue
1275
1276 Parameters
1277 ----------
1278 index : `int`
1279 node_property : `int`
1280 value : `float`
1281
1282 Returns
1283 -------
1284 None
1285 The underlying C function returns a tuple containing only the
1286 error code (errcode,), which `_process_result` unwraps and
1287 returns as None. Errors trigger warnings or exceptions depending
1288 on configuration.
1289 """
1290 if self._use_project is False:
1291 return self._process_result(epanet.ENsetnodevalue(index, node_property, value))
1292 else:
1293 return self._process_result(epanet.EN_setnodevalue(self._ph, index, node_property,
1294 value))
1295
[docs]
1296 def setnodevalues(self, node_property: int, values: list[float]) -> None:
1297 """
1298 EN_setnodevalues
1299
1300 Parameters
1301 ----------
1302 node_property : `int`
1303 values : `list[float]`
1304
1305 Returns
1306 -------
1307 None
1308 The underlying C function returns a tuple containing only the
1309 error code (errcode,), which `_process_result` unwraps and
1310 returns as None. Errors trigger warnings or exceptions depending
1311 on configuration.
1312 """
1313 if self._use_project is False:
1314 return self._process_result(epanet.ENsetnodevalues(node_property, values))
1315 else:
1316 return self._process_result(epanet.EN_setnodevalues(self._ph, node_property, values))
1317
[docs]
1318 def setjuncdata(self, index: int, elev: float, dmnd: float, dmnd_pat: str) -> None:
1319 """
1320 EN_setjuncdata
1321
1322 Parameters
1323 ----------
1324 index : `int`
1325 elev : `float`
1326 dmnd : `float`
1327 dmdn_pat : `float`
1328
1329 Returns
1330 -------
1331 None
1332 The underlying C function returns a tuple containing only the
1333 error code (errcode,), which `_process_result` unwraps and
1334 returns as None. Errors trigger warnings or exceptions depending
1335 on configuration.
1336 """
1337 if self._use_project is False:
1338 return self._process_result(epanet.ENsetjuncdata(index, elev, dmnd, dmnd_pat))
1339 else:
1340 return self._process_result(epanet.EN_setjuncdata(self._ph, index, elev, dmnd,
1341 dmnd_pat))
1342
[docs]
1343 def settankdata(self, index: int, elev: float, initlvl: float, minlvl: float, maxlvl: float,
1344 diam: float, minvol: float, volcurve: str) -> None:
1345 """
1346 EN_settankdata
1347
1348 Parameters
1349 ----------
1350 index : `int`
1351 elev : `float`
1352 initlvl : `float`
1353 minlvl : `float`
1354 maxlvl : `float`
1355 diam : `float`
1356 minvol : `float`
1357 volcurve : `str`
1358
1359 Returns
1360 -------
1361 None
1362 The underlying C function returns a tuple containing only the
1363 error code (errcode,), which `_process_result` unwraps and
1364 returns as None. Errors trigger warnings or exceptions depending
1365 on configuration.
1366 """
1367 if self._use_project is False:
1368 return self._process_result(epanet.ENsettankdata(index, elev, initlvl, minlvl, maxlvl,
1369 diam, minvol, volcurve))
1370 else:
1371 return self._process_result(epanet.EN_settankdata(self._ph, index, elev, initlvl,
1372 minlvl, maxlvl, diam, minvol,
1373 volcurve))
1374
[docs]
1375 def getcoord(self, index: int) -> list:
1376 """
1377 EN_getcoord
1378
1379 Parameters
1380 ----------
1381 index : `int`
1382
1383 Returns
1384 -------
1385 list
1386 A list containing the x- and y-coordinates of the node: [x, y].
1387 The underlying C function returns a tuple (errcode, x, y),
1388 which `_process_result` unwraps and returns as a list of two floats.
1389 """
1390 if self._use_project is False:
1391 return self._process_result(epanet.ENgetcoord(index))
1392 else:
1393 return self._process_result(epanet.EN_getcoord(self._ph, index))
1394
[docs]
1395 def setcoord(self, index: int, x: float, y: float) -> None:
1396 """
1397 EN_setcoord
1398
1399 Parameters
1400 ----------
1401 index : `int`
1402 x : `float`
1403 y : `float`
1404
1405 Returns
1406 -------
1407 None
1408 The underlying C function returns a tuple containing only the
1409 error code (errcode,), which `_process_result` unwraps and
1410 returns as None. Errors trigger warnings or exceptions depending
1411 on configuration.
1412 """
1413 if self._use_project is False:
1414 return self._process_result(epanet.ENsetcoord(index, x, y))
1415 else:
1416 return self._process_result(epanet.EN_setcoord(self._ph, index, x, y))
1417
[docs]
1418 def getdemandmodel(self) -> list:
1419 """
1420 EN_getdemandmodel
1421
1422 Returns
1423 -------
1424 list
1425 A list containing the demand model parameters:
1426 [type, pmin, preq, pexp].
1427 The underlying C function returns a tuple
1428 (errcode, type, pmin, preq, pexp), which `_process_result`
1429 unwraps and returns as a list of these values.
1430 """
1431 if self._use_project is False:
1432 return self._process_result(epanet.ENgetdemandmodel())
1433 else:
1434 return self._process_result(epanet.EN_getdemandmodel(self._ph))
1435
[docs]
1436 def setdemandmodel(self, demand_type: int, pmin: float, preq: float, pexp: float) -> None:
1437 """
1438 EN_setdemandmodel
1439
1440 Parameters
1441 ----------
1442 demand_type : `int`
1443 pmin : `float`
1444 preq : `float`
1445 pexp : `float`
1446
1447 Returns
1448 -------
1449 None
1450 The underlying C function returns a tuple containing only the
1451 error code (errcode,), which `_process_result` unwraps and
1452 returns as None. Errors trigger warnings or exceptions depending
1453 on configuration.
1454 """
1455 if self._use_project is False:
1456 return self._process_result(epanet.ENsetdemandmodel(demand_type, pmin, preq, pexp))
1457 else:
1458 return self._process_result(epanet.EN_setdemandmodel(self._ph, demand_type,
1459 pmin, preq, pexp))
1460
[docs]
1461 def adddemand(self, node_index: int, base_demand: float, demand_pattern: str, demand_name: str) -> None:
1462 """
1463 EN_adddemand
1464
1465 node_index : `int`
1466 base_demand : `float`
1467 demand_pattern : `str`
1468 demand_name : `str`
1469
1470 Returns
1471 -------
1472 None
1473 The underlying C function returns a tuple containing only the
1474 error code (errcode,), which `_process_result` unwraps and
1475 returns as None. Errors trigger warnings or exceptions depending
1476 on configuration.
1477 """
1478 if self._use_project is False:
1479 return self._process_result(epanet.ENadddemand(node_index, base_demand, demand_pattern,
1480 demand_name))
1481 else:
1482 return self._process_result(epanet.EN_adddemand(self._ph, node_index, base_demand,
1483 demand_pattern, demand_name))
1484
[docs]
1485 def deletedemand(self, node_index: int, demand_index: int) -> None:
1486 """
1487 EN_deletedemand
1488
1489 Parameters
1490 ----------
1491 node_index : `int`
1492 demand_index : `int`
1493
1494 Returns
1495 -------
1496 None
1497 The underlying C function returns a tuple containing only the
1498 error code (errcode,), which `_process_result` unwraps and
1499 returns as None. Errors trigger warnings or exceptions depending
1500 on configuration.
1501 """
1502 if self._use_project is False:
1503 return self._process_result(epanet.ENdeletedemand(node_index, demand_index))
1504 else:
1505 return self._process_result(epanet.EN_deletedemand(self._ph, node_index, demand_index))
1506
[docs]
1507 def getdemandindex(self, node_index: int, demand_name: str) -> int:
1508 """
1509 EN_getdemandindex
1510
1511 Parameters
1512 ----------
1513 node_index : `int`
1514 demand_name : `str`
1515
1516 Returns
1517 -------
1518 int
1519 The index of the demand with the given name at the specified node.
1520 The underlying C function returns a tuple (errcode, demandIndex),
1521 which `_process_result` unwraps and returns as a plain integer.
1522 """
1523 if self._use_project is False:
1524 return self._process_result(epanet.ENgetdemandindex(node_index, demand_name))
1525 else:
1526 return self._process_result(epanet.EN_getdemandindex(self._ph, node_index, demand_name))
1527
[docs]
1528 def getnumdemands(self, node_index: int) -> int:
1529 """
1530 EN_getnumdemands
1531
1532 Parameters
1533 ----------
1534 node_index : `int`
1535
1536 Returns
1537 -------
1538 int
1539 The number of demands defined for the specified node. The
1540 underlying C function returns a tuple (errcode, numDemands),
1541 which `_process_result` unwraps and returns as a plain integer.
1542 """
1543 if self._use_project is False:
1544 return self._process_result(epanet.ENgetnumdemands(node_index))
1545 else:
1546 return self._process_result(epanet.EN_getnumdemands(self._ph, node_index))
1547
[docs]
1548 def getbasedemand(self, node_index: int, demand_index: int) -> float:
1549 """
1550 EN_getbasedemand
1551
1552 Parameters
1553 ----------
1554 node_index : `int`
1555 demand_index : `int`
1556
1557 Returns
1558 -------
1559 float
1560 The base demand value for the specified demand at the given node.
1561 The underlying C function returns a tuple (errcode, baseDemand),
1562 which `_process_result` unwraps and returns as a plain float.
1563 """
1564 if self._use_project is False:
1565 return self._process_result(epanet.ENgetbasedemand(node_index, demand_index))
1566 else:
1567 return self._process_result(epanet.EN_getbasedemand(self._ph, node_index, demand_index))
1568
[docs]
1569 def setbasedemand(self, node_index: int, demand_index: int, base_demand: float) -> None:
1570 """
1571 EN_setbasedemand
1572
1573 Parameters
1574 ----------
1575 node_index : `int`
1576 demand_index : `int`
1577 base_demand : `float`
1578
1579 Returns
1580 -------
1581 None
1582 The underlying C function returns a tuple containing only the
1583 error code (errcode,), which `_process_result` unwraps and
1584 returns as None. Errors trigger warnings or exceptions depending
1585 on configuration.
1586 """
1587 if self._use_project is False:
1588 return self._process_result(epanet.ENsetbasedemand(node_index, demand_index,
1589 base_demand))
1590 else:
1591 return self._process_result(epanet.EN_setbasedemand(self._ph, node_index, demand_index,
1592 base_demand))
1593
[docs]
1594 def getdemandpattern(self, node_index: int, demand_index: int) -> int:
1595 """
1596 EN_getdemandpattern
1597
1598 Parameters
1599 ----------
1600 node_index : `int`
1601 demand_index : `int`
1602
1603 Returns
1604 -------
1605 int
1606 The index of the demand pattern assigned to the specified demand.
1607 The underlying C function returns a tuple (errcode, patIndex),
1608 which `_process_result` unwraps and returns as a plain integer.
1609 """
1610 if self._use_project is False:
1611 return self._process_result(epanet.ENgetdemandpattern(node_index, demand_index))
1612 else:
1613 return self._process_result(epanet.EN_getdemandpattern(self._ph, node_index,
1614 demand_index))
1615
[docs]
1616 def setdemandpattern(self, node_index: int, demand_index: int, pat_index: int) -> None:
1617 """
1618 EN_setdemandpattern
1619
1620 Parameters
1621 ----------
1622 node_index : `int`
1623 demand_index : `int`
1624 pat_index : `int`
1625
1626 Returns
1627 -------
1628 None
1629 The underlying C function returns a tuple containing only the
1630 error code (errcode,), which `_process_result` unwraps and
1631 returns as None. Errors trigger warnings or exceptions depending
1632 on configuration.
1633 """
1634 if self._use_project is False:
1635 return self._process_result(epanet.ENsetdemandpattern(node_index, demand_index,
1636 pat_index))
1637 else:
1638 return self._process_result(epanet.EN_setdemandpattern(self._ph, node_index,
1639 demand_index, pat_index))
1640
[docs]
1641 def getdemandname(self, node_index: int, demand_index: int) -> str:
1642 """
1643 EN_getdemandname
1644
1645 Parameters
1646 ----------
1647 node_index : `int`
1648 demand_index : `int`
1649
1650 Returns
1651 -------
1652 str
1653 The name of the specified demand. The underlying C function
1654 returns a tuple (errcode, demandName), which `_process_result`
1655 unwraps and returns as a plain string.
1656 """
1657 if self._use_project is False:
1658 return self._process_result(epanet.ENgetdemandname(node_index, demand_index))
1659 else:
1660 return self._process_result(epanet.EN_getdemandname(self._ph, node_index, demand_index))
1661
[docs]
1662 def setdemandname(self, node_index: int, demand_index: int, demand_name: str) -> None:
1663 """
1664 EN_setdemandname
1665
1666 Parameters
1667 ----------
1668 node_index : `int`
1669 demand_index : `int`
1670 demand_name : `str`
1671
1672 Returns
1673 -------
1674 None
1675 The underlying C function returns a tuple containing only the
1676 error code (errcode,), which `_process_result` unwraps and
1677 returns as None. Errors trigger warnings or exceptions depending
1678 on configuration.
1679 """
1680 if self._use_project is False:
1681 return self._process_result(epanet.ENsetdemandname(node_index, demand_index,
1682 demand_name))
1683 else:
1684 return self._process_result(epanet.EN_setdemandname(self._ph, node_index, demand_index,
1685 demand_name))
1686
[docs]
1687 def addlink(self, id: str, link_type: int, from_node: str, to_node: str) -> int:
1688 """
1689 EN_addlink
1690
1691 Parameters
1692 ----------
1693 id : `str`
1694 link_type : `int`
1695 from_node : `str`
1696 to_node : `str`
1697
1698 Returns
1699 -------
1700 int
1701 The index of the newly added link. The underlying C function
1702 returns a tuple (errcode, index), which `_process_result`
1703 unwraps and returns as a plain integer.
1704 """
1705 if self._use_project is False:
1706 return self._process_result(epanet.ENaddlink(id, link_type, from_node, to_node))
1707 else:
1708 return self._process_result(epanet.EN_addlink(self._ph, id, link_type, from_node,
1709 to_node))
1710
[docs]
1711 def deletelink(self, index: int, action_code: int) -> None:
1712 """
1713 EN_deletelink
1714
1715 Parameters
1716 ----------
1717 index : `int`
1718 action_code : `int`
1719
1720 Returns
1721 -------
1722 None
1723 The underlying C function returns a tuple containing only the
1724 error code (errcode,), which `_process_result` unwraps and
1725 returns as None. Errors trigger warnings or exceptions depending
1726 on configuration.
1727 """
1728 if self._use_project is False:
1729 return self._process_result(epanet.ENdeletelink(index, action_code))
1730 else:
1731 return self._process_result(epanet.EN_deletelink(self._ph, index, action_code))
1732
[docs]
1733 def getlinkindex(self, link_id: str) -> int:
1734 """
1735 EN_getlinkindex
1736
1737 Parameters
1738 ----------
1739 link_id : `str`
1740
1741 Returns
1742 -------
1743 int
1744 The index of the link with the given ID. The underlying C
1745 function returns a tuple (errcode, index), which `_process_result`
1746 unwraps and returns as a plain integer.
1747 """
1748 if self._use_project is False:
1749 return self._process_result(epanet.ENgetlinkindex(link_id))
1750 else:
1751 return self._process_result(epanet.EN_getlinkindex(self._ph, link_id))
1752
[docs]
1753 def getlinkid(self, index: int) -> str:
1754 """
1755 EN_getlinkid
1756
1757 Parameters
1758 ----------
1759 index : `int`
1760
1761 Returns
1762 -------
1763 str
1764 The ID of the link at the given index. The underlying C function
1765 returns a tuple (errcode, id), which `_process_result` unwraps
1766 and returns as a plain string.
1767 """
1768 if self._use_project is False:
1769 return self._process_result(epanet.ENgetlinkid(index))
1770 else:
1771 return self._process_result(epanet.EN_getlinkid(self._ph, index))
1772
[docs]
1773 def setlinkid(self, index: int, new_id: str) -> None:
1774 """
1775 EN_setlinkid
1776
1777 Parameters
1778 ----------
1779 index : `int`
1780 new_id : `str`
1781
1782 Returns
1783 -------
1784 None
1785 The underlying C function returns a tuple containing only the
1786 error code (errcode,), which `_process_result` unwraps and
1787 returns as None. Errors trigger warnings or exceptions depending
1788 on configuration.
1789 """
1790 if self._use_project is False:
1791 return self._process_result(epanet.ENsetlinkid(index, new_id))
1792 else:
1793 return self._process_result(epanet.EN_setlinkid(self._ph, index, new_id))
1794
[docs]
1795 def getlinktype(self, index: int) -> int:
1796 """
1797 EN_getlinktype
1798
1799 Parameters
1800 ----------
1801 index : `int`
1802
1803 Returns
1804 -------
1805 int
1806 The type of the link at the given index. The underlying C
1807 function returns a tuple (errcode, linkType), which
1808 `_process_result` unwraps and returns as a plain integer.
1809 """
1810 if self._use_project is False:
1811 return self._process_result(epanet.ENgetlinktype(index))
1812 else:
1813 return self._process_result(epanet.EN_getlinktype(self._ph, index))
1814
[docs]
1815 def setlinktype(self, index: int, link_type: int, action_code: int) -> int:
1816 """
1817 EN_setlinktype
1818
1819 Parameters
1820 ----------
1821 index : `int`
1822 link_type : `int`
1823 action_code : `int`
1824
1825 Returns
1826 -------
1827 int
1828 The (possibly updated) link index. The underlying C function
1829 returns a tuple (errcode, input_index), which `_process_result`
1830 unwraps and returns as a plain integer.
1831 """
1832 if self._use_project is False:
1833 return self._process_result(epanet.ENsetlinktype(index, link_type, action_code))
1834 else:
1835 return self._process_result(epanet.EN_setlinktype(self._ph, index, link_type,
1836 action_code))
1837
[docs]
1838 def getlinknodes(self, index: int) -> list:
1839 """
1840 EN_getlinknodes
1841
1842 Parameters
1843 ----------
1844 index : `int`
1845
1846 Returns
1847 -------
1848 list
1849 A list containing the indices of the upstream and downstream nodes
1850 of the link: [node1, node2].
1851 The underlying C function returns a tuple (errcode, node1, node2),
1852 which `_process_result` unwraps and returns as a list of two integers.
1853 """
1854 if self._use_project is False:
1855 return self._process_result(epanet.ENgetlinknodes(index))
1856 else:
1857 return self._process_result(epanet.EN_getlinknodes(self._ph, index))
1858
[docs]
1859 def setlinknodes(self, index: int, node1: int, node2: int) -> None:
1860 """
1861 EN_setlinknodes
1862
1863 Parameters
1864 ----------
1865 index : `int`
1866 node1 : `int`
1867 node2 : `int`
1868
1869 Returns
1870 -------
1871 None
1872 The underlying C function returns a tuple containing only the
1873 error code (errcode,), which `_process_result` unwraps and
1874 returns as None. Errors trigger warnings or exceptions depending
1875 on configuration.
1876 """
1877 if self._use_project is False:
1878 return self._process_result(epanet.ENsetlinknodes(index, node1, node2))
1879 else:
1880 return self._process_result(epanet.EN_setlinknodes(self._ph, index, node1, node2))
1881
[docs]
1882 def getlinkvalue(self, index: int, property: int) -> float:
1883 """
1884 EN_getlinkvalue
1885
1886 Parameters
1887 ----------
1888 index : `int`
1889 property : `int`
1890
1891 Returns
1892 -------
1893 float
1894 The value of the specified link property. The underlying C
1895 function returns a tuple (errcode, value), which `_process_result`
1896 unwraps and returns as a plain float.
1897 """
1898 if self._use_project is False:
1899 return self._process_result(epanet.ENgetlinkvalue(index, property))
1900 else:
1901 return self._process_result(epanet.EN_getlinkvalue(self._ph, index, property))
1902
[docs]
1903 def setlinkvalue(self, index: int, property: int, value: float) -> None:
1904 """
1905 EN_setlinkvalue
1906
1907 Parameters
1908 ----------
1909 index : `int`
1910 property : `int`
1911 value : `float`
1912
1913 Returns
1914 -------
1915 None
1916 The underlying C function returns a tuple containing only the
1917 error code (errcode,), which `_process_result` unwraps and
1918 returns as None. Errors trigger warnings or exceptions depending
1919 on configuration.
1920 """
1921 if self._use_project is False:
1922 return self._process_result(epanet.ENsetlinkvalue(index, property, value))
1923 else:
1924 return self._process_result(epanet.EN_setlinkvalue(self._ph, index, property, value))
1925
[docs]
1926 def setlinkvalues(self, property: int, values: list[float]) -> int:
1927 """
1928 EN_setlinkvalues
1929
1930 Parameters
1931 ----------
1932 property : `int`
1933 values : `list[float]`
1934
1935 Returns
1936 -------
1937 int
1938 The index of the first link for which the update failed.
1939 The underlying C function returns a tuple (errcode, badIndex), which
1940 `_process_result` unwraps and returns as a plain integer.
1941 A return value of 0 indicates that all updates succeeded.
1942
1943
1944 """
1945 if self._use_project is False:
1946 return self._process_result(epanet.ENsetlinkvalues(property, values))
1947 else:
1948 return self._process_result(epanet.EN_setlinkvalues(self._ph, property, values))
1949
[docs]
1950 def setpipedata(self, index: int, length: float, diam: float, rough: float, mloss: float) -> None:
1951 """
1952 EN_setpipedata
1953
1954 Parameters
1955 ----------
1956 index : `int`
1957 length : `float`
1958 diam : `float`
1959 rough : `float`
1960 mloss : `float`
1961
1962 Returns
1963 -------
1964 None
1965 The underlying C function returns a tuple containing only the
1966 error code (errcode,), which `_process_result` unwraps and
1967 returns as None. Errors trigger warnings or exceptions depending
1968 on configuration.
1969 """
1970 if self._use_project is False:
1971 return self._process_result(epanet.ENsetpipedata(index, length, diam, rough, mloss))
1972 else:
1973 return self._process_result(epanet.EN_setpipedata(self._ph, index, length, diam, rough,
1974 mloss))
1975
[docs]
1976 def getvertexcount(self, index: int) -> int:
1977 """
1978 EN_getvertexcount
1979
1980 Parameters
1981 ----------
1982 index : `int`
1983
1984 Returns
1985 -------
1986 int
1987 The number of vertices associated with the link. The underlying
1988 C function returns a tuple (errcode, count), which `_process_result`
1989 unwraps and returns as a plain integer.
1990 """
1991 if self._use_project is False:
1992 return self._process_result(epanet.ENgetvertexcount(index))
1993 else:
1994 return self._process_result(epanet.EN_getvertexcount(self._ph, index))
1995
[docs]
1996 def getvertex(self, index: int, vertex: int) -> list:
1997 """
1998 EN_getvertex
1999
2000 Parameters
2001 ----------
2002 index : `int`
2003 vertex : `int`
2004
2005 Returns
2006 -------
2007 list
2008 A list [x, y] containing the coordinates of the specified
2009 vertex. The underlying C function returns a tuple (errcode, x, y),
2010 which `_process_result` unwraps and returns as a list of two floats.
2011 """
2012 if self._use_project is False:
2013 return self._process_result(epanet.ENgetvertex(index, vertex))
2014 else:
2015 return self._process_result(epanet.EN_getvertex(self._ph, index, vertex))
2016
[docs]
2017 def setvertices(self, index: int, x: list[float], y: list[float], count: int) -> None:
2018 """
2019 EN_setvertices
2020
2021 Parameters
2022 ----------
2023 index : `int`
2024 x : `list[float]`
2025 y : `list[float]`
2026 count : `int`
2027
2028 Returns
2029 -------
2030 None
2031 The underlying C function returns a tuple containing only the
2032 error code (errcode,), which `_process_result` unwraps and
2033 returns as None. Errors trigger warnings or exceptions depending
2034 on configuration.
2035 """
2036 if self._use_project is False:
2037 return self._process_result(epanet.ENsetvertices(index, x, y, count))
2038 else:
2039 return self._process_result(epanet.EN_setvertices(self._ph, index, x, y, count))
2040
[docs]
2041 def getpumptype(self, link_index: int) -> int:
2042 """
2043 EN_getpumptype
2044
2045 Parameters
2046 ----------
2047 link_index : `int`
2048
2049 Returns
2050 -------
2051 int
2052 The pump type of the specified link. The underlying C function
2053 returns a tuple (errcode, pumpType), which `_process_result`
2054 unwraps and returns as a plain integer.
2055 """
2056 if self._use_project is False:
2057 return self._process_result(epanet.ENgetpumptype(link_index))
2058 else:
2059 return self._process_result(epanet.EN_getpumptype(self._ph, link_index))
2060
[docs]
2061 def getheadcurveindex(self, link_index: int) -> int:
2062 """
2063 EN_getheadcurveindex
2064
2065 Parameters
2066 ----------
2067 link_index : `int`
2068
2069 Returns
2070 -------
2071 int
2072 The index of the head curve assigned to the pump. The underlying
2073 C function returns a tuple (errcode, curveIndex), which `_process_result`
2074 unwraps and returns as a plain integer.
2075 """
2076 if self._use_project is False:
2077 return self._process_result(epanet.ENgetheadcurveindex(link_index))
2078 else:
2079 return self._process_result(epanet.EN_getheadcurveindex(self._ph, link_index))
2080
[docs]
2081 def setheadcurveindex(self, link_index: int, curve_index: int) -> None:
2082 """
2083 EN_setheadcurveindex
2084
2085 Parameters
2086 ----------
2087 link_index : `int`
2088 curve_index : `int`
2089
2090 Returns
2091 -------
2092 None
2093 The underlying C function returns a tuple containing only the
2094 error code (errcode,), which `_process_result` unwraps and
2095 returns as None. Errors trigger warnings or exceptions depending
2096 on configuration.
2097 """
2098 if self._use_project is False:
2099 return self._process_result(epanet.ENsetheadcurveindex(link_index, curve_index))
2100 else:
2101 return self._process_result(epanet.EN_setheadcurveindex(self._ph, link_index,
2102 curve_index))
2103
[docs]
2104 def addpattern(self, id: str) -> None:
2105 """
2106 EN_addpattern
2107
2108 Parameters
2109 ----------
2110 id : `str`
2111
2112 Returns
2113 -------
2114 None
2115 The underlying C function returns a tuple containing only the
2116 error code (errcode,), which `_process_result` unwraps and
2117 returns as None. Errors trigger warnings or exceptions depending
2118 on configuration.
2119 """
2120 if self._use_project is False:
2121 return self._process_result(epanet.ENaddpattern(id))
2122 else:
2123 return self._process_result(epanet.EN_addpattern(self._ph, id))
2124
[docs]
2125 def deletepattern(self, index: int) -> None:
2126 """
2127 EN_deletepattern
2128
2129 Parameters
2130 ----------
2131 index : `int`
2132
2133 Returns
2134 -------
2135 None
2136 The underlying C function returns a tuple containing only the
2137 error code (errcode,), which `_process_result` unwraps and
2138 returns as None. Errors trigger warnings or exceptions depending
2139 on configuration.
2140 """
2141 if self._use_project is False:
2142 return self._process_result(epanet.ENdeletepattern(index))
2143 else:
2144 return self._process_result(epanet.EN_deletepattern(self._ph, index))
2145
[docs]
2146 def getpatternindex(self, pattern_id: str) -> int:
2147 """
2148 EN_getpatternindex
2149
2150 Parameters
2151 ----------
2152 pattern_id : `str`
2153
2154 Returns
2155 -------
2156 int
2157 The index of the pattern with the given ID. The underlying C
2158 function returns a tuple (errcode, index), which `_process_result`
2159 unwraps and returns as a plain integer.
2160 """
2161 if self._use_project is False:
2162 return self._process_result(epanet.ENgetpatternindex(pattern_id))
2163 else:
2164 return self._process_result(epanet.EN_getpatternindex(self._ph, pattern_id))
2165
[docs]
2166 def getpatternid(self, index: int) -> str:
2167 """
2168 EN_getpatternid
2169
2170 Parameters
2171 ----------
2172 index : `int`
2173
2174 Returns
2175 -------
2176 str
2177 The ID of the pattern at the given index. The underlying C
2178 function returns a tuple (errcode, id), which `_process_result`
2179 unwraps and returns as a plain string.
2180 """
2181 if self._use_project is False:
2182 return self._process_result(epanet.ENgetpatternid(index))
2183 else:
2184 return self._process_result(epanet.EN_getpatternid(self._ph, index))
2185
[docs]
2186 def setpatternid(self, index: int, id: str) -> None:
2187 """
2188 EN_setpatternid
2189
2190 Parameters
2191 ----------
2192 index : `int`
2193 id : `str`
2194
2195 Returns
2196 -------
2197 None
2198 The underlying C function returns a tuple containing only the
2199 error code (errcode,), which `_process_result` unwraps and
2200 returns as None. Errors trigger warnings or exceptions depending
2201 on configuration.
2202 """
2203 if self._use_project is False:
2204 return self._process_result(epanet.ENsetpatternid(index, id))
2205 else:
2206 return self._process_result(epanet.EN_setpatternid(self._ph, index, id))
2207
[docs]
2208 def getpatternlen(self, index: int) -> int:
2209 """
2210 EN_getpatternlen
2211
2212 Parameters
2213 ----------
2214 index : `int`
2215
2216 Returns
2217 -------
2218 int
2219 The number of periods in the specified pattern. The underlying
2220 C function returns a tuple (errcode, length), which
2221 `_process_result` unwraps and returns as a plain integer.
2222 """
2223 if self._use_project is False:
2224 return self._process_result(epanet.ENgetpatternlen(index))
2225 else:
2226 return self._process_result(epanet.EN_getpatternlen(self._ph, index))
2227
[docs]
2228 def getpatternvalue(self, index: int, period: int) -> float:
2229 """
2230 EN_getpatternvalue
2231
2232 Parameters
2233 ----------
2234 index : `int`
2235 period : `int`
2236
2237 Returns
2238 -------
2239 float
2240 The multiplier value for the specified pattern period. The underlying
2241 C function returns a tuple (errcode, value), which `_process_result`
2242 unwraps and returns as a plain float.
2243 """
2244 if self._use_project is False:
2245 return self._process_result(epanet.ENgetpatternvalue(index, period))
2246 else:
2247 return self._process_result(epanet.EN_getpatternvalue(self._ph, index, period))
2248
[docs]
2249 def setpatternvalue(self, index: int, period: int, value: float) -> None:
2250 """
2251 EN_setpatternvalue
2252
2253 Parameters
2254 ----------
2255 index : `int`
2256 period : `int`
2257 value : `float`
2258
2259 Returns
2260 -------
2261 None
2262 The underlying C function returns a tuple containing only the
2263 error code (errcode,), which `_process_result` unwraps and
2264 returns as None. Errors trigger warnings or exceptions depending
2265 on configuration.
2266 """
2267 if self._use_project is False:
2268 return self._process_result(epanet.ENsetpatternvalue(index, period, value))
2269 else:
2270 return self._process_result(epanet.EN_setpatternvalue(self._ph, index, period, value))
2271
[docs]
2272 def getaveragepatternvalue(self, index: int) -> float:
2273 """
2274 EN_getaveragepatternvalue
2275
2276 Parameters
2277 ----------
2278 index : `int`
2279
2280 Returns
2281 -------
2282 float
2283 The average multiplier value of the specified pattern. The underlying C
2284 function returns a tuple (errcode, value), which `_process_result`
2285 unwraps and returns as a plain float.
2286 """
2287 if self._use_project is False:
2288 return self._process_result(epanet.ENgetaveragepatternvalue(index))
2289 else:
2290 return self._process_result(epanet.EN_getaveragepatternvalue(self._ph, index))
2291
[docs]
2292 def setpattern(self, index: int, values: list[float], len: int) -> None:
2293 """
2294 EN_setpattern
2295
2296 Parameters
2297 ----------
2298 index : `int`
2299 values : `list[float]`
2300 len : `int`
2301
2302 Returns
2303 -------
2304 None
2305 The underlying C function returns a tuple containing only the
2306 error code (errcode,), which `_process_result` unwraps and
2307 returns as None. Errors trigger warnings or exceptions depending
2308 on configuration.
2309 """
2310 if self._use_project is False:
2311 return self._process_result(epanet.ENsetpattern(index, values, len))
2312 else:
2313 return self._process_result(epanet.EN_setpattern(self._ph, index, values, len))
2314
[docs]
2315 def addcurve(self, id: str) -> None:
2316 """
2317 EN_addcurve
2318
2319 Parameters
2320 ----------
2321 id : `str`
2322
2323 Returns
2324 -------
2325 None
2326 The underlying C function returns a tuple containing only the
2327 error code (errcode,), which `_process_result` unwraps and
2328 returns as None. Errors trigger warnings or exceptions depending
2329 on configuration.
2330 """
2331 if self._use_project is False:
2332 return self._process_result(epanet.ENaddcurve(id))
2333 else:
2334 return self._process_result(epanet.EN_addcurve(self._ph, id))
2335
[docs]
2336 def deletecurve(self, index: int) -> None:
2337 """
2338 EN_deletecurve
2339
2340 Parameters
2341 ----------
2342 index : `int`
2343
2344 Returns
2345 -------
2346 None
2347 The underlying C function returns a tuple containing only the
2348 error code (errcode,), which `_process_result` unwraps and
2349 returns as None. Errors trigger warnings or exceptions depending
2350 on configuration.
2351 """
2352 if self._use_project is False:
2353 return self._process_result(epanet.ENdeletecurve(index))
2354 else:
2355 return self._process_result(epanet.EN_deletecurve(self._ph, index))
2356
[docs]
2357 def getcurveindex(self, id: str) -> int:
2358 """
2359 EN_getcurveindex
2360
2361 Parameters
2362 ----------
2363 id : `str`
2364
2365 Returns
2366 -------
2367 int
2368 The index of the curve with the given ID. The underlying C
2369 function returns a tuple (errcode, idnex), which `_process_result`
2370 unwraps and returns as a plain integer.
2371 """
2372 if self._use_project is False:
2373 return self._process_result(epanet.ENgetcurveindex(id))
2374 else:
2375 return self._process_result(epanet.EN_getcurveindex(self._ph, id))
2376
[docs]
2377 def getcurveid(self, index: int) -> str:
2378 """
2379 EN_getcurveid
2380
2381 Parameters
2382 ----------
2383 index : `int`
2384
2385 Returns
2386 -------
2387 str
2388 The ID of the curve at the given index. The underlying C
2389 function returns a tuple (errcode, id), which `_process_result`
2390 unwraps and returns as a plain string.
2391 """
2392 if self._use_project is False:
2393 return self._process_result(epanet.ENgetcurveid(index))
2394 else:
2395 return self._process_result(epanet.EN_getcurveid(self._ph, index))
2396
[docs]
2397 def setcurveid(self, index: int, id: str) -> None:
2398 """
2399 EN_setcurveid
2400
2401 Parameters
2402 ----------
2403 index : `int`
2404 id : `str`
2405
2406 Returns
2407 -------
2408 None
2409 The underlying C function returns a tuple containing only the
2410 error code (errcode,), which `_process_result` unwraps and
2411 returns as None. Errors trigger warnings or exceptions depending
2412 on configuration.
2413 """
2414 if self._use_project is False:
2415 return self._process_result(epanet.ENsetcurveid(index, id))
2416 else:
2417 return self._process_result(epanet.EN_setcurveid(self._ph, index, id))
2418
[docs]
2419 def getcurvelen(self, index: int) -> int:
2420 """
2421 EN_getcurvelen
2422
2423 Parameters
2424 ----------
2425 index : `int`
2426
2427 Returns
2428 -------
2429 int
2430 The number of points in the specified curve. The underlying C
2431 function returns a tuple (errcode, value), which `_process_result`
2432 unwraps and returns as a plain integer.
2433 """
2434 if self._use_project is False:
2435 return self._process_result(epanet.ENgetcurvelen(index))
2436 else:
2437 return self._process_result(epanet.EN_getcurvelen(self._ph, index))
2438
[docs]
2439 def getcurvetype(self, index: int) -> int:
2440 """
2441 EN_getcurvetype
2442
2443 Parameters
2444 ----------
2445 index : `int`
2446
2447 Returns
2448 -------
2449 int
2450 The type of the curve at the given index. The underlying C
2451 function returns a tuple (errcode, type), which `_process_result`
2452 unwraps and returns as a plain integer.
2453 """
2454 if self._use_project is False:
2455 return self._process_result(epanet.ENgetcurvetype(index))
2456 else:
2457 return self._process_result(epanet.EN_getcurvetype(self._ph, index))
2458
[docs]
2459 def getcurvevalue(self, curve_index: int, point_index: int) -> list:
2460 """
2461 EN_getcurvevalue
2462
2463 Parameters
2464 ----------
2465 curve_index : `int`
2466 point_index : `int`
2467
2468 Returns
2469 -------
2470 list
2471 A list [x, y] containing the coordinates of the specified curve
2472 point. The underlying C function returns (errcode, x, y), which
2473 `_process_result` unwraps and returns as a list of two floats.
2474 """
2475 if self._use_project is False:
2476 return self._process_result(epanet.ENgetcurvevalue(curve_index, point_index))
2477 else:
2478 return self._process_result(epanet.EN_getcurvevalue(self._ph, curve_index, point_index))
2479
[docs]
2480 def setcurvevalue(self, curve_index: int, point_index: int, x: float, y: float) -> None:
2481 """
2482 EN_setcurvevalue
2483
2484 Parameters
2485 ----------
2486 curve_index : `int`
2487 point_index : `int`
2488 x : `float`
2489 y : `float`
2490
2491 Returns
2492 -------
2493 None
2494 The underlying C function returns a tuple containing only the
2495 error code (errcode,), which `_process_result` unwraps and
2496 returns as None. Errors trigger warnings or exceptions depending
2497 on configuration.
2498 """
2499 if self._use_project is False:
2500 return self._process_result(epanet.ENsetcurvevalue(curve_index, point_index, x, y))
2501 else:
2502 return self._process_result(epanet.EN_setcurvevalue(self._ph, curve_index, point_index,
2503 x, y))
2504
[docs]
2505 def getcurve(self, index: int) -> list:
2506 """
2507 EN_getcurve
2508
2509 Parameters
2510 ----------
2511 index : `int`
2512
2513 Returns
2514 -------
2515 A list [x_values, y_values] containing the curve's point
2516 coordinates. The underlying C function returns
2517 (errcode, xValuesList, yValuesList), which `_process_result`
2518 unwraps and returns as a list of two lists of floats.
2519 """
2520 if self._use_project is False:
2521 return self._process_result(epanet.ENgetcurve(index))
2522 else:
2523 return self._process_result(epanet.EN_getcurve(self._ph, index))
2524
[docs]
2525 def setcurve(self, index: int, x_values: list[float], y_values: list[float], n_points: int) -> None:
2526 """
2527 EN_setcurve
2528
2529 Parameters
2530 ----------
2531 index : `int`
2532 x_values : `list[float]`
2533 y_values : `list[float]`
2534 n_points : `int`
2535
2536 Returns
2537 -------
2538 None
2539 The underlying C function returns a tuple containing only the
2540 error code (errcode,), which `_process_result` unwraps and
2541 returns as None. Errors trigger warnings or exceptions depending
2542 on configuration.
2543 """
2544 if self._use_project is False:
2545 return self._process_result(epanet.ENsetcurve(index, x_values, y_values, n_points))
2546 else:
2547 return self._process_result(epanet.EN_setcurve(self._ph, index, x_values, y_values,
2548 n_points))
2549
[docs]
2550 def addcontrol(self, type: int, link_index: int, setting: float, node_index: int, level: float) -> int:
2551 """
2552 EN_addcontrol
2553
2554 Parameters
2555 ----------
2556 type : `int`
2557 link_index : `int`
2558 setting : `float`
2559 node_index . `int`
2560 level : `float`
2561
2562 Returns
2563 -------
2564 int
2565 The index of the newly added control. The underlying C function
2566 returns a tuple (errcode, index), which `_process_result`
2567 unwraps and returns as a plain integer.
2568 """
2569 if self._use_project is False:
2570 return self._process_result(epanet.ENaddcontrol(type, link_index, setting, node_index,
2571 level))
2572 else:
2573 return self._process_result(epanet.EN_addcontrol(self._ph, type, link_index, setting,
2574 node_index, level))
2575
[docs]
2576 def deletecontrol(self, index: int) -> None:
2577 """
2578 EN_deletecontrol
2579
2580 Parameters
2581 ----------
2582 index : `int`
2583
2584 Returns
2585 -------
2586 None
2587 The underlying C function returns a tuple containing only the
2588 error code (errcode,), which `_process_result` unwraps and
2589 returns as None. Errors trigger warnings or exceptions depending
2590 on configuration.
2591 """
2592 if self._use_project is False:
2593 return self._process_result(epanet.ENdeletecontrol(index))
2594 else:
2595 return self._process_result(epanet.EN_deletecontrol(self._ph, index))
2596
[docs]
2597 def getcontrol(self, index: int) -> list:
2598 """
2599 EN_getcontrol
2600
2601 Parameters
2602 ----------
2603 index : `int`
2604
2605 Returns
2606 -------
2607 list
2608 A list containing the properties of the specified control. The
2609 underlying C function returns a tuple
2610 (errcode, type, linkIndex, setting, nodeIndex, level), which
2611 `_process_result` unwraps and returns as a list of these values.
2612 """
2613 if self._use_project is False:
2614 return self._process_result(epanet.ENgetcontrol(index))
2615 else:
2616 return self._process_result(epanet.EN_getcontrol(self._ph, index))
2617
[docs]
2618 def setcontrol(self, index: int, type: int, link_index: int, setting: float, node_index: int,
2619 level: float) -> None:
2620 """
2621 EN_setcontrol
2622
2623 Parameters
2624 ----------
2625 index : `int`
2626 type : `int`
2627 link_index : `int`
2628 setting : `float`
2629 node_index : `int`
2630 level : `float`
2631
2632 Returns
2633 -------
2634 None
2635 The underlying C function returns a tuple containing only the
2636 error code (errcode,), which `_process_result` unwraps and
2637 returns as None. Errors trigger warnings or exceptions depending
2638 on configuration.
2639 """
2640 if self._use_project is False:
2641 return self._process_result(epanet.ENsetcontrol(index, type, link_index, setting,
2642 node_index, level))
2643 else:
2644 return self._process_result(epanet.EN_setcontrol(self._ph, index, type, link_index,
2645 setting, node_index, level))
2646
[docs]
2647 def addrule(self, rule: str) -> None:
2648 """
2649 EN_addrule
2650
2651 Parameters
2652 ----------
2653 rule : `str`
2654
2655 Returns
2656 -------
2657 None
2658 The underlying C function returns a tuple containing only the
2659 error code (errcode,), which `_process_result` unwraps and
2660 returns as None. Errors trigger warnings or exceptions depending
2661 on configuration.
2662 """
2663 if self._use_project is False:
2664 return self._process_result(epanet.ENaddrule(rule))
2665 else:
2666 return self._process_result(epanet.EN_addrule(self._ph, rule))
2667
[docs]
2668 def deleterule(self, index: int) -> None:
2669 """
2670 EN_deleterule
2671
2672 Parameters
2673 ----------
2674 index : `int`
2675
2676 Returns
2677 -------
2678 None
2679 The underlying C function returns a tuple containing only the
2680 error code (errcode,), which `_process_result` unwraps and
2681 returns as None. Errors trigger warnings or exceptions depending
2682 on configuration.
2683 """
2684 if self._use_project is False:
2685 return self._process_result(epanet.ENdeleterule(index))
2686 else:
2687 return self._process_result(epanet.EN_deleterule(self._ph, index))
2688
[docs]
2689 def getrule(self, index: int) -> list:
2690 """
2691 EN_getrule
2692
2693 Parameters
2694 ----------
2695 index : `int`
2696
2697 Returns
2698 -------
2699 list
2700 A list describing the rule structure.
2701 The underlying C function returns a tuple
2702 (errcode, nPremises, nThenActions, nElseActions, priority), which
2703 `_process_result` unwraps and returns as a list of these values.
2704 """
2705 if self._use_project is False:
2706 return self._process_result(epanet.ENgetrule(index))
2707 else:
2708 return self._process_result(epanet.EN_getrule(self._ph, index))
2709
[docs]
2710 def getruleid(self, index: int) -> str:
2711 """
2712 EN_getruleID
2713
2714 Parameters
2715 ----------
2716 index : `int`
2717
2718 Returns
2719 -------
2720 str
2721 The ID of the rule at the given index. The underlying C
2722 function returns a tuple (errcode, id), which `_process_result`
2723 unwraps and returns as a plain string.
2724 """
2725 if self._use_project is False:
2726 return self._process_result(epanet.ENgetruleID(index))
2727 else:
2728 return self._process_result(epanet.EN_getruleID(self._ph, index))
2729
[docs]
2730 def getpremise(self, rule_index: int, premise_index: int) -> list:
2731 """
2732 EN_getpremise
2733
2734 Parameters
2735 ----------
2736 rule_index : `int`
2737 premise_index : `int`
2738
2739 Returns
2740 -------
2741 list
2742 A list describing the premise. The underlying C function
2743 returns a tuple
2744 (errcode, logop, object, objIndex, variable, relop, status, value),
2745 which `_process_result` unwraps and returns as a list.
2746 """
2747 if self._use_project is False:
2748 return self._process_result(epanet.ENgetpremise(rule_index, premise_index))
2749 else:
2750 return self._process_result(epanet.EN_getpremise(self._ph, rule_index, premise_index))
2751
[docs]
2752 def setpremise(self, rule_index: int, premise_index: int, logop: int, object: int,
2753 obj_index: int, variable: int, relop: int, status: int, value: float) -> None:
2754 """
2755 EN_setpremise
2756
2757 Parameters
2758 ----------
2759 rule_index : `int`
2760 premise_index : `int`
2761 logop : `int`
2762 object : `int`
2763 obj_index : `int`
2764 variable : `int`
2765 relop : `int`
2766 status : `int`
2767 value : `float`
2768
2769 Returns
2770 -------
2771 None
2772 The underlying C function returns a tuple containing only the
2773 error code (errcode,), which `_process_result` unwraps and
2774 returns as None. Errors trigger warnings or exceptions depending
2775 on configuration.
2776 """
2777 if self._use_project is False:
2778 return self._process_result(epanet.ENsetpremise(rule_index, premise_index, logop,
2779 object, obj_index, variable, relop,
2780 status, value))
2781 else:
2782 return self._process_result(epanet.EN_setpremise(self._ph, rule_index, premise_index,
2783 logop, object, obj_index, variable,
2784 relop, status, value))
2785
[docs]
2786 def setpremiseindex(self, rule_index: int, premise_index: int, obj_index: int) -> None:
2787 """
2788 EN_setpremiseindex
2789
2790 Parameters
2791 ----------
2792 rule_index : `int`
2793 premise_index : `int`
2794 obj_index : `int`
2795
2796 Returns
2797 -------
2798 None
2799 The underlying C function returns a tuple containing only the
2800 error code (errcode,), which `_process_result` unwraps and
2801 returns as None. Errors trigger warnings or exceptions depending
2802 on configuration.
2803 """
2804 if self._use_project is False:
2805 return self._process_result(epanet.ENsetpremiseindex(rule_index, premise_index,
2806 obj_index))
2807 else:
2808 return self._process_result(epanet.EN_setpremiseindex(self._ph, rule_index,
2809 premise_index, obj_index))
2810
[docs]
2811 def setpremisestatus(self, rule_index: int, premise_index: int, status: int) -> None:
2812 """
2813 EN_setpremisestatus
2814
2815 Parameters
2816 ----------
2817 rule_index : `int`
2818 premise_index : `int`
2819 status : `int`
2820
2821 Returns
2822 -------
2823 None
2824 The underlying C function returns a tuple containing only the
2825 error code (errcode,), which `_process_result` unwraps and
2826 returns as None. Errors trigger warnings or exceptions depending
2827 on configuration.
2828 """
2829 if self._use_project is False:
2830 return self._process_result(epanet.ENsetpremisestatus(rule_index, premise_index,
2831 status))
2832 else:
2833 return self._process_result(epanet.EN_setpremisestatus(self._ph, rule_index,
2834 premise_index, status))
2835
[docs]
2836 def setpremisevalue(self, rule_index: int, premise_index: int, value: float) -> None:
2837 """
2838 EN_setpremisevalue
2839
2840 Parameters
2841 ----------
2842 rule_index : `int`
2843 premise_index : `int`
2844 value : `float`
2845
2846 Returns
2847 -------
2848 None
2849 The underlying C function returns a tuple containing only the
2850 error code (errcode,), which `_process_result` unwraps and
2851 returns as None. Errors trigger warnings or exceptions depending
2852 on configuration.
2853 """
2854 if self._use_project is False:
2855 return self._process_result(epanet.ENsetpremisevalue(rule_index, premise_index, value))
2856 else:
2857 return self._process_result(epanet.EN_setpremisevalue(self._ph, rule_index, premise_index, value))
2858
[docs]
2859 def getthenaction(self, rule_index: int, action_index: int) -> list:
2860 """
2861 EN_getthenaction
2862
2863 Parameters
2864 ----------
2865 rule_index : `int`
2866 action_index : `int`
2867
2868 Returns
2869 -------
2870 list
2871 A list containing the properties of a THEN-action.
2872 The underlying C function returns a tuple
2873 (errcode, linkIndex, status, setting),
2874 which `_process_result` unwraps and returns as a list.
2875 """
2876 if self._use_project is False:
2877 return self._process_result(epanet.ENgetthenaction(rule_index, action_index))
2878 else:
2879 return self._process_result(epanet.EN_getthenaction(self._ph, rule_index, action_index))
2880
[docs]
2881 def setthenaction(self, rule_index: int, action_index: int, link_index: int, status: int,
2882 setting: float) -> None:
2883 """
2884 EN_setthenaction
2885
2886 Parameters
2887 ----------
2888 rule_index : `int`
2889 action_index : `int`
2890 link_index : `int`
2891 status : `int`
2892 setting : `float`
2893
2894 Returns
2895 -------
2896 None
2897 The underlying C function returns a tuple containing only the
2898 error code (errcode,), which `_process_result` unwraps and
2899 returns as None. Errors trigger warnings or exceptions depending
2900 on configuration.
2901 """
2902 if self._use_project is False:
2903 return self._process_result(epanet.ENsetthenaction(rule_index, action_index, link_index,
2904 status, setting))
2905 else:
2906 return self._process_result(epanet.EN_setthenaction(self._ph, rule_index, action_index,
2907 link_index, status, setting))
2908
[docs]
2909 def getelseaction(self, rule_index: int, action_index: int) -> list:
2910 """
2911 EN_getelseaction
2912
2913 Parameters
2914 ----------
2915 rule_index : `int`
2916 action_index : `int`
2917
2918 Returns
2919 -------
2920 list
2921 A list containing the properties of an ELSE-action.
2922 The underlying C function returns a tuple
2923 (errcode, linkIndex, status, setting),
2924 which `_process_result` unwraps and returns as a list.
2925
2926 """
2927 if self._use_project is False:
2928 return self._process_result(epanet.ENgetelseaction(rule_index, action_index))
2929 else:
2930 return self._process_result(epanet.EN_getelseaction(self._ph, rule_index, action_index))
2931
[docs]
2932 def setelseaction(self, rule_index: int, action_index: int, link_index: int, status: int,
2933 setting: float) -> None:
2934 """
2935 EN_setelseaction
2936
2937 Parameters
2938 ----------
2939 rule_index : `int`
2940 action_index : `int`
2941 link_index : `int`
2942 status : `int`
2943 setting : `float`
2944
2945 Returns
2946 -------
2947 None
2948 The underlying C function returns a tuple containing only the
2949 error code (errcode,), which `_process_result` unwraps and
2950 returns as None. Errors trigger warnings or exceptions depending
2951 on configuration.
2952 """
2953 if self._use_project is False:
2954 return self._process_result(epanet.ENsetelseaction(rule_index, action_index, link_index,
2955 status, setting))
2956 else:
2957 return self._process_result(epanet.EN_setelseaction(self._ph, rule_index, action_index,
2958 link_index, status, setting))
2959
[docs]
2960 def setrulepriority(self, index: int, priority: float) -> None:
2961 """
2962 EN_setrulepriority
2963
2964 Parameters
2965 ----------
2966 index : `int`
2967 priority : `float`
2968
2969 Returns
2970 -------
2971 None
2972 The underlying C function returns a tuple containing only the
2973 error code (errcode,), which `_process_result` unwraps and
2974 returns as None. Errors trigger warnings or exceptions depending
2975 on configuration.
2976 """
2977 if self._use_project is False:
2978 return self._process_result(epanet.ENsetrulepriority(index, priority))
2979 else:
2980 return self._process_result(epanet.EN_setrulepriority(self._ph, index, priority))
2981
[docs]
2982 def gettag(self, obj_type: int, obj_idx: int) -> str:
2983 """
2984 EN_gettag
2985
2986 Parameters
2987 ----------
2988 obj_type : `int`
2989 obj_idx : `int`
2990
2991 Returns
2992 -------
2993 str
2994 The tag assigned to the object. The underlying C function
2995 returns a tuple (errcode, tag), which `_process_result`
2996 unwraps and returns as a plain string.
2997 """
2998 if self._use_project is False:
2999 return self._process_result(epanet.ENgettag(obj_type, obj_idx))
3000 else:
3001 return self._process_result(epanet.EN_gettag(self._ph, obj_type, obj_idx))
3002
[docs]
3003 def settag(self, obj_type: int, obj_idx: int, tag: str) -> None:
3004 """
3005 EN_settag
3006
3007 Parameters
3008 ----------
3009 obj_type : `int`
3010 obj_idx : `int`
3011 tag : `str`
3012
3013 Returns
3014 -------
3015 None
3016 The underlying C function returns a tuple containing only the
3017 error code (errcode,), which `_process_result` unwraps and
3018 returns as None. Errors trigger warnings or exceptions depending
3019 on configuration.
3020 """
3021 if self._use_project is False:
3022 return self._process_result(epanet.ENsettag(obj_type, obj_idx, tag))
3023 else:
3024 return self._process_result(epanet.EN_settag(self._ph, obj_type, obj_idx, tag))
3025
[docs]
3026 def timetonextevent(self) -> list:
3027 """
3028 EN_timetonextevent
3029
3030 Returns
3031 -------
3032 list
3033 A list containing information about when the next hydraulic
3034 time step occurs. The underlying C function returns a tuple
3035 (errcode, eventType, duration, elemIndex), which
3036 `_process_result` unwraps and returns as a list.
3037 """
3038 if self._use_project is False:
3039 return self._process_result(epanet.ENtimetonextevent())
3040 else:
3041 return self._process_result(epanet.EN_timetonextevent(self._ph))
3042
[docs]
3043 def getnodevalues(self, property: int) -> list[float]:
3044 """
3045 EN_getnodevalues
3046
3047 Parameters
3048 ----------
3049 property : `int`
3050
3051 Returns
3052 -------
3053 `list[float]`
3054 A list of node property values. The underlying C function
3055 returns a tuple (errcode, valuesList), which `_process_result`
3056 unwraps and returns as a plain list of floats.
3057 """
3058 if self._use_project is False:
3059 return self._process_result(epanet.ENgetnodevalues(property))
3060 else:
3061 return self._process_result(epanet.EN_getnodevalues(self._ph, property))
3062
[docs]
3063 def getnodevalues_numpy(self, property: int) -> numpy.ndarray:
3064 """
3065 EN_getnodevalues (NumPy compatible)
3066
3067 Parameters
3068 ----------
3069 property : `int`
3070
3071 Returns
3072 -------
3073 `numpy.ndarray`
3074 A NumPy array of node property values. The underlying C
3075 function returns a tuple (errcode, array), which
3076 `_process_result` unwraps and returns as a NumPy array.
3077 """
3078 if self._use_project is False:
3079 return self._process_result(epanet.ENgetnodevalues_NPY(property))
3080 else:
3081 return self._process_result(epanet.EN_getnodevalues_NPY(self._ph, property))
3082
[docs]
3083 def getlinkvalues(self, property: int) -> list[float]:
3084 """
3085 EN_getlinkvalues
3086
3087 Parameters
3088 ----------
3089 property : `int`
3090
3091 Returns
3092 -------
3093 `list[float]`
3094 A list of link property values. The underlying C function
3095 returns a tuple (errcode, valuesList), which `_process_result`
3096 unwraps and returns as a plain list of floats.
3097 """
3098 if self._use_project is False:
3099 return self._process_result(epanet.ENgetlinkvalues(property))
3100 else:
3101 return self._process_result(epanet.EN_getlinkvalues(self._ph, property))
3102
[docs]
3103 def getlinkvalues_numpy(self, property: int) -> numpy.ndarray:
3104 """
3105 EN_getlinkvalues (NumPy compatible)
3106
3107 Parameters
3108 ----------
3109 property : `int`
3110
3111 Returns
3112 -------
3113 `numpy.ndarray`
3114 A NumPy array of link property values. The underlying C
3115 function returns a tuple (errcode, array), which `_process_result`
3116 unwraps and returns as a NumPy array.
3117 """
3118 if self._use_project is False:
3119 return self._process_result(epanet.ENgetlinkvalues_NPY(property))
3120 else:
3121 return self._process_result(epanet.EN_getlinkvalues_NPY(self._ph, property))
3122
[docs]
3123 def setvertex(self, link_idx: int, vertex_idx: int, x: float, y: float) -> None:
3124 """
3125 EN_setvertex
3126
3127 Parameters
3128 ----------
3129 link_idx : `int`
3130 vertex_idx : `int`
3131 x : `float`
3132 y : `float`
3133
3134 Returns
3135 -------
3136 None
3137 The underlying C function returns a tuple containing only the
3138 error code (errcode,), which `_process_result` unwraps and
3139 returns as None. Errors trigger warnings or exceptions depending
3140 on configuration.
3141 """
3142 if self._use_project is False:
3143 return self._process_result(epanet.ENsetvertex(link_idx, vertex_idx, x, y))
3144 else:
3145 return self._process_result(epanet.EN_setvertex(self._ph, link_idx, vertex_idx, x, y))
3146
[docs]
3147 def loadpatternfile(self, filename: str, id: str) -> None:
3148 """
3149 EN_loadpatternfile
3150
3151 Parameters
3152 ----------
3153 filename : `str`
3154 id : `str`
3155
3156 Returns
3157 -------
3158 None
3159 The underlying C function returns a tuple containing only the
3160 error code (errcode,), which `_process_result` unwraps and
3161 returns as None. Errors trigger warnings or exceptions depending
3162 on configuration.
3163 """
3164 if self._use_project is False:
3165 return self._process_result(epanet.ENloadpatternfile(filename, id))
3166 else:
3167 return self._process_result(epanet.EN_loadpatternfile(self._ph, filename, id))
3168
[docs]
3169 def setcurvetype(self, curve_idx: int, curve_type: int) -> None:
3170 """
3171 EN_setcurvetype
3172
3173 Parameters
3174 ----------
3175 curve_idx : `int`
3176 curve_type : `int`
3177
3178 Returns
3179 -------
3180 None
3181 The underlying C function returns a tuple containing only the
3182 error code (errcode,), which `_process_result` unwraps and
3183 returns as None. Errors trigger warnings or exceptions depending
3184 on configuration.
3185 """
3186 if self._use_project is False:
3187 return self._process_result(epanet.ENsetcurvetype(curve_idx, curve_type))
3188 else:
3189 return self._process_result(epanet.EN_setcurvetype(self._ph, curve_idx, curve_type))
3190
[docs]
3191 def getcontrolenabled(self, control_idx: int) -> int:
3192 """
3193 EN_getcontrolenabled: Gets the enabled status of a simple control.
3194
3195 Parameters
3196 ----------
3197 control_idx : `int`
3198
3199 Returns
3200 -------
3201 int
3202 1 if the control is enabled, 0 if disabled. The underlying C
3203 function returns a tuple (errcode, enabled), which
3204 `_process_result` unwraps and returns as a plain integer.
3205 """
3206 if self._use_project is False:
3207 return self._process_result(epanet.ENgetcontrolenabled(control_idx))
3208 else:
3209 return self._process_result(epanet.EN_getcontrolenabled(self._ph, control_idx))
3210
[docs]
3211 def setcontrolenabled(self, control_idx: int, enabled: int) -> None:
3212 """
3213 EN_setcontrolenabled
3214
3215 Parameters
3216 ----------
3217 control_idx : `int`
3218 enabled : `int`
3219
3220 Returns
3221 -------
3222 None
3223 The underlying C function returns a tuple containing only the
3224 error code (errcode,), which `_process_result` unwraps and
3225 returns as None. Errors trigger warnings or exceptions depending
3226 on configuration.
3227 """
3228 if self._use_project is False:
3229 return self._process_result(epanet.ENsetcontrolenabled(control_idx, enabled))
3230 else:
3231 return self._process_result(epanet.EN_setcontrolenabled(self._ph, control_idx, enabled))
3232
[docs]
3233 def getruleenabled(self, rule_idx: int) -> int:
3234 """
3235 EN_getruleenabled: Gets the enabled status of a rule-based control.
3236
3237 Parameters
3238 ----------
3239 rule_idx : `int`
3240
3241 Returns
3242 -------
3243 int
3244 1 if the rule is enabled, 0 if disabled. The underlying C
3245 function returns a tuple (errcode, enabled), which
3246 `_process_result` unwraps and returns as a plain integer.
3247 """
3248 if self._use_project is False:
3249 return self._process_result(epanet.ENgetruleenabled(rule_idx))
3250 else:
3251 return self._process_result(epanet.EN_getruleenabled(self._ph, rule_idx))
3252
[docs]
3253 def setruleenabled(self, rule_idx: int, enabled: int) -> None:
3254 """
3255 EN_setruleenabled
3256
3257 Parameters
3258 ----------
3259 rule_idx : `int`
3260 enabled : `int`
3261
3262 Returns
3263 -------
3264 None
3265 The underlying C function returns a tuple containing only the
3266 error code (errcode,), which `_process_result` unwraps and
3267 returns as None. Errors trigger warnings or exceptions depending
3268 on configuration.
3269 """
3270 if self._use_project is False:
3271 return self._process_result(epanet.ENsetruleenabled(rule_idx, enabled))
3272 else:
3273 return self._process_result(epanet.EN_setruleenabled(self._ph, rule_idx, enabled))
3274
[docs]
3275 def MSXENopen(self, inp_file: str, rpt_file: str, out_file: str) -> None:
3276 """
3277 MSXENopen: pass-thru to open the EPANET toolkit system
3278
3279 Parameters
3280 ----------
3281 inp_file : `str`
3282 name of the EPANET input file
3283 rpt_file : `str`
3284 name of the EPANET report file
3285 out_file : `str`
3286 name of the EPANET output/binary file
3287
3288 Returns
3289 -------
3290 None
3291 The underlying C function returns a tuple containing only the
3292 error code (errcode,), which `_process_result` unwraps and
3293 returns as None. Errors trigger warnings or exceptions depending
3294 on configuration.
3295 """
3296 return self._process_result(epanet.MSXENopen(inp_file, rpt_file, out_file), msx_call=True)
3297
[docs]
3298 def MSXopen(self, fname: str) -> None:
3299 """
3300 MSXopen: opens the EPANET-MSX toolkit system.
3301
3302 Parameters
3303 ----------
3304 fname : `str`
3305 name of an MSX input file
3306
3307 Returns
3308 -------
3309 None
3310 The underlying C function returns a tuple containing only the
3311 error code (errcode,), which `_process_result` unwraps and
3312 returns as None. Errors trigger warnings or exceptions depending
3313 on configuration.
3314 """
3315 return self._process_result(epanet.MSXopen(fname), msx_call=True)
3316
[docs]
3317 def MSXsolveH(self) -> None:
3318 """
3319 MSXsolveH: Runs the hydraulic solver for MSX.
3320
3321 Returns
3322 -------
3323 None
3324 The underlying C function returns a tuple containing only the
3325 error code (errcode,), which `_process_result` unwraps and
3326 returns as None. Errors trigger warnings or exceptions depending
3327 on configuration.
3328 """
3329 return self._process_result(epanet.MSXsolveH(), msx_call=True)
3330
[docs]
3331 def MSXusehydfile(self, fname: str) -> None:
3332 """
3333 MSXusehydfile: registers a hydraulics solution file with the MSX system.
3334
3335 Parameters
3336 ----------
3337 fname : `str`
3338 A hydraulic file
3339
3340 Returns
3341 -------
3342 None
3343 The underlying C function returns a tuple containing only the
3344 error code (errcode,), which `_process_result` unwraps and
3345 returns as None. Errors trigger warnings or exceptions depending
3346 on configuration.
3347 """
3348 return self._process_result(epanet.MSXusehydfile(fname), msx_call=True)
3349
[docs]
3350 def MSXsolveQ(self) -> None:
3351 """
3352 MSXsolveQ: Runs the water-quality solver for MSX.
3353
3354 Returns
3355 -------
3356 None
3357 The underlying C function returns a tuple containing only the
3358 error code (errcode,), which `_process_result` unwraps and
3359 returns as None. Errors trigger warnings or exceptions depending
3360 on configuration.
3361 """
3362 return self._process_result(epanet.MSXsolveQ(), msx_call=True)
3363
[docs]
3364 def MSXinit(self, save_flag: int) -> None:
3365 """
3366 MSXinit: Initializes an MSX water quality analsis.
3367
3368 Parameters
3369 ----------
3370 save_flag : `int`
3371 Flag indicating whether MSX should save intermediate results.
3372
3373 Returns
3374 -------
3375 None
3376 The underlying C function returns a tuple containing only the
3377 error code (errcode,), which `_process_result` unwraps and
3378 returns as None. Errors trigger warnings or exceptions depending
3379 on configuration.
3380 """
3381 return self._process_result(epanet.MSXinit(save_flag), msx_call=True)
3382
[docs]
3383 def MSXstep(self) -> list:
3384 """
3385 MSXstep: Advances the MSX water‑quality simulation by one time step.
3386
3387 Returns
3388 -------
3389 list
3390 A list containing the current time (seconds) and the time remaining
3391 until the next quality step (seconds). The underlying C
3392 function returns a tuple (errcode, t, tleft), which
3393 `_process_result` unwraps and returns as a list.
3394 """
3395 return self._process_result(epanet.MSXstep(), msx_call=True)
3396
[docs]
3397 def MSXsaveoutfile(self, fname: str) -> None:
3398 """
3399 MSXsaveoutfile: Saves all results of the WQ simulation.
3400
3401 Parameters
3402 ----------
3403 fname : `str`
3404 Output file to write MSX results to.
3405
3406 Returns
3407 -------
3408 None
3409 The underlying C function returns a tuple containing only the
3410 error code (errcode,), which `_process_result` unwraps and
3411 returns as None. Errors trigger warnings or exceptions depending
3412 on configuration.
3413 """
3414 return self._process_result(epanet.MSXsaveoutfile(fname), msx_call=True)
3415
[docs]
3416 def MSXsavemsxfile(self, fname: str) -> None:
3417 """
3418 MSXsavemsxfile
3419
3420 Parameters
3421 ----------
3422 fname : `str`
3423 File name to save the current MSX model.
3424
3425 Returns
3426 -------
3427 None
3428 The underlying C function returns a tuple containing only the
3429 error code (errcode,), which `_process_result` unwraps and
3430 returns as None. Errors trigger warnings or exceptions depending
3431 on configuration.
3432 """
3433 return self._process_result(epanet.MSXsavemsxfile(fname), msx_call=True)
3434
[docs]
3435 def MSXreport(self) -> None:
3436 """
3437 MSXreport: Generates the MSX report file defined earlier via MSXENopen().
3438
3439 Returns
3440 -------
3441 None
3442 The underlying C function returns a tuple containing only the
3443 error code (errcode,), which `_process_result` unwraps and
3444 returns as None. Errors trigger warnings or exceptions depending
3445 on configuration.
3446 """
3447 return self._process_result(epanet.MSXreport(), msx_call=True)
3448
[docs]
3449 def MSXclose(self) -> None:
3450 """
3451 MSXclose: Closes the EPANET-MSX toolkit system.
3452
3453 Returns
3454 -------
3455 None
3456 The underlying C function returns a tuple containing only the
3457 error code (errcode,), which `_process_result` unwraps and
3458 returns as None. Errors trigger warnings or exceptions depending
3459 on configuration.
3460 """
3461 return self._process_result(epanet.MSXclose(), msx_call=True)
3462
[docs]
3463 def MSXENclose(self) -> None:
3464 """
3465 MSXENclose: pass-thru to close the EPANET toolkit system
3466
3467 Returns
3468 -------
3469 None
3470 The underlying C function returns a tuple containing only the
3471 error code (errcode,), which `_process_result` unwraps and
3472 returns as None. Errors trigger warnings or exceptions depending
3473 on configuration.
3474
3475 """
3476 return self._process_result(epanet.MSXENclose(), msx_call=True)
3477
[docs]
3478 def MSXgetindex(self, item_type: int, id: str) -> int:
3479 """
3480 MSXgetindex
3481
3482 Parameters
3483 ----------
3484 item_type : `int`
3485 id : `str`
3486
3487 Returns
3488 -------
3489 int
3490 The index of the MSX item. The underlying C function
3491 returns a tuple (errcode, index), which `_process_result`
3492 unwraps and returns as a plain integer.
3493 """
3494 return self._process_result(epanet.MSXgetindex(item_type, id), msx_call=True)
3495
[docs]
3496 def MSXgetIDlen(self, item_type: int, index: int) -> int:
3497 """
3498 MSXgetIDlen
3499
3500 Parameters
3501 ----------
3502 item_type : `int`
3503 index : `int`
3504
3505 Returns
3506 -------
3507 int
3508 Maximum number of characters available in the object's ID.
3509 The underlying C function returns a tuple (errcode, length),
3510 which `_process_result` unwraps and returns as a plain integer.
3511 """
3512 return self._process_result(epanet.MSXgetIDlen(item_type, index), msx_call=True)
3513
[docs]
3514 def MSXgetID(self, item_type: int, index: int) -> str:
3515 """
3516 MSXgetID
3517
3518 Parameters
3519 ----------
3520 item_type : `int`
3521 index : `int`
3522
3523 Returns
3524 -------
3525 str
3526 The ID/name of the specified MSX object. The underlying C
3527 function returns a tuple (errcode, id), which
3528 `_process_result` unwraps and returns as a plain string.
3529 """
3530 return self._process_result(epanet.MSXgetID(item_type, index), msx_call=True)
3531
[docs]
3532 def MSXgetcount(self, item_type: int) -> int:
3533 """
3534 MSXgetcount
3535
3536 Parameters
3537 ----------
3538 item_type : `int`
3539
3540 Returns
3541 -------
3542 int
3543 Number of objects of the given type. The underlying C
3544 function returns a tuple (errcode, count), which
3545 `_process_result` unwraps and returns as a plain integer.
3546 """
3547 return self._process_result(epanet.MSXgetcount(item_type), msx_call=True)
3548
[docs]
3549 def MSXgetspecies(self, index: int) -> list:
3550 """
3551 MSXgetspecies
3552
3553 Parameters
3554 ----------
3555 index : `int`
3556
3557 Returns
3558 -------
3559 list
3560 A list containing the attributes of a chemical species.
3561 The underlying C function returns a tuple
3562 (errcode, type, units, aTol, rTol), which
3563 `_process_result` unwraps and returns as a list.
3564 """
3565 return self._process_result(epanet.MSXgetspecies(index), msx_call=True)
3566
[docs]
3567 def MSXgetconstant(self, index: int) -> float:
3568 """
3569 MSXgetconstant
3570
3571 Parameters
3572 ----------
3573 index : `int`
3574
3575 Returns
3576 -------
3577 float
3578 The value of the reaction constant. The underlying C
3579 function returns a tuple (errcode, value), which
3580 `_process_result` unwraps and returns as a plain float.
3581 """
3582 return self._process_result(epanet.MSXgetconstant(index), msx_call=True)
3583
[docs]
3584 def MSXgetparameter(self, item_type: int, index: int, param: int) -> float:
3585 """
3586 MSXgetparameter
3587
3588 Parameters
3589 ----------
3590 item_type : `int`
3591 index : `int`
3592 param : `int`
3593
3594 Returns
3595 -------
3596 float
3597 The value of the requested MSX parameter. The underlying C
3598 function returns a tuple (errcode, value), which
3599 `_process_result` unwraps and returns as a plain float.
3600 """
3601 return self._process_result(epanet.MSXgetparameter(item_type, index, param), msx_call=True)
3602
[docs]
3603 def MSXgetsource(self, node: int, species: int) -> list:
3604 """
3605 MSXgetsource
3606
3607 Parameters
3608 ----------
3609 node : `int`
3610 species : `int`
3611
3612 Returns
3613 -------
3614 list
3615 A list containing information about the source term.
3616 The underlying C function returns a tuple
3617 (errcode, type, level, pat), which
3618 `_process_result` unwraps and returns as a list.
3619 """
3620 return self._process_result(epanet.MSXgetsource(node, species), msx_call=True)
3621
[docs]
3622 def MSXgetpatternlen(self, pat: int) -> int:
3623 """
3624 MSXgetpatternlen
3625
3626 Parameters
3627 ----------
3628 pat : `int`
3629
3630 Returns
3631 -------
3632 int
3633 Number of periods in the MSX pattern. The underlying C
3634 function returns a tuple (errcode, length), which
3635 `_process_result` unwraps and returns as a plain integer.
3636 """
3637 return self._process_result(epanet.MSXgetpatternlen(pat), msx_call=True)
3638
[docs]
3639 def MSXgetpatternvalue(self, pat: int, period: int) -> float:
3640 """
3641 MSXgetpatternvalue
3642
3643 Parameters
3644 ----------
3645 pat : `int`
3646 period : `int`
3647
3648 Returns
3649 -------
3650 float
3651 The multiplier value for the given pattern period. The
3652 underlying C function returns a tuple (errcode, value),
3653 which _process_result` unwraps and returns as a plain float.
3654 """
3655 return self._process_result(epanet.MSXgetpatternvalue(pat, period), msx_call=True)
3656
[docs]
3657 def MSXgetinitqual(self, item_type: int, index: int, species: int) -> float:
3658 """
3659 MSXgetinitqual
3660
3661 Parameters
3662 ----------
3663 item_type : `int`
3664 index : `int`
3665 species : `int`
3666
3667 Returns
3668 -------
3669 float
3670 Initial concentration of the species at the given object.
3671 The underlying C function returns a tuple (errcode, value),
3672 which `_process_result` unwraps and returns as a plain float.
3673 """
3674 return self._process_result(epanet.MSXgetinitqual(item_type, index, species), msx_call=True)
3675
[docs]
3676 def MSXgetqual(self, item_type: int, index: int, species: int) -> float:
3677 """
3678 MSXgetqual
3679
3680 Parameters
3681 ----------
3682 item_type : `int`
3683 index : `int`
3684 species : `int`
3685
3686 Returns
3687 -------
3688 float
3689 Current concentration of the species at the given object.
3690 The underlying C function returns a tuple (errcode, value),
3691 which `_process_result` unwraps and returns as a plain float.
3692 """
3693 return self._process_result(epanet.MSXgetqual(item_type, index, species), msx_call=True)
3694
[docs]
3695 def MSXgeterror(self, err_code: int) -> str:
3696 """
3697 MSXgeterror
3698
3699 Parameters
3700 ----------
3701 err_code : `int`
3702
3703 Returns
3704 -------
3705 str
3706 The error message corresponding to the given error code
3707 If MSXgeterror itself fails, a RuntimeError is raised.
3708 """
3709 err, msg = epanet.MSXgeterror(err_code)
3710 if err != 0:
3711 raise RuntimeError("Failed to get error message")
3712 else:
3713 return msg
3714
[docs]
3715 def MSXsetconstant(self, index: int, value: float) -> None:
3716 """
3717 MSXsetconstant
3718
3719 Parameters
3720 ----------
3721 index : `int`
3722 value : `float`
3723
3724 Returns
3725 -------
3726 None
3727 The underlying C function returns a tuple containing only the
3728 error code (errcode,), which `_process_result` unwraps and
3729 returns as None. Errors trigger warnings or exceptions depending
3730 on configuration.
3731 """
3732 return self._process_result(epanet.MSXsetconstant(index, value))
3733
[docs]
3734 def MSXsetparameter(self, item_type: int, index: int, param: int, value: float) -> None:
3735 """
3736 MSXsetparameter
3737
3738 Parameters
3739 ----------
3740 item_type : `int`
3741 index : `int`
3742 param : `int`
3743 value : `float`
3744
3745 Returns
3746 -------
3747 None
3748 The underlying C function returns a tuple containing only the
3749 error code (errcode,), which `_process_result` unwraps and
3750 returns as None. Errors trigger warnings or exceptions depending
3751 on configuration.
3752 """
3753 return self._process_result(epanet.MSXsetparameter(item_type, index, param, value),
3754 msx_call=True)
3755
[docs]
3756 def MSXsetinitqual(self, item_type: int, index: int, species: int, value: float) -> None:
3757 """
3758 MSXsetinitqual
3759
3760 Parameters
3761 ----------
3762 item_type : `int`
3763 index : `int`
3764 species : `int`
3765 value : `float`
3766
3767 Returns
3768 -------
3769 None
3770 The underlying C function returns a tuple containing only the
3771 error code (errcode,), which `_process_result` unwraps and
3772 returns as None. Errors trigger warnings or exceptions depending
3773 on configuration.
3774 """
3775 return self._process_result(epanet.MSXsetinitqual(item_type, index, species, value),
3776 msx_call=True)
3777
[docs]
3778 def MSXsetsource(self, node: int, species: int, item_type: int, level: float, pat: int) -> None:
3779 """
3780 MSXsetsource
3781
3782 Parameters
3783 ----------
3784 node : `int`
3785 species : `int`
3786 item_type : `int`
3787 level : `float`
3788 pat : `int`
3789
3790 Returns
3791 -------
3792 None
3793 The underlying C function returns a tuple containing only the
3794 error code (errcode,), which `_process_result` unwraps and
3795 returns as None. Errors trigger warnings or exceptions depending
3796 on configuration.
3797 """
3798 return self._process_result(epanet.MSXsetsource(node, species, item_type, level, pat),
3799 msx_call=True)
3800
[docs]
3801 def MSXsetpatternvalue(self, pat: int, period: int, value: float) -> None:
3802 """
3803 MSXsetpatternvalue
3804
3805 Parameters
3806 ----------
3807 pat : `int`
3808 period : `int`
3809 value : `float`
3810
3811 Returns
3812 -------
3813 None
3814 The underlying C function returns a tuple containing only the
3815 error code (errcode,), which `_process_result` unwraps and
3816 returns as None. Errors trigger warnings or exceptions depending
3817 on configuration.
3818 """
3819 return self._process_result(epanet.MSXsetpatternvalue(pat, period, value), msx_call=True)
3820
[docs]
3821 def MSXsetpattern(self, pat: int, mult: list[float], len: int) -> None:
3822 """
3823 MSXsetpattern
3824
3825 Parameters
3826 ----------
3827 pat : `int`
3828 mult : `list[float]`
3829 len : `int`
3830
3831 Returns
3832 -------
3833 None
3834 The underlying C function returns a tuple containing only the
3835 error code (errcode,), which `_process_result` unwraps and
3836 returns as None. Errors trigger warnings or exceptions depending
3837 on configuration.
3838 """
3839 return self._process_result(epanet.MSXsetpattern(pat, mult, len), msx_call=True)
3840
[docs]
3841 def MSXaddpattern(self, id: str) -> None:
3842 """
3843 MSXaddpattern
3844
3845 Parameters
3846 ----------
3847 id : `str`
3848
3849 Returns
3850 -------
3851 None
3852 The underlying C function returns a tuple containing only the
3853 error code (errcode,), which `_process_result` unwraps and
3854 returns as None. Errors trigger warnings or exceptions depending
3855 on configuration.
3856 """
3857 return self._process_result(epanet.MSXaddpattern(id), msx_call=True)