forked from adrpo/OMCallPythonAdvanced
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.mo
More file actions
160 lines (139 loc) · 6.59 KB
/
package.mo
File metadata and controls
160 lines (139 loc) · 6.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package OMCallPythonAdvanced
extends Modelica.Icons.Package;
package Py
extends Modelica.Icons.FunctionsPackage;
class PythonHandle
extends ExternalObject;
function constructor "External object constructor will intialized python"
output PythonHandle pyHandle;
external "C" pyHandle = omc_PyInit() annotation(
IncludeDirectory = "modelica://OMCallPythonAdvanced/Resources/C-Sources",
Include = "#include \"OMCallPythonAdvanced.h\"");
end constructor;
function destructor "External object destructor that frees the python dll"
input PythonHandle pyHandle;
external "C" omc_PyEnd(pyHandle) annotation(
IncludeDirectory = "modelica://OMCallPythonAdvanced/Resources/C-Sources",
Include = "#include \"OMCallPythonAdvanced.h\"");
end destructor;
end PythonHandle;
function initialize
input PythonHandle pyHandle;
external "C" omc_Py_Initialize(pyHandle) annotation(
IncludeDirectory = "modelica://OMCallPythonAdvanced/Resources/C-Sources",
Include = "#include \"OMCallPythonAdvanced.h\"",
LibraryDirectory = "modelica://OMCallPythonAdvanced/Resources/Library/",
Library = {"OMCallPythonAdvanced", "python39"});
end initialize;
function run
input PythonHandle pyHandle;
input String pyProgram;
output Integer status "0 is OK, -1 is bad";
external "C" status = omc_PyRun_SimpleString(pyHandle, pyProgram) annotation(
IncludeDirectory = "modelica://OMCallPythonAdvanced/Resources/C-Sources",
Include = "#include \"OMCallPythonAdvanced.h\"",
LibraryDirectory = "modelica://OMCallPythonAdvanced/Resources/Library/",
Library = {"OMCallPythonAdvanced", "python39"});
end run;
function twoRealArgumentsReturnReal
input PythonHandle pyHandle;
input Real x;
input Real y;
input String pyProgram "python code";
input String pyModuleName "the module to import";
input String pyFunctionName "the function to call from the module";
output Real z;
output Integer status "0 if OK, -1 if error";
external "C" status = omc_PyRun_TwoArgumentsOneReturn(pyHandle, x, y, pyProgram, pyModuleName, pyFunctionName, z) annotation(
IncludeDirectory = "modelica://OMCallPythonAdvanced/Resources/C-Sources",
Include = "#include \"OMCallPythonAdvanced.h\"",
LibraryDirectory = "modelica://OMCallPythonAdvanced/Resources/Library/",
Library = {"OMCallPythonAdvanced", "python39"});
end twoRealArgumentsReturnReal;
function fourRealArgumentsReturnReal
input PythonHandle pyHandle;
input Real x;
input Real y;
input Real a;
input Real b;
input String pyProgram "python code";
input String pyModuleName "the module to import";
input String pyFunctionName "the function to call from the module";
output Real z;
output Integer status "0 if OK, -1 if error";
external "C" status = omc_PyRun_FourArgumentsOneReturn(pyHandle, x, y, a, b, pyProgram, pyModuleName, pyFunctionName, z) annotation(
IncludeDirectory = "modelica://OMCallPythonAdvanced/Resources/C-Sources",
Include = "#include \"OMCallPythonAdvanced.h\"",
LibraryDirectory = "modelica://OMCallPythonAdvanced/Resources/Library/",
Library = {"OMCallPythonAdvanced", "python39"});
end fourRealArgumentsReturnReal;
function fiveRealArgumentsReturnReal
input PythonHandle pyHandle;
input Real x;
input Real y;
input Real a;
input Real b;
input Real c;
input String pyProgram "python code";
input String pyModuleName "the module to import";
input String pyFunctionName "the function to call from the module";
output Real z;
output Integer status "0 if OK, -1 if error";
external "C" status = omc_PyRun_FiveArgumentsOneReturn(pyHandle, x, y, a, b, c, pyProgram, pyModuleName, pyFunctionName, z) annotation(
IncludeDirectory = "modelica://OMCallPythonAdvanced/Resources/C-Sources",
Include = "#include \"OMCallPythonAdvanced.h\"",
LibraryDirectory = "modelica://OMCallPythonAdvanced/Resources/Library/",
Library = {"OMCallPythonAdvanced", "python39"});
end fiveRealArgumentsReturnReal;
function sixRealArgumentsReturnReal
input PythonHandle pyHandle;
input Real x;
input Real y;
input Real a;
input Real b;
input Real c;
input Real d;
input String pyProgram "python code";
input String pyModuleName "the module to import";
input String pyFunctionName "the function to call from the module";
output Real z;
output Integer status "0 if OK, -1 if error";
external "C" status = omc_PyRun_SixArgumentsOneReturn(pyHandle, x, y, a, b, c, d, pyProgram, pyModuleName, pyFunctionName, z) annotation(
IncludeDirectory = "modelica://OMCallPythonAdvanced/Resources/C-Sources",
Include = "#include \"OMCallPythonAdvanced.h\"",
LibraryDirectory = "modelica://OMCallPythonAdvanced/Resources/Library/",
Library = {"OMCallPythonAdvanced", "python39"});
end sixRealArgumentsReturnReal;
function nineRealArgumentsReturnReal
input PythonHandle pyHandle;
input Real x;
input Real y;
input Real a;
input Real b;
input Real c;
input Real d;
input Real e;
input Real f;
input Real g;
input String pyProgram "python code";
input String pyModuleName "the module to import";
input String pyFunctionName "the function to call from the module";
output Real z;
output Integer status "0 if OK, -1 if error";
external "C" status = omc_PyRun_NineArgumentsOneReturn(pyHandle, x, y, a, b, c, d, e, f, g, pyProgram, pyModuleName, pyFunctionName, z) annotation(
IncludeDirectory = "modelica://OMCallPythonAdvanced/Resources/C-Sources",
Include = "#include \"OMCallPythonAdvanced.h\"",
LibraryDirectory = "modelica://OMCallPythonAdvanced/Resources/Library/",
Library = {"OMCallPythonAdvanced", "python39"});
end nineRealArgumentsReturnReal;
function finalize
input PythonHandle pyHandle;
external "C" omc_Py_Finalize(pyHandle) annotation(
IncludeDirectory = "modelica://OMCallPythonAdvanced/Resources/C-Sources",
Include = "#include \"OMCallPythonAdvanced.h\"",
LibraryDirectory = "modelica://OMCallPythonAdvanced/Resources/Library/",
Library = {"OMCallPythonAdvanced", "python39"});
end finalize;
end Py;
annotation(version="1.0.0");
end OMCallPythonAdvanced;