Buildings.Utilities.IO.Python27.Functions.BaseClasses
Package with functions that call Python
Information
This package contains functions that call Python.
Extends from Modelica.Icons.BasesPackage (Icon for packages containing base classes).
Package Content
Name | Description |
---|---|
PythonObject | class used to create the external object: PythonObject |
exchange | Function that communicates with Python |
Buildings.Utilities.IO.Python27.Functions.BaseClasses.PythonObject
class used to create the external object: PythonObject
Information
Class derived from ExternalObject
having two local external functions
named destructor
and constructor
.
These functions create and release an external object that allows the storage of a Python object.
Extends from ExternalObject.
Modelica definition
class PythonObject
"class used to create the external object: PythonObject"
extends ExternalObject;
function constructor
"Construct an external object that can be used to store a Python object"
output PythonObject pytObj;
external "C" pytObj = initPythonMemory();
end constructor;
function destructor "Release memory"
input PythonObject pytObj;
external "C" freePythonMemory(pytObj);
end destructor;
end PythonObject;
Buildings.Utilities.IO.Python27.Functions.BaseClasses.exchange
Function that communicates with Python
Information
This function exchanges data with Python. See Buildings.Utilities.IO.Python27.UsersGuide for instructions, and Buildings.Utilities.IO.Python27.Functions.Examples for examples.
Inputs
Type | Name | Default | Description |
---|---|---|---|
String | moduleName | Name of the python module that contains the function | |
String | functionName | moduleName | Name of the python function |
PythonObject | pytObj | Memory that holds the Python object | |
Boolean | passPythonObject | Set to true if the Python function returns and receives an object, see User's Guide | |
String | pythonPath | Value of PYTHONPATH environment variable | |
Real | dblWri[max(1, nDblWri)] | Double values to write | |
Integer | intWri[max(1, nIntWri)] | Integer values to write | |
String | strWri[max(1, nStrWri)] | String values to write | |
Integer | nDblWri | nDblWri( ... | Number of double values to write |
Integer | nDblRea | nDblRea( ... | Number of double values to read |
Integer | nIntWri | nIntWri( ... | Number of integer values to write |
Integer | nIntRea | nIntRea( ... | Number of integer values to read |
Integer | nStrWri | nStrWri( ... | Number of strings to write |
Outputs
Type | Name | Description |
---|---|---|
Real | dblRea[max(1, nDblRea)] | Double values returned by Python |
Integer | intRea[max(1, nIntRea)] | Integer values returned by Python |
Modelica definition
function exchange "Function that communicates with Python"
input String moduleName
"Name of the python module that contains the function";
input String functionName=moduleName "Name of the python function";
input BaseClasses.PythonObject pytObj "Memory that holds the Python object";
input Boolean passPythonObject
"Set to true if the Python function returns and receives an object, see User's Guide";
input String pythonPath "Value of PYTHONPATH environment variable";
input Real dblWri[max(1, nDblWri)] "Double values to write";
input Integer intWri[max(1, nIntWri)] "Integer values to write";
input String strWri[max(1, nStrWri)] "String values to write";
input Integer nDblWri(min=0) "Number of double values to write";
input Integer nDblRea(min=0) "Number of double values to read";
input Integer nIntWri(min=0) "Number of integer values to write";
input Integer nIntRea(min=0) "Number of integer values to read";
input Integer nStrWri(min=0) "Number of strings to write";
// input Integer nStrRea(min=0) "Number of strings to read";
// input Integer strLenRea(min=0)
// "Maximum length of each string that is read. If exceeded, the simulation stops with an error";
output Real dblRea[max(1, nDblRea)] "Double values returned by Python";
output Integer intRea[max(1, nIntRea)] "Integer values returned by Python";
external "C" pythonExchangeValues(moduleName, functionName,
pythonPath,
dblWri, nDblWri,
dblRea, nDblRea,
intWri, nIntWri,
intRea, nIntRea,
strWri, nStrWri,
pytObj,
passPythonObject);
end exchange;