%%
%%
%%
%%
%%Copyright1994-2014TheMathWorks,Inc.
%%
%%Abstract:
%%ThisTLClibraryfilecontainsallobsoleteTLCfunctionsrequiredfor
%%backwardscompatability.
%%
 
%if EXISTS("_OBSOLETELIB_") == 0
%assign _OBSOLETELIB_ = 1
 
 
%%Function:LibIndexStruct====================================================
%%Abstract:
%%Determinehowtoindexa1-Darray.
%%
%function LibIndexStruct(widthAndOffset, ucv, lcv, idx) void
  %return SLibGet1DArrayIndexer(widthAndOffset, ucv, lcv, idx)
%endfunction
 
 
 
%%Function:LibBlockGetRollThreshold==========================================
%%Abstract:
%%Obsoletedfunctiontogettheappropriaterollthresholdfortheblock.
%%
%function LibBlockGetRollThreshold(block, rollThreshold) void
  %return rollThreshold
%endfunction
 
 
%%Function:LibIndexMatrix====================================================
%%Abstract:
%%Determinehowtoindexa2-Darray.
%%
%function LibIndexMatrix(nRows, rucv, rlcv, ridx, nCols, cucv, clcv, cidx) void
 
  %openfile msg
   
    The LibIndexMatrix function that shipped with R12 has been replaced
    by SLibGet2DArrayIndexer. These functions are not identical.
    LibIndexMatrix incorrectly handled rlcv and clcv by adding the
    signal index to them. In addition, there was no roller support for
    2-D arrays. As of Oct 14, 2000 was no 2-D roller available, thus
    you must specify rlcv="", clcv="" when using SLiBGet2DArrayIndexer.
    You need to replace your calls of LibIndexMatrix to use
    SLibGet2DArrayIndexer and make the appropriate function argument changes.
  %closefile msg
 
  %setcommandswitch "-v1"
  %<LibReportError(msg)>
%endfunction
 
 
 
%%Function:LibBaseAddrOfMdlStruct===========================================
%%Abstract:
%%Determinethebaseaddressforastructureorarraydeclared.
%%
%function LibBaseAddrOfMdlStruct(name) void
  %assign warnTxt = "LibBaseAddrofMdlStruct is obsolete. Replace with " ...
    "explicit definition (e.g. &name)."
    %<LibReportWarning(warnTxt)>;
  %return "&%<name>"
%endfunction
 
 
%%Function:LibRenameParameter================================================
%%
%%Abstract:
%%Thiscallshouldbemadefrominsidetheblock'sBlockInstanceSetup
%%function.Thisfunction
%%
%%1)renamestheparametertothenamespecified
%%2)createsanewreferencetotheparameterbythatname
%%
%%Synopsis:
%%LibRenameParameter(block,param,newName)
%%
%%block=referencetotheblock
%%param=referencetotheblockparameter
%%newName=newnamefortheparameter
%%
%function LibRenameParameter(block, param, newName) void
 
  %if ShowObsoleteWarnings
    %assign warnTxt = "This function is now obsolete. Specifying parameter names is " ...
      "now supported via the mdlRTW() function of C-MEX S-Functions."
    %<LibBlockReportWarning(block, warnTxt)>
  %endif
 
  %% rename the specified parameter
  %assign param.Name = newName
 
  %% create a reference in the parent scope for future reference
  %assign %<newName> = param
  %assign block = block + %<newName>
 
%endfunction %% LibRenameParameter
 
 
%%Function:LibDefineRWork====================================================
%%
%%Abstract:
%%Thiscallshouldbemadefrominsidetheblock'sBlockInstanceSetup
%%function,andaddsthespecifedrworkdefinitiontotheblock.
%%Thefunctioncreatesandmaintainsaninternalrecordfortherwork
%%definition,removingtheSimulinkdefinitionifnecessary.
%%
%%LibDefineRWork(block,"PrevT",1)
%%LibDefineRWork(block,"PrevU",3)
%%
%%Internallythiscreatesablockrecord
%%
%%NumRWorkDefines2
%%RWorkDefine{
%%Name"PrevT"
%%Width1
%%StartIndex0
%%}
%%RWorkDefine{
%%Name"PrevU"
%%Width3
%%StartIndex1
%%}
%%PrevTRWorkDefine[0]
%%PrevURWorkDefine[1]
%%
%%NotethatPrevTandPrevUarereferencestoRWorkDefine[0]
%%andRWorkDefine[1],respectively,andareaddedbythesystem
%%filewhichexecutestheblock's"BlockInstanceSetup"function.
%%
%%Synopsis:
%%LibDefineRWork(block,name,width)
%%
%%block=referencetotheblock
%%name=whatyouwanttocalltherwork
%%width=thewidthofthisrwork
%%
%function LibDefineRWork(block, name, width) void
 
  %if ShowObsoleteWarnings
    %assign warnTxt = "This function is now obsolete. Specifying RWork names is now " ...
      "supported via the mdlRTW() function of C-MEX S-Functions."
    %<LibBlockReportWarning(block, warnTxt)>
  %endif
 
  %if block.UserDefinedRWork == 0
    %% remove Simulink definition from block, if necessary
    %if (block.NumRWorkDefines > 0)
      %foreach rwIdx = NumRWorkDefines
        %undef RWorkDefine
      %endforeach
    %endif
    %assign block.NumRWorkDefines = 0
    %assign block.UserDefinedRWork = 1
  %endif
 
  %% Get StartIndex
 
  %if block.NumRWorkDefines > 0
    %assign lastDefine = block.RWorkDefine[block.NumRWorkDefines-1]
    %assign startIndex = lastDefine.StartIndex + lastDefine.Width
  %else
    %assign startIndex = 0
  %endif
   
  %% create the new RWork record and attach it to the block
 
  %assign tmpVar = RWorkDefine { Name name; Width width; StartIndex startIndex }
  %assign block = block + RWorkDefine
 
  %% promote Name into parent scope
 
  %assign %<tmpVar.Name> = block.RWorkDefine[block.NumRWorkDefines]
  %assign block = block + %<tmpVar.Name>
 
  %% increment NumRWorkDefines
 
  %assign block.NumRWorkDefines = block.NumRWorkDefines + 1
 
%endfunction %% LibDefineRWork
 
 
%%Function:LibDefineIWork====================================================
%%
%%Abstract:
%%Thiscallshouldbemadefrominsidetheblock'sBlockInstanceSetup
%%function,andaddsthespecifedIWorktotheblock.Thefunction
%%createsandmaintainsaninternalrecordfortheIWorkdefinition.
%%Forexample,ablockmayhaveIWorkrecordsforsystemenable.
%%
%%LibDefineIWork(block,"SystemEnable",1)
%%LibDefineIWork(block,"IcNeedsLoading",1)
%%
%%Internallythiscreatesablockrecord
%%
%%NumIWorkDefines2
%%IWorkDefine{
%%Name"SystemEnable"
%%Width1
%%StartIndex0
%%}
%%IWorkDefine{
%%Name"IcNeedsLoading"
%%Width1
%%StartIndex1
%%}
%%SystemEnableIWorkDefine[0]
%%ICNeeedsLoadingIWorkDefine[1]
%%
%%NotethatSystemEnableandIcNeedsLoadingarereferencesto
%%IWorkDefine[0]andIWorkDefine[1],respectively,andareadded
%%bythesystemfilewhichexecutestheblock's"BlockInstanceSetup"
%%function.
%%
%%Synopsis:
%%LibDefineIWork(block,name,width)
%%
%%block=referencetotheblock
%%name=whatyouwanttocalltheiwork
%%width=thewidthoftheiwork
%%
%function LibDefineIWork(block, name, width) void
 
  %if ShowObsoleteWarnings
    %assign warnTxt = "This function is now obsolete. Specifying IWork names is now " ...
      "supported via the mdlRTW() function of C-MEX S-Functions."
    %<LibBlockReportWarning(block, warnTxt)>
  %endif
 
  %if block.UserDefinedIWork == 0
    %% remove Simulink definition from block, if necessary
    %if (block.NumIWorkDefines > 0)
      %foreach iwIdx = NumIWorkDefines
        %undef IWorkDefine
      %endforeach
    %endif
    %assign block.NumIWorkDefines = 0
    %assign block.UserDefinedIWork = 1
  %endif
 
  %% Get StartIndex
 
  %if block.NumIWorkDefines > 0
    %assign lastDefine = block.IWorkDefine[block.NumIWorkDefines-1]
    %assign startIndex = lastDefine.StartIndex + lastDefine.Width
  %else
    %assign startIndex = 0
  %endif
   
  %% create the IWork record and attach it to the block
 
  %assign tmpVar = IWorkDefine { Name name; Width width; StartIndex startIndex }
  %assign block = block + IWorkDefine
 
  %% promote Name into parent scope
 
  %assign %<tmpVar.Name> = block.IWorkDefine[block.NumIWorkDefines]
  %assign block = block + %<tmpVar.Name>
 
  %% increment NumIWorkDefines
 
  %assign block.NumIWorkDefines = block.NumIWorkDefines + 1
 
%endfunction %% LibDefineIWork
 
 
%%Function:LibDefinePWork====================================================
%%
%%Abstract:
%%Thiscallshouldbemadefrominsidetheblock'sBlockInstanceSetup
%%function,andaddsthespecifedPWorktotheblock.Thefunction
%%createsandmaintainsaninternalrecordforthePWorkdefinition.
%%Forexample,ablockmayhaveaPWorkrecordfordatalogging.
%%
%%LibDefinePWork(block,"LoggedData",3)
%%
%%Internallythiscreatesablockrecord
%%
%%NumPWorkDefines1
%%PWorkDefine{
%%Name"LoggedData"
%%Width3
%%StartIndex0
%%}
%%LoggedDataPWorkDefine[0]
%%
%%NotethatLoggedDataisareferencetoPWorkDefine[0]whichisadded
%%bythesystemfilewhichexecutestheblock's"BlockInstanceSetup"
%%function.
%%
%%Synopsis:
%%LibDefinePWork(block,name,width)
%%
%%block=referencetotheblock
%%name=whatyouwanttocallthepwork
%%width=thewidthofthepwork
%%
%function LibDefinePWork(block, name, width) void
 
  %if ShowObsoleteWarnings
    %assign warnTxt = "This function is now obsolete. Specifying PWork names is now " ...
      "supported via the mdlRTW() function of C-MEX S-Functions."
    %<LibBlockReportWarning(block, warnTxt)>
  %endif
 
  %if block.UserDefinedPWork == 0
    %% remove Simulink definition from block, if necessary
    %if (block.NumPWorkDefines > 0)
      %foreach pwIdx = NumPWorkDefines
        %undef PWorkDefine
      %endforeach
    %endif
    %assign block.NumPWorkDefines = 0
    %assign block.UserDefinedPWork = 1
  %endif
 
  %% Get StartIndex
 
  %if block.NumPWorkDefines > 0
    %assign lastDefine = block.PWorkDefine[block.NumPWorkDefines-1]
    %assign startIndex = lastDefine.StartIndex + lastDefine.Width
  %else
    %assign startIndex = 0
  %endif
   
  %% create the PWork record and attach it to the block
 
  %assign tmpVar = PWorkDefine { Name name; Width width; StartIndex startIndex }
  %assign block = block + PWorkDefine
 
  %% promote Name into parent scope
 
  %assign %<tmpVar.Name> = block.PWorkDefine[block.NumPWorkDefines]
  %assign block = block + %<tmpVar.Name>
 
  %% increment NumPWorkDefines
 
  %assign block.NumPWorkDefines = block.NumPWorkDefines + 1
 
%endfunction %% LibDefinePWork
 
 
%%Function:LibDiscreteState==================================================
%%
%function LibDiscreteState(ucv, lcv, idx) void
 
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibDiscreteState has been renamed to " ...
      "LibBlockDiscreteState. Please update the target file."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
 
  %return LibBlockDiscreteState(ucv,lcv,idx)
 
%endfunction %% LibDiscreteState
 
 
%%Function:LibContinuousState================================================
%%
%function LibContinuousState(ucv, lcv, idx) void
 
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibContinuousState has been renamed to " ...
      "LibBlockContinuousState. Please update the target file."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
 
  %return LibBlockContinuousState(ucv,lcv,idx)
 
%endfunction %% LibContinuousState
 
 
%%Function:LibPrevZCState====================================================
%%
%function LibPrevZCState(ucv, lcv, pzcIdx) void
 
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibPrevZCState has been renamed to " ...
      "LibBlockPrevZCState. Please update the target file."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
 
  %return LibBlockPrevZCState(ucv,lcv,pzcIdx)
 
%endfunction %% LibPrevZCState
 
 
%%Function:LibDataOutputPortWidth===========================================
%%
%%Abstract:
%%Returnthewidthoftheblocksoutputport.
%%
%%Synopsis:
%%LibDataOutputPortWidth(portNum)
%%portNum=portnumber(startingfrom0)
%%
%function LibDataOutputPortWidth(portNum) void
 
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibDataOutputPortWidth has been " ...
      "renamed to LibBlockOutputSignalWidth. Please update the target " ...
      "file."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
 
  %return LibBlockOutputSignalWidth(portNum)
 
%endfunction %% LibDataOutputPortWidth
 
 
%%Function:LibMaxDataOutputPortWidth=========================================
%%
%%Abstract:
%%Returnthemaximumwidthofalltheoutputports.
%%
%%Synopsis:
%%LibMaxDataOutputPortWidth()
%%
%function LibMaxDataOutputPortWidth() void
 
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibMaxDataOutputPortWidth is obsolete. " ...
      "Please update the target file."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
 
  %assign maxWidth = -1
  %foreach portIdx = NumDataOutputPorts
    %assign width = LibDataOutputPortWidth(portIdx)
    %if width > maxWidth
      %assign maxWidth = width
    %endif
  %endforeach
  %return maxWidth
 
%endfunction %% LibDataOutputPortWidth
 
 
%%Function:LibDataInputPortWidth=============================================
%%
%%Abstract:
%%Returnthewidthofaninputport.
%%
%%Synopsis:
%%LibDataInputPortWidth(portNum)
%%portNum=Inputportnumber(startingfrom0)
%%
%function LibDataInputPortWidth(portNum) void
 
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibDataInputPortWidth has been " ...
      "renamed to LibBlockInputSignalWidth. Please update the target " ...
      "file."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
 
  %return LibBlockInputSignalWidth(portNum)
 
%endfunction %% LibDataInputPortWidth
 
 
%%Function:LibMaxDataInputPortWidth==========================================
%%
%%Abstract:
%%Returnthemaximumwidthofalltheinputports.
%%
%%Synopsis:
%%LibMaxDataInputPortWidth()
%%
%function LibMaxDataInputPortWidth() void
 
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibMaxDataInputPortWidth is obsolete. " ...
      "Please update the target file."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
 
  %assign maxWidth = -1
  %foreach portIdx = NumDataInputPorts
    %assign width = LibDataInputPortWidth(portIdx)
    %if width > maxWidth
      %assign maxWidth = width
    %endif
  %endforeach
  %return maxWidth
 
%endfunction %% LibMaxDataInputPortWidth
 
 
 
%%Function:LibMaxBlockIOWidth================================================
%%
%%Abstract:
%%Iftheblockhasoutputportsreturnthemaximumwidthoftheoutput
%%ports,otherwise,returnthemaximumwidthofitsinputports.
%%
%%Synopsis:
%%LibMaxBlockIOWidth()
%%
%%
%function LibMaxBlockIOWidth() void
 
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibMaxBlockIOWidth is obsolete. Please " ...
      "update the target file."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
 
  %if NumDataOutputPorts > 0
    %return LibMaxDataOutputPortWidth()
  %else
    %return LibMaxDataInputPortWidth()
  %endif
%endfunction %% LibMaxBlockIOWidth
 
 
%%Function:LibBlockInportLocation============================================
%%
%%Abstract:
%%Returnstheappropriateidentifiergivingthesignalsource
%%foraninportblock.
%%
%%SeeLibBlockInputSignalfortypesofstringswhichcanbereturned.
%%
%%Synopsis:
%%StringLibBlockInportLocation(ucv,lcv,sigIdx)
%%
%%ucv=usercontrolvariablestring
%%lcv=loopcontrolvariablestring
%%sigIdx=stringorintegeroffsetintoblocksignal
%%
%function LibBlockInportLocation(ucv, lcv, sigIdx) void
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibBlockInportLocation is obsolete. " ...
      "Please update the target file to use the new function " ...
      "LibBlockSrcSignalLocation instead."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
  %return LibBlockSrcSignalLocation("inport", ucv, lcv, sigIdx)
%endfunction %% LibBlockInportLocation
 
 
%%Function:LibBlockControlPortLocation=======================================
%%
%%Abstract:
%%Returnstheappropriateidentifiergivingthesignalsource
%%foranenableortriggerportblock.
%%
%%SeeLibBlockInputSignalfortypesofstringswhichcanbereturned.
%%
%%Synopsis:
%%StringLibBlockControlPortLocation(porttype,ucv,lcv,sigIdx)
%%
%%portType="enable"or"trigger"
%%ucv=usercontrolvariablestring
%%lcv=loopcontrolvariablestring
%%sigIdx=stringorintegeroffsetintoblocksignal
%%
%function LibBlockControlPortLocation(portType, ucv, lcv, sigIdx) void
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibBlockControlPortLocation is " ...
      "obsolete. Please update the target file to use the new function " ...
      "LibBlockSrcSignalLocation instead."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
  %return LibBlockSrcSignalLocation(portType, ucv, lcv, sigIdx)
%endfunction %% LibBlockControlPortLocation
 
 
%%Function:LibBlockOutportLocation===========================================
%%
%%Abstract:
%%Returnstheappropriateidentifierforanoutportblock(this
%%willbealocationinthesystemoutputvector,Y)whichexpands
%%to:
%%
%%Y.block[ucv]-ucvspecified
%%y0[lcv]-lcvspecifiedandsignaliswide
%%Y.block-lcvspecifiedandsignalisscalar
%%Y.block[sigIdx]-otherwise
%%
%%Note1:Theindexisappropriatelyreplacedwithucvorlcv
%%whenspecified(ucvhashigherprecedencethanlcv).
%%
%%Note2:Thewidthoftheoutputportisdeterminedbythewidthof
%%theinputport.
%%
%%Synopsis:
%%StringLibBlockOutportLocation(ucv,lcv,sigIdx)
%%
%%ucv=usercontrolvariable
%%lcv=loopcontrolvariable
%%sigIdx=offsetintoblocksignal
%%
%function LibBlockOutportLocation(ucv, lcv, sigIdx) void
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibBlockOutportLocation is " ...
      "obsolete. Please update the target file to use the new function " ...
      "LibBlockDstSignalLocation instead."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
  %return LibBlockDstSignalLocation("outportblk", ucv, lcv, sigIdx)
%endfunction %% LibBlockOutportLocation
 
 
%%Function:LibMapSignalSource================================================
%%Abstract:
%%Thisfunctionisobsolete.UpdatetouseFcnMapDataTypedSignalSource.
%%
%function LibMapSignalSource(mapSource, mapIndex, ucv, lcv) void
 
  %assign errTxt = "The function LibMapSignalSource is obsolete. Please " ...
    "update the target file to use FcnMapDataTypedSignalSource."
  %<LibBlockReportError([], errTxt)>
 
%endfunction %% LibMapSignalSource
 
 
%%Function:LibControlPortInputSignal=========================================
%%
%%Abstract:
%%Returnstheappropriatecontrolportinputsignaldependingonthe
%%sourceofinputsignal(i.e.,Ui,Xi,Bi,orGi).
%%
%%Synopsis:
%%LibControlPortInputSignal(portIdx,sigIdx)
%%
%%portIdx=controlportnumber,startingfrom0
%%sigIdx=offsetintothesignal,i.e.,currentindexofforeach
%%
%function LibControlPortInputSignal(portIdx, sigIdx) void
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibControlPortInputSignal is " ...
      "obsolete. Please update the target file to use the new function " ...
      "LibBlockInputSignal instead."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
  %assign ip = ControlInputPort[portIdx]
  %return FcnMapDataTypedSignalSource(ip, "", "", sigIdx, "")
%endfunction %% LibControlPortInputSignal
 
 
%%Function:LibExternalResetSignal============================================
%%
%%Abstract:
%%Returnstheappropriateresetsignalintotheresetport
%%dependingonthesourceofinputsignal(i.e.,Ui,Xi,Bi,orGi).
%%
%%Synopsis:
%%LibExternalResetSignal(portIdx,sigIdx)
%%
%%portIdx=Resetportnumber,startingfrom0
%%sigIdx=offsetintothesignal,i.e.,currentindexofforeach
%%
%function LibExternalResetSignal(portIdx, sigIdx) void
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibExternalResetSignal is " ...
      "obsolete. Please update the target file to use the new function " ...
      "LibBlockInputSignal instead."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
  %return LibBlockInputSignal(portIdx, "", "", sigIdx)
%endfunction %% LibExternalResetSignal
 
 
%%Function:LibSourceSignalBlock==============================================
%%Abstract:
%%Thisfunctionreturnsareferencetotheblockthatoutputsthe
%%specifiedsignal.Theactualreturnvalueis
%%
%%block-ifthesourceblockisnon-virtual
%%0-ifthesourceblockisvirtualblock,orcannotbedetermined
%%becausethesignalSrcisbeingwrittenintobymultipleblocks
%%
%%Synopsis:
%%%<LibSourceSignalBlock(signalSrc)>
%%
%%signalSrc=Signalsourcespecifiedinthe.rtwfile.Forexample,
%%B0,X0,U0,orG.
%%
%function LibSourceSignalBlock(signalSrc) void
 
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibSourceSignalBlock is " ...
      "obsolete. Please update the target file to use the new function " ...
      "LibBlockSrcSignalBlock instead."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
   
  %assign portObj = SLibCreateDummyPortRecord()
  %assign portObj.SignalSrc[0] = signalSrc
 
  %assign sigRec = SLibGetSourceRecord(portObj, 0)
   
  %if ISEMPTY(sigRec) || !ISFIELD(sigRec,"SigSrc")
    %return 0
  %else
    %return System[sigRec.SigSrc[0]].Block[sigRec.SigSrc[2]]
  %endif
   
%endfunction
 
 
%%Function:LibOpenTIDScope==================================================
%%
%%Abstract:
%%ReturntheappropriateTIDscopegiventhattidis
%%
%%Discrete:if(ssIsSampleHit(S,%<tid>,tid)){
%%Continuous:if(ssIsContinuousTask(S,tid)){
%%
%%Synopsis:
%%%<LibOpenTIDScope(tid)>
%%tid=TIDofblock
%%
%%SeeAlso:
%%LibTIDScope
 
%function LibOpenTIDScope(tid) void
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibOpenTIDScope is " ...
      "obsolete. Please update the target file to use the new function " ...
      "LibIsSampleHit."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
 
  %assign period = ::CompiledModel.SampleTime[tid].PeriodAndOffset[0]
  %assign offset = ::CompiledModel.SampleTime[tid].PeriodAndOffset[1]
  %if period == 0.0 && offset == 0.0
    %return "if (%<RTMIsContinuousTask()>) {"
  %else
    %return "if (%<RTMIsSampleHit(tid)>) {"
  %endif
%endfunction
 
 
%%Function:LibTIDScope======================================================
%%
%%Abstract:
%%ReturntheappropriateTIDscopegiventhattidis
%%
%%Discrete:ssIsSampleHit(S,%<tid>,tid)
%%Continuous:ssIsContinuousTask(S,tid)
%%
%%Synopsis:
%%%<LibTIDScope(tid)>
%%tid=TIDofblock
%%
%%SeeAlso:
%%LibOpenTIDScope
 
%function LibTIDScope(tid) void
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibTIDScope is " ...
      "obsolete. Please update the target file to use the new function " ...
      "LibIsSampleHit."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
 
  %assign period = ::CompiledModel.SampleTime[tid].PeriodAndOffset[0]
  %assign offset = ::CompiledModel.SampleTime[tid].PeriodAndOffset[1]
  %if period == 0.0 && offset == 0.0
    %return "%<RTMIsContinuousTask()>"
  %else
    %return "%<RTMIsSampleHit(tid)>"
  %endif
%endfunction
 
%function LibGetFormattedValue(rec, nv) void
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibGetFormattedValue is obsolete. " ...
      "Please update the target file to use the new function " ...
      "SLibGetCastedValue."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
  %return SLibGetCastedValue(rec, nv)
%endfunction
 
%function LibSpecialTIDScope(tid, sti) void
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibSpecialTIDScope is obsolete. " ...
      "Please update the target file to use the new function " ...
      "LibIsSpecialSampleHit."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
  %return LibIsSpecialSampleHit(sti,tid)
%endfunction
 
   
%%Function:LibSystemFcnIsInlined(system,fcn)=================================
%%Description:
%%Functionthatreturns1(True)ifthefunctionforthesystemhasbeen
%%Inlined.
%%
%function LibSystemFcnIsInlined(system, fcn) void
  %if ShowObsoleteWarnings
    %assign sysIdx = system.CallSites[0][2]
    %assign blkIdx = system.CallSites[0][3]
    %assign ssBlock = ::CompiledModel.System[sysIdx].Block[blkIdx]
 
    %assign warnTxt = "The function LibSystemFcnIsInlined is obsolete. " ...
      "Please update the target file to use the new function " ...
      "LibSystemIsInlined."
    %<LibReportWarning(ssBlock, warnTxt)>
  %endif
  %return LibSystemIsInlined(system)
%endfunction %% LibSystemFcnIsInlined
 
 
%%Function:LibIsFcnInlineable(system,fcn)void===============================
%%Description:
%%Functionthatreturns1(True)ifthefunctionforthesystemmeetsthe
%%criteriaforbeingautomaticallyormanuallyinlined.
%%
%function LibIsFcnInlineable(system,fcn) void
  %if ShowObsoleteWarnings
    %assign sysIdx = system.CallSites[0][2]
    %assign blkIdx = system.CallSites[0][3]
    %assign ssBlock = ::CompiledModel.System[sysIdx].Block[blkIdx]
 
    %assign warnTxt = "The function LibIsFcnInlineable is obsolete. " ...
      "Please update the target file to use the new function " ...
      "LibSystemIsInlined."
    %<LibReportWarning(ssBlock, warnTxt)>
  %endif
  %return LibSystemIsInlined(system)
%endfunction %% LibIsFcnInlineable
 
 
%%Function:LibIsFcnManuallyInlined(system,fcn)void==========================
%%Description:
%%Returnsoneofthefollowingvalues:
%%
%%1:Thesystemhasbeenexplicitlyinlinedbytheuserand
%%theTLCglobalvariableFunctionInlineModeissetto
%%"Manual"or"Either".
%%0:Thesystemhasbeenexplicitlyun-inlinedbytheuserand
%%theTLCglobalvariableFunctionInlineModeissetto
%%"Manual"or"Either".
%%-1:IfFunctionInlineModeissetto"Manual"or"Either"andthe
%%thedidn'tspecifywhetherornottoinlinethesubsystem(inwhich
%%caseitwillmostlikelybeinlinedifitis"small").If
%%FunctionInlineModeis"None"or"Automatic",then-1isreturned.
%%
%function LibIsFcnManuallyInlined(system,fcn) void
  %if ShowObsoleteWarnings
    %assign sysIdx = system.CallSites[0][2]
    %assign blkIdx = system.CallSites[0][3]
    %assign ssBlock = ::CompiledModel.System[sysIdx].Block[blkIdx]
 
    %assign warnTxt = "The function LibIsFcnManuallyInlined is obsolete. " ...
      "Please update the target file to use the new function " ...
      "LibSystemIsInlined."
    %<LibReportWarning(ssBlock, warnTxt)>
  %endif
  %return LibSystemIsInlined(system)
%endfunction %% LibIsFcnManuallyInlined
 
%%Function:LibIsOutputUpdateFcnForced(system)================================
%%
%%Purpose:
%%DetermineiftheOutputUpdateFcncanbeinlined.
%%
%%Syntax:
%%LibIsOutputUpdateFcnForced(system)
%%
%%Arguments:
%%system:Referencetoasystem
%%
%%Returns:
%%1iftheOutputUpdateFcnforthesystemmusthavethreearguments
%%andcannotbeinlined
%%0otherwise
%%
%%Description:
%%LibIsOutputUpdateFcnForcedreturnsaoneiftheOutputUpdateFcnforthe
%%systemmusthavethreeargumentsandcannotbeinlined.
%%
%function LibIsOutputUpdateFcnForced(system) void
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibIsOutputUpdateFcnForced is obsolete." ...
      "Please update the target file to use the new function " ...
      "LibSystemIsForceNonInline."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
  %return (system.ForceNonInline == "on")
%endfunction
 
 
%%Function:LibIsEqual=======================================================
%%
%%Abstract:
%%Thisfunctionisobsolete,usthebuilt-inTLCfunctionISEQUAL
%%
%%Purpose:
%%Comparetwoexpressions(notnecessarilyofthesametype)for
%%equality.
%%
%%Syntax:
%%LibIsEqual(expr1,expr2)
%%
%%Arguments:
%%expr1:Firstexpression
%%expr2:Secondexpression
%%
%%Returns:
%%1ifexpr1equalsexpr2
%%0otherwise
%%
%%Description:
%%LibIsEqualreturns1ifexpr1equalsexpr2and0otherwise.LibIsEqual
%%differsfromthesimpleequality"=="sinceitdoestypechecking.
%%Differenttypeexpressionsgenerallyreturn0.Forexample,"0"does
%%notequal0.However,"Number"canbecomparedto"Real"and"String"
%%canbecomparedto"Identifier".
%%
%%Validcomparisons:
%%
%%expr1Typeexpr2Type
%%--------------------
%%expr2Type
%%NumberReal
%%RealNumber
%%IdentifierString
%%StringIdentifier
%%
%%Comparinganyothertypeswillreturnfalse,independentofthevalues
%%oftheexpressions.
%%
%function LibIsEqual(expr1, expr2) void
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibIsEqual is obsolete." ...
      "Please update the target file to use the built-in TLC command ISEQUAL."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
 
  %if ( TYPE(expr1) == TYPE(expr2) ) ...
    || ( TYPE(expr1) == "Number" && TYPE(expr2) == "Real" ) ...
    || ( TYPE(expr1) == "Real" && TYPE(expr2) == "Number" ) ...
    || ( TYPE(expr1) == "Identifier" && TYPE(expr2) == "String" ) ...
    || ( TYPE(expr1) == "String" && TYPE(expr2) == "Identifier" )
    %if expr1 == expr2
      %return 1
    %else
      %return 0
    %endif
  %else
    %return 0
  %endif
%endfunction
 
 
%%Function:LibIsEmpty========================================================
%%
%%Abstract:
%%Thisfunctionisobsolete,usthebuilt-inTLCfunctionISEMPTY
%%
%%Purpose:
%%Determineifaninputisempty.
%%
%%Syntax:
%%LibIsEmpty(input)
%%
%%Arguments:
%%input:Inputexpressiontobetested
%%
%%Returns:
%%1for""(emptystring)
%%1for[],[[],[]],etc.(emptyvectors)
%%1for[[[],[]];[[],[]]],etc.(emptymatrices)
%%0otherwise
%%
%%Description:
%%LibIsEmptydeterminesifaninputisemptyornull.
%%
%function LibIsEmpty(input) void
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibIsEqual is obsolete." ...
      "Please update the target file to use the built-in TLC command ISEMPTY."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
 
  %switch TYPE(input)
    %case "String"
    %return input == ""
  %case "Unsigned"
  %case "Number"
  %case "Real32"
  %case "Real"
  %case "Gaussian"
  %case "UnsignedGaussian"
  %case "Complex32"
  %case "Complex"
    %return SIZE(input, 1) == 0
  %case "Vector"
    %foreach colIdx = SIZE(input, 1)
      %if !LibIsEmpty(input[colIdx])
        %return 0
      %endif
    %endforeach
    %return 1
  %case "Matrix"
    %foreach rowIdx = SIZE(input, 0)
      %foreach colIdx = SIZE(input, 1)
        %if !LibIsEmpty(input[rowIdx][colIdx])
          %return 0
        %endif
      %endforeach
    %endforeach
    %return 1
  %default
    %<LibReportFatalError("Invalid type: %<TYPE(input)>")>
  %endswitch
%endfunction
 
%%Function:LibIsFinite======================================================
%%
%%Abstract:
%%Obsolete,useISFINITE.
%%
%%Purpose:
%%Determineifanumberisfinite.
%%
%%Syntax:
%%LibIsFinite(value)
%%
%%Arguments:
%%value:AnynumberincludingInf,MinusInf,andNaN
%%
%%Returns:
%%1ifthenumberisnotInf,MinusInf,orNaN
%%0otherwise
%%
%%Description:
%%LibIsFinitereturnsoneifthenumberisfiniteandzerootherwise.
%%
%function LibIsFinite(value) void
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function LibIsFinite is obsolete." ...
      "Please update the target file to use the built-in TLC command ISFINITE."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
 
  %if ISINF(value) || ISNAN(value)
    %return 0
  %else
    %return 1
  %endif
%endfunction
 
%%Function:SLibGetDataTypeSizeFromId=========================================
%%Abstract:
%%Thisroutineisnotreliableforsometargetsandshouldnotbeused.
%%ReturnthesizeofdatatypeinbytescorrespondingtoadatatypeIDor
%%aliaseddatatypeID.Weassumesizeof(real_T)=8bytes(unless
%%supercededtobe4inthecaseofdSPACEDSP32targets:C30&C40targets).
%%ThisisdeterminedbasedontheexistenceofTLCvariable'DSP32';the
%%resultofwhichisstoredin'SizeOfDouble'.Thesizeofunaliasednon
%%built-indatatypesisalsoassumedtobe8bytes.
%%
%function SLibGetDataTypeSizeFromId(id) void
  %if ShowObsoleteWarnings
    %assign warnTxt = "The function SLibGetDataTypeSizeFromId is obsolete." ...
      "Please update the target file to use the sizeof C utility to determine " ...
      "the size of a type type."
    %<LibBlockReportWarning([], warnTxt)>
  %endif
  %if !LibIsBuiltInDataType(id)
    %assign origId = id
    %assign id = LibGetDataTypeStorageIdFromId(origId)
    %if id < 0
      %assign id = origId
    %endif
  %endif
  %switch LibGetDataTypeIdAliasedThruToFromId(id)
    %case tSS_DOUBLE
      %return SizeOfDouble
    %case tSS_SINGLE
      %return 4
    %case tSS_UINT8
      %return 1
    %case tSS_UINT16
      %return 2
    %case tSS_UINT32
      %return 4
    %case tSS_BOOLEAN
      %return 1
    %case tSS_INT8
      %return 1
    %case tSS_INT16
      %return 2
    %case tSS_INT32
      %return 4
    %default
      %return 8
  %endswitch
%endfunction
 
%%Function:SLibReusedBlkName=================================================
%%Abstract:
%%Thisfunctionreturnsthemangledblockpatheg."/BlockName"of
%%ablockinsideareusedsystemusingthecallsideinformation.
%%
%function SLibReusedBlkName(sysIdx, csIdx, blkIdx)
  %assign ss = System[sysIdx]
  %assign blk = ss.Block[blkIdx]
  %assign blkName = SLibBlkName(blk)
  %if ss.Type == "root"
    %return "/" + blkName
  %else
    %return SLibGrBlockName(ss.GraphCallSites[csIdx]) + "/" + blkName
  %endif
%endfunction
 
%function SLibMarkAllExtIOAccessed() void
  %foreach idx = ExternalInputs.NumExternalInputs
    %assign extInp = ExternalInputs.ExternalInput[idx]
    %<LibAccessArg(extInp)>
  %endforeach
  %foreach idx = ExternalOutputs.NumExternalOutputs
    %assign extOut = ExternalOutputs.ExternalOutput[idx]
    %<LibAccessArg(extOut)>
  %endforeach
%endfunction
 
%%ObsoleteZCrelatedTLCFiles
 
%%
%%
%%Function:FcnGetLocalNonSampledZCPath=====================================
%%Abstract:
%%ThisfunctionreturnstheidentifierpathforaNonSampledZCelement.
%%(e.g."rtPrevZCSigState.sub1.sub2.,localPrevZC->sub1.sub2.")
%%
%%Arguments:
%%
%%sysIdx-Systemcontainingzerocrossing
%%csIdx-Systeminstancecontainingzerocrossing
%%accessSysIdx-Systemaccessingthiszerocrossing
%%
%function FcnGetLocalNonSampledZCPath(sysIdx, csIdx, accessSysIdx) void
  %assign cross = System[sysIdx].CrossNoArgFcnBound
  %assign varGroupIdx = FcnSysVarGroupIndex(System[sysIdx], ...
    "ZCSV", csIdx)
  %return SLibCGIRVarGroupPath(varGroupIdx, accessSysIdx, cross)
%endfunction
 
%%DocFunction{BlkStateAndWorkVectFcns}:LibBlockNonSampledZC================
%%Abstract:
%%ReturnsastringcorrespondingtothespecifiedblockNonSampledZC.
%%
%%LibBlockNonSampledZCreturnstheappropriateelementforthenon-sampled
%%zerocrossingstatebasedonucv,lcv,andNonSampledZCIdx.
%%
%%Arguments:
%%ucv:Usercontrolvariablestring
%%lcv:Loopcontrolvariablestring
%%NonSampledZCIdx:Non-Sampledzerocrossingindex
%%
%function LibBlockNonSampledZC(ucv, lcv, NSZCIdx) void
  %assign blkZcRecIdx = BlkZcRec[0].BlkZcRecIdx
  %assign zcsIdx = SLibBlockGetZCSignalIndexFromNSZCIdx(0, NSZCIdx)
  %assign zcs = ::CompiledModel.ZcRec.BlkZcRec[blkZcRecIdx].ZcSignalInfo[zcsIdx]
  %return SLibNonSampledZCState(zcs, ucv, lcv, NSZCIdx)
  %%
%endfunction %% LibBlockNonSampledZCState
 
%%Function:SLibNonSampledZCState============================================
%%Abstract:
%%SLibNonSampledZCStatereturnstheappropriateidentifierforthenon
%%sampledzerocrossingstatebasedontheZCErecorducv,lcv,andpzcIdx.
%%
%%Arguments:
%%zcs:globalzerocrossingrecord
%%ucv:Usercontrolvariablestring
%%lcv:Loopcontrolvariablestring
%%NonSampledZCIdx:NonSampledzerocrossingindex
%%
%function SLibNonSampledZCState(zcs, ucv, lcv, NSZCIdx) void
  %assign zcElIdx = SLibBlockGetZCSignalElIndexFromNSZCIdx(0, NSZCIdx)
  %assign blkZcRecIdx = zcs.BlkZcRecIdx
  %assign blkZcRec = ::CompiledModel.ZcRec.BlkZcRec[blkZcRecIdx]
  %assign sigIndexer = SLibGet1DArrayIndexer(zcs.Width, ucv, lcv, zcElIdx)
   
  %if ucv != "" || lcv == "" || (lcv != "" && zcs.Width == 1)
    %% user control variable specified, not rolling, or rolling a scalar
    %assign idxVec = SLibGetSystemAndCallSideIndex(blkZcRec)
    %assign sysIdx = idxVec[0]
    %assign csIdx = idxVec[1]
    %assign varGroupIdx = FcnSysVarGroupIndex(System[sysIdx], ...
      "ZCSV", csIdx)
    %assign cross = System[sysIdx].CrossNoArgFcnBound
    %assign zcPath = SLibCGIRVarGroupPath...
      (varGroupIdx, HStructDeclSystemIdx, cross)
    %assign name = FcnGetZCSignalCGVarName(zcs)
    %return "%<zcPath>%<name>%<sigIndexer>"
  %else
    %% rolling
    %return "zcsv%<sigIndexer>"
  %endif
%endfunction
 
%%Function:SLibNonsampledZCAddr==============================================
%%
%function SLibNonsampledZCAddr() void
  %return SLibZCSignalValueAddr(0)
%endfunction %% SLibNonsampledZCAddr
 
%%Function:SLibZeroOutZeroCrossingsForSystem================================
%%Abstract:
%%Thisfunctionwillgeneratethecodetozerooutthederivatives
%%inaconditionallyexecutedsubsystem.Noteitis
%function SLibZeroOutZeroCrossingsForSystem(ssBlock,system) Output
  %return SLibZeroOutZcSignalsForSystem(ssBlock,system)
%endfunction
 
%%Function:SLibGetSystemNonSampledZC=========================================
%%Abstract:
%%ReturnsthecontentsofasystemsnonsampledZCstructure.
%%
%function SLibGetSystemNonSampledZC(sysIdx) void
  %return SLibGetSystemZcSignalValue(sysIdx)
%endfunction
 
%%Function:LibCacheSystemNonSampledZCStructDef=============================
%%Abstract:
%%Cachethenonsampledzcstructdefinitions
%%
%function LibCacheSystemNonSampledZCStructDef(sysIdx) void
  %return LibCacheSystemZCSignalValueStructDef(sysIdx)
%endfunction
 
%%Function:LibNonSampledZCStructIsEmpty=====================================
%%Abstract:
%%Isthecacheempty?
%%
%function LibNonSampledZCStructIsEmpty() void
  return LibZCSignalValueStructIsEmpty()
%endfunction
 
%%FunctionSLibInitPrevZCState================================================
%%Abstract:
%%Initializethepreviouszero-crossingstateforablock.Notethatit
%%isinitializedtoavaluethatguaranteesthatthetriggerisnevertrue
%%attimezero.Sincetheregistrationcodesetspreviouszc'sto
%%UNINITIALIZED_ZCSIG,onlyoverwritewhennecessary(i.e.,rising/falling
%%triggersforunsignedandbooleandatatypes).
%%
%function SLibInitPrevZCStates() void
  %return SLibInitPrevZCSignalStates()
%endfunction
 
%%Function:LibGetNonSampledZCsStruct========================================
%%Abstract:
%%Returnsthevariableforthenon-sampledzerocrossings.
%%
%function LibGetNonSampledZCsStruct() void
  %return LibGetZCSignalValueStruct()
%endfunction %% LibGetNonSampledZCsStruct
 
%%Function:LibGetNonsampledZCStruct========================================
%%Abstract:
%%Returnsthevariableforthenon-sampledzerocrossings.
%%Calledbyopaquelib.tlc:SLibCGIRVarGroupPath().
%%
%function LibGetNonsampledZCStruct() void
  %return LibGetNonSampledZCsStruct()
%endfunction %% LibGetNonsampledZCStruct
 
%%
%%Function:LibBlockPrevZCState===============================================
%%Abstract:
%%LibBlockPrevZCStatereturnstheappropriateelementfortheprevious
%%zerocrossingstatebasedonucv,lcv,andpzcIdx.
%%
%%Arguments:
%%ucv:Usercontrolvariablestring
%%lcv:Loopcontrolvariablestring
%%pzcIdx:Previouszerocrossingindex
%%
%function LibBlockPrevZCState(ucv, lcv, pzcIdx) void
  %assign zcsIdx = SLibBlockGetZCSignalIndexFromZCEIdx(0, pzcIdx)
  %assign blkZcRecIdx = BlkZcRec[0].BlkZcRecIdx
  %assign zcs = ::CompiledModel.ZcRec.BlkZcRec[blkZcRecIdx].ZcSignalInfo[zcsIdx]
  %return SLibPrevZCState(zcs, ucv, lcv, pzcIdx)
%endfunction %% LibBlockPrevZCState
 
%%Function:SLibPrevZCState===================================================
%%Abstract:
%%SLibPrevZCStatereturnstheappropriateidentifierfortheprevious
%%zerocrossingstatebasedontheZCErecorducv,lcv,andpzcIdx.
%%
%%Arguments:
%%zcs:globalzerocrossingrecord
%%ucv:Usercontrolvariablestring
%%lcv:Loopcontrolvariablestring
%%pzcIdx:Previouszerocrossingindex
%%
%function SLibPrevZCState(zcs, ucv, lcv, pzcIdx) void
  %assign zcElIdx = SLibBlockGetZCSignalElIndexFromZCEIdx(0, pzcIdx)
  %assign blkZcRecIdx = zcs.BlkZcRecIdx
  %assign blkZcRec = ::CompiledModel.ZcRec.BlkZcRec[blkZcRecIdx]
  %assign sigIndexer = SLibGet1DArrayIndexer(zcs.Width, ucv, lcv, zcElIdx)
  %if ucv != "" || lcv == "" || (lcv != "" && zcs.Width == 1)
    %% user control variable specified, not rolling, or rolling a scalar
    %assign idxVec = SLibGetSystemAndCallSideIndex(blkZcRec)
    %assign sysIdx = idxVec[0]
    %assign varGroupIdx = zcs.varGroupIdx[0]
    %assign accessSysIdx = HStructDeclSystemIdx
    %assign zcPath = SLibCGIRVarGroupPath(varGroupIdx, accessSysIdx, ...
      System[sysIdx].CrossNoArgFcnBound)
    %assign name = FcnGetZCEventCGVarName(zcs)
    %return "%<zcPath>%<name>%<sigIndexer>"
  %else
    %% rolling
    %return "pzc%<sigIndexer>"
  %endif
%endfunction
 
%%Function:LibCGTypeSymbolicVectorWidth======================================
%%Abstract:
%%Returnsasingledimensionasastringforvectortypeandemptrystring
%%forscalar.
%%
%function LibCGTypeSymbolicVectorWidth(cgTypeIdx) void
  %assign width = LibCGTypeSymbolicWidth(cgTypeIdx)
  %if "1" == width && !LibCGTypeIsMatrix(cgTypeIdx)
    %return ""
  %else
    %return "[" + width + "]"
  %endif
%endfunction
 
%%ObsoleteZCrelatedTLCFiles
 
%endif %% _OBSOLETELIB_
 
%%[EOF]obsoletelib.tlc