%%============================================================================
%%
%%Abstract:
%%
%%Thissystemfilegeneratestheextmode_task_info.mfilecontaining
%%informationrelatedtothetasksintheExternalModemodel.
%%
%%Copyright2017-2019TheMathWorks,Inc.
%%
%if EXISTS("_EXTMODETASKLIB_") == 0
%assign _EXTMODETASKLIB_ = 1
 
%%Function:SLibWriteExtModeTaskInfoFile=======================================
%%Abstract:
%%Theoutputofthisfileprovidesinformationonthetasksthat
%%arepartoftheExternalModemodel.
%%
%%Notes
%%oinXCP-basedexternalMode,theextmode_task_info()output
%%isusedbycoder.internal.xcp.updateCodeDescriptorscript
%%toretrievethetask/rateidassignedtothevarioussignals
%%whenthemodelcontainsModelRef
%%
%function SLibWriteExtModeTaskInfoFile() void
 
%selectfile STDOUT
%if RTWVerbose
### Creating extmode_task_info.m.
%endif
%selectfile NULL_FILE
 
%openfile ExtModeTaskInfoDotM = "extmode_task_info.m"
function [taskInfo, numtask, isDeploymentDiagram]=extmode_task_info()
  %assign stOneBased = 1
 
  %% Concurrent execution is not currently supported
  %assign isDeploymentDiagram = LibIsDeploymentDiagram()
  %assert !isDeploymentDiagram
 
  %foreach st = NumSampleTimes
    %% We are only interested in periodic tasks. Initialize, Reset and
    %% Terminate tasks have a period of "inf". If present, they will be
    %% after the periodic tasks, so will not affect the index in taskInfo of
    %% the periodic tasks.
    %if !ISINF(SampleTime[st].PeriodAndOffset[0])
      taskInfo(%<stOneBased>).samplePeriod = %;
      taskInfo(%<stOneBased>).sampleOffset = %;
 
      %if EXISTS(SampleTime[st].Priority)
        taskInfo(%<stOneBased>).taskPrio = %;
      %else
        taskInfo(%<stOneBased>).taskPrio = 0;
      %endif
 
      %if ISEQUAL(1, %<stOneBased>)
        taskInfo(%<stOneBased>).taskName = 'BaseRate';
      %else
        %assign tmprate = stOneBased - 1
        taskInfo(%<stOneBased>).taskName = ['SubRate' '%<tmprate>'];
      %endif
      taskInfo(%<stOneBased>).entryPoints = {};
     
      %assign stOneBased = stOneBased + 1
    %endif
 
  %endforeach
 
  %assign ntask = stOneBased - 1
 
  %if ISEQUAL(0, ntask)
    taskInfo(1).samplePeriod = %;
    taskInfo(1).sampleOffset = %;
    taskInfo(1).taskPrio = 0;
    taskInfo(1).taskName = 'BaseRate';
    taskInfo(1).entryPoints = {};
    %assign ntask = 1
  %endif
 
  numtask = %<ntask>;
  for i = 1:numtask
    if ( 0 == isnumeric(taskInfo(i).samplePeriod) )
      taskInfo(i).samplePeriod = evalin('base', 'str2double(taskInfo(i).samplePeriod)');
    end
    if ( isempty(taskInfo(i).taskName) )
      taskInfo(i).taskName = ['AutoGen' i ];
    end
  end
 
  isDeploymentDiagram = %<isDeploymentDiagram>;
 
end %%%function extmode_task_info()
%closefile ExtModeTaskInfoDotM
%selectfile NULL_FILE
%endfunction %% SLibWriteExtModeTaskInfoFile
 
%endif %% _EXTMODETASKLIB_
 
%%[EOF]extmodetasklib.tlc