Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Simulink API: Identify SF blocks with 'User specified states/transition execution order' set 'ON'

Asked by Rolf on 16 Jan 2013

Hi all, I would like to write a script which helps me to identify stateflow blocks in my models where certain settings were made (e.g. find all stateflow charts where 'User secified states/transition execution order' is set to ON). I would like to use this script to proof for a review that certain settings were not used in my model etc.

I tried to do it with the find_system() command. But I don't know what parameter to use in this function to identifiy stateflow charts.

It would be easy to identify all gain blocks in my model - the correct command to show all locations would be: find_system(gcs, 'BlockType', 'Gain')

However I saw that this does not work that easy for searching stateflow blocks. If I click on a stateflow chart and do a get_param(gcb, 'BlockType') the return is 'SubSystem' - so it seems that there is no unique Blocktype for stateflow charts, it is only treated as subsystem.

The next step after detection of all statefow charts would be to identify those where parameter 'User specified states/transition execution order' was set to ON. I also don't know how to do that.

Does anybody know how to do that , or is there another solution ?

--- Is there maybe a global switch where 'User secified states/transition execution order' can be switched ON/OFF for the whole model. A compare of the generated code with/without that switch could identify where the setting is used and where it takes effect.

---

Thanks for your help, Rolf

0 Comments

Rolf

Products

No products are associated with this question.

1 Answer

Answer by Guy Rouleau on 16 Jan 2013

Try the Stateflow API

http://www.mathworks.com/help/stateflow/api/overview-of-the-stateflow-api.html

You should be able to find any/all charts in a model with this API and get/set its properties.

1 Comment

Rolf on 17 Jan 2013

Hi Guy. Thanks for the hint. Here is what I made out of it:

chroot = sfroot; %% Get handle to the SF root object charts = chroot.find('-isa','Stateflow.Chart')

for i=1:1:size(charts,1) if (charts(i).UserSpecifiedStateTransitionExecutionOrder) disp(' '); disp ( '** WARNING - UserSpecStateTransExecOrder active in'); disp (['** chart : ',(charts(i).Name)]); disp (['** used in: ',(charts(i).Path)]); disp '**Please review explicitly the trans exec order there.'; end end

Guy Rouleau

Contact us