Why do I receive an error while simulating a stateflow chart which passes an enumerated data in Stateflow 7.9 (R2012a)?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 16 Nov 2012
Commenté : TAB
le 20 Oct 2015
I have defined the enumerated type signal with the head file mybasiccolors.h:
Simulink.defineIntEnumType('BasicColors', ...
{'Red', 'Yellow', 'Blue'}, ...
[0;1;2], ...
'Description', 'Basic colors', ...
'DefaultValue', 'Blue', ...
'HeaderFile', 'mybasiccolors.h', ..
'DataScope', 'Imported', ...
'AddClassNameToEnumNames', true);
I want to simulate only the model but not generate code. Therefore, the "mybasiccolors.h" should not be needed during simulation stage.
In Stateflow 7.8 (R2011b), the simulation completed. But in MATLAB R2012a, it pops up error regards missing the "mybasiccolors.h" file:
Data has compiled structure or enumeration type ‘BasicColors’, which specifies customer header file ‘mybasiccolors.h’.
This custom header file must be directly or indirectly included in model’s Configuration Parameters ‘Simulation Target/Custom Code/Header file’ field.
Réponse acceptée
MathWorks Support Team
le 16 Nov 2012
This behavior is expected in R2012a. From R2012a onwards, if data in a Stateflow chart uses an enumerated type with a custom header file, you will have to include the header information in Simulation Target > Custom Code pane as documented in the followingr release note and documentation page:
If you do not have access to the header file and do not plan to generate code at all, you should be able to define the enumeration the following way (without the header file) and simulate his model:
Simulink.defineIntEnumType('BasicColors', ...
{'Red', 'Yellow', 'Blue'}, ...
[0;1;2], ...
'Description', 'Basic colors', ...
'DefaultValue', 'Blue', ...
'DataScope', 'Imported', ...
'AddClassNameToEnumNames', true);
1 commentaire
TAB
le 20 Oct 2015
Any reason why this change.
A related option "SimGenImportedTypeDefs" is removed from Code Generation settings GUI and by default it is Off for the model.
But making set_param('modelname', 'SimGenImportedTypeDefs', 'On') from command line works.
After turning On SimGenImportedTypeDefs, there is no need to define the header file.
Any side/bad effects of turning "SimGenImportedTypeDefs" On from command line.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Stateflow dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!