How can I programmatically set the enum name of a chart with output port monitoring of child activity?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/152131/image.png)
0 commentaires
Réponses (1)
Sebastian Castro
le 14 Juil 2015
Modifié(e) : Sebastian Castro
le 14 Juil 2015
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 commentaires
Alexander Wille
le 14 Juil 2015
Modifié(e) : Alexander Wille
le 14 Juil 2015
Alessio Canepa
le 31 Déc 2016
Hi Alexander, I've the same problem. Did you find a way to set that property progmatically? Thanks
Voir également
Catégories
En savoir plus sur Stateflow Programmatic Interface 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!