%assign ::modelName = CompiledModel.Name
%assign ::solverMode = CompiledModel.FixedStepOpts.SolverMode
%assign ::fundamentalStepSize = CompiledModel.FundamentalStepSize
+%assign ::tid01Eq = CompiledModel.FixedStepOpts.TID01EQ
%assign ::numSampleTimes = CompiledModel.NumSynchronousSampleTimes
%% Need to set the template compliance flag before you can use the API
{
/* Initialize model */
%<LibCallModelInitialize()>\
-
+ /* Step the model for any subrate */
xSemaphoreGive(initialized_signal);
+ %foreach idx = LibGetNumSyncPeriodicTasks()
+ %assign tid = idx + tid01Eq
+ %assign sampleTime = LibGetSampleTimePeriodAndOffset(tid,0)
+ %assign steps = FEVAL("round", sampleTime / CompiledModel.FundamentalStepSize)
+ #define STEPS_FOR_TID%<tid> ((int)%<steps>)
+ %endforeach
while (1) {
/* Lock semaphore */
if (xSemaphoreTake(step_signal, portMAX_DELAY)) {
working = TRUE;
- %<LibCallModelStep(0)>\
- steps_working++;
- working = FALSE;
- }
+ %if LibNumSynchronousSampleTimes() > 1
+ int i;
+ for (i = %<tid01Eq>; i < %<LibNumSynchronousSampleTimes()>; i++) {
+ switch(i) {
+ %foreach idx = LibGetNumSyncPeriodicTasks()
+ %assign tid = idx + tid01Eq
+ case %<tid> :
+ %assign sampleTime = LibGetSampleTimePeriodAndOffset(tid,0)
+ if ((steps_working % STEPS_FOR_TID%<tid>) == 0) {
+ %<LibCallModelStep(tid)>\
+ }
+ break;
+ %endforeach
+ default :
+ break;
+ }
+ }
+ %else
+ %<LibCallModelStep(0)>\
+ %endif
+ steps_working++;
+ working = FALSE;
+ }
}
%% /* In case of shutdown, delete this task */