Export Activate Models to Functional Mock-up Units with Source Code

Yannik Schneidereit
Yannik Schneidereit Altair Community Member
edited February 2022 in Community Q&A

Hello,

I would like to export an activate model to fmu with c source code.

I already done this in matlab/ simulink with the command: exportToFMU2CS('mdlName','SaveSourceCodeToFMU','on')

How could I do this in activate?

 

Thank you for your help!

Answers

  • João Marabisa
    João Marabisa
    Altair Employee
    edited February 2022

    Hi Yannik,

    Is there any specific reason why you're using code instead of the interface to export the FMU model?

    There is a very easy way to export an FMU model on Activate's interface:

    1) Create a Superblock of your C block:

    image

    2) Export the FMU as Model exchange:

    image

    3) Import that model using FMU block:

    image

    4) Manipulate the input port and Run:

    image

    I attached the models (SCM + FMU), please see if it works for your purposes!

    Thanks, João.

  • Yannik Schneidereit
    Yannik Schneidereit Altair Community Member
    edited February 2022

    Hi João,

    thank you for your help! Unfortunately your solution don't solve my Problem.

    I need the C header and C sources, wich describe the fmu. They are in the folder "sources" in the ZIP file. How could I export the fmu with this optional directory?

     

    The following is from the FMI Specification 2.0.3:

    https://fmi-standard.org/downloads/ 

    image

  • João Marabisa
    João Marabisa
    Altair Employee
    edited February 2022

    Hi João,

    thank you for your help! Unfortunately your solution don't solve my Problem.

    I need the C header and C sources, wich describe the fmu. They are in the folder "sources" in the ZIP file. How could I export the fmu with this optional directory?

     

    The following is from the FMI Specification 2.0.3:

    https://fmi-standard.org/downloads/ 

    image

    Hi Yannik,

    Did you try to change the extension of your .FMU to .ZIP and access the files inside it?

  • Yannik Schneidereit
    Yannik Schneidereit Altair Community Member
    edited February 2022

    Hi Yannik,

    Did you try to change the extension of your .FMU to .ZIP and access the files inside it?

    That makes no difference. The exported Simulink fmu is .fmu and i could access the files inside. And in the simulink export .fmu is the "sources" folder.

  • João Marabisa
    João Marabisa
    Altair Employee
    edited February 2022

    Hi João,

    thank you for your help! Unfortunately your solution don't solve my Problem.

    I need the C header and C sources, wich describe the fmu. They are in the folder "sources" in the ZIP file. How could I export the fmu with this optional directory?

     

    The following is from the FMI Specification 2.0.3:

    https://fmi-standard.org/downloads/ 

    image

    Hi Yannik,

    If you really want the C source code in the FMU, you have 02 options:

    1. Select the SuperBlock that you want to export, and write in the Activate Prompt Command: vssPProjExportToFMU(struct('fmufile','E:\myfmufilename.fmu')); 
    • Note that you must have installed visual studio build tools. 
  • There is a (beta) version of C code generation on Activate:
  • image

    Note that (1) will export the FMU exactly as you want, but there are some blocks in Activate that aren't supported to be exported yet.

    Thanks, João.