pythonfmu3 0.2.2__py3-none-any.whl → 0.2.2.2__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.

Potentially problematic release.


This version of pythonfmu3 might be problematic. Click here for more details.

Files changed (199) hide show
  1. pythonfmu3/__init__.py +8 -8
  2. pythonfmu3/__main__.py +52 -52
  3. pythonfmu3/_version.py +1 -1
  4. pythonfmu3/builder.py +260 -260
  5. pythonfmu3/default_experiment.py +7 -7
  6. pythonfmu3/deploy.py +118 -118
  7. pythonfmu3/enums.py +48 -48
  8. pythonfmu3/fmi3slave.py +438 -438
  9. pythonfmu3/logmsg.py +14 -14
  10. pythonfmu3/osutil.py +22 -22
  11. pythonfmu3/pythonfmu-export/.clang-format +35 -35
  12. pythonfmu3/pythonfmu-export/CMakeLists.txt +59 -59
  13. pythonfmu3/pythonfmu-export/build/ALL_BUILD.vcxproj +184 -0
  14. pythonfmu3/pythonfmu-export/build/ALL_BUILD.vcxproj.filters +8 -0
  15. pythonfmu3/pythonfmu-export/build/CMakeCache.txt +369 -0
  16. pythonfmu3/pythonfmu-export/build/CMakeFiles/0ee4db0675778dfba98c7160896d5a45/generate.stamp.rule +1 -0
  17. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CMakeCCompiler.cmake +72 -0
  18. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CMakeCXXCompiler.cmake +83 -0
  19. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CMakeDetermineCompilerABI_C.bin +0 -0
  20. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CMakeDetermineCompilerABI_CXX.bin +0 -0
  21. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CMakeRCCompiler.cmake +6 -0
  22. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CMakeSystem.cmake +15 -0
  23. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/CMakeCCompilerId.c +838 -0
  24. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/CompilerIdC.exe +0 -0
  25. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/CompilerIdC.vcxproj +71 -0
  26. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CMakeCCompilerId.obj +0 -0
  27. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.exe.recipe +11 -0
  28. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.tlog/CL.command.1.tlog +0 -0
  29. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.tlog/CL.read.1.tlog +0 -0
  30. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.tlog/CL.write.1.tlog +0 -0
  31. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.tlog/CompilerIdC.lastbuildstate +2 -0
  32. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.tlog/link.command.1.tlog +0 -0
  33. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.tlog/link.read.1.tlog +0 -0
  34. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdC/Debug/CompilerIdC.tlog/link.write.1.tlog +0 -0
  35. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/CMakeCXXCompilerId.cpp +826 -0
  36. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/CompilerIdCXX.exe +0 -0
  37. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/CompilerIdCXX.vcxproj +71 -0
  38. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj +0 -0
  39. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.exe.recipe +11 -0
  40. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.command.1.tlog +0 -0
  41. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.read.1.tlog +0 -0
  42. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.write.1.tlog +0 -0
  43. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CompilerIdCXX.lastbuildstate +2 -0
  44. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.command.1.tlog +0 -0
  45. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.read.1.tlog +0 -0
  46. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.write.1.tlog +0 -0
  47. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/VCTargetsPath.txt +1 -0
  48. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/VCTargetsPath.vcxproj +31 -0
  49. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/x64/Debug/VCTargetsPath.recipe +11 -0
  50. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.24.0/x64/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate +2 -0
  51. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CMakeCCompiler.cmake +81 -0
  52. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CMakeCXXCompiler.cmake +101 -0
  53. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CMakeDetermineCompilerABI_C.bin +0 -0
  54. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CMakeDetermineCompilerABI_CXX.bin +0 -0
  55. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CMakeRCCompiler.cmake +6 -0
  56. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CMakeSystem.cmake +15 -0
  57. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/CMakeCCompilerId.c +904 -0
  58. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/CompilerIdC.exe +0 -0
  59. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/CompilerIdC.vcxproj +72 -0
  60. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CMakeCCompilerId.obj +0 -0
  61. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.exe.recipe +11 -0
  62. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.tlog/CL.command.1.tlog +0 -0
  63. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.tlog/CL.read.1.tlog +0 -0
  64. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.tlog/CL.write.1.tlog +0 -0
  65. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.tlog/CompilerIdC.lastbuildstate +2 -0
  66. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.tlog/link.command.1.tlog +0 -0
  67. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.tlog/link.read.1.tlog +0 -0
  68. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdC/Debug/CompilerIdC.tlog/link.write.1.tlog +0 -0
  69. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/CMakeCXXCompilerId.cpp +919 -0
  70. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/CompilerIdCXX.exe +0 -0
  71. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/CompilerIdCXX.vcxproj +72 -0
  72. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj +0 -0
  73. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.exe.recipe +11 -0
  74. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.command.1.tlog +0 -0
  75. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.read.1.tlog +0 -0
  76. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.write.1.tlog +0 -0
  77. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CompilerIdCXX.lastbuildstate +2 -0
  78. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.command.1.tlog +0 -0
  79. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.read.1.tlog +0 -0
  80. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.write.1.tlog +0 -0
  81. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/VCTargetsPath.txt +1 -0
  82. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/VCTargetsPath.vcxproj +31 -0
  83. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/x64/Debug/VCTargetsPath.recipe +11 -0
  84. pythonfmu3/pythonfmu-export/build/CMakeFiles/3.30.2/x64/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate +2 -0
  85. pythonfmu3/pythonfmu-export/build/CMakeFiles/CMakeConfigureLog.yaml +568 -0
  86. pythonfmu3/pythonfmu-export/build/CMakeFiles/CMakeOutput.log +357 -0
  87. pythonfmu3/pythonfmu-export/build/CMakeFiles/TargetDirectories.txt +3 -0
  88. pythonfmu3/pythonfmu-export/build/CMakeFiles/cmake.check_cache +1 -0
  89. pythonfmu3/pythonfmu-export/build/CMakeFiles/generate.stamp +1 -0
  90. pythonfmu3/pythonfmu-export/build/CMakeFiles/generate.stamp.depend +28 -0
  91. pythonfmu3/pythonfmu-export/build/CMakeFiles/generate.stamp.list +2 -0
  92. pythonfmu3/pythonfmu-export/build/ZERO_CHECK.vcxproj +174 -0
  93. pythonfmu3/pythonfmu-export/build/ZERO_CHECK.vcxproj.filters +13 -0
  94. pythonfmu3/pythonfmu-export/build/cmake_install.cmake +50 -0
  95. pythonfmu3/pythonfmu-export/build/install_manifest.txt +0 -0
  96. pythonfmu3/pythonfmu-export/build/pythonfmu-export.sln +53 -0
  97. pythonfmu3/pythonfmu-export/build/src/CMakeFiles/generate.stamp +1 -0
  98. pythonfmu3/pythonfmu-export/build/src/CMakeFiles/generate.stamp.depend +2 -0
  99. pythonfmu3/pythonfmu-export/build/src/Debug/pythonfmu-export.pdb +0 -0
  100. pythonfmu3/pythonfmu-export/build/src/Release/pythonfmu-export.exp +0 -0
  101. pythonfmu3/pythonfmu-export/build/src/Release/pythonfmu-export.lib +0 -0
  102. pythonfmu3/pythonfmu-export/build/src/cmake_install.cmake +34 -0
  103. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/PySlaveInstance.obj +0 -0
  104. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/cppfmu_cs.obj +0 -0
  105. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/exports.def +1885 -0
  106. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/fmi_functions.obj +0 -0
  107. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/objects.txt +3 -0
  108. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/CL.command.1.tlog +0 -0
  109. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/CL.read.1.tlog +0 -0
  110. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/CL.write.1.tlog +0 -0
  111. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/CustomBuild.command.1.tlog +10 -0
  112. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/CustomBuild.read.1.tlog +1 -0
  113. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/CustomBuild.write.1.tlog +2 -0
  114. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/link.command.1.tlog +1 -0
  115. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/link.read.1.tlog +1 -0
  116. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/link.read.3.tlog +1 -0
  117. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/link.write.1.tlog +1 -0
  118. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/pythonfmu-export.lastbuildstate +2 -0
  119. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/pythonfmu-export.tlog/unsuccessfulbuild +0 -0
  120. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Debug/vc142.pdb +0 -0
  121. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/MinSizeRel/objects.txt +3 -0
  122. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/RelWithDebInfo/objects.txt +3 -0
  123. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/PySlaveInstance.obj +0 -0
  124. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/cppfmu_cs.obj +0 -0
  125. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/exports.def +538 -0
  126. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/fmi_functions.obj +0 -0
  127. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/objects.txt +3 -0
  128. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.dll.recipe +14 -0
  129. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/CL.command.1.tlog +0 -0
  130. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/CL.read.1.tlog +0 -0
  131. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/CL.write.1.tlog +0 -0
  132. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/CustomBuild.command.1.tlog +10 -0
  133. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/CustomBuild.read.1.tlog +1 -0
  134. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/CustomBuild.write.1.tlog +2 -0
  135. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/link.command.1.tlog +0 -0
  136. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/link.delete.1.tlog +0 -0
  137. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/link.read.1.tlog +0 -0
  138. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/link.write.1.tlog +0 -0
  139. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/pythonfmu-export.lastbuildstate +2 -0
  140. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.dir/Release/pythonfmu-export.tlog/pythonfmu-export.write.1u.tlog +0 -0
  141. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.vcxproj +414 -0
  142. pythonfmu3/pythonfmu-export/build/src/pythonfmu-export.vcxproj.filters +48 -0
  143. pythonfmu3/pythonfmu-export/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.recipe +11 -0
  144. pythonfmu3/pythonfmu-export/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.command.1.tlog +10 -0
  145. pythonfmu3/pythonfmu-export/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.read.1.tlog +29 -0
  146. pythonfmu3/pythonfmu-export/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.write.1.tlog +3 -0
  147. pythonfmu3/pythonfmu-export/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.tlog/ZERO_CHECK.lastbuildstate +2 -0
  148. pythonfmu3/pythonfmu-export/build/x64/Release/ALL_BUILD/ALL_BUILD.recipe +17 -0
  149. pythonfmu3/pythonfmu-export/build/x64/Release/ALL_BUILD/ALL_BUILD.tlog/ALL_BUILD.lastbuildstate +2 -0
  150. pythonfmu3/pythonfmu-export/build/x64/Release/ALL_BUILD/ALL_BUILD.tlog/CustomBuild.command.1.tlog +10 -0
  151. pythonfmu3/pythonfmu-export/build/x64/Release/ALL_BUILD/ALL_BUILD.tlog/CustomBuild.read.1.tlog +27 -0
  152. pythonfmu3/pythonfmu-export/build/x64/Release/ALL_BUILD/ALL_BUILD.tlog/CustomBuild.write.1.tlog +2 -0
  153. pythonfmu3/pythonfmu-export/build/x64/Release/ZERO_CHECK/ZERO_CHECK.recipe +11 -0
  154. pythonfmu3/pythonfmu-export/build/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.command.1.tlog +10 -0
  155. pythonfmu3/pythonfmu-export/build/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.read.1.tlog +29 -0
  156. pythonfmu3/pythonfmu-export/build/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.write.1.tlog +3 -0
  157. pythonfmu3/pythonfmu-export/build/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/ZERO_CHECK.lastbuildstate +2 -0
  158. pythonfmu3/pythonfmu-export/build_unix.sh +4 -4
  159. pythonfmu3/pythonfmu-export/build_win.sh +4 -4
  160. pythonfmu3/pythonfmu-export/src/CMakeLists.txt +45 -45
  161. pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_common.hpp +161 -161
  162. pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_cs.cpp +192 -192
  163. pythonfmu3/pythonfmu-export/src/cppfmu/cppfmu_cs.hpp +185 -185
  164. pythonfmu3/pythonfmu-export/src/cppfmu/fmi_functions.cpp +937 -937
  165. pythonfmu3/pythonfmu-export/src/fmi/fmi3FunctionTypes.h +638 -638
  166. pythonfmu3/pythonfmu-export/src/fmi/fmi3Functions.h +343 -343
  167. pythonfmu3/pythonfmu-export/src/fmi/fmi3PlatformTypes.h +94 -94
  168. pythonfmu3/pythonfmu-export/src/pythonfmu/IPyState.hpp +17 -17
  169. pythonfmu3/pythonfmu-export/src/pythonfmu/PySlaveInstance.cpp +744 -744
  170. pythonfmu3/pythonfmu-export/src/pythonfmu/PySlaveInstance.hpp +111 -111
  171. pythonfmu3/pythonfmu-export/src/pythonfmu/PyState.hpp +84 -84
  172. pythonfmu3/resources/binaries/x86_64-linux/libpythonfmu-export.so +0 -0
  173. pythonfmu3/resources/binaries/x86_64-windows/pythonfmu-export.dll +0 -0
  174. pythonfmu3/resources/binaries/x86_64-windows1/pythonfmu-export.dll +0 -0
  175. pythonfmu3/tests/conftest.py +5 -5
  176. pythonfmu3/tests/data/csvdemo.csv +7 -7
  177. pythonfmu3/tests/slaves/PythonSlaveWithException.py +18 -18
  178. pythonfmu3/tests/slaves/localmodule.py +8 -8
  179. pythonfmu3/tests/slaves/pythonslave.py +52 -52
  180. pythonfmu3/tests/slaves/pythonslave_read_file.py +23 -23
  181. pythonfmu3/tests/slaves/slavewithdep.py +21 -21
  182. pythonfmu3/tests/test_builder.py +195 -195
  183. pythonfmu3/tests/test_deploy.py +48 -48
  184. pythonfmu3/tests/test_fmi3slave.py +152 -152
  185. pythonfmu3/tests/test_integration.py +350 -350
  186. pythonfmu3/tests/test_logger.py +180 -180
  187. pythonfmu3/tests/test_multiple_fmus.py +141 -141
  188. pythonfmu3/tests/test_variables.py +334 -334
  189. pythonfmu3/tests/utils.py +13 -13
  190. pythonfmu3/unit.py +62 -62
  191. pythonfmu3/variable_types.py +101 -101
  192. pythonfmu3/variables.py +400 -400
  193. pythonfmu3-0.2.2.dist-info/LICENSE → pythonfmu3-0.2.2.2.dist-info/LICENSE.txt +23 -23
  194. {pythonfmu3-0.2.2.dist-info → pythonfmu3-0.2.2.2.dist-info}/METADATA +9 -6
  195. pythonfmu3-0.2.2.2.dist-info/RECORD +200 -0
  196. {pythonfmu3-0.2.2.dist-info → pythonfmu3-0.2.2.2.dist-info}/WHEEL +1 -1
  197. {pythonfmu3-0.2.2.dist-info → pythonfmu3-0.2.2.2.dist-info}/entry_points.txt +1 -0
  198. pythonfmu3-0.2.2.dist-info/RECORD +0 -54
  199. {pythonfmu3-0.2.2.dist-info → pythonfmu3-0.2.2.2.dist-info}/top_level.txt +0 -0
@@ -1,350 +1,350 @@
1
- import math
2
- from pathlib import Path
3
-
4
- import pytest
5
-
6
- from pythonfmu3.builder import FmuBuilder
7
-
8
- pytestmark = pytest.mark.skipif(
9
- not FmuBuilder.has_binary(), reason="No binary available for the current platform."
10
- )
11
- fmpy = pytest.importorskip(
12
- "fmpy", reason="fmpy is required for testing the produced FMU"
13
- )
14
-
15
-
16
- def mapped(md):
17
- m = {}
18
- for v in md.modelVariables:
19
- m[v.name] = v
20
- return m
21
-
22
-
23
- @pytest.mark.integration
24
- def test_integration_demo(tmp_path):
25
- script_file = Path(__file__).parent / "slaves/pythonslave.py"
26
- fmu = FmuBuilder.build_FMU(script_file, dest=tmp_path, needsExecutionTool="false")
27
- assert fmu.exists()
28
- res = fmpy.simulate_fmu(str(fmu), stop_time=0.5)
29
-
30
- assert res["realOut"][-1] == pytest.approx(res["time"][-1], rel=1e-7)
31
-
32
-
33
- @pytest.mark.integration
34
- def test_integration_reset(tmp_path):
35
- script_file = Path(__file__).parent / "slaves/pythonslave.py"
36
- fmu = FmuBuilder.build_FMU(script_file, dest=tmp_path, needsExecutionTool="false")
37
- assert fmu.exists()
38
-
39
- md = fmpy.read_model_description(str(fmu))
40
- unzipdir = fmpy.extract(str(fmu))
41
- model = fmpy.fmi3.FMU3Slave(guid=md.guid,
42
- unzipDirectory=unzipdir,
43
- modelIdentifier=md.coSimulation.modelIdentifier,
44
- instanceName="instance"
45
- )
46
- model.instantiate()
47
- model.enterInitializationMode()
48
- model.exitInitializationMode()
49
-
50
- vars = mapped(md)
51
- vr = vars["realOut"].valueReference
52
- dt = 0.1
53
-
54
- initial_value = model.getFloat64([vr])[0]
55
- assert initial_value == pytest.approx(3.0, rel=1e-7)
56
- model.doStep(0.0, dt, True)
57
- read = model.getFloat64([vr])[0]
58
- assert read == pytest.approx(dt, rel=1e-7)
59
- model.reset()
60
- read = model.getFloat64([vr])[0]
61
- assert read == pytest.approx(initial_value, rel=1e-7)
62
-
63
- model.terminate()
64
- model.freeInstance()
65
-
66
-
67
- @pytest.mark.integration
68
- def test_integration_get_state(tmp_path):
69
- script_file = Path(__file__).parent / "slaves/pythonslave.py"
70
- fmu = FmuBuilder.build_FMU(
71
- script_file,
72
- dest=tmp_path,
73
- needsExecutionTool="false",
74
- canGetAndSetFMUstate="true")
75
- assert fmu.exists()
76
-
77
- md = fmpy.read_model_description(str(fmu))
78
- unzipdir = fmpy.extract(str(fmu))
79
- model = fmpy.fmi3.FMU3Slave(guid=md.guid,
80
- unzipDirectory=unzipdir,
81
- modelIdentifier=md.coSimulation.modelIdentifier,
82
- instanceName="instance"
83
- )
84
- model.instantiate()
85
- model.enterInitializationMode()
86
- model.exitInitializationMode()
87
-
88
- vars = mapped(md)
89
- vr = vars["realOut"].valueReference
90
- dt = 0.1
91
- t = 0.0
92
-
93
- def step_model():
94
- nonlocal t
95
- model.doStep(t, dt, True)
96
- t += dt
97
-
98
- step_model()
99
- state = model.getFMUState()
100
- assert model.getFloat64([vr])[0] == pytest.approx(dt, rel=1e-7)
101
- step_model()
102
- assert model.getFloat64([vr])[0] == pytest.approx(dt * 2, rel=1e-7)
103
- model.setFMUState(state)
104
- assert model.getFloat64([vr])[0] == pytest.approx(dt, rel=1e-7)
105
- step_model()
106
- assert model.getFloat64([vr])[0] == pytest.approx(dt * 3, rel=1e-7)
107
- model.freeFMUState(state)
108
-
109
- model.terminate()
110
- model.freeInstance()
111
-
112
-
113
- @pytest.mark.integration
114
- def test_integration_get_serialize_state(tmp_path):
115
-
116
- script_file = Path(__file__).parent / "slaves/pythonslave.py"
117
- fmu = FmuBuilder.build_FMU(
118
- script_file,
119
- dest=tmp_path,
120
- canGetAndSetFMUstate="true",
121
- canSerializeFMUstate="true")
122
- assert fmu.exists()
123
-
124
- md = fmpy.read_model_description(fmu)
125
- unzip_dir = fmpy.extract(fmu)
126
-
127
- model = fmpy.fmi3.FMU3Slave(
128
- guid=md.guid,
129
- unzipDirectory=unzip_dir,
130
- modelIdentifier=md.coSimulation.modelIdentifier,
131
- instanceName='instance1')
132
-
133
- model.instantiate()
134
- model.enterInitializationMode()
135
- model.exitInitializationMode()
136
-
137
- vars = mapped(md)
138
- vrs = [vars["realOut"].valueReference]
139
- t = 0.0
140
- dt = 0.1
141
-
142
- def step_model():
143
- nonlocal t
144
- model.doStep(t, dt)
145
- t += dt
146
-
147
- step_model()
148
- state = model.getFMUState()
149
- assert model.getFloat64(vrs)[0] == pytest.approx(dt, rel=1e-7)
150
- step_model()
151
- assert model.getFloat64(vrs)[0] == pytest.approx(dt * 2, rel=1e-7)
152
- model.setFMUState(state)
153
- assert model.getFloat64(vrs)[0] == pytest.approx(dt, rel=1e-7)
154
- step_model()
155
- assert model.getFloat64(vrs)[0] == pytest.approx(dt * 3, rel=1e-7)
156
-
157
- serialize_fmu_state = model.serializeFMUState(state)
158
- model.freeFMUState(state)
159
- de_serialize_fmu_state = model.deserializeFMUState(serialize_fmu_state)
160
- model.setFMUState(de_serialize_fmu_state)
161
- assert model.getFloat64(vrs)[0] == pytest.approx(dt, rel=1e-7)
162
-
163
- model.freeFMUState(de_serialize_fmu_state)
164
-
165
- model.terminate()
166
- model.freeInstance()
167
-
168
-
169
- @pytest.mark.integration
170
- def test_integration_get(tmp_path):
171
- script_file = Path(__file__).parent / "slaves/pythonslave.py"
172
- fmu = FmuBuilder.build_FMU(script_file, dest=tmp_path, needsExecutionTool="false")
173
- assert fmu.exists()
174
-
175
- md = fmpy.read_model_description(fmu)
176
- unzip_dir = fmpy.extract(fmu)
177
-
178
- model = fmpy.fmi3.FMU3Slave(
179
- guid=md.guid,
180
- unzipDirectory=unzip_dir,
181
- modelIdentifier=md.coSimulation.modelIdentifier,
182
- instanceName='instance1')
183
-
184
- model.instantiate()
185
- model.enterInitializationMode()
186
- model.exitInitializationMode()
187
-
188
- to_test = {
189
- "intParam": 42,
190
- "intOut": 23,
191
- "realOut": 3.0,
192
- "booleanVariable": True,
193
- "stringVariable": "Hello World!",
194
- "realIn": 2.0 / 3.0,
195
- "booleanParameter": False,
196
- "stringParameter": "dog",
197
- "container.someReal": 99.0,
198
- "container.subContainer.someInteger": -15
199
- }
200
-
201
- model_value = None
202
- variables = mapped(md)
203
- for key, value in to_test.items():
204
- var = variables[key]
205
- vrs = [var.valueReference]
206
- if var.type == "Int32":
207
- model_value = model.getInt32(vrs)[0]
208
- elif var.type == "Float64":
209
- model_value = model.getFloat64(vrs)[0]
210
- elif var.type == "Boolean":
211
- model_value = model.getBoolean(vrs)[0]
212
- elif var.type == "String":
213
- model_value = model.getString(vrs)[0]
214
- else:
215
- pytest.xfail("Unsupported type")
216
-
217
- assert model_value == value
218
-
219
- model.terminate()
220
- model.freeInstance()
221
-
222
-
223
- @pytest.mark.integration
224
- def test_integration_read_from_file(tmp_path):
225
- script_file = Path(__file__).parent / "slaves/pythonslave_read_file.py"
226
- project_file = Path(__file__).parent / "data/hello.txt"
227
- fmu = FmuBuilder.build_FMU(script_file, project_files=[project_file], dest=tmp_path, needsExecutionTool="false")
228
- assert fmu.exists()
229
-
230
- md = fmpy.read_model_description(fmu)
231
- unzip_dir = fmpy.extract(fmu)
232
-
233
- model = fmpy.fmi3.FMU3Slave(
234
- guid=md.guid,
235
- unzipDirectory=unzip_dir,
236
- modelIdentifier=md.coSimulation.modelIdentifier,
237
- instanceName='instance1')
238
-
239
- model.instantiate()
240
- model.enterInitializationMode()
241
- model.exitInitializationMode()
242
-
243
- variables = mapped(md)
244
- var = variables["file_content"]
245
- model_value = model.getString([var.valueReference])[0]
246
-
247
- with (open(project_file, 'r')) as file:
248
- data = file.read()
249
-
250
- assert model_value == data
251
-
252
- model.terminate()
253
- model.freeInstance()
254
-
255
-
256
- @pytest.mark.integration
257
- def test_integration_set(tmp_path):
258
- script_file = Path(__file__).parent / "slaves/pythonslave.py"
259
- fmu = FmuBuilder.build_FMU(script_file, dest=tmp_path, needsExecutionTool="false")
260
- assert fmu.exists()
261
-
262
- md = fmpy.read_model_description(fmu)
263
- unzip_dir = fmpy.extract(fmu)
264
-
265
- model = fmpy.fmi3.FMU3Slave(
266
- guid=md.guid,
267
- unzipDirectory=unzip_dir,
268
- modelIdentifier=md.coSimulation.modelIdentifier,
269
- instanceName='instance1')
270
-
271
- model.instantiate()
272
- model.enterInitializationMode()
273
- model.exitInitializationMode()
274
-
275
- to_test = {
276
- "intParam": 20,
277
- "realIn": 1.0 / 3.0,
278
- "booleanParameter": True,
279
- "stringParameter": "cat",
280
- "container.someReal": 42.0,
281
- "container.subContainer.someInteger": 421
282
- }
283
-
284
- model_value = None
285
- variables = mapped(md)
286
- for key, value in to_test.items():
287
- var = variables[key]
288
- vrs = [var.valueReference]
289
- if var.type == "Int32":
290
- model.setInt32(vrs, [value])
291
- model_value = model.getInt32(vrs)[0]
292
- elif var.type == "Float64":
293
- model.setFloat64(vrs, [value])
294
- model_value = model.getFloat64(vrs)[0]
295
- elif var.type == "Boolean":
296
- model.setBoolean(vrs, [value])
297
- model_value = model.getBoolean(vrs)[0]
298
- elif var.type == "String":
299
- model.setString(vrs, [value])
300
- model_value = model.getString(vrs)[0]
301
- else:
302
- pytest.xfail("Unsupported type")
303
-
304
- assert model_value == value
305
-
306
- model.terminate()
307
- model.freeInstance()
308
-
309
-
310
- @pytest.mark.integration
311
- def test_simple_integration_fmpy(tmp_path):
312
-
313
- script_file = Path(__file__).parent / "slaves/pythonslave.py"
314
- fmu = FmuBuilder.build_FMU(script_file, dest=tmp_path)
315
- assert fmu.exists()
316
- res = fmpy.simulate_fmu(str(fmu), stop_time=2.0)
317
-
318
- assert res["realOut"][-1] == pytest.approx(res["time"][-1], rel=1e-7)
319
-
320
-
321
- @pytest.mark.integration
322
- def test_integration_has_local_dep(tmp_path):
323
-
324
- script_file = Path(__file__).parent / "slaves/slavewithdep.py"
325
- local_file = Path(__file__).parent / "slaves/localmodule.py"
326
-
327
- fmu = FmuBuilder.build_FMU(
328
- script_file,
329
- dest=tmp_path,
330
- project_files=[local_file],
331
- needsExecutionTool="false",
332
- )
333
- assert fmu.exists()
334
-
335
- res = fmpy.simulate_fmu(str(fmu), stop_time=0.5)
336
-
337
- assert res["realOut"][-1] == pytest.approx(
338
- 22.0 * 5.0 * math.exp(res["time"][-1] / 0.1), rel=1e-7
339
- )
340
-
341
-
342
- @pytest.mark.integration
343
- def test_integration_throw_py_error(tmp_path):
344
-
345
- script_file = Path(__file__).parent / "slaves/PythonSlaveWithException.py"
346
- fmu = FmuBuilder.build_FMU(script_file, dest=tmp_path)
347
- assert fmu.exists()
348
-
349
- with pytest.raises(Exception):
350
- fmpy.simulate_fmu(str(fmu), stop_time=1.0)
1
+ import math
2
+ from pathlib import Path
3
+
4
+ import pytest
5
+
6
+ from pythonfmu3.builder import FmuBuilder
7
+
8
+ pytestmark = pytest.mark.skipif(
9
+ not FmuBuilder.has_binary(), reason="No binary available for the current platform."
10
+ )
11
+ fmpy = pytest.importorskip(
12
+ "fmpy", reason="fmpy is required for testing the produced FMU"
13
+ )
14
+
15
+
16
+ def mapped(md):
17
+ m = {}
18
+ for v in md.modelVariables:
19
+ m[v.name] = v
20
+ return m
21
+
22
+
23
+ @pytest.mark.integration
24
+ def test_integration_demo(tmp_path):
25
+ script_file = Path(__file__).parent / "slaves/pythonslave.py"
26
+ fmu = FmuBuilder.build_FMU(script_file, dest=tmp_path, needsExecutionTool="false")
27
+ assert fmu.exists()
28
+ res = fmpy.simulate_fmu(str(fmu), stop_time=0.5)
29
+
30
+ assert res["realOut"][-1] == pytest.approx(res["time"][-1], rel=1e-7)
31
+
32
+
33
+ @pytest.mark.integration
34
+ def test_integration_reset(tmp_path):
35
+ script_file = Path(__file__).parent / "slaves/pythonslave.py"
36
+ fmu = FmuBuilder.build_FMU(script_file, dest=tmp_path, needsExecutionTool="false")
37
+ assert fmu.exists()
38
+
39
+ md = fmpy.read_model_description(str(fmu))
40
+ unzipdir = fmpy.extract(str(fmu))
41
+ model = fmpy.fmi3.FMU3Slave(guid=md.guid,
42
+ unzipDirectory=unzipdir,
43
+ modelIdentifier=md.coSimulation.modelIdentifier,
44
+ instanceName="instance"
45
+ )
46
+ model.instantiate()
47
+ model.enterInitializationMode()
48
+ model.exitInitializationMode()
49
+
50
+ vars = mapped(md)
51
+ vr = vars["realOut"].valueReference
52
+ dt = 0.1
53
+
54
+ initial_value = model.getFloat64([vr])[0]
55
+ assert initial_value == pytest.approx(3.0, rel=1e-7)
56
+ model.doStep(0.0, dt, True)
57
+ read = model.getFloat64([vr])[0]
58
+ assert read == pytest.approx(dt, rel=1e-7)
59
+ model.reset()
60
+ read = model.getFloat64([vr])[0]
61
+ assert read == pytest.approx(initial_value, rel=1e-7)
62
+
63
+ model.terminate()
64
+ model.freeInstance()
65
+
66
+
67
+ @pytest.mark.integration
68
+ def test_integration_get_state(tmp_path):
69
+ script_file = Path(__file__).parent / "slaves/pythonslave.py"
70
+ fmu = FmuBuilder.build_FMU(
71
+ script_file,
72
+ dest=tmp_path,
73
+ needsExecutionTool="false",
74
+ canGetAndSetFMUstate="true")
75
+ assert fmu.exists()
76
+
77
+ md = fmpy.read_model_description(str(fmu))
78
+ unzipdir = fmpy.extract(str(fmu))
79
+ model = fmpy.fmi3.FMU3Slave(guid=md.guid,
80
+ unzipDirectory=unzipdir,
81
+ modelIdentifier=md.coSimulation.modelIdentifier,
82
+ instanceName="instance"
83
+ )
84
+ model.instantiate()
85
+ model.enterInitializationMode()
86
+ model.exitInitializationMode()
87
+
88
+ vars = mapped(md)
89
+ vr = vars["realOut"].valueReference
90
+ dt = 0.1
91
+ t = 0.0
92
+
93
+ def step_model():
94
+ nonlocal t
95
+ model.doStep(t, dt, True)
96
+ t += dt
97
+
98
+ step_model()
99
+ state = model.getFMUState()
100
+ assert model.getFloat64([vr])[0] == pytest.approx(dt, rel=1e-7)
101
+ step_model()
102
+ assert model.getFloat64([vr])[0] == pytest.approx(dt * 2, rel=1e-7)
103
+ model.setFMUState(state)
104
+ assert model.getFloat64([vr])[0] == pytest.approx(dt, rel=1e-7)
105
+ step_model()
106
+ assert model.getFloat64([vr])[0] == pytest.approx(dt * 3, rel=1e-7)
107
+ model.freeFMUState(state)
108
+
109
+ model.terminate()
110
+ model.freeInstance()
111
+
112
+
113
+ @pytest.mark.integration
114
+ def test_integration_get_serialize_state(tmp_path):
115
+
116
+ script_file = Path(__file__).parent / "slaves/pythonslave.py"
117
+ fmu = FmuBuilder.build_FMU(
118
+ script_file,
119
+ dest=tmp_path,
120
+ canGetAndSetFMUstate="true",
121
+ canSerializeFMUstate="true")
122
+ assert fmu.exists()
123
+
124
+ md = fmpy.read_model_description(fmu)
125
+ unzip_dir = fmpy.extract(fmu)
126
+
127
+ model = fmpy.fmi3.FMU3Slave(
128
+ guid=md.guid,
129
+ unzipDirectory=unzip_dir,
130
+ modelIdentifier=md.coSimulation.modelIdentifier,
131
+ instanceName='instance1')
132
+
133
+ model.instantiate()
134
+ model.enterInitializationMode()
135
+ model.exitInitializationMode()
136
+
137
+ vars = mapped(md)
138
+ vrs = [vars["realOut"].valueReference]
139
+ t = 0.0
140
+ dt = 0.1
141
+
142
+ def step_model():
143
+ nonlocal t
144
+ model.doStep(t, dt)
145
+ t += dt
146
+
147
+ step_model()
148
+ state = model.getFMUState()
149
+ assert model.getFloat64(vrs)[0] == pytest.approx(dt, rel=1e-7)
150
+ step_model()
151
+ assert model.getFloat64(vrs)[0] == pytest.approx(dt * 2, rel=1e-7)
152
+ model.setFMUState(state)
153
+ assert model.getFloat64(vrs)[0] == pytest.approx(dt, rel=1e-7)
154
+ step_model()
155
+ assert model.getFloat64(vrs)[0] == pytest.approx(dt * 3, rel=1e-7)
156
+
157
+ serialize_fmu_state = model.serializeFMUState(state)
158
+ model.freeFMUState(state)
159
+ de_serialize_fmu_state = model.deserializeFMUState(serialize_fmu_state)
160
+ model.setFMUState(de_serialize_fmu_state)
161
+ assert model.getFloat64(vrs)[0] == pytest.approx(dt, rel=1e-7)
162
+
163
+ model.freeFMUState(de_serialize_fmu_state)
164
+
165
+ model.terminate()
166
+ model.freeInstance()
167
+
168
+
169
+ @pytest.mark.integration
170
+ def test_integration_get(tmp_path):
171
+ script_file = Path(__file__).parent / "slaves/pythonslave.py"
172
+ fmu = FmuBuilder.build_FMU(script_file, dest=tmp_path, needsExecutionTool="false")
173
+ assert fmu.exists()
174
+
175
+ md = fmpy.read_model_description(fmu)
176
+ unzip_dir = fmpy.extract(fmu)
177
+
178
+ model = fmpy.fmi3.FMU3Slave(
179
+ guid=md.guid,
180
+ unzipDirectory=unzip_dir,
181
+ modelIdentifier=md.coSimulation.modelIdentifier,
182
+ instanceName='instance1')
183
+
184
+ model.instantiate()
185
+ model.enterInitializationMode()
186
+ model.exitInitializationMode()
187
+
188
+ to_test = {
189
+ "intParam": 42,
190
+ "intOut": 23,
191
+ "realOut": 3.0,
192
+ "booleanVariable": True,
193
+ "stringVariable": "Hello World!",
194
+ "realIn": 2.0 / 3.0,
195
+ "booleanParameter": False,
196
+ "stringParameter": "dog",
197
+ "container.someReal": 99.0,
198
+ "container.subContainer.someInteger": -15
199
+ }
200
+
201
+ model_value = None
202
+ variables = mapped(md)
203
+ for key, value in to_test.items():
204
+ var = variables[key]
205
+ vrs = [var.valueReference]
206
+ if var.type == "Int32":
207
+ model_value = model.getInt32(vrs)[0]
208
+ elif var.type == "Float64":
209
+ model_value = model.getFloat64(vrs)[0]
210
+ elif var.type == "Boolean":
211
+ model_value = model.getBoolean(vrs)[0]
212
+ elif var.type == "String":
213
+ model_value = model.getString(vrs)[0]
214
+ else:
215
+ pytest.xfail("Unsupported type")
216
+
217
+ assert model_value == value
218
+
219
+ model.terminate()
220
+ model.freeInstance()
221
+
222
+
223
+ @pytest.mark.integration
224
+ def test_integration_read_from_file(tmp_path):
225
+ script_file = Path(__file__).parent / "slaves/pythonslave_read_file.py"
226
+ project_file = Path(__file__).parent / "data/hello.txt"
227
+ fmu = FmuBuilder.build_FMU(script_file, project_files=[project_file], dest=tmp_path, needsExecutionTool="false")
228
+ assert fmu.exists()
229
+
230
+ md = fmpy.read_model_description(fmu)
231
+ unzip_dir = fmpy.extract(fmu)
232
+
233
+ model = fmpy.fmi3.FMU3Slave(
234
+ guid=md.guid,
235
+ unzipDirectory=unzip_dir,
236
+ modelIdentifier=md.coSimulation.modelIdentifier,
237
+ instanceName='instance1')
238
+
239
+ model.instantiate()
240
+ model.enterInitializationMode()
241
+ model.exitInitializationMode()
242
+
243
+ variables = mapped(md)
244
+ var = variables["file_content"]
245
+ model_value = model.getString([var.valueReference])[0]
246
+
247
+ with (open(project_file, 'r')) as file:
248
+ data = file.read()
249
+
250
+ assert model_value == data
251
+
252
+ model.terminate()
253
+ model.freeInstance()
254
+
255
+
256
+ @pytest.mark.integration
257
+ def test_integration_set(tmp_path):
258
+ script_file = Path(__file__).parent / "slaves/pythonslave.py"
259
+ fmu = FmuBuilder.build_FMU(script_file, dest=tmp_path, needsExecutionTool="false")
260
+ assert fmu.exists()
261
+
262
+ md = fmpy.read_model_description(fmu)
263
+ unzip_dir = fmpy.extract(fmu)
264
+
265
+ model = fmpy.fmi3.FMU3Slave(
266
+ guid=md.guid,
267
+ unzipDirectory=unzip_dir,
268
+ modelIdentifier=md.coSimulation.modelIdentifier,
269
+ instanceName='instance1')
270
+
271
+ model.instantiate()
272
+ model.enterInitializationMode()
273
+ model.exitInitializationMode()
274
+
275
+ to_test = {
276
+ "intParam": 20,
277
+ "realIn": 1.0 / 3.0,
278
+ "booleanParameter": True,
279
+ "stringParameter": "cat",
280
+ "container.someReal": 42.0,
281
+ "container.subContainer.someInteger": 421
282
+ }
283
+
284
+ model_value = None
285
+ variables = mapped(md)
286
+ for key, value in to_test.items():
287
+ var = variables[key]
288
+ vrs = [var.valueReference]
289
+ if var.type == "Int32":
290
+ model.setInt32(vrs, [value])
291
+ model_value = model.getInt32(vrs)[0]
292
+ elif var.type == "Float64":
293
+ model.setFloat64(vrs, [value])
294
+ model_value = model.getFloat64(vrs)[0]
295
+ elif var.type == "Boolean":
296
+ model.setBoolean(vrs, [value])
297
+ model_value = model.getBoolean(vrs)[0]
298
+ elif var.type == "String":
299
+ model.setString(vrs, [value])
300
+ model_value = model.getString(vrs)[0]
301
+ else:
302
+ pytest.xfail("Unsupported type")
303
+
304
+ assert model_value == value
305
+
306
+ model.terminate()
307
+ model.freeInstance()
308
+
309
+
310
+ @pytest.mark.integration
311
+ def test_simple_integration_fmpy(tmp_path):
312
+
313
+ script_file = Path(__file__).parent / "slaves/pythonslave.py"
314
+ fmu = FmuBuilder.build_FMU(script_file, dest=tmp_path)
315
+ assert fmu.exists()
316
+ res = fmpy.simulate_fmu(str(fmu), stop_time=2.0)
317
+
318
+ assert res["realOut"][-1] == pytest.approx(res["time"][-1], rel=1e-7)
319
+
320
+
321
+ @pytest.mark.integration
322
+ def test_integration_has_local_dep(tmp_path):
323
+
324
+ script_file = Path(__file__).parent / "slaves/slavewithdep.py"
325
+ local_file = Path(__file__).parent / "slaves/localmodule.py"
326
+
327
+ fmu = FmuBuilder.build_FMU(
328
+ script_file,
329
+ dest=tmp_path,
330
+ project_files=[local_file],
331
+ needsExecutionTool="false",
332
+ )
333
+ assert fmu.exists()
334
+
335
+ res = fmpy.simulate_fmu(str(fmu), stop_time=0.5)
336
+
337
+ assert res["realOut"][-1] == pytest.approx(
338
+ 22.0 * 5.0 * math.exp(res["time"][-1] / 0.1), rel=1e-7
339
+ )
340
+
341
+
342
+ @pytest.mark.integration
343
+ def test_integration_throw_py_error(tmp_path):
344
+
345
+ script_file = Path(__file__).parent / "slaves/PythonSlaveWithException.py"
346
+ fmu = FmuBuilder.build_FMU(script_file, dest=tmp_path)
347
+ assert fmu.exists()
348
+
349
+ with pytest.raises(Exception):
350
+ fmpy.simulate_fmu(str(fmu), stop_time=1.0)