CATIA-Systems / FMIKit-Simulink

Import and export Functional Mock-up Units with Simulink
Other
155 stars 50 forks source link

Reusable function support for grtfmi.tlc #397

Closed TolgaS61 closed 1 year ago

TolgaS61 commented 1 year ago

Hello, I was previously building FMUs with FMIKit 3.0-alpha.2 in MATLAB R2018b and using multiple instances in simulations in Simulink and other environments without any problems. Now that I started testing a build in the newest FMIKit 3.0 and simulating multiple instances in Simulink, the FMU logs following error:

The FMU can only be instantiated once per process. -> Error

This might of course be expected, as reusable function was disabled for grtfmi in FMIKit 3.0-beta.1 (6be34aef8649b20e93361da1e3c592b9f83a77eb). However, do I have to expect any issues if I use R2018b with older versions of the FMIKit, where it still was enabled? Earlier I used R2019b for builds, but with multiple instances there was some faulty behaviour, so I switched back to R2018b, because in other issues (#307, #326) you mentioned that code generation changed in R2019a, so that some of the internal structure is shared. With R2018b and FMIKit 3.0-alpha.2 I don't have any issues, so could "reusable function" be enabled for the earlier MATLAB versions again, or am I missing something?

Of course if there is another workaround to simulate multiple instances of a single FMU, it would be sufficient, too. Especially in Simulink, where I also need to build nested FMUs containing multiple instances of another FMU, which is not possible anymore when using FMUs built with the newest FMIKit. Thank you!

t-sommer commented 1 year ago

It is still possible to have several instances of the same FMU, as long as they are extracted to different directories, i.e. every FMU block must have a different unzip directory. This approach should also work when exporting models with nested FMUs.

Please re-open if it does not work.