Programmatically read the definitions of a custom storage class in a custom package
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Andrei
el 20 de Mayo de 2024
Respondida: Abhas
el 24 de Mayo de 2024
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 comentarios
Respuesta aceptada
Abhas
el 24 de Mayo de 2024
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Deployment, Integration, and Supported Hardware en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!