
3 Writing S-Functions As C-MEX files
3-96
To configure an S-function to call a function-call subsystem:
1 Specify which elements are to execute the function-call system in
mdlInitializeSampleTimes. For example:
ssSetCallSystemOutput(S,0); /* call on 1st element */
ssSetCallSystemOutput(S,2); /
* call on 3rd element */
2 Execute the subsystem in the appropriate mdlOutputs or mdlUpdates
S-function routines. For example:
static void mdlOutputs(...)
{
if (((int)*uPtrs[0]) % 2 == 1) {
if (!ssCallSystemWithTid(S,0,tid)) {
/* Error occurred, which will be reported by Simulink */
return;
}
} else {
if (!ssCallSystemWithTid(S,2,tid)) {
/* Error occurred, which will be reported by Simulink */
return;
}
}
...
}
See simulink/src/sfun_fcncall.c for an example.
Function-callsubsystemsareapowerfulmodelingconstruct.You canconfigure
Stateflow® blocks to execute function-call subsystems, thereby extending the
capabilities and integration of state logic (Stateflow) with dataflow (Simulink).
For more information on their use in Stateflow, see the Stateflow
documentation.
Komentarze do niniejszej Instrukcji