Display Transition Id's in Stateflow

10 views (last 30 days)
Rayce Neal
Rayce Neal on 11 Jun 2020
Edited: Tomasz Karczmarski on 18 Nov 2020
I am looking to show the transition ID's in stateflow. The ones I am referring to specifically are the transition ID's that Code inspector shows tracing for.
I understand that you can click those links and they will open the model directly to those transitions but I am needing all ID's to be shown. So Is there a matlab setting to enable this feature?

Answers (1)

Tomasz Karczmarski
Tomasz Karczmarski on 18 Nov 2020
Edited: Tomasz Karczmarski on 18 Nov 2020
I assume that you are referring to transition links displayed in Simulink Code Inspector Report, the ones that look similar to this:
<model>/Chart/Transition:2
Those links are built using feature called Simulink ID (or SID). It is possible to obtain list of those SIDs using MATLAB script. The model in question must be already open before executing these commands.
I have been using MATLAB R2020b.
rt = sfroot;
% Let's fill array transitionsH with handles for all transitions in
% Statelfow chart
transitionsH = rt.find('-isa','Stateflow.Transition');
% This will find all transitions in all models open at the time.
% Let's fill cell array tranSIDs with Simulink IDs (SIDs) for each
% transition stored in transitionsH
tranSIDs = arrayfun(@(x) Simulink.ID.getSID(x), transitionsH, 'UniformOutput', false);
% Let's fill cell array clickableLinks with hyperlinks to transitions
% stored in transitionsH. Clicking on those links will highlight relevant
% transition.
clickableLinks = arrayfun(@(x) sf('GetHyperLinkedNameForObject',x.Id), transitionsH, 'UniformOutput', false);
% You can use those links in messages displayed in MATLAB command window, like such:
disp(['This is the transition I was talking about: ' clickableLinks{1}]);
% You'll have to remember that property "x.Id" used in this call is
% volatile and it cannot be guaranteed to hold the same value next time the model
% is loaded, so I discourage you from persisting them. They should be obtained
% fresh before they are used (which means that array transitionsH must be refreshed).
% If instead of clicking on a link you would prefer to use MATLAB script to
% highlight each transition you can use SIDs from tranSIDs and pass them to
% the following function:
Simulink.ID.hilite(tranSIDs{1});

Categories

Find more on Complex Logic in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!