From: Ramon Nogueron on
How can I use make_rtw or generate code manually from a block in my model?

I want to generate a s-function from a block but instead of using the context menu I want to do it in command line, so then I could automatize the process when there are changes.

Thank you.
Ramon.
From: Phil Goddard on
Generating an S-function from the command line is not going to be an easy process.

Under the hood MATLAB/Simulink/RTW is
a) creating a new model with visibility turned off
b) copying the subsystem into the new model (along with inports and outports if required)
c) putting a mask on top of the subsytem (to do this it renders the tunable-parameters dialog box so that it knows which parameters to put into the mask)
d) creates the mex file (s-function) for the whole new model and puts it under the mask.

The difficulty in replicating this programatically is with step c.

The command that gets executed when you manually right click on a subsystem and select the option to build an S-function from it is
>> rtwprivate('ssgensfun','Create',get_param('modelName/Heirachy/SubsystemName','Handle'))

where the only thing you need to change in that line for your specific system is the string 'modelName/Heirachy/SubsystemName'.

That will kick off the process, but will still bring up the tunable parameters dialog and wait for you to manually tell it what parameters are tunable.
The only way I can think of getting this to happen automatically would be for you to use some java.awt.Robot functionality (search the newsgroup for some examples of that class) to position the mouse over the dialog and mimic the pressing of the OK button.

Phil.
From: Ramon Nogueron on
Hi,

Thanks, that command makes the trick but as you said the pop-up window about tunnable vars still there.
I can't believe there is not other subroutine after the pop-up I could call.
I don't like at all using the robot, but in the case I finally have no other option, how can I get access to that window?

Thank you.
R.


"Phil Goddard" <philNOSPAM(a)goddardconsulting.ca> wrote in message <hab5lh$4s4$1(a)fred.mathworks.com>...
> Generating an S-function from the command line is not going to be an easy process.
>
> Under the hood MATLAB/Simulink/RTW is
> a) creating a new model with visibility turned off
> b) copying the subsystem into the new model (along with inports and outports if required)
> c) putting a mask on top of the subsytem (to do this it renders the tunable-parameters dialog box so that it knows which parameters to put into the mask)
> d) creates the mex file (s-function) for the whole new model and puts it under the mask.
>
> The difficulty in replicating this programatically is with step c.
>
> The command that gets executed when you manually right click on a subsystem and select the option to build an S-function from it is
> >> rtwprivate('ssgensfun','Create',get_param('modelName/Heirachy/SubsystemName','Handle'))
>
> where the only thing you need to change in that line for your specific system is the string 'modelName/Heirachy/SubsystemName'.
>
> That will kick off the process, but will still bring up the tunable parameters dialog and wait for you to manually tell it what parameters are tunable.
> The only way I can think of getting this to happen automatically would be for you to use some java.awt.Robot functionality (search the newsgroup for some examples of that class) to position the mouse over the dialog and mimic the pressing of the OK button.
>
> Phil.
From: Phil Goddard on
On my machine the following works.
You'll most likely need to play around with the x and y positions of the mouse to get the mouseMove correct for your machine.

r = java.awt.Robot;
button1 = java.awt.event.InputEvent.BUTTON1_MASK;
rtwprivate('ssgensfun','Create',get_param('untitled/Subsystem','Handle'));
r.mouseMove(600,520)
r.mousePress(button1);r.mouseRelease(button1);

Phil.