pythonfmu3 0.2.2.2__py3-none-any.whl → 0.2.4__py3-none-any.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.
- pythonfmu3/__init__.py +8 -8
- pythonfmu3/__main__.py +52 -52
- pythonfmu3/_version.py +1 -1
- pythonfmu3/builder.py +260 -260
- pythonfmu3/default_experiment.py +7 -7
- pythonfmu3/deploy.py +118 -118
- pythonfmu3/enums.py +48 -48
- pythonfmu3/fmi3slave.py +438 -438
- pythonfmu3/logmsg.py +14 -14
- pythonfmu3/osutil.py +22 -22
- pythonfmu3/pythonfmu-export/.clang-format +35 -35
- pythonfmu3/pythonfmu-export/CMakeLists.txt +59 -59
- pythonfmu3/pythonfmu-export/build_unix.sh +4 -4
- pythonfmu3/pythonfmu-export/build_win.sh +4 -4
- pythonfmu3/pythonfmu-export/src/CMakeLists.txt +45 -45
- pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_common.hpp +161 -161
- pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_cs.cpp +192 -192
- pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_cs.hpp +185 -185
- pythonfmu3/pythonfmu-export/src/cppfmu/fmi_functions.cpp +937 -937
- pythonfmu3/pythonfmu-export/src/fmi/fmi3FunctionTypes.h +638 -638
- pythonfmu3/pythonfmu-export/src/fmi/fmi3Functions.h +343 -343
- pythonfmu3/pythonfmu-export/src/fmi/fmi3PlatformTypes.h +94 -94
- pythonfmu3/pythonfmu-export/src/pythonfmu/IPyState.hpp +17 -17
- pythonfmu3/pythonfmu-export/src/pythonfmu/PySlaveInstance.cpp +744 -744
- pythonfmu3/pythonfmu-export/src/pythonfmu/PySlaveInstance.hpp +111 -111
- pythonfmu3/pythonfmu-export/src/pythonfmu/PyState.hpp +84 -84
- pythonfmu3/resources/binaries/x86_64-linux/libpythonfmu-export.so +0 -0
- pythonfmu3/resources/binaries/x86_64-windows/pythonfmu-export.dll +0 -0
- pythonfmu3/tests/conftest.py +5 -5
- pythonfmu3/tests/data/csvdemo.csv +7 -7
- pythonfmu3/tests/slaves/PythonSlaveWithException.py +18 -18
- pythonfmu3/tests/slaves/localmodule.py +8 -8
- pythonfmu3/tests/slaves/pythonslave.py +52 -52
- pythonfmu3/tests/slaves/pythonslave_read_file.py +23 -23
- pythonfmu3/tests/slaves/slavewithdep.py +21 -21
- pythonfmu3/tests/test_builder.py +195 -195
- pythonfmu3/tests/test_deploy.py +48 -48
- pythonfmu3/tests/test_fmi3slave.py +152 -152
- pythonfmu3/tests/test_integration.py +350 -350
- pythonfmu3/tests/test_logger.py +180 -180
- pythonfmu3/tests/test_multiple_fmus.py +141 -141
- pythonfmu3/tests/test_variables.py +334 -334
- pythonfmu3/tests/utils.py +13 -13
- pythonfmu3/unit.py +62 -62
- pythonfmu3/variable_types.py +101 -101
- pythonfmu3/variables.py +400 -400
- {pythonfmu3-0.2.2.2.dist-info → pythonfmu3-0.2.4.dist-info}/METADATA +7 -9
- pythonfmu3-0.2.4.dist-info/RECORD +54 -0
- {pythonfmu3-0.2.2.2.dist-info → pythonfmu3-0.2.4.dist-info}/WHEEL +1 -1
- {pythonfmu3-0.2.2.2.dist-info → pythonfmu3-0.2.4.dist-info}/entry_points.txt +0 -1
- pythonfmu3-0.2.2.2.dist-info/LICENSE.txt → pythonfmu3-0.2.4.dist-info/licenses/LICENSE +23 -23
- pythonfmu3/pythonfmu-export/build/ALL_BUILD.vcxproj +0 -184
- pythonfmu3/pythonfmu-export/build/ALL_BUILD.vcxproj.filters +0 -8
- pythonfmu3/pythonfmu-export/build/CMakeCache.txt +0 -369
- pythonfmu3/pythonfmu-export/build/CMakeFiles/0ee4db0675778dfba98c7160896d5a45/generate.stamp.rule +0 -1
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CMakeCCompiler.cmake +0 -72
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CMakeCXXCompiler.cmake +0 -83
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CMakeDetermineCompilerABI_C.bin +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CMakeDetermineCompilerABI_CXX.bin +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CMakeRCCompiler.cmake +0 -6
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CMakeSystem.cmake +0 -15
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/CMakeCCompilerId.c +0 -838
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/CompilerIdC.exe +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/CompilerIdC.vcxproj +0 -71
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CMakeCCompilerId.obj +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.exe.recipe +0 -11
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.tlog/CL.command.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.tlog/CL.read.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.tlog/CL.write.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.tlog/CompilerIdC.lastbuildstate +0 -2
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.tlog/link.command.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.tlog/link.read.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.tlog/link.write.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/CMakeCXXCompilerId.cpp +0 -826
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/CompilerIdCXX.exe +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/CompilerIdCXX.vcxproj +0 -71
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.exe.recipe +0 -11
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.command.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.read.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.write.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CompilerIdCXX.lastbuildstate +0 -2
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.command.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.read.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.write.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/VCTargetsPath.txt +0 -1
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/VCTargetsPath.vcxproj +0 -31
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/x64/Debug/VCTargetsPath.recipe +0 -11
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/x64/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate +0 -2
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CMakeCCompiler.cmake +0 -81
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CMakeCXXCompiler.cmake +0 -101
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CMakeDetermineCompilerABI_C.bin +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CMakeDetermineCompilerABI_CXX.bin +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CMakeRCCompiler.cmake +0 -6
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CMakeSystem.cmake +0 -15
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/CMakeCCompilerId.c +0 -904
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/CompilerIdC.exe +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/CompilerIdC.vcxproj +0 -72
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CMakeCCompilerId.obj +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.exe.recipe +0 -11
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.tlog/CL.command.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.tlog/CL.read.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.tlog/CL.write.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.tlog/CompilerIdC.lastbuildstate +0 -2
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.tlog/link.command.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.tlog/link.read.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.tlog/link.write.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/CMakeCXXCompilerId.cpp +0 -919
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/CompilerIdCXX.exe +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/CompilerIdCXX.vcxproj +0 -72
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.exe.recipe +0 -11
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.command.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.read.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.write.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CompilerIdCXX.lastbuildstate +0 -2
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.command.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.read.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.write.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/VCTargetsPath.txt +0 -1
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/VCTargetsPath.vcxproj +0 -31
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/x64/Debug/VCTargetsPath.recipe +0 -11
- pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/x64/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate +0 -2
- pythonfmu3/pythonfmu-export/build/CMakeFiles/CMakeConfigureLog.yaml +0 -568
- pythonfmu3/pythonfmu-export/build/CMakeFiles/CMakeOutput.log +0 -357
- pythonfmu3/pythonfmu-export/build/CMakeFiles/TargetDirectories.txt +0 -3
- pythonfmu3/pythonfmu-export/build/CMakeFiles/cmake.check_cache +0 -1
- pythonfmu3/pythonfmu-export/build/CMakeFiles/generate.stamp +0 -1
- pythonfmu3/pythonfmu-export/build/CMakeFiles/generate.stamp.depend +0 -28
- pythonfmu3/pythonfmu-export/build/CMakeFiles/generate.stamp.list +0 -2
- pythonfmu3/pythonfmu-export/build/ZERO_CHECK.vcxproj +0 -174
- pythonfmu3/pythonfmu-export/build/ZERO_CHECK.vcxproj.filters +0 -13
- pythonfmu3/pythonfmu-export/build/cmake_install.cmake +0 -50
- pythonfmu3/pythonfmu-export/build/install_manifest.txt +0 -0
- pythonfmu3/pythonfmu-export/build/pythonfmu-export.sln +0 -53
- pythonfmu3/pythonfmu-export/build/src/CMakeFiles/generate.stamp +0 -1
- pythonfmu3/pythonfmu-export/build/src/CMakeFiles/generate.stamp.depend +0 -2
- pythonfmu3/pythonfmu-export/build/src/Debug/pythonfmu-export.pdb +0 -0
- pythonfmu3/pythonfmu-export/build/src/Release/pythonfmu-export.exp +0 -0
- pythonfmu3/pythonfmu-export/build/src/Release/pythonfmu-export.lib +0 -0
- pythonfmu3/pythonfmu-export/build/src/cmake_install.cmake +0 -34
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/PySlaveInstance.obj +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/cppfmu_cs.obj +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/exports.def +0 -1885
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/fmi_functions.obj +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/objects.txt +0 -3
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/CL.command.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/CL.read.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/CL.write.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/CustomBuild.command.1.tlog +0 -10
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/CustomBuild.read.1.tlog +0 -1
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/CustomBuild.write.1.tlog +0 -2
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/link.command.1.tlog +0 -1
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/link.read.1.tlog +0 -1
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/link.read.3.tlog +0 -1
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/link.write.1.tlog +0 -1
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/pythonfmu-export.lastbuildstate +0 -2
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/unsuccessfulbuild +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/vc142.pdb +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/MinSizeRel/objects.txt +0 -3
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/RelWithDebInfo/objects.txt +0 -3
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/PySlaveInstance.obj +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/cppfmu_cs.obj +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/exports.def +0 -538
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/fmi_functions.obj +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/objects.txt +0 -3
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.dll.recipe +0 -14
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/CL.command.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/CL.read.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/CL.write.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/CustomBuild.command.1.tlog +0 -10
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/CustomBuild.read.1.tlog +0 -1
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/CustomBuild.write.1.tlog +0 -2
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/link.command.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/link.delete.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/link.read.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/link.write.1.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/pythonfmu-export.lastbuildstate +0 -2
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/pythonfmu-export.write.1u.tlog +0 -0
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.vcxproj +0 -414
- pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.vcxproj.filters +0 -48
- pythonfmu3/pythonfmu-export/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.recipe +0 -11
- pythonfmu3/pythonfmu-export/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.command.1.tlog +0 -10
- pythonfmu3/pythonfmu-export/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.read.1.tlog +0 -29
- pythonfmu3/pythonfmu-export/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.write.1.tlog +0 -3
- pythonfmu3/pythonfmu-export/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.tlog/ZERO_CHECK.lastbuildstate +0 -2
- pythonfmu3/pythonfmu-export/build/x64/Release/ALL_BUILD/ALL_BUILD.recipe +0 -17
- pythonfmu3/pythonfmu-export/build/x64/Release/ALL_BUILD/ALL_BUILD.tlog/ALL_BUILD.lastbuildstate +0 -2
- pythonfmu3/pythonfmu-export/build/x64/Release/ALL_BUILD/ALL_BUILD.tlog/CustomBuild.command.1.tlog +0 -10
- pythonfmu3/pythonfmu-export/build/x64/Release/ALL_BUILD/ALL_BUILD.tlog/CustomBuild.read.1.tlog +0 -27
- pythonfmu3/pythonfmu-export/build/x64/Release/ALL_BUILD/ALL_BUILD.tlog/CustomBuild.write.1.tlog +0 -2
- pythonfmu3/pythonfmu-export/build/x64/Release/ZERO_CHECK/ZERO_CHECK.recipe +0 -11
- pythonfmu3/pythonfmu-export/build/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.command.1.tlog +0 -10
- pythonfmu3/pythonfmu-export/build/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.read.1.tlog +0 -29
- pythonfmu3/pythonfmu-export/build/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.write.1.tlog +0 -3
- pythonfmu3/pythonfmu-export/build/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/ZERO_CHECK.lastbuildstate +0 -2
- pythonfmu3/resources/binaries/x86_64-windows1/pythonfmu-export.dll +0 -0
- pythonfmu3-0.2.2.2.dist-info/RECORD +0 -200
- {pythonfmu3-0.2.2.2.dist-info → pythonfmu3-0.2.4.dist-info}/top_level.txt +0 -0
pythonfmu3/__init__.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
from ._version import __version__
|
|
2
|
-
from .builder import FmuBuilder
|
|
3
|
-
from .enums import Fmi3Causality, Fmi3Initial, Fmi3Status, Fmi3Variability
|
|
4
|
-
from .fmi3slave import Fmi3Slave, Fmi3StepResult
|
|
5
|
-
from .variables import Boolean, Enumeration, Int32, Int64, UInt64, Float64, String, Dimension
|
|
6
|
-
from .default_experiment import DefaultExperiment
|
|
7
|
-
from .variable_types import Float64Type, EnumerationType
|
|
8
|
-
from .unit import BaseUnit, Unit
|
|
1
|
+
from ._version import __version__
|
|
2
|
+
from .builder import FmuBuilder
|
|
3
|
+
from .enums import Fmi3Causality, Fmi3Initial, Fmi3Status, Fmi3Variability
|
|
4
|
+
from .fmi3slave import Fmi3Slave, Fmi3StepResult
|
|
5
|
+
from .variables import Boolean, Enumeration, Int32, Int64, UInt64, Float64, String, Dimension
|
|
6
|
+
from .default_experiment import DefaultExperiment
|
|
7
|
+
from .variable_types import Float64Type, EnumerationType
|
|
8
|
+
from .unit import BaseUnit, Unit
|
pythonfmu3/__main__.py
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
|
|
3
|
-
from pythonfmu3 import builder, deploy
|
|
4
|
-
from ._version import __version__
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def cli_main():
|
|
8
|
-
parser = argparse.ArgumentParser(prog="pythonfmu")
|
|
9
|
-
|
|
10
|
-
parser.add_argument("-V", "--version", action="version", version=__version__)
|
|
11
|
-
|
|
12
|
-
def default_execution(**kwargs):
|
|
13
|
-
print("A subcommand must be provided.\n")
|
|
14
|
-
parser.print_help()
|
|
15
|
-
|
|
16
|
-
parser.set_defaults(execute=default_execution)
|
|
17
|
-
|
|
18
|
-
subparsers = parser.add_subparsers(
|
|
19
|
-
title="Subcommands", description="Call `pythonfmu _command_ -h` to get more help."
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
build_parser = subparsers.add_parser(
|
|
23
|
-
"build",
|
|
24
|
-
description="Build an FMU from a Python script.",
|
|
25
|
-
help="Build an FMU from a Python script."
|
|
26
|
-
)
|
|
27
|
-
builder.create_command_parser(build_parser)
|
|
28
|
-
|
|
29
|
-
deploy_parser = subparsers.add_parser(
|
|
30
|
-
"deploy",
|
|
31
|
-
description="""Deploy a Python FMU.
|
|
32
|
-
|
|
33
|
-
The command will look in the `resources` folder for one of the following files:
|
|
34
|
-
`requirements.txt` or `environment.yml`.
|
|
35
|
-
|
|
36
|
-
If you specify a environment file but no package manager, `conda` will be selected
|
|
37
|
-
for `.yaml` and `.yml` otherwise `pip` will be used.
|
|
38
|
-
|
|
39
|
-
The tool assume the Python environment in which the FMU should be executed
|
|
40
|
-
is the current one.
|
|
41
|
-
""",
|
|
42
|
-
help="Install Python FMU dependencies."
|
|
43
|
-
)
|
|
44
|
-
deploy.create_command_parser(deploy_parser)
|
|
45
|
-
|
|
46
|
-
options = vars(parser.parse_args())
|
|
47
|
-
execute = options.pop("execute")
|
|
48
|
-
execute(**options)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if __name__ == "__main__":
|
|
52
|
-
cli_main()
|
|
1
|
+
import argparse
|
|
2
|
+
|
|
3
|
+
from pythonfmu3 import builder, deploy
|
|
4
|
+
from ._version import __version__
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def cli_main():
|
|
8
|
+
parser = argparse.ArgumentParser(prog="pythonfmu")
|
|
9
|
+
|
|
10
|
+
parser.add_argument("-V", "--version", action="version", version=__version__)
|
|
11
|
+
|
|
12
|
+
def default_execution(**kwargs):
|
|
13
|
+
print("A subcommand must be provided.\n")
|
|
14
|
+
parser.print_help()
|
|
15
|
+
|
|
16
|
+
parser.set_defaults(execute=default_execution)
|
|
17
|
+
|
|
18
|
+
subparsers = parser.add_subparsers(
|
|
19
|
+
title="Subcommands", description="Call `pythonfmu _command_ -h` to get more help."
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
build_parser = subparsers.add_parser(
|
|
23
|
+
"build",
|
|
24
|
+
description="Build an FMU from a Python script.",
|
|
25
|
+
help="Build an FMU from a Python script."
|
|
26
|
+
)
|
|
27
|
+
builder.create_command_parser(build_parser)
|
|
28
|
+
|
|
29
|
+
deploy_parser = subparsers.add_parser(
|
|
30
|
+
"deploy",
|
|
31
|
+
description="""Deploy a Python FMU.
|
|
32
|
+
|
|
33
|
+
The command will look in the `resources` folder for one of the following files:
|
|
34
|
+
`requirements.txt` or `environment.yml`.
|
|
35
|
+
|
|
36
|
+
If you specify a environment file but no package manager, `conda` will be selected
|
|
37
|
+
for `.yaml` and `.yml` otherwise `pip` will be used.
|
|
38
|
+
|
|
39
|
+
The tool assume the Python environment in which the FMU should be executed
|
|
40
|
+
is the current one.
|
|
41
|
+
""",
|
|
42
|
+
help="Install Python FMU dependencies."
|
|
43
|
+
)
|
|
44
|
+
deploy.create_command_parser(deploy_parser)
|
|
45
|
+
|
|
46
|
+
options = vars(parser.parse_args())
|
|
47
|
+
execute = options.pop("execute")
|
|
48
|
+
execute(**options)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
if __name__ == "__main__":
|
|
52
|
+
cli_main()
|
pythonfmu3/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.2.
|
|
1
|
+
__version__ = "0.2.4"
|
pythonfmu3/builder.py
CHANGED
|
@@ -1,260 +1,260 @@
|
|
|
1
|
-
"""Python FMU builder"""
|
|
2
|
-
import argparse
|
|
3
|
-
import importlib
|
|
4
|
-
import itertools
|
|
5
|
-
import logging
|
|
6
|
-
import re
|
|
7
|
-
import shutil
|
|
8
|
-
import sys
|
|
9
|
-
import tempfile
|
|
10
|
-
import zipfile
|
|
11
|
-
from pathlib import Path
|
|
12
|
-
from typing import Iterable, Optional, Tuple, Union
|
|
13
|
-
from xml.dom.minidom import parseString
|
|
14
|
-
from xml.etree.ElementTree import Element, SubElement, tostring
|
|
15
|
-
from .osutil import get_lib_extension, get_platform
|
|
16
|
-
from .fmi3slave import FMI3_MODEL_OPTIONS, Fmi3Slave
|
|
17
|
-
|
|
18
|
-
FilePath = Union[str, Path]
|
|
19
|
-
HERE = Path(__file__).parent
|
|
20
|
-
|
|
21
|
-
logger = logging.getLogger(__name__)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def get_class_name(file_name: Path) -> str:
|
|
25
|
-
with open(str(file_name), 'r') as file:
|
|
26
|
-
data = file.read()
|
|
27
|
-
return re.search(r'class (\w+)\(\s*Fmi3Slave\s*\)\s*:', data).group(1)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def get_model_description(filepath: Path, module_name: str) -> Tuple[str, Element]:
|
|
31
|
-
"""Extract the FMU model description as XML.
|
|
32
|
-
|
|
33
|
-
Args:
|
|
34
|
-
filepath (pathlib.Path) : script file path
|
|
35
|
-
module_name (str) : python module to load
|
|
36
|
-
|
|
37
|
-
Returns:
|
|
38
|
-
Tuple[str, xml.etree.TreeElement.Element] : FMU model name, model description
|
|
39
|
-
"""
|
|
40
|
-
# Add current folder to handle local dependencies
|
|
41
|
-
sys.path.insert(0, str(filepath.parent))
|
|
42
|
-
try:
|
|
43
|
-
# Import the user interface
|
|
44
|
-
spec = importlib.util.spec_from_file_location(module_name, filepath)
|
|
45
|
-
fmu_interface = importlib.util.module_from_spec(spec)
|
|
46
|
-
spec.loader.exec_module(fmu_interface)
|
|
47
|
-
# Instantiate the interface
|
|
48
|
-
class_name = get_class_name(filepath)
|
|
49
|
-
instance = getattr(fmu_interface, class_name)(instance_name="dummyInstance", resources=str(filepath.parent))
|
|
50
|
-
finally:
|
|
51
|
-
sys.path.remove(str(filepath.parent)) # remove inserted temporary path
|
|
52
|
-
|
|
53
|
-
if not isinstance(instance, Fmi3Slave):
|
|
54
|
-
raise TypeError(
|
|
55
|
-
f"The provided class '{class_name}' does not inherit from {Fmi3Slave.__qualname__}"
|
|
56
|
-
)
|
|
57
|
-
# Produce the xml
|
|
58
|
-
return instance.modelName, instance.to_xml()
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
class FmuBuilder:
|
|
62
|
-
|
|
63
|
-
@staticmethod
|
|
64
|
-
def build_FMU(
|
|
65
|
-
script_file: FilePath,
|
|
66
|
-
dest: FilePath = ".",
|
|
67
|
-
project_files: Iterable[FilePath] = set(),
|
|
68
|
-
documentation_folder: Optional[FilePath] = None,
|
|
69
|
-
terminals : Optional[FilePath] = None,
|
|
70
|
-
**options,
|
|
71
|
-
) -> Path:
|
|
72
|
-
script_file = Path(script_file)
|
|
73
|
-
if not script_file.exists():
|
|
74
|
-
raise ValueError(f"No such file {script_file!s}")
|
|
75
|
-
if not script_file.suffix.endswith(".py"):
|
|
76
|
-
raise ValueError(f"File {script_file!s} must have extension '.py'!")
|
|
77
|
-
|
|
78
|
-
dest = Path(dest)
|
|
79
|
-
if not dest.exists():
|
|
80
|
-
dest.mkdir(parents=True)
|
|
81
|
-
project_files = set(map(Path, project_files))
|
|
82
|
-
|
|
83
|
-
if documentation_folder is not None:
|
|
84
|
-
documentation_folder = Path(documentation_folder)
|
|
85
|
-
if not documentation_folder.exists():
|
|
86
|
-
raise ValueError(
|
|
87
|
-
f"The documentation folder does not exists {documentation_folder!s}"
|
|
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
|
-
)
|
|
100
|
-
|
|
101
|
-
module_name = script_file.stem
|
|
102
|
-
|
|
103
|
-
with tempfile.TemporaryDirectory(prefix="pythonfmu_") as tempd:
|
|
104
|
-
temp_dir = Path(tempd)
|
|
105
|
-
shutil.copy2(script_file, temp_dir)
|
|
106
|
-
|
|
107
|
-
# Embed pythonfmu in the FMU so it does not need to be included
|
|
108
|
-
dep_folder = temp_dir / "pythonfmu3"
|
|
109
|
-
dep_folder.mkdir()
|
|
110
|
-
for dep in HERE.glob('*.py'): # Find all python files at the same level as this one
|
|
111
|
-
shutil.copy2(dep, dep_folder)
|
|
112
|
-
for file_ in project_files:
|
|
113
|
-
if file_ == script_file.parent:
|
|
114
|
-
new_folder = temp_dir / file_.name
|
|
115
|
-
new_folder.mkdir()
|
|
116
|
-
for f in file_.iterdir():
|
|
117
|
-
if f.is_dir():
|
|
118
|
-
temp_dest = new_folder / f.name
|
|
119
|
-
shutil.copytree(f, temp_dest)
|
|
120
|
-
elif f.name != script_file.name:
|
|
121
|
-
shutil.copy2(f, new_folder)
|
|
122
|
-
else:
|
|
123
|
-
logger.debug(
|
|
124
|
-
"Skip file with the same name as the script found in project file."
|
|
125
|
-
)
|
|
126
|
-
else:
|
|
127
|
-
if file_.is_dir():
|
|
128
|
-
temp_dest = temp_dir / file_.name
|
|
129
|
-
shutil.copytree(file_, temp_dest)
|
|
130
|
-
else:
|
|
131
|
-
shutil.copy2(file_, temp_dir)
|
|
132
|
-
|
|
133
|
-
model_identifier, xml = get_model_description(
|
|
134
|
-
temp_dir.absolute() / script_file.name, module_name
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
dest_file = dest / f"{model_identifier}.fmu"
|
|
138
|
-
|
|
139
|
-
type_node = xml.find("CoSimulation")
|
|
140
|
-
option_names = [opt.name for opt in FMI3_MODEL_OPTIONS]
|
|
141
|
-
for option, value in options.items():
|
|
142
|
-
if option in option_names:
|
|
143
|
-
type_node.set(option, str(value).lower())
|
|
144
|
-
|
|
145
|
-
with zipfile.ZipFile(dest_file, "w") as zip_fmu:
|
|
146
|
-
|
|
147
|
-
resource = Path("resources")
|
|
148
|
-
|
|
149
|
-
# Add files copied in temporary directory
|
|
150
|
-
for f in temp_dir.rglob("*"):
|
|
151
|
-
if f.is_file() and f.parent.name != "__pycache__":
|
|
152
|
-
relative_f = f.relative_to(temp_dir)
|
|
153
|
-
zip_fmu.write(f, arcname=(resource / relative_f))
|
|
154
|
-
|
|
155
|
-
# Add information for the Python loader
|
|
156
|
-
zip_fmu.writestr(str(resource.joinpath("slavemodule.txt")), module_name)
|
|
157
|
-
|
|
158
|
-
# Add FMI API wrapping Python class source
|
|
159
|
-
sources = Path("sources")
|
|
160
|
-
src = HERE / "pythonfmu-export"
|
|
161
|
-
for f in itertools.chain(
|
|
162
|
-
src.rglob("*.hpp"), src.rglob("*.cpp"), src.rglob("CMakeLists.txt")
|
|
163
|
-
):
|
|
164
|
-
relative_f = f.relative_to(src)
|
|
165
|
-
if "build" in relative_f.parts:
|
|
166
|
-
continue;
|
|
167
|
-
zip_fmu.write(f, arcname=(sources / relative_f))
|
|
168
|
-
|
|
169
|
-
# Add FMI API wrapping Python class library
|
|
170
|
-
binaries = Path("binaries")
|
|
171
|
-
src_binaries = HERE / "resources" / "binaries"
|
|
172
|
-
for f in itertools.chain(
|
|
173
|
-
src_binaries.rglob("*.dll"),
|
|
174
|
-
src_binaries.rglob("*.so"),
|
|
175
|
-
src_binaries.rglob("*.dylib"),
|
|
176
|
-
):
|
|
177
|
-
relative_f = f.relative_to(src_binaries)
|
|
178
|
-
arcname = (
|
|
179
|
-
binaries
|
|
180
|
-
/ relative_f.parent
|
|
181
|
-
/ f"{model_identifier}{relative_f.suffix}"
|
|
182
|
-
)
|
|
183
|
-
zip_fmu.write(f, arcname=arcname)
|
|
184
|
-
|
|
185
|
-
# Add the documentation folder
|
|
186
|
-
if documentation_folder is not None:
|
|
187
|
-
documentation = Path("documentation")
|
|
188
|
-
for f in documentation_folder.rglob("*"):
|
|
189
|
-
if f.is_file():
|
|
190
|
-
relative_f = f.relative_to(documentation_folder)
|
|
191
|
-
zip_fmu.write(f, arcname=(documentation / relative_f))
|
|
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
|
-
|
|
199
|
-
# Add the model description
|
|
200
|
-
xml_str = parseString(tostring(xml, "UTF-8"))
|
|
201
|
-
zip_fmu.writestr(
|
|
202
|
-
"modelDescription.xml", xml_str.toprettyxml(encoding="UTF-8")
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
return dest_file
|
|
206
|
-
|
|
207
|
-
@staticmethod
|
|
208
|
-
def has_binary() -> bool:
|
|
209
|
-
"""Does the binary for this platform exits?"""
|
|
210
|
-
binary_folder = get_platform()
|
|
211
|
-
lib_ext = get_lib_extension() or "*" # if library extension is unknown, it will look for '*.*' in src_binaries
|
|
212
|
-
src_binaries = HERE / "resources" / "binaries" / binary_folder
|
|
213
|
-
return src_binaries.exists() and len(list(src_binaries.glob(f"*.{lib_ext}"))) >= 1
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
def create_command_parser(parser: argparse.ArgumentParser):
|
|
217
|
-
parser.add_argument(
|
|
218
|
-
"-f",
|
|
219
|
-
"--file",
|
|
220
|
-
dest="script_file",
|
|
221
|
-
help="Path to the Python script.",
|
|
222
|
-
required=True
|
|
223
|
-
)
|
|
224
|
-
|
|
225
|
-
parser.add_argument(
|
|
226
|
-
"-d", "--dest", dest="dest", help="Where to save the FMU.", default="."
|
|
227
|
-
)
|
|
228
|
-
|
|
229
|
-
parser.add_argument(
|
|
230
|
-
"--doc",
|
|
231
|
-
dest="documentation_folder",
|
|
232
|
-
help="Documentation folder to include in the FMU.",
|
|
233
|
-
default=None
|
|
234
|
-
)
|
|
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
|
-
|
|
243
|
-
for option in FMI3_MODEL_OPTIONS:
|
|
244
|
-
action = "store_false" if option.value else "store_true"
|
|
245
|
-
parser.add_argument(
|
|
246
|
-
f"--{option.cli}",
|
|
247
|
-
dest=option.name,
|
|
248
|
-
help=f"If given, {option.name}={action[6:]}",
|
|
249
|
-
action=action
|
|
250
|
-
)
|
|
251
|
-
|
|
252
|
-
parser.add_argument(
|
|
253
|
-
"project_files",
|
|
254
|
-
metavar="Project files",
|
|
255
|
-
nargs="*",
|
|
256
|
-
help="Additional project files required by the Python script.",
|
|
257
|
-
default=set()
|
|
258
|
-
)
|
|
259
|
-
|
|
260
|
-
parser.set_defaults(execute=FmuBuilder.build_FMU)
|
|
1
|
+
"""Python FMU builder"""
|
|
2
|
+
import argparse
|
|
3
|
+
import importlib
|
|
4
|
+
import itertools
|
|
5
|
+
import logging
|
|
6
|
+
import re
|
|
7
|
+
import shutil
|
|
8
|
+
import sys
|
|
9
|
+
import tempfile
|
|
10
|
+
import zipfile
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Iterable, Optional, Tuple, Union
|
|
13
|
+
from xml.dom.minidom import parseString
|
|
14
|
+
from xml.etree.ElementTree import Element, SubElement, tostring
|
|
15
|
+
from .osutil import get_lib_extension, get_platform
|
|
16
|
+
from .fmi3slave import FMI3_MODEL_OPTIONS, Fmi3Slave
|
|
17
|
+
|
|
18
|
+
FilePath = Union[str, Path]
|
|
19
|
+
HERE = Path(__file__).parent
|
|
20
|
+
|
|
21
|
+
logger = logging.getLogger(__name__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get_class_name(file_name: Path) -> str:
|
|
25
|
+
with open(str(file_name), 'r') as file:
|
|
26
|
+
data = file.read()
|
|
27
|
+
return re.search(r'class (\w+)\(\s*Fmi3Slave\s*\)\s*:', data).group(1)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def get_model_description(filepath: Path, module_name: str) -> Tuple[str, Element]:
|
|
31
|
+
"""Extract the FMU model description as XML.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
filepath (pathlib.Path) : script file path
|
|
35
|
+
module_name (str) : python module to load
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
Tuple[str, xml.etree.TreeElement.Element] : FMU model name, model description
|
|
39
|
+
"""
|
|
40
|
+
# Add current folder to handle local dependencies
|
|
41
|
+
sys.path.insert(0, str(filepath.parent))
|
|
42
|
+
try:
|
|
43
|
+
# Import the user interface
|
|
44
|
+
spec = importlib.util.spec_from_file_location(module_name, filepath)
|
|
45
|
+
fmu_interface = importlib.util.module_from_spec(spec)
|
|
46
|
+
spec.loader.exec_module(fmu_interface)
|
|
47
|
+
# Instantiate the interface
|
|
48
|
+
class_name = get_class_name(filepath)
|
|
49
|
+
instance = getattr(fmu_interface, class_name)(instance_name="dummyInstance", resources=str(filepath.parent))
|
|
50
|
+
finally:
|
|
51
|
+
sys.path.remove(str(filepath.parent)) # remove inserted temporary path
|
|
52
|
+
|
|
53
|
+
if not isinstance(instance, Fmi3Slave):
|
|
54
|
+
raise TypeError(
|
|
55
|
+
f"The provided class '{class_name}' does not inherit from {Fmi3Slave.__qualname__}"
|
|
56
|
+
)
|
|
57
|
+
# Produce the xml
|
|
58
|
+
return instance.modelName, instance.to_xml()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class FmuBuilder:
|
|
62
|
+
|
|
63
|
+
@staticmethod
|
|
64
|
+
def build_FMU(
|
|
65
|
+
script_file: FilePath,
|
|
66
|
+
dest: FilePath = ".",
|
|
67
|
+
project_files: Iterable[FilePath] = set(),
|
|
68
|
+
documentation_folder: Optional[FilePath] = None,
|
|
69
|
+
terminals : Optional[FilePath] = None,
|
|
70
|
+
**options,
|
|
71
|
+
) -> Path:
|
|
72
|
+
script_file = Path(script_file)
|
|
73
|
+
if not script_file.exists():
|
|
74
|
+
raise ValueError(f"No such file {script_file!s}")
|
|
75
|
+
if not script_file.suffix.endswith(".py"):
|
|
76
|
+
raise ValueError(f"File {script_file!s} must have extension '.py'!")
|
|
77
|
+
|
|
78
|
+
dest = Path(dest)
|
|
79
|
+
if not dest.exists():
|
|
80
|
+
dest.mkdir(parents=True)
|
|
81
|
+
project_files = set(map(Path, project_files))
|
|
82
|
+
|
|
83
|
+
if documentation_folder is not None:
|
|
84
|
+
documentation_folder = Path(documentation_folder)
|
|
85
|
+
if not documentation_folder.exists():
|
|
86
|
+
raise ValueError(
|
|
87
|
+
f"The documentation folder does not exists {documentation_folder!s}"
|
|
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
|
+
)
|
|
100
|
+
|
|
101
|
+
module_name = script_file.stem
|
|
102
|
+
|
|
103
|
+
with tempfile.TemporaryDirectory(prefix="pythonfmu_") as tempd:
|
|
104
|
+
temp_dir = Path(tempd)
|
|
105
|
+
shutil.copy2(script_file, temp_dir)
|
|
106
|
+
|
|
107
|
+
# Embed pythonfmu in the FMU so it does not need to be included
|
|
108
|
+
dep_folder = temp_dir / "pythonfmu3"
|
|
109
|
+
dep_folder.mkdir()
|
|
110
|
+
for dep in HERE.glob('*.py'): # Find all python files at the same level as this one
|
|
111
|
+
shutil.copy2(dep, dep_folder)
|
|
112
|
+
for file_ in project_files:
|
|
113
|
+
if file_ == script_file.parent:
|
|
114
|
+
new_folder = temp_dir / file_.name
|
|
115
|
+
new_folder.mkdir()
|
|
116
|
+
for f in file_.iterdir():
|
|
117
|
+
if f.is_dir():
|
|
118
|
+
temp_dest = new_folder / f.name
|
|
119
|
+
shutil.copytree(f, temp_dest)
|
|
120
|
+
elif f.name != script_file.name:
|
|
121
|
+
shutil.copy2(f, new_folder)
|
|
122
|
+
else:
|
|
123
|
+
logger.debug(
|
|
124
|
+
"Skip file with the same name as the script found in project file."
|
|
125
|
+
)
|
|
126
|
+
else:
|
|
127
|
+
if file_.is_dir():
|
|
128
|
+
temp_dest = temp_dir / file_.name
|
|
129
|
+
shutil.copytree(file_, temp_dest)
|
|
130
|
+
else:
|
|
131
|
+
shutil.copy2(file_, temp_dir)
|
|
132
|
+
|
|
133
|
+
model_identifier, xml = get_model_description(
|
|
134
|
+
temp_dir.absolute() / script_file.name, module_name
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
dest_file = dest / f"{model_identifier}.fmu"
|
|
138
|
+
|
|
139
|
+
type_node = xml.find("CoSimulation")
|
|
140
|
+
option_names = [opt.name for opt in FMI3_MODEL_OPTIONS]
|
|
141
|
+
for option, value in options.items():
|
|
142
|
+
if option in option_names:
|
|
143
|
+
type_node.set(option, str(value).lower())
|
|
144
|
+
|
|
145
|
+
with zipfile.ZipFile(dest_file, "w") as zip_fmu:
|
|
146
|
+
|
|
147
|
+
resource = Path("resources")
|
|
148
|
+
|
|
149
|
+
# Add files copied in temporary directory
|
|
150
|
+
for f in temp_dir.rglob("*"):
|
|
151
|
+
if f.is_file() and f.parent.name != "__pycache__":
|
|
152
|
+
relative_f = f.relative_to(temp_dir)
|
|
153
|
+
zip_fmu.write(f, arcname=(resource / relative_f))
|
|
154
|
+
|
|
155
|
+
# Add information for the Python loader
|
|
156
|
+
zip_fmu.writestr(str(resource.joinpath("slavemodule.txt")), module_name)
|
|
157
|
+
|
|
158
|
+
# Add FMI API wrapping Python class source
|
|
159
|
+
sources = Path("sources")
|
|
160
|
+
src = HERE / "pythonfmu-export"
|
|
161
|
+
for f in itertools.chain(
|
|
162
|
+
src.rglob("*.hpp"), src.rglob("*.cpp"), src.rglob("CMakeLists.txt")
|
|
163
|
+
):
|
|
164
|
+
relative_f = f.relative_to(src)
|
|
165
|
+
if "build" in relative_f.parts:
|
|
166
|
+
continue;
|
|
167
|
+
zip_fmu.write(f, arcname=(sources / relative_f))
|
|
168
|
+
|
|
169
|
+
# Add FMI API wrapping Python class library
|
|
170
|
+
binaries = Path("binaries")
|
|
171
|
+
src_binaries = HERE / "resources" / "binaries"
|
|
172
|
+
for f in itertools.chain(
|
|
173
|
+
src_binaries.rglob("*.dll"),
|
|
174
|
+
src_binaries.rglob("*.so"),
|
|
175
|
+
src_binaries.rglob("*.dylib"),
|
|
176
|
+
):
|
|
177
|
+
relative_f = f.relative_to(src_binaries)
|
|
178
|
+
arcname = (
|
|
179
|
+
binaries
|
|
180
|
+
/ relative_f.parent
|
|
181
|
+
/ f"{model_identifier}{relative_f.suffix}"
|
|
182
|
+
)
|
|
183
|
+
zip_fmu.write(f, arcname=arcname)
|
|
184
|
+
|
|
185
|
+
# Add the documentation folder
|
|
186
|
+
if documentation_folder is not None:
|
|
187
|
+
documentation = Path("documentation")
|
|
188
|
+
for f in documentation_folder.rglob("*"):
|
|
189
|
+
if f.is_file():
|
|
190
|
+
relative_f = f.relative_to(documentation_folder)
|
|
191
|
+
zip_fmu.write(f, arcname=(documentation / relative_f))
|
|
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
|
+
|
|
199
|
+
# Add the model description
|
|
200
|
+
xml_str = parseString(tostring(xml, "UTF-8"))
|
|
201
|
+
zip_fmu.writestr(
|
|
202
|
+
"modelDescription.xml", xml_str.toprettyxml(encoding="UTF-8")
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
return dest_file
|
|
206
|
+
|
|
207
|
+
@staticmethod
|
|
208
|
+
def has_binary() -> bool:
|
|
209
|
+
"""Does the binary for this platform exits?"""
|
|
210
|
+
binary_folder = get_platform()
|
|
211
|
+
lib_ext = get_lib_extension() or "*" # if library extension is unknown, it will look for '*.*' in src_binaries
|
|
212
|
+
src_binaries = HERE / "resources" / "binaries" / binary_folder
|
|
213
|
+
return src_binaries.exists() and len(list(src_binaries.glob(f"*.{lib_ext}"))) >= 1
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def create_command_parser(parser: argparse.ArgumentParser):
|
|
217
|
+
parser.add_argument(
|
|
218
|
+
"-f",
|
|
219
|
+
"--file",
|
|
220
|
+
dest="script_file",
|
|
221
|
+
help="Path to the Python script.",
|
|
222
|
+
required=True
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
parser.add_argument(
|
|
226
|
+
"-d", "--dest", dest="dest", help="Where to save the FMU.", default="."
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
parser.add_argument(
|
|
230
|
+
"--doc",
|
|
231
|
+
dest="documentation_folder",
|
|
232
|
+
help="Documentation folder to include in the FMU.",
|
|
233
|
+
default=None
|
|
234
|
+
)
|
|
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
|
+
|
|
243
|
+
for option in FMI3_MODEL_OPTIONS:
|
|
244
|
+
action = "store_false" if option.value else "store_true"
|
|
245
|
+
parser.add_argument(
|
|
246
|
+
f"--{option.cli}",
|
|
247
|
+
dest=option.name,
|
|
248
|
+
help=f"If given, {option.name}={action[6:]}",
|
|
249
|
+
action=action
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
parser.add_argument(
|
|
253
|
+
"project_files",
|
|
254
|
+
metavar="Project files",
|
|
255
|
+
nargs="*",
|
|
256
|
+
help="Additional project files required by the Python script.",
|
|
257
|
+
default=set()
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
parser.set_defaults(execute=FmuBuilder.build_FMU)
|
pythonfmu3/default_experiment.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
class DefaultExperiment:
|
|
2
|
-
|
|
3
|
-
def __init__(self, start_time: float = None, stop_time: float = None, step_size: float = None, tolerance: float = None):
|
|
4
|
-
self.start_time = start_time
|
|
5
|
-
self.stop_time = stop_time
|
|
6
|
-
self.step_size = step_size
|
|
7
|
-
self.tolerance = tolerance
|
|
1
|
+
class DefaultExperiment:
|
|
2
|
+
|
|
3
|
+
def __init__(self, start_time: float = None, stop_time: float = None, step_size: float = None, tolerance: float = None):
|
|
4
|
+
self.start_time = start_time
|
|
5
|
+
self.stop_time = stop_time
|
|
6
|
+
self.step_size = step_size
|
|
7
|
+
self.tolerance = tolerance
|