How do I change the properties of an Enum stored in a data dictionary programmatically?

10 ビュー (過去 30 日間)
Hello,
I have a data dictionary an I defined several enums inside it through the Model Explorer window.
Now I want to change some of the properties of those enums programatically through MATLAB code (for example: based on some configuration for the embedded coder). Is there any way to do it? I coulnd't find any relevant documentation regarding this issue, Only how to add or remove enums from data dictionary.
I tried to do the following thing but it didn't work:
myDictionaryObj = Simulink.data.dictionary.open(ModuleName);
dDataSectObj = getSection(myDictionaryObj,'Design Data');
entriesEnum = find(dDataSectObj,'-value','-class','EnumTypeDefinition');
I Specifically want to progarmatically change the enum settings in the 'Code Generation' tab: Data Scope and Header file.
Any help will be much appreciated.
Thanks

採用された回答

Fangjun Jiang
Fangjun Jiang 2024 年 3 月 19 日
  5 件のコメント
Fangjun Jiang
Fangjun Jiang 2024 年 3 月 20 日
編集済み: Fangjun Jiang 2024 年 3 月 20 日
That was a problem. Several years ago, I have requested the Mathworks to hve full SLDD API to access all data object property values. But so far in R2024a, it still just has getValue() and setValue() methods.
I can suggest this workarounds:
  1. Create the enumeral class object, set the .DataScope and .HeaderFile property and then import it to SLDD.
The other workaround Simulink.data.evalinGlobal('ModelName','a=11;') works for an existing ordinary variable in the SLDD to change value, but it does not work for an existing enumeral class such as Simulink.data.evalinGlobal('ModelName','myColors.DataScope="Exported";')
Daniel Purits
Daniel Purits 2024 年 3 月 20 日
Understood. Thanks @Fangjun Jiang for your anwer!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeString についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by