Why do I receive an error while simulating a stateflow chart which passes an enumerated data in Stateflow 7.9 (R2012a)?

2 次查看(过去 30 天)
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.

采纳的回答

MathWorks Support Team
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 个评论
TAB
TAB 2015-10-20
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Stateflow 的更多信息

产品


版本

R2012a

Community Treasure Hunt

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

Start Hunting!

Translated by