%%
%%File:sfun_multirate.tlcgeneratedfromsfun_multirate.ttlcrevsion1.5.6.3
%%
%%
%%Copyright1990-2009TheMathWorks,Inc.
%%
%%Abstract:
%%Level-2multipleportsfunctionsfun_multirateblocktargetfile
%%Seesimulink/src/sfun_multirate.c
 
 
%implements "sfun_multirate" "C"
 
 
  %% Function: mdlOutputs =====================================================
  %% Abstract:
  %%
  %% Compute the three outputs, which is the input signal decimated by the
  %% specified parameter. The decimation is handled by sample times.
  %% The decimation is only performed if the block is enabled.
  %%
  %% Note, the usage of the enable should really be protected such that
  %% each task has it's own enable state. In this example, the enable
  %% occurs immediately which may or may not be the expected behavior.
  %%
  %function Outputs(block, system) Output
    %assign portIdxName = ["InputPortIdx0"]
    %assign inPortTid0 = LibGetGlobalTIDFromLocalSFcnTID("InputPortIdx0")
    %assign inPortTid1 = LibGetGlobalTIDFromLocalSFcnTID("InputPortIdx1")
 
    %if inPortTid0 == inPortTid1
      %assign tmpBuf = OutputsForTID(block,system,inPortTid0)
      %if !WHITE_SPACE(tmpBuf)
    /* %<Type> Block: %<Name> */
    if (%<LibIsSFcnSampleHit("InputPortIdx0")>) {
    %<tmpBuf>
    }
      %endif
    %else
      %assign tmpBuf = OutputsForTID(block,system,inPortTid0)
      %if !WHITE_SPACE(tmpBuf)
    /* %<Type> Block: %<Name> */
    if (%<LibIsSFcnSampleHit("InputPortIdx0")>) {
    %<tmpBuf>
    }
      %endif
      %assign tmpBuf = OutputsForTID(block,system,inPortTid1)
      %if !WHITE_SPACE(tmpBuf)
    if (%<LibIsSFcnSampleHit("InputPortIdx1")>) {
    %<tmpBuf>
    }
      %endif
    %endif
 
  %endfunction
 
  %function OutputsForTID(block, system, tid) Output
    %openfile retBuf
    %if tid == LibGetGlobalTIDFromLocalSFcnTID("InputPortIdx0")
      %assign enable = LibBlockInputSignal(0, "", "", 0)
      %assign enabled = LibBlockIWork(0, "", "", 0)
      %assert LibGetGlobalTIDFromLocalSFcnTID("InputPortIdx0") <= ...
    LibGetGlobalTIDFromLocalSFcnTID("InputPortIdx1")
      %assign inputPortTsIsDiff = ...
    LibGetGlobalTIDFromLocalSFcnTID("InputPortIdx0") != ...
    LibGetGlobalTIDFromLocalSFcnTID("InputPortIdx1")
      %openfile tmpBuf
      %if inputPortTsIsDiff
    if (%<LibIsSFcnSpecialSampleHit("InputPortIdx1","InputPortIdx0")>) {
      %endif
         %<enabled> = (%<enable> > 0.0);
      %if inputPortTsIsDiff
        }
      %endif
      %closefile tmpBuf
      /* %<Type> Block: %<Name> */
      %if LibGetSFcnTIDType("InputPortIdx0") == "continuous"
    %% Only check the enable signal on a major time step.
    if (%<LibIsMajorTimeStep()>) {
      %<tmpBuf>
    }
      %else
    %<tmpBuf>
      %endif
    %endif
   
    %if tid == LibGetGlobalTIDFromLocalSFcnTID("InputPortIdx1")
      %assign enabled = LibBlockIWork(0, "", "", 0)
      /* %<Type> Block: %<Name> */
      %assign signal = LibBlockInputSignal(1, "", "", 0)
      if (%<enabled>) {
      %assign tsIsDiff = ...
    LibGetGlobalTIDFromLocalSFcnTID("InputPortIdx1") != ...
    LibGetGlobalTIDFromLocalSFcnTID("OutputPortIdx0")
      %if tsIsDiff
    if (%<LibIsSFcnSpecialSampleHit("OutputPortIdx0", "InputPortIdx1")>) {
      %endif
      %assign y = LibBlockOutputSignal(0, "", "", 0)
           %<y> = %<signal>;
      %if tsIsDiff
        }
      %endif
         
      %assign tsIsDiff = ...
    LibGetGlobalTIDFromLocalSFcnTID("InputPortIdx1") != ...
    LibGetGlobalTIDFromLocalSFcnTID("OutputPortIdx1")
      %if tsIsDiff
    if (%<LibIsSFcnSpecialSampleHit("OutputPortIdx1", "InputPortIdx1")>) {
    %endif
    %assign y = LibBlockOutputSignal(1, "", "", 0)
        %<y> = %<signal>;
      %if tsIsDiff
        }
      %endif
       
      %assign tsIsDiff = ...
    LibGetGlobalTIDFromLocalSFcnTID("InputPortIdx1") != ...
    LibGetGlobalTIDFromLocalSFcnTID("OutputPortIdx2")
      %if tsIsDiff
    if (%<LibIsSFcnSpecialSampleHit("OutputPortIdx2", "InputPortIdx1")>) {
      %endif
      %assign y = LibBlockOutputSignal(2, "", "", 0)
        %<y> = %<signal>;
      %if tsIsDiff
    }
      %endif
      }
    %endif
    %closefile retBuf
     
    %return retBuf
  %endfunction
 
%%[EOF]sfun_multirate.tlc