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

%implements Constant "C"


%% Function: BlockInstanceSetup ================================================
%% Abstract:
%%      Set expression folding compliant
%%
%function BlockInstanceSetup(block,system) void
  %if block.InFixptMode
    %<FixPt_Setup(block, system)>
    %<FixPt_LibBlockSetIsExpressionCompliant(block,system)>\
  %else
    %<LibBlockSetIsExpressionCompliant(block)>
  %endif  
%endfunction


%% Function: BlockOutputSignal =================================================
%% Abstract:
%%      Return the appropriate reference to the parameter.  This function *may*
%%      be used by Simulink when optimizing the Block IO data structure.
%%
%function BlockOutputSignal(block,system,portIdx,ucv,lcv,idx,retType) void
  %switch retType
    %case "Signal"
      %return LibBlockParameter(Value,ucv,lcv,idx)
    %case "SignalAddr"
      %return LibBlockParameterAddr(Value,ucv,lcv,idx)
      %%START_ASSERT
    %default
      %assign errTxt = "Unsupported return type: %<retType>"
      %<LibBlockReportError(block,errTxt)>
      %%END_ASSERT
  %endswitch
%endfunction


%% Function: Start =============================================================
%% Abstract:
%%      Set the output to the constant parameter value if the block output is
%%      visible in the mdlStart function scope, i.e., it is in the global rtB
%%      structure.
%%
%function Start(block, system) Output
  %if LibBlockOutputSignalIsInBlockIO(0) && ...
      (ISFIELD(block, "WriteOutputInStart") && block.WriteOutputInStart)
    /* %<Type> Block: %<Name> */
    %assign rollVars = ["Y", "P"]
    %roll idx = RollRegions, lcv = RollThreshold, block, "Roller", rollVars
      %assign yr = LibBlockOutputSignal(0,"", lcv, "%<tRealPart>%<idx>")
      %assign pr = LibBlockParameter(Value, "", lcv, "%<tRealPart>%<idx>")
      %<yr> = %<pr>;
      %if LibBlockOutputSignalIsComplex(0)
	%assign yi = LibBlockOutputSignal(0, "", lcv, "%<tImagPart>%<idx>")
	%assign pi = LibBlockParameter(Value, "", lcv, "%<tImagPart>%<idx>")
	%<yi> = %<pi>;
      %endif
    %endroll  

  %endif
%endfunction %% Start


%% Function: Outputs ===========================================================
%% Abstract:
%%      The Outputs function is called either when generating dead code (for
%%      documentation purposes) into mdlStart if this block has a Constant TID,
%%      or when generating mdlOutputs if the TID is not constant.
%%
%function Outputs(block, system) Output
  %assign rollVars = ["Y", "P"]
  %roll idx = RollRegions, lcv = RollThreshold, block, "Roller", rollVars
    %assign yr = LibBlockOutputSignal(0,"", lcv, "%<tRealPart>%<idx>")
    %assign pr = LibBlockParameter(Value, "", lcv, "%<tRealPart>%<idx>")
    %<yr> = %<pr>;
    %if LibBlockOutputSignalIsComplex(0)
      %assign yi = LibBlockOutputSignal(0, "", lcv, "%<tImagPart>%<idx>")
      %assign pi = LibBlockParameter(Value, "", lcv, "%<tImagPart>%<idx>")
      %<yi> = %<pi>;
    %endif
  %endroll
  
%endfunction

%% [EOF] constant.tlc
