%%
%%
%%
%%
%%Copyright1994-2009TheMathWorks,Inc.
%%
%%Abstract:
%%ThisTLClibraryfilecontainssystemutilityfunctions.
%%
 
%if EXISTS("_SUTILLIB_") == 0
%assign _SUTILLIB_ = 1
 
%%Function:SLibSetNeedAbsoluteTime(tid)===================
%%
%function SLibSetNeedAbsoluteTime(tid)
  %if SLibIsERTCodeFormat()
    %assert TYPE(tid) == "Number" && tid >= 0
    %assign ::CompiledModel.SampleTime[tid].NeedAbsoluteTime = "yes"
    %if ::CompiledModel.SampleTime[tid].TimeSource == "BaseRate"
      %<SLibSetNeedAbsoluteTime(0)>
    %elseif ::CompiledModel.SampleTime[tid].TimeSource == "Caller"
       %<SLibSetNeedAbsoluteTime(FcnGetAsyncPromotedTID(tid))>
    %endif
    %assign fcnType = ::BlockFcn
    %if LibAsynchronousTriggeredTID(tid) && fcnType != "UNKNOWN"
      %if fcnType == "Output" || fcnType == "Outputs"
        %assign fcnType = "OutputUpdate"
      %endif
      %assign flagName = "asyncTaskAccessTimeIn%<fcnType>"
      %if !ISFIELD(::CompiledModel.SampleTime[tid],flagName)
        %addtorecord ::CompiledModel.SampleTime[tid] %<flagName> 1
      %endif
    %endif
  %endif
  %return ""
%endfunction
 
%%DocFunction{SampleTimeFunctions}:LibAsyncTaskAccessTimeInFcn==================
%%Abstract:
%%Returns1ifthespecifiedasynchronoustaskidentifier(TID)accessabsolutetime
%%ingivenfunctiontype
%%
%function LibAsyncTaskAccessTimeInFcn(tid, fcnType)
  %if fcnType == "Output" || fcnType == "Outputs"
    %assign fcnType = "OutputUpdate"
  %endif
  %assign flagName = "asyncTaskAccessTimeIn%<fcnType>"
  %return ISFIELD(::CompiledModel.SampleTime[tid],flagName) && ...
    ::CompiledModel.SampleTime[tid].%<flagName>
%endfunction
 
%%Function:SLibSetNeedFloatAbsoluteTime(tid)===================
%%
%%
%function SLibSetNeedFloatAbsoluteTime(tid)
  %if SLibIsERTCodeFormat()
    %assert TYPE(tid) == "Number" && tid >= 0
    %assign ::CompiledModel.SampleTime[tid].NeedAbsoluteTime = "yes"
    %assign ::CompiledModel.SampleTime[tid].NeedFloatTime = "yes"
  %endif
  %return ""
%endfunction
 
%%Function:SLibNeedAbsoluteTime==============================================
%%Abstract:
%%ReturntrueifanyofSampleTimeneedabsolutetime.
%%
%function SLibNeedAbsoluteTime()
  %assign needAbsoluteT = TLC_FALSE
  %with ::CompiledModel
    %foreach tid = NumSampleTimes
      %if SampleTime[tid].NeedAbsoluteTime == "yes"
    %assign needAbsoluteT = TLC_TRUE
    %break
      %endif
    %endforeach
  %endwith
  %return(needAbsoluteT)
%endfunction
 
%%Function:SLibNeedAbsoluteTimeForTID==============================================
%%Abstract:
%%ReturntrueifTIDneedabsolutetime,iftidpassedinis"",
%%ReturntrueifanyofSampleTimeneedabsolutetime.
%%
%function SLibNeedAbsoluteTimeForTID(tid)
   %if TYPE(tid) == "Number" && tid >= 0
     %return(::CompiledModel.SampleTime[tid].NeedAbsoluteTime == "yes")
   %else
     %return(SLibNeedAbsoluteTime())
   %endif
%endfunction
 
%%Function:SLibClockTickIsUnit32Pair==============================================
%%Abtract:
%%ReturntrueifthedatatypeidofClockTickDataTypeIdis
%%tSS_TIMER_UINT32_PAIR
%function SLibClockTickIsUnit32Pair(tid)
  %assert TYPE(tid) == "Number" && tid >= 0
   
  %return (::CompiledModel.SampleTime[tid].ClockTickDataTypeId == ...
    tSS_TIMER_UINT32_PAIR)
%endfunction
 
%%Function:SLibGetReimAndIdx=================================================
%%Abstract:
%%SplittheinputargumentsigIdxintoreimandidx.
%%
%function SLibGetReimAndIdx(sigIdx) void
  %%
  %assign idxType = TYPE(sigIdx)
  %%
  %if idxType == "String"
    %%
    %assign idNum = IDNUM(sigIdx)
    %%
  %elseif idxType == "Number"
    %%
    %assign idNum = ["", %<sigIdx>]
    %%
  %else
    %assign errTxt = "The last input argument '%<sigIdx>' is of type " ...
      "'%<idxType>', expecting an argument of type /"Number/" or " ...
      "/"String/". "
    %<LibReportError(errTxt)>
    %%
    %assign idNum = "error"
  %endif
  %%
  %return idNum
  %%
%endfunction %% SLibGetReimAndIdx
 
 
%endif %% _SUTILLIB_
 
%%[EOF]sutillib.tlc