From: Jorge on
Hi, there!

I am trying to develop a kind of "for" block that executes a function-call subsystem a number of times (in one single time step) as if time were elapsing at each iteration for the subsystem only. The idea is to nest a simulation into one step of the actual simulation while minimizing changes to the simulated model to be nested (as compared to a version that is not nested). This seems possible if one resorts to the framework for asynchronous tasks. I developed a 2-level S-function based on the code for "Task Sync" and so far I have managed to implement code generation that does what I want. The problem now is to have the correct behaviour in simulation. I reckon it won't be enough just to do something like this:

static void mdlOutputs(SimStruct *S, int_T tid)
{
for (int i= 0; i < SomeArg; ++i) {
ssCallSystemWithTid(S, 0, tid);
}
}

Is there anything that might make time pass for the function-call subsystem at each iteration? Something on the lines of LibSetAsyncClockTicks, but now on the s-function side? Might the undocumented SS_TIMESOURCE_SELF_INTERNAL have anything to do with it?

Thanks in advance,

Jorge.