Automate SFunction generation - Simulink workflow

1 次查看(过去 30 天)
Hi,
I've got a subsystem block that I'm generating an SFunction of, which I'm then using in a model.
How do I automate the generation of the SFunction so that when the subsystem changes the SFunction is regenerated, so I can be sure I have the latest version? Any script I can write to do this will be called when the library file containing the subsystem changes, but I don't know what to put in the script.
As far as I can see, if the SFunction is regenerated it will replace all the code files - so it isn't necessary to make any changes to the model that uses it. Please correct me if I'm wrong in this assumption. (This is assuming I can treat the block as a black box and the inputs/outputs won't be changing).
Many thanks,
  1 个评论
James
James 2011-9-15
I want to write a script that is the equivalent of: Right-clicking on a model block, selecting RealTimeWorkshop, then Generate Code, then clicking Build on the dialogue that pops up.
I've been told anything that can be done in the Simulink GUI can be done via the command line. I just don't know how.

请先登录,再进行评论。

采纳的回答

Kaustubha Govind
Kaustubha Govind 2011-9-15
Try the following:
set_param('subsystem_model', 'SystemTargetFile', 'rtwsfcn.tlc');
set_param('subsystem_model', 'CreateModel', 'off');
rtwbuild('subsystem_model/subsystem_name');

更多回答(1 个)

TAB
TAB 2011-9-15
You can trace the change in your library file containing subsystem by its 'ModifiedDate'.
Write a script to find the modified date as
% Load model library & get its handle
h=load_system('subsystem_library_model');
% Get object from handle
ho=get_param(h,'object');
% Get last modified date & time
LastMdfd=ho.ModifiedDate;
Output will be in the formate 'Thu Sep 15 16:19:06 2011'
You can save the ModifiedDate in a text file and compare the current obtaind date with saved date .
  2 个评论
James
James 2011-9-15
Thanks Tabrez, but it's not that I'm trying to do.
I want to write a script that is the equivalent of:
Right-clicking on a model block, selecting RealTimeWorkshop, then Generate Code, then clicking Build on the dialogue that pops up.
I need it done a lot so a script to do this will save a lot of time.
James
James 2011-9-15
Well, I am doing that (the script will fire when versioncontrol software sees a change) but that's not the point of the problem.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by