How to call Stateflow charts in a sequence

3 views (last 30 days)
I'm looking to set up a simulink/stateflow simulation to replicate a program that we currently are using, and I was wondering if it was possible to call a stateflow chart like a function. I know there is the Function Call option on the chart itself, but I'm not entirily sure if the way I want to set this up is compatible. Basically, I would like to recreate a simple main() while 1 loop that calls on a handful of flowcharts, something like this:
% The main project I am working with is coded with C++ so if there are
% minor syntax problems I apologize
main()
{
% Program initialization
while 1
Chart_1();
Chart_2();
Chart_3();
%etc.
end
}
Ideally, I would like to be able to take the simulation and convert it BACK into C++ code and return with that structure as well, and I haven't been able to find a good way to go about that. I have my charts, and now I just would like to enter and run them once each in a sequence in a never ending loop.
Would it be benificial to create a main() chart, that outputs a function call, and each of these Chart_X() functions output the next function in the list? Or could I have 1 function block that contains that code above and it runs that chart without using the Function Call event?
In the photo, ideally the event() would be replaced with the Chart_X() function.
Another way of tackling it that I've tried, but am unsure of how to do, is having main() function block have one signal just used for the function call. It would connect to each chart and only activate teh one that is called in the main function sequence.
Thank you for the help!

Answers (1)

Fangjun Jiang
Fangjun Jiang on 9 Nov 2021
Use a Function-Call Generator block and a Function-Call Split block to sheduel the calling sequence.

Categories

Find more on Complex Logic in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!