How to prevent stateflow from opening the system?

1 回表示 (過去 30 日間)
bert de Jong
bert de Jong 2020 年 2 月 12 日
コメント済み: bert de Jong 2020 年 3 月 31 日
When loading a model using 'load_system', simulink is opened in the background. When adding a subsystem (using the API) to the loaded model, the simulink remains in the background (so far so good). However if you add, for example, a state to a stateflow block (using the API again), simulink pops up to the foreground. To make things worse, the window is activated every time a new state is added.
How to prevent simulink to go to the foreground when sending these types of commands?
  2 件のコメント
Fangjun Jiang
Fangjun Jiang 2020 年 2 月 12 日
Stateflow chart is sometimes treated differently than a subsystem. Can you contact the Mathworks tech support with a simplified script and see what they say?
bert de Jong
bert de Jong 2020 年 2 月 12 日
Tech support should be active on these forums as well. An example scipt is a good idea :) :
ns = new_system('example');
load_system(ns);
add_block('sflib/Chart', 'example/sf');
rt = sfroot;
top=rt.find('-isa', 'Simulink.BlockDiagram','-and', 'Name', 'example');
sfChart = top.find('-isa','Stateflow.Chart','-and','Path','example/sf');
newState=Stateflow.State(sfChart);
newState.Name='newState';
% Next statement will open the simulink window:
newState.IsSubchart=1;

サインインしてコメントする。

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2020 年 2 月 12 日
Maybe, it is dependent on how you program it? The following example doesn't show the model until the last line.
bdclose all;
ns = new_system('example');
add_block('sflib/Chart', 'example/sf');
rt = sfroot;
m = rt.find('-isa','Stateflow.Machine');
ch = m.find('-isa','Stateflow.Chart','-and','Name','sf');
sA = Stateflow.State(ch);
sA.Name = 'A';
sA.Position = [50 50 310 200];
sA1 = Stateflow.State(ch);
sA1.Name = 'A1';
sA1.Position = [80 120 90 60];
sA2 = Stateflow.State(ch);
sA2.Name = 'A2';
sA2.Position = [240 120 90 60];
%% use this to view
set(ns,'Open','On')
  3 件のコメント
Fangjun Jiang
Fangjun Jiang 2020 年 2 月 12 日
Please update when tech support replies. I am interested to know.
bert de Jong
bert de Jong 2020 年 3 月 31 日
It is builtin behaviour that cannot be changed.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by