%%============================================================================
%%
%%Abstract:
%%TLCfileformodelreferenceblocks.
%%
%%Copyright1994-2019TheMathWorks,Inc.
%%============================================================================
%%
 
%implements "ModelReference" "C"
 
 
%function BlockInstanceSetup(block,system) void
  %<LibBlockSetCustomStorageComplianceLevel(block,2)>
%endfunction
 
%%Function:LibMarkNonFiniteAccessed=========================================
%%Abstract:
%%Thisfunctioncallsnonefinitelibararyfunctionstonotifythemodel
%%thatnonefinitevalueshavebeenaccessedandmustbedeclaredand
%%initialized.
%function LibMarkNonFiniteAccessed(block) void
  %assign blockInterface = GetModelrefInterface(block)
  %assign nonFinite= blockInterface.NonFiniteInfo
   
  %assign infIdx = 0
  %assign minusInfIdx = 1
  %assign nanIdx = 2
   
  %if nonFinite[infIdx]
    %assign dummyInf = LibRealNonFinite("inf")
  %endif
  %if nonFinite[minusInfIdx]
    %assign dummyMInf = LibRealNonFinite("-inf")
  %endif
  %if nonFinite[nanIdx]
    %assign dummyNan = LibRealNonFinite("nan")
  %endif
%endfunction
 
%%Function:ModelBlockCallOutputUpdateWithInitStatusGuard=====================
%%Abstract:
%%Generatesinitializestatusguardcodeifnecessarybeforecallingperiodic
%%outputorupdatefunctionsforModelblockthathasperiodiceventportand
%%isreferencingrate-basedmodel.
%function ModelBlockCallOutputUpdateWithInitStatusGuard( ...
  block, system, sysFcn, tidInChildModel, tidInParentModel, forSingleTasking) Output
   
  %assert(sysFcn == "Output" || sysFcn == "Update" || sysFcn == "OutputUpdate")
 
  %if GetModelrefHasMdlPeriodicPort(block) && ...
    !SLibParameterChangeEventTID(tidInParentModel)
    %return
  %endif
   
  %assign useInitStatusGuard = ...
    block.ParamSettings.UseInitStatusGuardForPeriodicOutputUpdate && ...
    (forSingleTasking || !SLibNonInlinedModelWideEventTID(tidInParentModel))
 
  %if useInitStatusGuard
    %assign initStatDWorkIdx = block.ParamSettings.InitStatusDWorkIdx
    %assert(initStatDWorkIdx != -1)
    if (%<LibBlockDWork(block.DWork[initStatDWorkIdx],"","",0)> == 1U) {
  %endif
 
  %<ModelBlockCallFunction(block, system, sysFcn, tidInChildModel)>
 
  %if useInitStatusGuard
    }
  %endif
%endfunction
 
%%Function:ModelRefTidGuard=================================================
%%Abstract:
%%GeneratesTIDguardcodeformodelreferenceblocks.Thisisused
%%byboththeupdateandoutputfunctions.Weonlygeneratetheguard
%%iftheModelblockismulti-rate(constantTIDnotincluded),andthe
%%parentmodelissingle-tasking.
%function ModelRefTidGuard()
  %assign tidGuard = ""
  %assign orOperator = ""
  %assign noGuardNeeded = TLC_FALSE
  %assign multTIDs = TLC_FALSE
  
  %if LibTriggeredTID(TID) || ISEQUAL(TID, "constant") || ...
    LibAsynchronousTriggeredTID(TID) || ...
    SLibIsPeriodicRateGrouping() || SIZE(TID,1) == 1
    %assign noGuardNeeded = TLC_TRUE
  %else
    %assert(TYPE(TID) == "Vector")
    %foreach tidIdx = SIZE(TID, 1)
      %if TID[tidIdx] == -2 %% ContantTid
    %continue
      %endif
      %if SLibModelWideEventTID(TID[tidIdx])
        %continue
      %endif
      %assign tidString = LibIsSampleHit(TID[tidIdx])
      %if tidString == "1"
    %assign noGuardNeeded = TLC_TRUE
      %endif
      %assign multTIDs = !ISEMPTY(tidGuard)
      %assign tidGuard = tidGuard + "%<orOperator>%<tidString>"
      %assign orOperator = " || "
    %endforeach
     
    %% Check if we really have multiple TIDs
    %if !multTIDs
      %assign noGuardNeeded = TLC_TRUE
    %endif
  %endif
  %return (noGuardNeeded) ? "" : tidGuard
%endfunction %% ModelRefTidGuard
 
 
%%Function:GenerateModelRefTIDInfo==========================================
%%Abstract:
%%GeneratesTIDguardcodeandTIDmapformodelreferenceblocks.
%function GenerateModelRefTIDInfo(block, sysFcn)
  %assign res = ["","",""]
 
  %% Generate the TID guard if necessary (multirate w/ no rate grouping)
  %assign tidGuard = ModelRefTidGuard()
   
  %assign needsTID = !Accelerator && GetModelRefFcnNeedsTID(block, sysFcn)
  %assign tidOpen = ""
  %if (tidGuard != "")
    %assign tidOpen = "if (%<tidGuard>) {"
  %elseif needsTID
    %assign tidOpen = "{"
  %endif
 
  %% If the model reference block has TID as an argument, then we
  %% need to map the parent blocks TID to the child TID. For example,
  %%
  %% If the parent has 3 sample times [0, 1, 2] and the referenced model
  %% has 2 sample times, [1 2]. Then we need to map the parent's TID
  %% [1 2] to [0 1] for the referenced model.
  %%
  %% We store the original TID in tmpTID because other blocks may need it.
  %assign tidMap = ""
  %if needsTID
    %openfile TIDBuffer
    %assign tid = LibTID()
    %assign else = ""
    int tmpTID = %<tid>;
    %foreach tidIdx = SIZE(TID,1)
      %<else> if (% == tmpTID) {
        %<tid> = %<tidIdx>;
      }
      %assign else = "else"
    %endforeach
    %closefile TIDBuffer
    %assign tidMap = TIDBuffer
  %endif
   
  %% Reset the TID variable to tmpTID if necessary
  %assign tidClose = ""
  %if needsTID
    %openfile tidCloseBuffer
    %<tid> = tmpTID;
    }
    %closefile tidCloseBuffer
    %assign tidClose = tidCloseBuffer
  %elseif (tidGuard != "")
    %assign tidClose = "}"
  %endif
 
  %assign res[0] = tidOpen
  %assign res[1] = tidMap
  %assign res[2] = tidClose
   
  %return res
%endfunction %%GenerateModelRefTIDInfo
   
%function mdlrefIsPortConstantSampleTime(block, port)
  %if(ISEQUAL(block.TID, "constant"))
    %return TLC_TRUE
  %elseif(ISEQUAL(block.TID, "triggered"))
    %assign retValue = ((! ISEMPTY(block.TriggeredBlockConstantSampleTimePorts)) && ...
                        (block.TriggeredBlockConstantSampleTimePorts[port] == 1))
    %return retValue
  %else
    %if block.PortBasedSampleTimes == "yes"
      %assign retValue = (LibBlockOutputSignalSampleTimeIndex(port) == -2)
    %else
      %assign retValue = TLC_FALSE
    %endif
    %return retValue
  %endif
%endfunction
 
%function SetupRuntimeResources(block, system) Output
  %assign sysFcn = "SetupRuntimeResources"
  %assign blockInterface = GetModelrefInterface(block)
  %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %<ModelBlockCallFunction(block, system, sysFcn, "")>
  %endif
 
  %if ISFIELD(block.ParamSettings, "InitStatusDWorkIdx")
    %assign initStatDWorkIdx = block.ParamSettings.InitStatusDWorkIdx
    %assert(initStatDWorkIdx != -1)
    %<LibBlockDWork(block.DWork[initStatDWorkIdx],"","",0)> = 0U;
  %endif
   
  %if ISFIELD(block.ParamSettings, "InitRestoreDataDWorkIdx")
    %assign restoreDataDWorkIdx = block.ParamSettings.InitRestoreDataDWorkIdx
    %assert(restoreDataDWorkIdx != -1)
    %if SLibModelBlockRTMAllocateInParent(block, blockInterface)
      %assign rtmArg = block.Identifier
      memcpy((void *) &(%<LibBlockDWork(block.DWork[restoreDataDWorkIdx],"","",0)>.rtm),
             (void *) &(%<rtmArg>), sizeof(%<rtmArg>));
    %else
      memcpy((void *) &(%<LibBlockDWork(block.DWork[restoreDataDWorkIdx],"","",0)>),
             (void *) &(%<LibBlockDWork(block.DWork[0],"","",0)>),
             sizeof(%<LibBlockDWork(block.DWork[0],"","",0)>));
    %endif
  %endif
   
  %if blockInterface.HasPrivateDWork
    %assign mdlName = block.ParamSettings.ReferencedModelName
    %<SLibGetCreateInitRestoreDataFcnNameForModel(mdlName)>();
  %endif
%endfunction
 
%function CleanupRuntimeResources(block, system) Output
  %assign sysFcn = "CleanupRuntimeResources"
  %assign blockInterface = GetModelrefInterface(block)
  %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %<ModelBlockCallFunction(block, system, sysFcn, "")>
  %endif
   
  %if blockInterface.HasPrivateDWork
    %assign mdlName = block.ParamSettings.ReferencedModelName
    %<SLibGetDestroyInitRestoreDataFcnNameForModel(mdlName)>();
  %endif
%endfunction
 
%%Function:Start============================================================
%%
%function Start(block, system) Output
  %if Accelerator
    %% Start function is executed in Simulink
    %assert(0)
  %elseif !ISFIELD(block.ParamSettings, "InitStatusDWorkIdx")
    %<LibMarkNonFiniteAccessed(block)>
    %assign sysFcn = "Start"
    %assign blockInterface = GetModelrefInterface(block)
    %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
      %<GetFunctionStr(block, sysFcn, 0, "", 0, "")>
    %endif
     
    %% For ports with constant sample time that are imported,
    %% we need to set the initial value
    %foreach portIdx = block.NumDataOutputPorts
      %% See if the port has a constant sample time
      %if (mdlrefIsPortConstantSampleTime(block, portIdx))
        %assign storageClass = LibBlockOutputSignalStorageClass(portIdx)
         
        %if (ISEQUAL(storageClass, "ImportedExtern") || ...
             ISEQUAL(storageClass, "ImportedExternPointer"))
          %assign op = FcnGetOutputPortRecord(portIdx)
          %assign bo = SLibGetSourceRecord(op, 0)
           
          %% It must also have an initial value
          %if ! ISEMPTY(bo.InitialValue)
            %assign id = LibGetRecordIdentifier(bo)
            %<FcnInitDataInitialValue(bo, id)>
          %endif
        %endif
      %endif
    %endforeach
  %endif
%endfunction
 
%%Function:InitializeConditions=============================================
%%
%function InitializeConditions(block, system) Output
  %assign sysFcn = "Initialize"
  %assign blockInterface = GetModelrefInterface(block)
     
  %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %<ModelBlockCallFunction(block, system, sysFcn, "")>
  %endif
%endfunction
 
%%Function:SystemInitialize==================================================
%%
%function SystemInitialize(block, system) Output
  %assign sysFcn = "SystemInitialize"
  %assign blockInterface = GetModelrefInterface(block)
     
  %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %<ModelBlockCallFunction(block, system, sysFcn, "")>
  %endif
%endfunction
 
%%Function:SystemReset=======================================================
%%
%function SystemReset(block, system) Output
  %assign sysFcn = "SystemReset"
  %assign blockInterface = GetModelrefInterface(block)
     
  %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %<ModelBlockCallFunction(block, system, sysFcn, "")>
  %endif
%endfunction
 
%%Function:Enable============================================================
%%
%function Enable(block, system) Output
  %assign sysFcn = "Enable"
  %assign blockInterface = GetModelrefInterface(block)
  %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %<ModelBlockCallFunction(block, system, sysFcn, "")>
  %endif
%endfunction
 
%%Function:Disable============================================================
%%
%function Disable(block, system) Output
  %assign sysFcn = "Disable"
  %assign blockInterface = GetModelrefInterface(block)
  %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %<ModelBlockCallFunction(block, system, sysFcn, "")>
  %endif
%endfunction
 
%%Function:ModelRefBlockHasFcn===========================================
%%Description:
%%FormodelreferenceblockthatisSingleTasking,
%%returntrueiftheblockhas%<fcnType>Fcnfield.
%%FormodelreferenceblockthatisMultitasking,
%%andif
%%tidisanumber,returntrueiftheblockhas
%%%<fcnType>forthetid.
%%tidisnotanumber,returntrueiftheblock
%%has%<fcnType>foranyofits
%%tids
%%
%function ModelRefBlockHasFcn(block, fcnType, tid)
  %assign blockInterface = GetModelrefInterface(block)
  %assign retVal = TLC_FALSE
  %with block
    %if !blockInterface.RateGrouped
      %if TYPE(tid) == "Number"
        %foreach tidIdx = NumSampleTimes
          %assign localTid = MapParentTID2ChildTID(block, tidIdx)
          %if (localTid == tid) && SLibNonInlinedModelWideEventTID(tidIdx)
            %return ISFIELD(blockInterface, "%<fcnType>TID%<localTid>Fcn")
          %endif
        %endforeach
      %endif
      %assign retVal = ISFIELD(blockInterface, "%<fcnType>Fcn")
    %else
      %if TYPE(tid) == "Number"
    %assign retVal = ISFIELD(blockInterface, "%<fcnType>TID%<tid>Fcn")
      %else
    %foreach tidIdx = NumSampleTimes
          %if SLibSynchronousTID(tidIdx) || SLibNonInlinedModelWideEventTID(tidIdx)
            %assign localTid = MapParentTID2ChildTID(block, tidIdx)
            %if localTid >= 0
              %if ISFIELD(blockInterface, "%<fcnType>TID%<localTid>Fcn")
                %assign retVal = TLC_TRUE
                %break
              %endif
            %endif
          %endif
    %endforeach
      %endif
    %endif
  %endwith
  %return retVal
%endfunction
       
%%Function:ModelBlockCallFunction============================================
%%Abstract:
%%Callthegivenfunctioninthereferencedmodel.
%function ModelBlockCallFunction(block, system, sysFcn, localTid) Output
  %if Accelerator
    /* Call into Simulink */
    %if sysFcn == "SystemInitialize"
      %<SLibCallMdlRefSystemInitializeInSimulink(system, block)>
    %elseif sysFcn == "SystemReset"
      %<SLibCallMdlRefSystemResetInSimulink(system, block)>
    %else
      %assign accFunction = GetAcceleratorStringForFunction(sysFcn)
      %<SLibCallBlockInSimulink(system, block, accFunction)>
    %endif
  %else
    %<GetFunctionStr(block, sysFcn, 0, localTid, 0, "")>
  %endif
%endfunction
 
%%Function:Outputs==========================================================
%%Thisfunctionwillbecalledifsingletasking.Otherwise,OutputsForTID
%%willbecalled.
%%
%function Outputs(block, system) Output
  %assign blockInterface = GetModelrefInterface(block)
   
  %with block
    %if !blockInterface.RateGrouped || Accelerator
      %if ModelRefBlockHasFcn(block,"Output","")
    %assign sysFcn = "Output"
      %elseif ModelRefBlockHasFcn(block,"OutputUpdate","")
    %assign sysFcn = "OutputUpdate"
      %else
    %return
      %endif
      %assign res = GenerateModelRefTIDInfo(block, "%<sysFcn>Fcn")
      %assign tidOpen = res[0]
      %assign tidMap = res[1]
      %assign tidClose = res[2]
      %<tidOpen>
      %<tidMap>
      %<ModelBlockCallOutputUpdateWithInitStatusGuard( ...
        block, system, sysFcn, "", "", TLC_TRUE)>
      %<tidClose>
    %else
      %% parent is single tasking, but unit is multitasking,
      %% Parent calls output fcn for each synchronous TID one by one.
      %foreach tidIdx = NumSampleTimes
        %if SLibSynchronousTID(tidIdx)
          %assign tidString = LibIsSampleHit(tidIdx)
          %if tidString == "1"
            %<OutputsForTID(block,system,tidIdx)>
          %else
            %openfile tmpBuf
            %<OutputsForTID(block,system,tidIdx)>
            %closefile tmpBuf
            %if !WHITE_SPACE(tmpBuf)
              if (%<tidString>) {
                %<tmpBuf>
              }
            %endif
          %endif
        %endif
      %endforeach
    %endif
  %endwith
%endfunction
 
%%Function:OutputsForTID===========================================================
%%Thisfunctioniscalledifmultitaskingtasking.Otherwise,Outputs
%%willbecalled.
%%
%function OutputsForTID(block, system, tid) Output
  %% If it a single-rate parameter, the block function we call is Outputs, not OutputsTID#
  %if (SIZE(TID,1) == 1 && ISEQUAL(TID, tid) && SLibParameterChangeEventTID(tid))
    %<Outputs(block, system)>
    %return
  %endif
   
  %assign blockInterface = GetModelrefInterface(block)
   
  %assign tidInChildModel = MapParentTID2ChildTID(block, tid)
   
  %% We should directly call any async function-calls,
  %% not use the OutputsForTID interface, unless it's an Init/Reset/Term call
  %assert !ModelBlockHasAsyncInput(tid, block) || SLibInitResetTermEventTID(tid)
   
  %if tidInChildModel >= 0
    %if ModelRefBlockHasFcn(block,"Output",tidInChildModel)
      %assign sysFcn = "Output"
    %elseif ModelRefBlockHasFcn(block,"OutputUpdate",tidInChildModel)
      %assign sysFcn = "OutputUpdate"
    %else
      %return
    %endif
  %else
    %return
  %endif
 
  %<ModelBlockCallOutputUpdateWithInitStatusGuard( ...
    block, system, sysFcn, tidInChildModel, tid, TLC_FALSE)>
%endfunction
 
 
%%Function:Update===========================================================
%%Thisfunctioniscalledifsingletasking.Otherwise,UpdateForTID
%%willbecalled.
%%
%function Update(block, system) Output
  %assign blockInterface = GetModelrefInterface(block)
  %with block
    %if !blockInterface.RateGrouped || Accelerator
      %% Parents and units are single tasking
      %% generate none rate grouping code
      %if ModelRefBlockHasFcn(block,"Update","")
    %assign res = GenerateModelRefTIDInfo(block, "UpdateFcn")
    %assign tidOpen = res[0]
    %assign tidMap = res[1]
    %assign tidClose = res[2]
    %<tidOpen>
    %<tidMap>
        %<ModelBlockCallOutputUpdateWithInitStatusGuard( ...
          block, system, "Update", "", "", TLC_TRUE)>
    %<tidClose>
      %endif
    %else
      %% Parent single tasking, but unit is multitasking,
      %% code of unit is rate grouped.
      %% Parent calls update fcn for each TID one by one
      %foreach tidIdx = NumSampleTimes
        %if SLibSynchronousTID(tidIdx) || SLibNonInlinedModelWideEventTID(tidIdx)
          %assign tidString = LibIsSampleHit(tidIdx)
          %if tidString == "1"
            %<UpdateForTID(block,system,tidIdx)>
          %else
            %openfile tmpBuf
            %<UpdateForTID(block,system,tidIdx)>
            %closefile tmpBuf
            %if !WHITE_SPACE(tmpBuf)
              if (%<tidString>) {
                %<tmpBuf>
              }
            %endif
          %endif
        %endif
      %endforeach
    %endif
  %endwith
%endfunction
 
%%Function:UpdateForTID===========================================================
%%Thisfunctioniscalledifmultitaskingtasking.Otherwise,Update
%%willbecalled.
%%
%function UpdateForTID(block, system, tid) Output
  %% If it a single-rate parameter, the block function we call is Update, not UpdateTID#
  %if (SIZE(TID,1) == 1 && ISEQUAL(TID, tid) && SLibParameterChangeEventTID(tid))
    %<Update(block, system)>
    %return
  %endif
  %assign blockInterface = GetModelrefInterface(block)
 
  %assign localTid = MapParentTID2ChildTID(block, tid)
   
  %% We should directly call any async function-calls,
  %% not use the OutputsForTID interface
  %assert !ModelBlockHasAsyncInput(tid, block)
 
  %if localTid < 0 || !ModelRefBlockHasFcn(block,"Update",localTid)
    %return
  %endif
   
  %<ModelBlockCallOutputUpdateWithInitStatusGuard( ...
    block, system, "Update", localTid, tid, TLC_FALSE)>
%endfunction
 
 
%%Function:SetDims============================================================
%%
%function SetDims(block, system, oIdx, rIdx) Output
  %assign sysFcn = "SetDims"
  %assign blockInterface = GetModelrefInterface(block)
  %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %if Accelerator
      /* Call into Simulink for MEX-version of S-function */
      %<SLibCallSFcnSetDimsInSimulink(system, block, oIdx, rIdx)>
    %else
      %assign outAndRuleIdx = ["%<oIdx>", "%<rIdx>"]
      %<GetSetDimsFunctionStr(outAndRuleIdx, block, sysFcn, 0, "", 0, "")>
    %endif
  %endif
%endfunction
 
%%Function:FinalizeAllDims============================================================
%%
%function FinalizeAllDims(block, system) Output
  %assign sysFcn = "FinalizeDims"
  %assign blockInterface = GetModelrefInterface(block)
  %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %<ModelBlockCallFunction(block, system, sysFcn, "")>
  %endif
%endfunction
 
%%Function:ZeroCrossings====================================================
%%
%function ZeroCrossings(block, system) Output
  %assign sysFcn = "ZeroCrossing"
  %assign blockInterface = GetModelrefInterface(block)
  %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %<ModelBlockCallFunction(block, system, sysFcn, "")>
  %endif
%endfunction
 
%%Function:Projection====================================================
%%
%function Projection(block, system) Output
  %assign sysFcn = "Projection"
  %assign blockInterface = GetModelrefInterface(block)
  %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %<ModelBlockCallFunction(block, system, sysFcn, "")>
  %endif
%endfunction
 
%%Function:Derivatives======================================================
%%
%function Derivatives(block, system) Output
  %assign sysFcn = "Derivative"
  %assign blockInterface = GetModelrefInterface(block)
  %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %<ModelBlockCallFunction(block, system, sysFcn, "")>
  %endif
%endfunction
 
%%ForcingFunction============================================================
%%Abstract:
%%
%function ForcingFunction(block, system) Output
  %assign sysFcn = "ForcingFunction"
  %assign blockInterface = GetModelrefInterface(block)
   
  %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %<ModelBlockCallFunction(block, system, sysFcn, "")>
  %else
    %<Derivatives(block,system)>
  %endif
%endfunction
 
%%MassMatrix============================================================
%%Abstract:
%%
%function MassMatrix(block, system) Output
  %assign sysFcn = "MassMatrix"
  %assign blockInterface = GetModelrefInterface(block)
 
  %if ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %assert (::CompiledModel.ModelIsLinearlyImplicit == "yes")
    %<ModelBlockCallFunction(block, system, sysFcn, "")>
  %endif
%endfunction
 
%%Function:Terminate========================================================
%%
%function Terminate(block, system) Output
  %assign sysFcn = "Terminate"
  %assign blockInterface = GetModelrefInterface(block)
 
  %if ISFIELD(block.ParamSettings, "InitStatusDWorkIdx")
    %assign initStatDWorkIdx = block.ParamSettings.InitStatusDWorkIdx
    %assert(initStatDWorkIdx != -1)
    if (%<LibBlockDWork(block.DWork[initStatDWorkIdx],"","",0)> == 1U) {
      %<CallModelBlockTerminatePortFunction(block, blockInterface, "")>
    }
  %elseif ISFIELD(blockInterface, "%<sysFcn>Fcn")
    %assign termInfo = GetModelWideEventFcnInfo(blockInterface, "PowerDownEvent", "")
    %if termInfo.eventTid != -1 && !ISEMPTY(termInfo.fcnName) && ::isRAccel
      %<SLibCallModelBlockFunction([], block, ...
        "OutputFcn", blockInterface, ...
        GETFIELD(blockInterface, termInfo.fcnName), 0, termInfo.eventTid, 0, "")>
    %endif
    %<ModelBlockCallFunction(block, system, sysFcn, "")>
  %endif
%endfunction
 
%%[EOF]modelref.tlc