Programmatically read the definitions of a custom storage class in a custom package
6 次查看(过去 30 天)
显示 更早的评论
Hello,
I've been trying to programatically read the custom storage class definitions of a custom package.
My first issue is that I could not find any way to directly load my package CustomDataClass but I need to create a Simulink data dictionary and then an Embedded Coder dictionary where I can load my package.
dataDictionary = Simulink.data.dictionary.create('DataDictionary.sldd');
coderDictionary = coder.dictionary.create(dataDictionary);
coderDictionary.loadPackage('CustomDataClass');
Afterwards I found all my custom storage classes and loaded one of them CustomParameter
storageClasses = getSection(coderDictionary,'StorageClasses');
entry = getEntry(storageClasses, 'CustomParameter');
I wanted to get a specific property like the HeaderFile but
entry.get('HeaderFile')
returns 'HeaderFile' is not a valid property. and
entry.getAvailableProperties
only returns {'Name'} {'Description'} {'DataSource'} even if I open Custom Storage Class Designer I can see more available properties with values.
Is it even possible what I'm trying to achieve? Am I missing something?
0 个评论
采纳的回答
Abhas
2024-5-24
Hi Andrei,
The get method and getAvailableProperties method limitations you're experiencing is beacuse all properties of a custom storage class are directly not accessible through the high-level API provided by coder.Dictionary objects. The getAvailableProperties method returns only {'Name'}, {'Description'}, and {'DataSource'}.
You can refer to the following documentation link to know more about the accessible properties: https://www.mathworks.com/help/ecoder/ref/coder.dictionary.entry-class.html
A viable workaround for accessing specific custom storage class properties that are not directly exposed through the coder dictionary API is:
Q = Simulink.Parameter;
Q.Value = int32(5);
Q.CoderInfo.StorageClass = 'Custom';
Q.CoderInfo.CustomStorageClass = 'Define';
Q.CoderInfo.CustomAttributes.HeaderFile=" " % You can specify the HeaderFile here
This method involves creating a Simulink.Parameter object (or similar), setting its storage class to your custom storage class, and then accessing the CustomAttributes field. This is more of a manual approach but can be effective for accessing or modifying properties not directly accessible through the coder dictionary entries.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!