How can I programmatically set the enum name of a chart with output port monitoring of child activity?
2 次查看(过去 30 天)
显示 更早的评论
When editing a Stateflow chart in the model explorer, there is a number of properties that can be set, such as 'Enable zero-crossing detection' etc. The corresponding object of a Stateflow.Chart (obtained using 'sfgco' or 'find') allows setting all these properties programmatically, except for one: the "Enum name"-property for charts where "Create output port for monitoring" is set to "Child activity". Where can I change that property programmatically?
Note that the "OutputData"-property allows setting the properties of the related output data element, but not the "Enum name"-property of the chart. The following screenshot illustrates the issue. After changing the OutputData.DataType-property, the related output data DataType-property changes, but not the "Enum name"-property of the governing chart.
0 个评论
回答(1 个)
Sebastian Castro
2015-7-14
编辑:Sebastian Castro
2015-7-14
I think you can use the Stateflow API to do this, though it'll take a little bit of digging. For example:
rt = sfroot;
m = rt.find('-isa','Simulink.BlockDiagram');
ch = m.find('-isa','Stateflow.Chart');
After those weird steps, you can search for the state you're interested in.
mode = ch.find('-isa','Stateflow.State','-and','Name','Mode Definitions and Transition');
Once you have "mode", you can look at the table in this document for all the accessible properties and methods of these so-called "Stateflow.State".
Without having access to MATLAB right now, and looking at the properties in that table, I'd guess you do something like:
mode.LoggingInfo.UserSpecifiedLogName = 'modeName';
... but the easiest thing to do is to check by displaying this "mode" variable and seeing which property name is the one with the Enum name.
Good luck, and I hope I'm on the right track :)
- Sebastian
2 个评论
Alessio Canepa
2016-12-31
Hi Alexander, I've the same problem. Did you find a way to set that property progmatically? Thanks
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphical Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!