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!