%%
%%
%%
%%
%%Copyright1994-2008TheMathWorks,Inc.
%%
%%Abstract:
%%Outportblocktemplatefile
 
%implements Outport "C"
 
 
%%Function:BlockInstanceSetup================================================
%%Abstract:
%%EventuallythiswillbehandledbySimulinkbutfornow,weeliminate
%%unnecessarydelaysintheS-Functiontargethere.Rootoutportsfedbya
%%function-callsubsystemmaycausea1timestepdelayfortheS-Function
%%targetsincetheoutportdoesnotexecuteinthecontextofthe
%%function-callsubsystem.
%%
%%NOTE:SLdetects/forcesfunction-calloutput/updatefunctionsinceoutput
%%functionistoolatetoimplementahookwhenthefunction-callsystem
%%inlines.ThisforcingisdoneinSimulinksinceSLneedstoknowwhen
%%f-csubsystemsareforced.
%%
%function BlockInstanceSetup(block, system) void
 
  %<LibBlockSetIsExpressionCompliant(block)>
   
  %assign DoAllOutputsInRoot = 1
  %assign block = block + DoAllOutputsInRoot
   
  %assign isRTWSFcn = (CodeFormat == "S-Function" && !Accelerator)
   
  %if isRTWSFcn && system.Type == "root"
    %assign sigWidth = LibGetRecordWidth(DataInputPort)
    %if sigWidth > 1
      %assign SourceIsFunctionCall = FEVAL("zeros",1,sigWidth)
    %else
      %assign SourceIsFunctionCall = [0]
    %endif
    %foreach uIdx = sigWidth
      %assign src = LibBlockSrcSignalBlock(0, uIdx)
      %if TYPE(src) == "Vector"
    %assign srcSystemIdx = src[0]
    %assign srcBlockIdx = src[1]
    %assign srcSystem = System[srcSystemIdx]
    %if srcSystem.Type == "function-call"
      %assign SourceIsFunctionCall[uIdx] = 1
      %assign block.DoAllOutputsInRoot = 0
    %endif
      %endif
    %endforeach
    %assign block = block + SourceIsFunctionCall
  %endif
   
%endfunction
 
%%[EOF]outport.tlc