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

조회 수: 13 (최근 30일)
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 :
*******************************************************************************/

답변 (1개)

Harsh
Harsh 2025년 5월 29일
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
jarvis
jarvis 2025년 6월 2일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by