User`s guide
Function-Call Subsystems
3-95
Function-Call Subsystems
You ca n create a triggered subsystem whose execution is determined by logic
internal to an S-function instead of by the value of a signal. A subsystem so
configured is called a function-call subsystem. To implement a function-call
subsystem:
• In the Trigger block, select
function-call as the Trigger type parameter.
• In the S-function, use t he
ssCallSystemWithTid macro to call the triggered
subsystem.
• In the model, connect theS-Functionblockoutput directly to the triggerport.
Note Function-call connections can only be performed on the first output
port.
Function-call subsystems are not executed directly by Simulink; rather, the
S-function determines when to execute the subsystem. When the s ubsystem
completes execution, control returns to the S-function. T his figure illustrates
the interaction between a function-call subsystem and an S-function:
Int his figure,
ssCallSystemWithTid executesthe function-callsubsystem that
is connected to the first output port element.
ssCallSystemWithTid returns 0
if an error occurs while executing the function-call subsystem or if the output
is unconnected. After the function-call subsystem executes, control is returned
to your S-function.
Function-call subsystems can only be connected to S-functions that have been
properly configured to accept them.
f()
Function-call
subsystem
void mdlOutputs(SimStruct *S, int_T tid)
{
...
if (!ssCallSystemWithTid(S,outputElement,tid)) {
return; /* error or output is unconnected */
}
<next statement>
...
}