Problem facing in CGT when try to include author name , description, Date for reference model's autogenerated files

13 views (last 30 days)
I'm facing problem in CGT template. I need to add author name, version, date,description of model in all generated code files.
I have added commands in CGT templates like
/*******************************************************************************
** Author : %<Creator>
** Model Rev : %<ModelVersion>
** Change Description : %<Description>
** Date : %<Date>
*******************************************************************************/
This is working fine as expected for main model's code files (top model)
/*******************************************************************************
** Author : vijay
** Model Rev : 1.55
** Change Description : test
** Date : 17-Mar-2025
*******************************************************************************/
But the above content is missing in .c and .h files of model that are used as reference model(inside top model).
Eventhough I have tried with doc block and I masked the content to creator,descrption in refence model. But it can't add the conntent. It print like this
/*******************************************************************************
** Author :
** Model Rev : 1.532
** Change Description :
** Date :
*******************************************************************************/

Answers (1)

Harsh
Harsh on 29 May 2025
When generating code for referenced models within a top-level Simulink model, you may notice that the fields "Author", "Change Description", and "Date" appear blank. This happens because the tokens "%<Creator>", "%<Description>", and "%<Date>" are not recognized in the code generation templates when used in the context of a referenced model.
To verify which tokens are supported, open the referenced model as the top model and navigate to "Model Settings > Code Generation > Templates > Code templates", then click the "Edit" button next to the source file template. In the opened CGT file (typically "ert_code_template.cgt"), you will find an abstract section listing the supported tokens such as "%<ModelName>", "%<ModelVersion>", and "%<SourceGeneratedOn>". You can use "%<SourceGeneratedOn>" as an alternative for the date. If needed, you may consider hard-coding values for "Author" and "Description" directly into the template as no alternative for them is present.
Finally, if you want to use your original approach with tokens like "%<Creator>", the correct way is to generate code for the referenced model by opening it as the top model. In this case, the tokens will be recognized and populated as expected.
  1 Comment
jarvis
jarvis on 2 Jun 2025
Yes, this will work. I know this when I generate code for reference model alone the properties will be there in generated code.
But my problem is I'm using m script to generate code for context model. In that scenerion Its not possible to develop script to generate code individually. If I do like that then there is no use of going with context model>
I checked many articles. nothing is there releated to pass refenrece property in code

Sign in to comment.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!