epanet-plus 0.2.1__cp311-cp311-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. docs/conf.py +67 -0
  2. epanet-msx-src/dispersion.h +27 -0
  3. epanet-msx-src/hash.c +107 -0
  4. epanet-msx-src/hash.h +28 -0
  5. epanet-msx-src/include/epanetmsx.h +104 -0
  6. epanet-msx-src/include/epanetmsx_export.h +42 -0
  7. epanet-msx-src/mathexpr.c +937 -0
  8. epanet-msx-src/mathexpr.h +39 -0
  9. epanet-msx-src/mempool.c +204 -0
  10. epanet-msx-src/mempool.h +24 -0
  11. epanet-msx-src/msxchem.c +1285 -0
  12. epanet-msx-src/msxcompiler.c +368 -0
  13. epanet-msx-src/msxdict.h +42 -0
  14. epanet-msx-src/msxdispersion.c +586 -0
  15. epanet-msx-src/msxerr.c +116 -0
  16. epanet-msx-src/msxfile.c +260 -0
  17. epanet-msx-src/msxfuncs.c +175 -0
  18. epanet-msx-src/msxfuncs.h +35 -0
  19. epanet-msx-src/msxinp.c +1504 -0
  20. epanet-msx-src/msxout.c +398 -0
  21. epanet-msx-src/msxproj.c +791 -0
  22. epanet-msx-src/msxqual.c +2011 -0
  23. epanet-msx-src/msxrpt.c +400 -0
  24. epanet-msx-src/msxtank.c +422 -0
  25. epanet-msx-src/msxtoolkit.c +1164 -0
  26. epanet-msx-src/msxtypes.h +551 -0
  27. epanet-msx-src/msxutils.c +524 -0
  28. epanet-msx-src/msxutils.h +56 -0
  29. epanet-msx-src/newton.c +158 -0
  30. epanet-msx-src/newton.h +34 -0
  31. epanet-msx-src/rk5.c +287 -0
  32. epanet-msx-src/rk5.h +39 -0
  33. epanet-msx-src/ros2.c +293 -0
  34. epanet-msx-src/ros2.h +35 -0
  35. epanet-msx-src/smatrix.c +816 -0
  36. epanet-msx-src/smatrix.h +29 -0
  37. epanet-src/AUTHORS +60 -0
  38. epanet-src/LICENSE +21 -0
  39. epanet-src/enumstxt.h +151 -0
  40. epanet-src/epanet.c +5937 -0
  41. epanet-src/epanet2.c +961 -0
  42. epanet-src/epanet2.def +131 -0
  43. epanet-src/errors.dat +79 -0
  44. epanet-src/flowbalance.c +186 -0
  45. epanet-src/funcs.h +219 -0
  46. epanet-src/genmmd.c +1000 -0
  47. epanet-src/hash.c +177 -0
  48. epanet-src/hash.h +28 -0
  49. epanet-src/hydcoeffs.c +1303 -0
  50. epanet-src/hydraul.c +1164 -0
  51. epanet-src/hydsolver.c +781 -0
  52. epanet-src/hydstatus.c +442 -0
  53. epanet-src/include/epanet2.h +466 -0
  54. epanet-src/include/epanet2_2.h +1962 -0
  55. epanet-src/include/epanet2_enums.h +518 -0
  56. epanet-src/inpfile.c +884 -0
  57. epanet-src/input1.c +672 -0
  58. epanet-src/input2.c +970 -0
  59. epanet-src/input3.c +2265 -0
  60. epanet-src/leakage.c +527 -0
  61. epanet-src/mempool.c +146 -0
  62. epanet-src/mempool.h +24 -0
  63. epanet-src/output.c +853 -0
  64. epanet-src/project.c +1691 -0
  65. epanet-src/quality.c +695 -0
  66. epanet-src/qualreact.c +800 -0
  67. epanet-src/qualroute.c +696 -0
  68. epanet-src/report.c +1559 -0
  69. epanet-src/rules.c +1500 -0
  70. epanet-src/smatrix.c +871 -0
  71. epanet-src/text.h +508 -0
  72. epanet-src/types.h +928 -0
  73. epanet-src/util/cstr_helper.c +59 -0
  74. epanet-src/util/cstr_helper.h +38 -0
  75. epanet-src/util/errormanager.c +92 -0
  76. epanet-src/util/errormanager.h +39 -0
  77. epanet-src/util/filemanager.c +212 -0
  78. epanet-src/util/filemanager.h +81 -0
  79. epanet-src/validate.c +408 -0
  80. epanet.cpython-311-darwin.so +0 -0
  81. epanet_plus/VERSION +1 -0
  82. epanet_plus/__init__.py +8 -0
  83. epanet_plus/epanet_plus.c +118 -0
  84. epanet_plus/epanet_toolkit.py +2833 -0
  85. epanet_plus/epanet_wrapper.py +2434 -0
  86. epanet_plus/include/epanet_plus.h +9 -0
  87. epanet_plus-0.2.1.dist-info/METADATA +157 -0
  88. epanet_plus-0.2.1.dist-info/RECORD +106 -0
  89. epanet_plus-0.2.1.dist-info/WHEEL +6 -0
  90. epanet_plus-0.2.1.dist-info/licenses/LICENSE +21 -0
  91. epanet_plus-0.2.1.dist-info/top_level.txt +11 -0
  92. examples/basic_usage.py +35 -0
  93. examples/epanet_msx.py +35 -0
  94. python-extension/ext.c +344 -0
  95. python-extension/pyepanet.c +2771 -0
  96. python-extension/pyepanet.h +144 -0
  97. python-extension/pyepanet2.c +2453 -0
  98. python-extension/pyepanet2.h +142 -0
  99. python-extension/pyepanet_plus.c +43 -0
  100. python-extension/pyepanet_plus.h +4 -0
  101. python-extension/pyepanetmsx.c +524 -0
  102. python-extension/pyepanetmsx.h +35 -0
  103. tests/test_epanet.py +18 -0
  104. tests/test_epanetmsx.py +38 -0
  105. tests/test_epyt.py +115 -0
  106. tests/test_load_inp_from_buffer.py +59 -0
@@ -0,0 +1,142 @@
1
+ #include <Python.h>
2
+
3
+
4
+ PyObject* method_ENopen(PyObject* self, PyObject* args);
5
+ PyObject* method_ENopenX(PyObject* self, PyObject* args);
6
+ PyObject* method_ENclose(PyObject* self, PyObject* Py_UNUSED(args));
7
+ PyObject* method_ENaddcontrol(PyObject* self, PyObject* args);
8
+ PyObject* method_ENaddcurve(PyObject* self, PyObject* args);
9
+ PyObject* method_ENadddemand(PyObject* self, PyObject* args);
10
+ PyObject* method_ENaddlink(PyObject* self, PyObject* args);
11
+ PyObject* method_ENaddnode(PyObject* self, PyObject* args);
12
+ PyObject* method_ENaddpattern(PyObject* self, PyObject* args);
13
+ PyObject* method_ENaddrule(PyObject* self, PyObject* args);
14
+ PyObject* method_ENclearreport(PyObject* self, PyObject* Py_UNUSED(args));
15
+ PyObject* method_ENcloseH(PyObject* self, PyObject* Py_UNUSED(args));
16
+ PyObject* method_ENcloseQ(PyObject* self, PyObject* Py_UNUSED(args));
17
+ PyObject* method_ENcopyreport(PyObject* self, PyObject* args);
18
+ PyObject* method_ENdeletecontrol(PyObject* self, PyObject* args);
19
+ PyObject* method_ENdeletecurve(PyObject* self, PyObject* args);
20
+ PyObject* method_ENdeletedemand(PyObject* self, PyObject* args);
21
+ PyObject* method_ENdeletelink(PyObject* self, PyObject* args);
22
+ PyObject* method_ENdeletenode(PyObject* self, PyObject* args);
23
+ PyObject* method_ENdeletepattern(PyObject* self, PyObject* args);
24
+ PyObject* method_ENdeleterule(PyObject* self, PyObject* args);
25
+ PyObject* method_ENgetaveragepatternvalue(PyObject* self, PyObject* args);
26
+ PyObject* method_ENgetbasedemand(PyObject* self, PyObject* args);
27
+ PyObject* method_ENgetcomment(PyObject* self, PyObject* args);
28
+ PyObject* method_ENgetcontrol(PyObject* self, PyObject* args);
29
+ PyObject* method_ENgetcoord(PyObject* self, PyObject* args);
30
+ PyObject* method_ENgetcount(PyObject* self, PyObject* args);
31
+ PyObject* method_ENgetcurve(PyObject* self, PyObject* args);
32
+ PyObject* method_ENgetcurveid(PyObject* self, PyObject* args);
33
+ PyObject* method_ENgetcurveindex(PyObject* self, PyObject* args);
34
+ PyObject* method_ENgetcurvelen(PyObject* self, PyObject* args);
35
+ PyObject* method_ENgetcurvetype(PyObject* self, PyObject* args);
36
+ PyObject* method_ENgetcurvevalue(PyObject* self, PyObject* args);
37
+ PyObject* method_ENgetdemandindex(PyObject* self, PyObject* args);
38
+ PyObject* method_ENgetdemandmodel(PyObject* self, PyObject* Py_UNUSED(args));
39
+ PyObject* method_ENgetdemandname(PyObject* self, PyObject* args);
40
+ PyObject* method_ENgetdemandpattern(PyObject* self, PyObject* args);
41
+ PyObject* method_ENgetelseaction(PyObject* self, PyObject* args);
42
+ PyObject* method_ENgeterror(PyObject* self, PyObject* args);
43
+ PyObject* method_ENgetflowunits(PyObject* self, PyObject* Py_UNUSED(args));
44
+ PyObject* method_ENgetheadcurveindex(PyObject* self, PyObject* args);
45
+ PyObject* method_ENgetlinkid(PyObject* self, PyObject* args);
46
+ PyObject* method_ENgetlinkindex(PyObject* self, PyObject* args);
47
+ PyObject* method_ENgetlinknodes(PyObject* self, PyObject* args);
48
+ PyObject* method_ENgetlinktype(PyObject* self, PyObject* args);
49
+ PyObject* method_ENgetlinkvalue(PyObject* self, PyObject* args);
50
+ PyObject* method_ENgetnodeid(PyObject* self, PyObject* args);
51
+ PyObject* method_ENgetnodeindex(PyObject* self, PyObject* args);
52
+ PyObject* method_ENgetnodetype(PyObject* self, PyObject* args);
53
+ PyObject* method_ENgetnodevalue(PyObject* self, PyObject* args);
54
+ PyObject* method_ENgetnumdemands(PyObject* self, PyObject* args);
55
+ PyObject* method_ENgetoption(PyObject* self, PyObject* args);
56
+ PyObject* method_ENgetpatternid(PyObject* self, PyObject* args);
57
+ PyObject* method_ENgetpatternindex(PyObject* self, PyObject* args);
58
+ PyObject* method_ENgetpatternlen(PyObject* self, PyObject* args);
59
+ PyObject* method_ENgetpatternvalue(PyObject* self, PyObject* args);
60
+ PyObject* method_ENgetpremise(PyObject* self, PyObject* args);
61
+ PyObject* method_ENgetpumptype(PyObject* self, PyObject* args);
62
+ PyObject* method_ENgetqualinfo(PyObject* self, PyObject* Py_UNUSED(args));
63
+ PyObject* method_ENgetqualtype(PyObject* self, PyObject* Py_UNUSED(args));
64
+ PyObject* method_ENgetresultindex(PyObject* self, PyObject* args);
65
+ PyObject* method_ENgetrule(PyObject* self, PyObject* args);
66
+ PyObject* method_ENgetruleID(PyObject* self, PyObject* args);
67
+ PyObject* method_ENgetstatistic(PyObject* self, PyObject* args);
68
+ PyObject* method_ENgetthenaction(PyObject* self, PyObject* args);
69
+ PyObject* method_ENgettimeparam(PyObject* self, PyObject* args);
70
+ PyObject* method_ENgettitle(PyObject* self, PyObject* Py_UNUSED(args));
71
+ PyObject* method_ENgetversion(PyObject* self, PyObject* Py_UNUSED(args));
72
+ PyObject* method_ENgetvertex(PyObject* self, PyObject* args);
73
+ PyObject* method_ENgetvertexcount(PyObject* self, PyObject* args);
74
+ PyObject* method_ENinit(PyObject* self, PyObject* args);
75
+ PyObject* method_ENinitH(PyObject* self, PyObject* args);
76
+ PyObject* method_ENinitQ(PyObject* self, PyObject* args);
77
+ PyObject* method_ENnextH(PyObject* self, PyObject* Py_UNUSED(args));
78
+ PyObject* method_ENnextQ(PyObject* self, PyObject* Py_UNUSED(args));
79
+ PyObject* method_ENopenH(PyObject* self, PyObject* Py_UNUSED(args));
80
+ PyObject* method_ENopenQ(PyObject* self, PyObject* Py_UNUSED(args));
81
+ PyObject* method_ENreport(PyObject* self, PyObject* Py_UNUSED(args));
82
+ PyObject* method_ENresetreport(PyObject* self, PyObject* Py_UNUSED(args));
83
+ PyObject* method_ENrunH(PyObject* self, PyObject* Py_UNUSED(args));
84
+ PyObject* method_ENrunQ(PyObject* self, PyObject* Py_UNUSED(args));
85
+ PyObject* method_ENsavehydfile(PyObject* self, PyObject* args);
86
+ PyObject* method_ENsaveH(PyObject* self, PyObject* Py_UNUSED(args));
87
+ PyObject* method_ENsaveinpfile(PyObject* self, PyObject* args);
88
+ PyObject* method_ENsetbasedemand(PyObject* self, PyObject* args);
89
+ PyObject* method_ENsetcomment(PyObject* self, PyObject* args);
90
+ PyObject* method_ENsetcontrol(PyObject* self, PyObject* args);
91
+ PyObject* method_ENsetcurveid(PyObject* self, PyObject* args);
92
+ PyObject* method_ENsetcurve(PyObject* self, PyObject* args);
93
+ PyObject* method_ENsetcoord(PyObject* self, PyObject* args);
94
+ PyObject* method_ENsetcurvevalue(PyObject* self, PyObject* args);
95
+ PyObject* method_ENsetdemandmodel(PyObject* self, PyObject* args);
96
+ PyObject* method_ENsetdemandname(PyObject* self, PyObject* args);
97
+ PyObject* method_ENsetdemandpattern(PyObject* self, PyObject* args);
98
+ PyObject* method_ENsetelseaction(PyObject* self, PyObject* args);
99
+ PyObject* method_ENsetflowunits(PyObject* self, PyObject* args);
100
+ PyObject* method_ENsetheadcurveindex(PyObject* self, PyObject* args);
101
+ PyObject* method_ENsetjuncdata(PyObject* self, PyObject* args);
102
+ PyObject* method_ENsetlinkid(PyObject* self, PyObject* args);
103
+ PyObject* method_ENsetlinknodes(PyObject* self, PyObject* args);
104
+ PyObject* method_ENsetlinktype(PyObject* self, PyObject* args);
105
+ PyObject* method_ENsetlinkvalue(PyObject* self, PyObject* args);
106
+ PyObject* method_ENsetnodeid(PyObject* self, PyObject* args);
107
+ PyObject* method_ENsetnodevalue(PyObject* self, PyObject* args);
108
+ PyObject* method_ENsetoption(PyObject* self, PyObject* args);
109
+ PyObject* method_ENsetpattern(PyObject* self, PyObject* args);
110
+ PyObject* method_ENsetpatternid(PyObject* self, PyObject* args);
111
+ PyObject* method_ENsetpatternvalue(PyObject* self, PyObject* args);
112
+ PyObject* method_ENsetpipedata(PyObject* self, PyObject* args);
113
+ PyObject* method_ENsetpremise(PyObject* self, PyObject* args);
114
+ PyObject* method_ENsetpremiseindex(PyObject* self, PyObject* args);
115
+ PyObject* method_ENsetpremisevalue(PyObject* self, PyObject* args);
116
+ PyObject* method_ENsetpremisestatus(PyObject* self, PyObject* args);
117
+ PyObject* method_ENsetqualtype(PyObject* self, PyObject* args);
118
+ PyObject* method_ENsetreport(PyObject* self, PyObject* args);
119
+ PyObject* method_ENsetrulepriority(PyObject* self, PyObject* args);
120
+ PyObject* method_ENsetstatusreport(PyObject* self, PyObject* args);
121
+ PyObject* method_ENsettankdata(PyObject* self, PyObject* args);
122
+ PyObject* method_ENsetthenaction(PyObject* self, PyObject* args);
123
+ PyObject* method_ENsettimeparam(PyObject* self, PyObject* args);
124
+ PyObject* method_ENsettitle(PyObject* self, PyObject* args);
125
+ PyObject* method_ENsetvertices(PyObject* self, PyObject* args);
126
+ PyObject* method_ENsolveH(PyObject* self, PyObject* Py_UNUSED(args));
127
+ PyObject* method_ENsolveQ(PyObject* self, PyObject* Py_UNUSED(args));
128
+ PyObject* method_ENstepQ(PyObject* self, PyObject* Py_UNUSED(args));
129
+ PyObject* method_ENusehydfile(PyObject* self, PyObject* args);
130
+ PyObject* method_ENwriteline(PyObject* self, PyObject* args);
131
+ PyObject* method_ENgettag(PyObject* self, PyObject* args);
132
+ PyObject* method_ENsettag(PyObject* self, PyObject* args);
133
+ PyObject* method_ENtimetonextevent(PyObject* self, PyObject* Py_UNUSED(args));
134
+ PyObject* method_ENgetnodevalues(PyObject* self, PyObject* args);
135
+ PyObject* method_ENgetlinkvalues(PyObject* self, PyObject* args);
136
+ PyObject* method_ENsetvertex(PyObject* self, PyObject* args);
137
+ PyObject* method_ENloadpatternfile(PyObject* self, PyObject* args);
138
+ PyObject* method_ENsetcurvetype(PyObject* self, PyObject* args);
139
+ PyObject* method_ENgetcontrolenabled(PyObject* self, PyObject* args);
140
+ PyObject* method_ENsetcontrolenabled(PyObject* self, PyObject* args);
141
+ PyObject* method_ENgetruleenabled(PyObject* self, PyObject* args);
142
+ PyObject* method_ENsetruleenabled(PyObject* self, PyObject* args);
@@ -0,0 +1,43 @@
1
+ #include <Python.h>
2
+ #include "epanet_plus.h"
3
+
4
+
5
+ PyObject* method_ENopenfrombuffer(PyObject* self, PyObject* args)
6
+ {
7
+ char* inpBuffer = NULL;
8
+ char* inpFile = NULL;
9
+ char* rptFile = NULL;
10
+ char* outFile = NULL;
11
+
12
+ if(!PyArg_ParseTuple(args, "ssss", &inpBuffer, &inpFile, &rptFile, &outFile)) {
13
+ return NULL;
14
+ }
15
+
16
+ PyObject* err = PyLong_FromLong(ENopenfrombuffer(inpBuffer, inpFile, rptFile, outFile));
17
+
18
+ PyObject* r = PyTuple_Pack(1, err);
19
+ Py_DECREF(err);
20
+
21
+ return r;
22
+ }
23
+
24
+ PyObject* method_EN_openfrombuffer(PyObject* self, PyObject* args)
25
+ {
26
+ uintptr_t ptr;
27
+ char* inpBuffer = NULL;
28
+ char* inpFile = NULL;
29
+ char* rptFile = NULL;
30
+ char* outFile = NULL;
31
+
32
+ if(!PyArg_ParseTuple(args, "Kssss", &ptr, &inpBuffer, &inpFile, &rptFile, &outFile)) {
33
+ return NULL;
34
+ }
35
+ EN_Project ph = (EN_Project) ptr;
36
+
37
+ PyObject* err = PyLong_FromLong(EN_openfrombuffer(ph, inpBuffer, inpFile, rptFile, outFile));
38
+
39
+ PyObject* r = PyTuple_Pack(1, err);
40
+ Py_DECREF(err);
41
+
42
+ return r;
43
+ }
@@ -0,0 +1,4 @@
1
+ #include <Python.h>
2
+
3
+ PyObject* method_ENopenfrombuffer(PyObject* self, PyObject* args);
4
+ PyObject* method_EN_openfrombuffer(PyObject* self, PyObject* args);
@@ -0,0 +1,524 @@
1
+ #include <Python.h>
2
+ #include "epanetmsx.h"
3
+ #include "msxtypes.h"
4
+
5
+ #define MAXID 31 // Max. # characters in ID name
6
+
7
+
8
+ PyObject* method_MSXENopen(PyObject* self, PyObject* args)
9
+ {
10
+ char *inpFile, *rptFile, *outFile = NULL;
11
+
12
+ if(!PyArg_ParseTuple(args, "sss", &inpFile, &rptFile, &outFile)) {
13
+ return NULL;
14
+ }
15
+
16
+ PyObject* err = PyLong_FromLong(MSXENopen(inpFile, rptFile, outFile));
17
+
18
+ PyObject* r = PyTuple_Pack(1, err);
19
+ Py_DECREF(err);
20
+
21
+ return r;
22
+ }
23
+
24
+ PyObject* method_MSXopen(PyObject* self, PyObject* args)
25
+ {
26
+ char* fname = NULL;
27
+ if(!PyArg_ParseTuple(args, "s", &fname)) {
28
+ return NULL;
29
+ }
30
+
31
+ PyObject* err = PyLong_FromLong(MSXopen(fname));
32
+
33
+ PyObject* r = PyTuple_Pack(1, err);
34
+ Py_DECREF(err);
35
+
36
+ return r;
37
+ }
38
+
39
+ PyObject* method_MSXsolveH(PyObject* self, PyObject* Py_UNUSED(args))
40
+ {
41
+ PyObject* err = PyLong_FromLong(MSXsolveH());
42
+
43
+ PyObject* r = PyTuple_Pack(1, err);
44
+ Py_DECREF(err);
45
+
46
+ return r;
47
+ }
48
+
49
+ PyObject* method_MSXusehydfile(PyObject* self, PyObject* args)
50
+ {
51
+ char* fname = NULL;
52
+ if(!PyArg_ParseTuple(args, "s", &fname)) {
53
+ return NULL;
54
+ }
55
+
56
+ PyObject* err = PyLong_FromLong(MSXusehydfile(fname));
57
+
58
+ PyObject* r = PyTuple_Pack(1, err);
59
+ Py_DECREF(err);
60
+
61
+ return r;
62
+ }
63
+
64
+ PyObject* method_MSXsolveQ(PyObject* self, PyObject* Py_UNUSED(args))
65
+ {
66
+ PyObject* err = PyLong_FromLong(MSXsolveQ());
67
+
68
+ PyObject* r = PyTuple_Pack(1, err);
69
+ Py_DECREF(err);
70
+
71
+ return r;
72
+ }
73
+
74
+ PyObject* method_MSXinit(PyObject* self, PyObject* args)
75
+ {
76
+ int saveFlag;
77
+ if(!PyArg_ParseTuple(args, "i", &saveFlag)) {
78
+ return NULL;
79
+ }
80
+
81
+ PyObject* err = PyLong_FromLong(MSXinit(saveFlag));
82
+
83
+ PyObject* r = PyTuple_Pack(1, err);
84
+ Py_DECREF(err);
85
+
86
+ return r;
87
+ }
88
+
89
+ PyObject* method_MSXstep(PyObject* self, PyObject* args)
90
+ {
91
+ double t, tleft;
92
+ PyObject* err = PyLong_FromLong(MSXstep(&t, &tleft));
93
+ PyObject* pyT = PyFloat_FromDouble(t);
94
+ PyObject* pyTLeft = PyFloat_FromDouble(tleft);
95
+
96
+ PyObject* r = PyTuple_Pack(3, err, pyT, pyTLeft);
97
+ Py_DECREF(err);
98
+ Py_DECREF(pyT);
99
+ Py_DECREF(pyTLeft);
100
+
101
+ return r;
102
+ }
103
+
104
+ PyObject* method_MSXsaveoutfile(PyObject* self, PyObject* args)
105
+ {
106
+ char* fname = NULL;
107
+ if(!PyArg_ParseTuple(args, "s", &fname)) {
108
+ return NULL;
109
+ }
110
+
111
+ PyObject* err = PyLong_FromLong(MSXsaveoutfile(fname));
112
+
113
+ PyObject* r = PyTuple_Pack(1, err);
114
+ Py_DECREF(err);
115
+
116
+ return r;
117
+ }
118
+
119
+ PyObject* method_MSXsavemsxfile(PyObject* self, PyObject* args)
120
+ {
121
+ char* fname = NULL;
122
+ if(!PyArg_ParseTuple(args, "s", &fname)) {
123
+ return NULL;
124
+ }
125
+
126
+ PyObject* err = PyLong_FromLong(MSXsavemsxfile(fname));
127
+
128
+ PyObject* r = PyTuple_Pack(1, err);
129
+ Py_DECREF(err);
130
+
131
+ return r;
132
+ }
133
+
134
+ PyObject* method_MSXreport(PyObject* self, PyObject* Py_UNUSED(args))
135
+ {
136
+ PyObject* err = PyLong_FromLong(MSXreport());
137
+
138
+ PyObject* r = PyTuple_Pack(1, err);
139
+ Py_DECREF(err);
140
+
141
+ return r;
142
+ }
143
+
144
+ PyObject* method_MSXclose(PyObject* self, PyObject* Py_UNUSED(args))
145
+ {
146
+ PyObject* err = PyLong_FromLong(MSXclose());
147
+
148
+ PyObject* r = PyTuple_Pack(1, err);
149
+ Py_DECREF(err);
150
+
151
+ return r;
152
+ }
153
+
154
+ PyObject* method_MSXENclose(PyObject* self, PyObject* Py_UNUSED(args))
155
+ {
156
+ PyObject* err = PyLong_FromLong(MSXENclose());
157
+
158
+ PyObject* r = PyTuple_Pack(1, err);
159
+ Py_DECREF(err);
160
+
161
+ return r;
162
+ }
163
+
164
+ PyObject* method_MSXgetindex(PyObject* self, PyObject* args)
165
+ {
166
+ int type, index;
167
+ char* id = NULL;
168
+
169
+ if(!PyArg_ParseTuple(args, "is", &type, &id)) {
170
+ return NULL;
171
+ }
172
+
173
+ PyObject* err = PyLong_FromLong(MSXgetindex(type, id, &index));
174
+ PyObject* pyIndex = PyLong_FromLong(index);
175
+
176
+ PyObject* r = PyTuple_Pack(2, err, pyIndex);
177
+ Py_DECREF(err);
178
+ Py_DECREF(pyIndex);
179
+
180
+ return r;
181
+ }
182
+
183
+ PyObject* method_MSXgetIDlen(PyObject* self, PyObject* args)
184
+ {
185
+ int type, index, len;
186
+ if(!PyArg_ParseTuple(args, "ii", &type, &index)) {
187
+ return NULL;
188
+ }
189
+
190
+ PyObject* err = PyLong_FromLong(MSXgetIDlen(type, index, &len));
191
+ PyObject* pyLen = PyLong_FromLong(len);
192
+
193
+ PyObject* r = PyTuple_Pack(2, err, pyLen);
194
+ Py_DECREF(err);
195
+ Py_DECREF(pyLen);
196
+
197
+ return r;
198
+ }
199
+
200
+ PyObject* method_MSXgetID(PyObject* self, PyObject* args)
201
+ {
202
+ int type, index;
203
+ if(!PyArg_ParseTuple(args, "ii", &type, &index)) {
204
+ return NULL;
205
+ }
206
+
207
+ char id[MAXID + 1]; // TODO: MSXgetIDlen
208
+ PyObject* err = PyLong_FromLong(MSXgetID(type, index, &id[0], MAXID));
209
+ PyObject* pyId = PyUnicode_FromString(&id[0]);
210
+
211
+ PyObject* r = PyTuple_Pack(2, err, pyId);
212
+ Py_DECREF(err);
213
+ Py_DECREF(pyId);
214
+
215
+ return r;
216
+ }
217
+
218
+ PyObject* method_MSXgetcount(PyObject* self, PyObject* args)
219
+ {
220
+ int type, count;
221
+ if(!PyArg_ParseTuple(args, "i", &type)) {
222
+ return NULL;
223
+ }
224
+
225
+ PyObject* err = PyLong_FromLong(MSXgetcount(type, &count));
226
+ PyObject* pyCount = PyLong_FromLong(count);
227
+
228
+ PyObject* r = PyTuple_Pack(2, err, pyCount);
229
+ Py_DECREF(err);
230
+ Py_DECREF(pyCount);
231
+
232
+ return r;
233
+ }
234
+
235
+ PyObject* method_MSXgetspecies(PyObject* self, PyObject* args)
236
+ {
237
+ int index, type;
238
+ char units[MAXUNITS];
239
+ double aTol, rTol;
240
+
241
+ if(!PyArg_ParseTuple(args, "i", &index)) {
242
+ return NULL;
243
+ }
244
+
245
+ PyObject* err = PyLong_FromLong(MSXgetspecies(index, &type, &units[0], &aTol, &rTol));
246
+ PyObject* pyType = PyLong_FromLong(type);
247
+ PyObject* pyUnits = PyUnicode_FromString(&units[0]);
248
+ PyObject* pyATol = PyFloat_FromDouble(aTol);
249
+ PyObject* pyRTol = PyFloat_FromDouble(rTol);
250
+
251
+ PyObject* r = PyTuple_Pack(5, err, pyType, pyUnits, pyATol, pyRTol);
252
+ Py_DECREF(err);
253
+ Py_DECREF(pyType);
254
+ Py_DECREF(pyUnits);
255
+ Py_DECREF(pyATol);
256
+ Py_DECREF(pyRTol);
257
+
258
+ return r;
259
+ }
260
+
261
+ PyObject* method_MSXgetconstant(PyObject* self, PyObject* args)
262
+ {
263
+ int index;
264
+ if(!PyArg_ParseTuple(args, "i", &index)) {
265
+ return NULL;
266
+ }
267
+
268
+ double value;
269
+ PyObject* err = PyLong_FromLong(MSXgetconstant(index, &value));
270
+ PyObject* pyValue = PyFloat_FromDouble(value);
271
+
272
+ PyObject* r = PyTuple_Pack(2, err, pyValue);
273
+ Py_DECREF(err);
274
+ Py_DECREF(pyValue);
275
+
276
+ return r;
277
+ }
278
+
279
+ PyObject* method_MSXgetparameter(PyObject* self, PyObject* args)
280
+ {
281
+ int type, index, param;
282
+ if(!PyArg_ParseTuple(args, "iii", &type, &index, &param)) {
283
+ return NULL;
284
+ }
285
+
286
+ double value;
287
+ PyObject* err = PyLong_FromLong(MSXgetparameter(type, index, param, &value));
288
+ PyObject* pyValue = PyFloat_FromDouble(value);
289
+
290
+ PyObject* r = PyTuple_Pack(2, err, pyValue);
291
+ Py_DECREF(err);
292
+ Py_DECREF(pyValue);
293
+
294
+ return r;
295
+ }
296
+
297
+ PyObject* method_MSXgetsource(PyObject* self, PyObject* args)
298
+ {
299
+ int node, species;
300
+ if(!PyArg_ParseTuple(args, "ii", &node, &species)) {
301
+ return NULL;
302
+ }
303
+
304
+ int type, pat;
305
+ double level;
306
+ PyObject* err = PyLong_FromLong(MSXgetsource(node, species, &type, &level, &pat));
307
+ PyObject* pyType = PyLong_FromLong(type);
308
+ PyObject* pyLevel = PyFloat_FromDouble(level);
309
+ PyObject* pyPat = PyLong_FromLong(pat);
310
+
311
+ PyObject* r = PyTuple_Pack(4, err, pyType, pyLevel, pyPat);
312
+ Py_DECREF(err);
313
+ Py_DECREF(pyType);
314
+ Py_DECREF(pyLevel);
315
+ Py_DECREF(pyPat);
316
+
317
+ return r;
318
+ }
319
+
320
+ PyObject* method_MSXgetpatternlen(PyObject* self, PyObject* args)
321
+ {
322
+ int pat, len;
323
+ if(!PyArg_ParseTuple(args, "i", &pat)) {
324
+ return NULL;
325
+ }
326
+
327
+ PyObject* err = PyLong_FromLong(MSXgetpatternlen(pat, &len));
328
+ PyObject* pyLen = PyLong_FromLong(len);
329
+
330
+ PyObject* r = PyTuple_Pack(2, err, pyLen);
331
+ Py_DECREF(err);
332
+ Py_DECREF(pyLen);
333
+
334
+ return r;
335
+ }
336
+
337
+ PyObject* method_MSXgetpatternvalue(PyObject* self, PyObject* args)
338
+ {
339
+ int pat, period;
340
+ if(!PyArg_ParseTuple(args, "ii", &pat, &period)) {
341
+ return NULL;
342
+ }
343
+
344
+ double value;
345
+ PyObject* err = PyLong_FromLong(MSXgetpatternvalue(pat, period, &value));
346
+ PyObject* pyValue = PyFloat_FromDouble(value);
347
+
348
+ PyObject* r = PyTuple_Pack(2, err, pyValue);
349
+ Py_DECREF(err);
350
+ Py_DECREF(pyValue);
351
+
352
+ return r;
353
+ }
354
+
355
+ PyObject* method_MSXgetinitqual(PyObject* self, PyObject* args)
356
+ {
357
+ int type, index, species;
358
+ if(!PyArg_ParseTuple(args, "iii", &type, &index, &species)) {
359
+ return NULL;
360
+ }
361
+
362
+ double value;
363
+ PyObject* err = PyLong_FromLong(MSXgetinitqual(type, index, species, &value));
364
+ PyObject* pyValue = PyFloat_FromDouble(value);
365
+
366
+ PyObject* r = PyTuple_Pack(2, err, pyValue);
367
+ Py_DECREF(err);
368
+ Py_DECREF(pyValue);
369
+
370
+ return r;
371
+ }
372
+
373
+ PyObject* method_MSXgetqual(PyObject* self, PyObject* args)
374
+ {
375
+ int type, index, species;
376
+ if(!PyArg_ParseTuple(args, "iii", &type, &index, &species)) {
377
+ return NULL;
378
+ }
379
+
380
+ double value;
381
+ PyObject* err = PyLong_FromLong(MSXgetqual(type, index, species, &value));
382
+ PyObject* pyValue = PyFloat_FromDouble(value);
383
+
384
+ PyObject* r = PyTuple_Pack(2, err, pyValue);
385
+ Py_DECREF(err);
386
+ Py_DECREF(pyValue);
387
+
388
+ return r;
389
+ }
390
+
391
+ PyObject* method_MSXgeterror(PyObject* self, PyObject* args)
392
+ {
393
+ int code;
394
+ if(!PyArg_ParseTuple(args, "i", &code)) {
395
+ return NULL;
396
+ }
397
+
398
+ char msg[MAXLINE + 1];
399
+ PyObject* err = PyLong_FromLong(MSXgeterror(code, &msg[0], MAXLINE));
400
+ PyObject* pyMsg = PyUnicode_FromString(&msg[0]);
401
+
402
+ PyObject* r = PyTuple_Pack(2, err, pyMsg);
403
+ Py_DECREF(err);
404
+ Py_DECREF(pyMsg);
405
+
406
+ return r;
407
+ }
408
+
409
+ PyObject* method_MSXsetconstant(PyObject* self, PyObject* args)
410
+ {
411
+ int index;
412
+ double value;
413
+ if(!PyArg_ParseTuple(args, "id", &index, &value)) {
414
+ return NULL;
415
+ }
416
+
417
+ PyObject* err = PyLong_FromLong(MSXsetconstant(index, value));
418
+
419
+ PyObject* r = PyTuple_Pack(1, err);
420
+ Py_DECREF(err);
421
+
422
+ return r;
423
+ }
424
+
425
+ PyObject* method_MSXsetparameter(PyObject* self, PyObject* args)
426
+ {
427
+ int type, index, param;
428
+ double value;
429
+ if(!PyArg_ParseTuple(args, "iiid", &type, &index, &param, &value)) {
430
+ return NULL;
431
+ }
432
+
433
+ PyObject* err = PyLong_FromLong(MSXsetparameter(type, index, param, value));
434
+
435
+ PyObject* r = PyTuple_Pack(1, err);
436
+ Py_DECREF(err);
437
+
438
+ return r;
439
+ }
440
+
441
+ PyObject* method_MSXsetinitqual(PyObject* self, PyObject* args)
442
+ {
443
+ int type, index, species;
444
+ double value;
445
+ if(!PyArg_ParseTuple(args, "iiid", &type, &index, &species, &value)) {
446
+ return NULL;
447
+ }
448
+
449
+ PyObject* err = PyLong_FromLong(MSXsetinitqual(type, index, species, value));
450
+
451
+ PyObject* r = PyTuple_Pack(1, err);
452
+ Py_DECREF(err);
453
+
454
+ return r;
455
+ }
456
+
457
+ PyObject* method_MSXsetsource(PyObject* self, PyObject* args)
458
+ {
459
+ int node, species, type, pat;
460
+ double level;
461
+ if(!PyArg_ParseTuple(args, "iiidi", &node, &species, &type, &level, &pat)) {
462
+ return NULL;
463
+ }
464
+
465
+ PyObject* err = PyLong_FromLong(MSXsetsource(node, species, type, level, pat));
466
+
467
+ PyObject* r = PyTuple_Pack(1, err);
468
+ Py_DECREF(err);
469
+
470
+ return r;
471
+ }
472
+
473
+ PyObject* method_MSXsetpatternvalue(PyObject* self, PyObject* args)
474
+ {
475
+ int pat, period;
476
+ double value;
477
+ if(!PyArg_ParseTuple(args, "iid", &pat, &period, &value)) {
478
+ return NULL;
479
+ }
480
+
481
+ PyObject* err = PyLong_FromLong(MSXsetpatternvalue(pat, period, value));
482
+
483
+ PyObject* r = PyTuple_Pack(1, err);
484
+ Py_DECREF(err);
485
+
486
+ return r;
487
+ }
488
+
489
+ PyObject* method_MSXsetpattern(PyObject* self, PyObject* args)
490
+ {
491
+ int pat, len;
492
+ PyListObject* mult = NULL;
493
+ if(!PyArg_ParseTuple(args, "iOi", &pat, &mult, &len)) {
494
+ return NULL;
495
+ }
496
+
497
+ double* multRaw = (double*) malloc(sizeof(double) * len);
498
+ for(int i=0; i != len; i++) {
499
+ multRaw[i] = PyFloat_AsDouble(PyList_GET_ITEM(mult, i));
500
+ }
501
+
502
+ PyObject* err = PyLong_FromLong(MSXsetpattern(pat, multRaw, len));
503
+ free(multRaw);
504
+
505
+ PyObject* r = PyTuple_Pack(1, err);
506
+ Py_DECREF(err);
507
+
508
+ return r;
509
+ }
510
+
511
+ PyObject* method_MSXaddpattern(PyObject* self, PyObject* args)
512
+ {
513
+ char* id = NULL;
514
+ if(!PyArg_ParseTuple(args, "s", &id)) {
515
+ return NULL;
516
+ }
517
+
518
+ PyObject* err = PyLong_FromLong(MSXaddpattern(id));
519
+
520
+ PyObject* r = PyTuple_Pack(1, err);
521
+ Py_DECREF(err);
522
+
523
+ return r;
524
+ }