-
Notifications
You must be signed in to change notification settings - Fork 1
/
package.mo
76 lines (64 loc) · 2.95 KB
/
package.mo
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
package OMCallPythonAdvanced
package Py
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", "python38"});
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", "python38"});
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", "python38"});
end twoRealArgumentsReturnReal;
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", "python38"});
end finalize;
end Py;
end OMCallPythonAdvanced;