%% $Revision: 1.1.6.3 $
%% 
%%
%% Copyright 1994-2003 The MathWorks, Inc.
%%
%% Abstract: Data Store Read block target file

%implements DataStoreRead "C"

%function GlobalDSMMdlRefSimTarget(block)
  %return IsModelReferenceSimTarget() && block.DataStoreGlobalDSM
%endfunction
  
%% Function: BlockInstanceSetup ==============================================
%% Abstract:
%%   Set expression folding compliance
%%
%function BlockInstanceSetup(block, system) void
  %<LibBlockSetIsExpressionCompliant(block)>
%endfunction


%% Function: Outputs ==========================================================
%% Abstract:
%%   Y[i] = DWorkSrc[i]
%%
%% Why DWORK is not declared in rollVars? Why did we pass lcv instead as ucv
%%
%function Outputs(block, system) Output
  %if GlobalDSMMdlRefSimTarget(block)
    %assign dataType = LibBlockOutputSignalDataTypeName(0, "")
    %assign width = LibBlockOutputSignalWidth(0)
    %assign y = LibBlockOutputSignalAddr(0, "", "", 0)
    memcpy(%<y>, %<CompiledModel.Name>_DSM[%<block.ModelIndex>], %<width>*sizeof(%<dataType>));
  %else
    %assign dworkSrc = DWorkSrc
    %assign rollVars = ["Y"]
    %roll sigIdx = RollRegions, lcv = RollThreshold, block, "Roller", rollVars
      %assign y = LibBlockOutputSignal(0, "", lcv, sigIdx)
      %assign u = LibBlockDWork(dworkSrc, lcv, "", sigIdx)
      %<y> = %<u>;
    %endroll
  %endif
%endfunction



%% [EOF] dsread.tlc
