pythonfmu3 0.1.16__tar.gz → 0.1.18__tar.gz
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.
- {pythonfmu3-0.1.16/pythonfmu3.egg-info → pythonfmu3-0.1.18}/PKG-INFO +4 -2
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/README.md +3 -1
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/__init__.py +2 -2
- pythonfmu3-0.1.18/pythonfmu3/_version.py +1 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/builder.py +25 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/fmi3slave.py +7 -2
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/build_unix.sh +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_cs.hpp +4 -1
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/cppfmu/fmi_functions.cpp +15 -13
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/pythonfmu/PySlaveInstance.cpp +32 -6
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/pythonfmu/PySlaveInstance.hpp +7 -1
- pythonfmu3-0.1.18/pythonfmu3/resources/binaries/x86_64-linux/libpythonfmu-export.so +0 -0
- pythonfmu3-0.1.18/pythonfmu3/resources/binaries/x86_64-windows/pythonfmu-export.dll +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/test_builder.py +17 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18/pythonfmu3.egg-info}/PKG-INFO +4 -2
- pythonfmu3-0.1.16/pythonfmu3/_version.py +0 -1
- pythonfmu3-0.1.16/pythonfmu3/resources/binaries/x86_64-linux/libpythonfmu-export.so +0 -0
- pythonfmu3-0.1.16/pythonfmu3/resources/binaries/x86_64-windows/pythonfmu-export.dll +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/LICENSE +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/MANIFEST.in +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/__main__.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/default_experiment.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/deploy.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/enums.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/logmsg.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/osutil.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/.clang-format +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/CMakeLists.txt +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/build_win.sh +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/CMakeLists.txt +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_common.hpp +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_cs.cpp +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/fmi/fmi3FunctionTypes.h +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/fmi/fmi3Functions.h +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/fmi/fmi3PlatformTypes.h +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/pythonfmu/IPyState.hpp +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/pythonfmu/PyState.hpp +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/__init__.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/conftest.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/data/csvdemo.csv +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/data/hello.txt +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/slaves/PythonSlaveWithException.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/slaves/localmodule.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/slaves/pythonslave.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/slaves/pythonslave_read_file.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/slaves/slavewithdep.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/test_deploy.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/test_fmi3slave.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/test_integration.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/test_logger.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/test_multiple_fmus.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/test_variables.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/tests/utils.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/unit.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/variable_types.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/variables.py +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3.egg-info/SOURCES.txt +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3.egg-info/dependency_links.txt +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3.egg-info/entry_points.txt +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3.egg-info/not-zip-safe +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3.egg-info/requires.txt +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3.egg-info/top_level.txt +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/setup.cfg +0 -0
- {pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: pythonfmu3
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.18
|
|
4
4
|
Summary: A lightweight framework that enables the packaging of Python3.x code as co-simulation FMUs.
|
|
5
5
|
Home-page: https://github.com/stephensmith25/PythonFMU3
|
|
6
6
|
Author: Stephen Smith
|
|
@@ -62,7 +62,7 @@ pip install pythonfmu3
|
|
|
62
62
|
3. Run `pythonfmu3 build` to create the fmu.
|
|
63
63
|
|
|
64
64
|
```
|
|
65
|
-
usage: pythonfmu3 build [-h] -f SCRIPT_FILE [-d DEST] [--doc DOCUMENTATION_FOLDER] [--no-external-tool]
|
|
65
|
+
usage: pythonfmu3 build [-h] -f SCRIPT_FILE [-d DEST] [--doc DOCUMENTATION_FOLDER] [--terminals TERMINALS_FILE] [--no-external-tool]
|
|
66
66
|
[--no-variable-step] [--interpolate-inputs] [--only-one-per-process] [--handle-state]
|
|
67
67
|
[--serialize-state] [--use-memory-management]
|
|
68
68
|
[Project files [Project files ...]]
|
|
@@ -79,6 +79,8 @@ optional arguments:
|
|
|
79
79
|
-d DEST, --dest DEST Where to save the FMU.
|
|
80
80
|
--doc DOCUMENTATION_FOLDER
|
|
81
81
|
Documentation folder to include in the FMU.
|
|
82
|
+
--terminals TERMINALS_FILE
|
|
83
|
+
Terminals file (terminalsAndIcons.xml) to include in the FMU.
|
|
82
84
|
--no-external-tool If given, needsExecutionTool=false
|
|
83
85
|
--no-variable-step If given, canHandleVariableCommunicationStepSize=false
|
|
84
86
|
--interpolate-inputs If given, canInterpolateInputs=true
|
|
@@ -36,7 +36,7 @@ pip install pythonfmu3
|
|
|
36
36
|
3. Run `pythonfmu3 build` to create the fmu.
|
|
37
37
|
|
|
38
38
|
```
|
|
39
|
-
usage: pythonfmu3 build [-h] -f SCRIPT_FILE [-d DEST] [--doc DOCUMENTATION_FOLDER] [--no-external-tool]
|
|
39
|
+
usage: pythonfmu3 build [-h] -f SCRIPT_FILE [-d DEST] [--doc DOCUMENTATION_FOLDER] [--terminals TERMINALS_FILE] [--no-external-tool]
|
|
40
40
|
[--no-variable-step] [--interpolate-inputs] [--only-one-per-process] [--handle-state]
|
|
41
41
|
[--serialize-state] [--use-memory-management]
|
|
42
42
|
[Project files [Project files ...]]
|
|
@@ -53,6 +53,8 @@ optional arguments:
|
|
|
53
53
|
-d DEST, --dest DEST Where to save the FMU.
|
|
54
54
|
--doc DOCUMENTATION_FOLDER
|
|
55
55
|
Documentation folder to include in the FMU.
|
|
56
|
+
--terminals TERMINALS_FILE
|
|
57
|
+
Terminals file (terminalsAndIcons.xml) to include in the FMU.
|
|
56
58
|
--no-external-tool If given, needsExecutionTool=false
|
|
57
59
|
--no-variable-step If given, canHandleVariableCommunicationStepSize=false
|
|
58
60
|
--interpolate-inputs If given, canInterpolateInputs=true
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from ._version import __version__
|
|
2
2
|
from .builder import FmuBuilder
|
|
3
|
-
from .enums import Fmi3Causality, Fmi3Initial, Fmi3Variability
|
|
4
|
-
from .fmi3slave import Fmi3Slave
|
|
3
|
+
from .enums import Fmi3Causality, Fmi3Initial, Fmi3Status, Fmi3Variability
|
|
4
|
+
from .fmi3slave import Fmi3Slave, Fmi3StepResult
|
|
5
5
|
from .variables import Boolean, Enumeration, Int32, Int64, UInt64, Float64, String, Dimension
|
|
6
6
|
from .default_experiment import DefaultExperiment
|
|
7
7
|
from .variable_types import Float64Type, EnumerationType
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.18"
|
|
@@ -66,6 +66,7 @@ class FmuBuilder:
|
|
|
66
66
|
dest: FilePath = ".",
|
|
67
67
|
project_files: Iterable[FilePath] = set(),
|
|
68
68
|
documentation_folder: Optional[FilePath] = None,
|
|
69
|
+
terminals : Optional[FilePath] = None,
|
|
69
70
|
**options,
|
|
70
71
|
) -> Path:
|
|
71
72
|
script_file = Path(script_file)
|
|
@@ -85,6 +86,17 @@ class FmuBuilder:
|
|
|
85
86
|
raise ValueError(
|
|
86
87
|
f"The documentation folder does not exists {documentation_folder!s}"
|
|
87
88
|
)
|
|
89
|
+
|
|
90
|
+
if terminals is not None:
|
|
91
|
+
terminals = Path(terminals)
|
|
92
|
+
if not terminals.exists():
|
|
93
|
+
raise ValueError(
|
|
94
|
+
f"The specified terminalsAndIcons file does not exists {terminals!s}"
|
|
95
|
+
)
|
|
96
|
+
if not terminals.name == "terminalsAndIcons.xml":
|
|
97
|
+
raise ValueError(
|
|
98
|
+
f"Incorrect terminal name {terminals!s}. Terminal file must be named terminalsAndIcons.xml"
|
|
99
|
+
)
|
|
88
100
|
|
|
89
101
|
module_name = script_file.stem
|
|
90
102
|
|
|
@@ -178,6 +190,12 @@ class FmuBuilder:
|
|
|
178
190
|
relative_f = f.relative_to(documentation_folder)
|
|
179
191
|
zip_fmu.write(f, arcname=(documentation / relative_f))
|
|
180
192
|
|
|
193
|
+
if terminals is not None:
|
|
194
|
+
terminalsFolder = Path("terminalsAndIcons")
|
|
195
|
+
relative_f = terminals.relative_to(terminals.parent)
|
|
196
|
+
zip_fmu.write(f, arcname=(terminalsFolder / relative_f))
|
|
197
|
+
|
|
198
|
+
|
|
181
199
|
# Add the model description
|
|
182
200
|
xml_str = parseString(tostring(xml, "UTF-8"))
|
|
183
201
|
zip_fmu.writestr(
|
|
@@ -215,6 +233,13 @@ def create_command_parser(parser: argparse.ArgumentParser):
|
|
|
215
233
|
default=None
|
|
216
234
|
)
|
|
217
235
|
|
|
236
|
+
parser.add_argument(
|
|
237
|
+
"--terminals",
|
|
238
|
+
dest="terminals",
|
|
239
|
+
help="Terminals file (terminalsAndIcons.xml) to include in the FMU.",
|
|
240
|
+
default=None
|
|
241
|
+
)
|
|
242
|
+
|
|
218
243
|
for option in FMI3_MODEL_OPTIONS:
|
|
219
244
|
action = "store_false" if option.value else "store_true"
|
|
220
245
|
parser.add_argument(
|
|
@@ -5,7 +5,7 @@ import datetime
|
|
|
5
5
|
from abc import ABC, abstractmethod
|
|
6
6
|
from collections import OrderedDict, namedtuple
|
|
7
7
|
from pathlib import Path
|
|
8
|
-
from typing import Any, ClassVar, Dict, List, Optional
|
|
8
|
+
from typing import Any, ClassVar, Dict, List, NamedTuple, Optional
|
|
9
9
|
from uuid import uuid1
|
|
10
10
|
from xml.etree.ElementTree import Element, SubElement
|
|
11
11
|
|
|
@@ -27,6 +27,11 @@ FMI3_MODEL_OPTIONS: List[ModelOptions] = [
|
|
|
27
27
|
ModelOptions("canSerializeFMUState", False, "serialize-state")
|
|
28
28
|
]
|
|
29
29
|
|
|
30
|
+
class Fmi3StepResult(NamedTuple):
|
|
31
|
+
status: Fmi3Status = Fmi3Status.ok
|
|
32
|
+
eventHandlingNeeded: bool = False
|
|
33
|
+
terminateSimulation: bool = False
|
|
34
|
+
earlyReturn: bool = False
|
|
30
35
|
|
|
31
36
|
class Fmi3Slave(ABC):
|
|
32
37
|
"""Abstract facade class to execute Python through FMI standard."""
|
|
@@ -235,7 +240,7 @@ class Fmi3Slave(ABC):
|
|
|
235
240
|
pass
|
|
236
241
|
|
|
237
242
|
@abstractmethod
|
|
238
|
-
def do_step(self, current_time: float, step_size: float) ->
|
|
243
|
+
def do_step(self, current_time: float, step_size: float) -> Fmi3StepResult:
|
|
239
244
|
pass
|
|
240
245
|
|
|
241
246
|
def terminate(self):
|
|
File without changes
|
{pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_cs.hpp
RENAMED
|
@@ -124,10 +124,13 @@ public:
|
|
|
124
124
|
FMIString value[]) const;
|
|
125
125
|
|
|
126
126
|
// Called from fmi3DoStep()/fmiDoStep(). Must be implemented in model code.
|
|
127
|
-
virtual
|
|
127
|
+
virtual FMIStatus DoStep(
|
|
128
128
|
FMIFloat64 currentCommunicationPoint,
|
|
129
129
|
FMIFloat64 communicationStepSize,
|
|
130
130
|
FMIBoolean newStep,
|
|
131
|
+
FMIBoolean* eventHandlingNeeded,
|
|
132
|
+
FMIBoolean* terminateSimulation,
|
|
133
|
+
FMIBoolean* earlyReturn,
|
|
131
134
|
FMIFloat64& endOfStep) = 0;
|
|
132
135
|
|
|
133
136
|
virtual void GetFMUstate(fmi3FMUState& state) = 0;
|
{pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/cppfmu/fmi_functions.cpp
RENAMED
|
@@ -50,7 +50,7 @@ struct Component
|
|
|
50
50
|
Component(cppfmu::FMIComponentEnvironment instanceEnvironment,
|
|
51
51
|
cppfmu::FMICallbackLogger logCallback,
|
|
52
52
|
cppfmu::FMIBoolean loggingOn) : loggerSettings{std::make_shared<cppfmu::Logger::Settings>()},
|
|
53
|
-
logger{instanceEnvironment, logCallback, loggerSettings}
|
|
53
|
+
logger{instanceEnvironment, logCallback, loggerSettings}
|
|
54
54
|
{
|
|
55
55
|
loggerSettings->debugLoggingEnabled = (loggingOn == cppfmu::FMITrue);
|
|
56
56
|
}
|
|
@@ -62,7 +62,6 @@ struct Component
|
|
|
62
62
|
|
|
63
63
|
// Co-simulation
|
|
64
64
|
std::unique_ptr<cppfmu::SlaveInstance> slave;
|
|
65
|
-
cppfmu::FMIFloat64 lastSuccessfulTime;
|
|
66
65
|
};
|
|
67
66
|
} // namespace
|
|
68
67
|
|
|
@@ -659,27 +658,30 @@ fmi3Status fmi3DoStep(
|
|
|
659
658
|
fmi3Instance c,
|
|
660
659
|
fmi3Float64 currentCommunicationPoint,
|
|
661
660
|
fmi3Float64 communicationStepSize,
|
|
662
|
-
fmi3Boolean
|
|
663
|
-
fmi3Boolean
|
|
664
|
-
fmi3Boolean
|
|
665
|
-
fmi3Boolean
|
|
666
|
-
fmi3Float64*)
|
|
661
|
+
fmi3Boolean noSetFmuStatePriorToCurrentPoint,
|
|
662
|
+
fmi3Boolean* eventHandlingNeeded ,
|
|
663
|
+
fmi3Boolean* terminateSimulation,
|
|
664
|
+
fmi3Boolean* earlyReturn,
|
|
665
|
+
fmi3Float64* lastSuccessfulTime)
|
|
667
666
|
{
|
|
668
667
|
const auto component = reinterpret_cast<Component*>(c);
|
|
669
668
|
try {
|
|
670
669
|
double endTime = currentCommunicationPoint;
|
|
671
|
-
const auto
|
|
670
|
+
const auto status = component->slave->DoStep(
|
|
672
671
|
currentCommunicationPoint,
|
|
673
672
|
communicationStepSize,
|
|
674
|
-
|
|
673
|
+
noSetFmuStatePriorToCurrentPoint,
|
|
674
|
+
eventHandlingNeeded,
|
|
675
|
+
terminateSimulation,
|
|
676
|
+
earlyReturn,
|
|
675
677
|
endTime);
|
|
676
|
-
if (
|
|
677
|
-
|
|
678
|
+
if (status == fmi3Status::fmi3OK) {
|
|
679
|
+
*lastSuccessfulTime =
|
|
678
680
|
currentCommunicationPoint + communicationStepSize;
|
|
679
681
|
return fmi3OK;
|
|
680
682
|
} else {
|
|
681
|
-
|
|
682
|
-
return
|
|
683
|
+
*lastSuccessfulTime = endTime;
|
|
684
|
+
return status;
|
|
683
685
|
}
|
|
684
686
|
} catch (const cppfmu::FatalError& e) {
|
|
685
687
|
component->logger.Log(fmi3Fatal, "", e.what());
|
|
@@ -200,20 +200,46 @@ void PySlaveInstance::ExitInitializationMode()
|
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
cppfmu::FMIStatus PySlaveInstance::DoStep(cppfmu::FMIFloat64 currentTime,
|
|
204
|
+
cppfmu::FMIFloat64 stepSize,
|
|
205
|
+
cppfmu::FMIBoolean noSetFmuStatePriorToCurrentPoint,
|
|
206
|
+
cppfmu::FMIBoolean* eventHandlingNeeded,
|
|
207
|
+
cppfmu::FMIBoolean* terminateSimulation,
|
|
208
|
+
cppfmu::FMIBoolean* earlyReturn,
|
|
209
|
+
cppfmu::FMIFloat64& endOfStep)
|
|
210
|
+
{
|
|
211
|
+
cppfmu::FMIStatus fmuStatus = cppfmu::FMIOK;
|
|
212
|
+
py_safe_run([this, &fmuStatus, currentTime, stepSize, terminateSimulation](PyGILState_STATE gilState) {
|
|
207
213
|
auto f = PyObject_CallMethod(pInstance_, "do_step", "(dd)", currentTime, stepSize);
|
|
208
214
|
if (f == nullptr) {
|
|
209
215
|
handle_py_exception("[doStep] PyObject_CallMethod", gilState);
|
|
210
216
|
}
|
|
211
|
-
|
|
217
|
+
|
|
218
|
+
if (PyObject_HasAttrString(f, "status")) {
|
|
219
|
+
PyObject* pyStatus = PyObject_GetAttrString(f, "status");
|
|
220
|
+
if (pyStatus) {
|
|
221
|
+
fmuStatus = static_cast<cppfmu::FMIStatus>(PyLong_AsLong(pyStatus));
|
|
222
|
+
Py_DECREF(pyStatus);
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
bool status = static_cast<bool>(PyObject_IsTrue(f));
|
|
226
|
+
if (!status) {
|
|
227
|
+
fmuStatus = cppfmu::FMIDiscard;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (PyObject_HasAttrString(f, "terminateSimulation")) {
|
|
232
|
+
PyObject* pyTerminateSimulation = PyObject_GetAttrString(f, "terminateSimulation");
|
|
233
|
+
if (pyTerminateSimulation) {
|
|
234
|
+
*terminateSimulation = static_cast<bool>(PyObject_IsTrue(pyTerminateSimulation));
|
|
235
|
+
Py_DECREF(pyTerminateSimulation);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
212
238
|
Py_DECREF(f);
|
|
213
239
|
clearLogBuffer();
|
|
214
240
|
});
|
|
215
241
|
|
|
216
|
-
return
|
|
242
|
+
return fmuStatus;
|
|
217
243
|
}
|
|
218
244
|
|
|
219
245
|
void PySlaveInstance::Reset()
|
|
@@ -25,7 +25,13 @@ public:
|
|
|
25
25
|
void ExitInitializationMode() override;
|
|
26
26
|
void Terminate() override;
|
|
27
27
|
void Reset() override;
|
|
28
|
-
|
|
28
|
+
cppfmu::FMIStatus DoStep(cppfmu::FMIFloat64 currentCommunicationPoint,
|
|
29
|
+
cppfmu::FMIFloat64 communicationStepSize,
|
|
30
|
+
cppfmu::FMIBoolean newStep,
|
|
31
|
+
cppfmu::FMIBoolean* eventHandlingNeeded,
|
|
32
|
+
cppfmu::FMIBoolean* terminateSimulation,
|
|
33
|
+
cppfmu::FMIBoolean* earlyReturn,
|
|
34
|
+
cppfmu::FMIFloat64& endOfStep) override;
|
|
29
35
|
|
|
30
36
|
void SetFloat64(const cppfmu::FMIValueReference* vr, std::size_t nvr, const cppfmu::FMIFloat64* value, std::size_t nValues) override;
|
|
31
37
|
void SetInt32(const cppfmu::FMIValueReference* vr, std::size_t nvr, const cppfmu::FMIInt32* value) override;
|
|
Binary file
|
|
Binary file
|
|
@@ -176,3 +176,20 @@ def test_documentation(tmp_path):
|
|
|
176
176
|
|
|
177
177
|
assert "documentation/index.html" in names
|
|
178
178
|
assert "documentation/licenses/license.txt" in names
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def test_terminals(tmp_path):
|
|
182
|
+
script_file = Path(__file__).parent / "slaves/pythonslave.py"
|
|
183
|
+
def build():
|
|
184
|
+
with tempfile.TemporaryDirectory() as terminals_dir:
|
|
185
|
+
terminals_dir = Path(terminals_dir)
|
|
186
|
+
terminals = terminals_dir / "terminalsAndIcons.xml"
|
|
187
|
+
terminals.write_text("Dummy Terminal 1")
|
|
188
|
+
|
|
189
|
+
return FmuBuilder.build_FMU(script_file, dest=tmp_path, terminals=terminals)
|
|
190
|
+
|
|
191
|
+
fmu = build()
|
|
192
|
+
with zipfile.ZipFile(fmu) as files:
|
|
193
|
+
names = files.namelist()
|
|
194
|
+
|
|
195
|
+
assert "terminalsAndIcons/terminalsAndIcons.xml" in names
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: pythonfmu3
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.18
|
|
4
4
|
Summary: A lightweight framework that enables the packaging of Python3.x code as co-simulation FMUs.
|
|
5
5
|
Home-page: https://github.com/stephensmith25/PythonFMU3
|
|
6
6
|
Author: Stephen Smith
|
|
@@ -62,7 +62,7 @@ pip install pythonfmu3
|
|
|
62
62
|
3. Run `pythonfmu3 build` to create the fmu.
|
|
63
63
|
|
|
64
64
|
```
|
|
65
|
-
usage: pythonfmu3 build [-h] -f SCRIPT_FILE [-d DEST] [--doc DOCUMENTATION_FOLDER] [--no-external-tool]
|
|
65
|
+
usage: pythonfmu3 build [-h] -f SCRIPT_FILE [-d DEST] [--doc DOCUMENTATION_FOLDER] [--terminals TERMINALS_FILE] [--no-external-tool]
|
|
66
66
|
[--no-variable-step] [--interpolate-inputs] [--only-one-per-process] [--handle-state]
|
|
67
67
|
[--serialize-state] [--use-memory-management]
|
|
68
68
|
[Project files [Project files ...]]
|
|
@@ -79,6 +79,8 @@ optional arguments:
|
|
|
79
79
|
-d DEST, --dest DEST Where to save the FMU.
|
|
80
80
|
--doc DOCUMENTATION_FOLDER
|
|
81
81
|
Documentation folder to include in the FMU.
|
|
82
|
+
--terminals TERMINALS_FILE
|
|
83
|
+
Terminals file (terminalsAndIcons.xml) to include in the FMU.
|
|
82
84
|
--no-external-tool If given, needsExecutionTool=false
|
|
83
85
|
--no-variable-step If given, canHandleVariableCommunicationStepSize=false
|
|
84
86
|
--interpolate-inputs If given, canInterpolateInputs=true
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.16"
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_common.hpp
RENAMED
|
File without changes
|
{pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_cs.cpp
RENAMED
|
File without changes
|
{pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/fmi/fmi3FunctionTypes.h
RENAMED
|
File without changes
|
|
File without changes
|
{pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/fmi/fmi3PlatformTypes.h
RENAMED
|
File without changes
|
{pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/pythonfmu/IPyState.hpp
RENAMED
|
File without changes
|
{pythonfmu3-0.1.16 → pythonfmu3-0.1.18}/pythonfmu3/pythonfmu-export/src/pythonfmu/PyState.hpp
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|