How Can I Send a String to an FMU?
Question
I would like to send a string value to an FMU right at the beginning of the simulation. How can I do that?
Possible use case: I have integrated a Silver FMU into CarMaker for a co-simulation. In CarMaker a test automation runs via the Test Manager, where several maneuvers are executed. In Silver I would like to record the simulation results in measurement data (*.mdf) files. Therefore the TestRun name is needed to identify the recordings in a meaningful way.
Solution
Strings can be transferred to an FMU in the same way as other parameters can be transferred to the FMU. However, this is not possible via a UAQ.
How to transfer parameters to an FMU is explained in the Programmer's Guide section 9.3.4 "FMU Parameterization".
Regarding the described use case, the question is how to pass the name of the currently executed TestRun variation within the Test Manager to the FMU, so that it can be used as a name for the .mdf file.
For this, we recommend to define a KeyValue in the Test Manager which has to be set as the string of interest. In the Test Manager you can automate this using a Tcl script and a StartProc.
Attached, you can find an exemplary Tcl script and Test Manager file for CarMaker 9.1. The scripts has to be stored in the Data > Script folder of your project directory and the StartProc can then be called in the Test Manager as explained in the User's Guide chapter 14.5.4 "ScriptFile". To avoid problems in the defined KeyValue due to spaces, the name will be adjusted automatically in the script.
The log messages that are contained in the script are output in the Script Control GUI.
- Date: 30.11.2020
- Product: CarMaker
- Version: 9.1
- Component: FMI
- Language: English