function varargout = dspblksine(action)
% DSPBLKSINE DSP Blockset Sine Wave block helper function.

% Copyright 1995-2000 The MathWorks, Inc.
% $Revision: 1.9 $ $Date: 2000/04/29 22:54:46 $

% Amplitude
% Frequency
% Phase
% SampleMode
% CompMethod
% SampleTime
% SamplesPerFrame
% ResetState

blk = gcb;

if nargin==0, action = 'dynamic'; end

Mode = get_param(blk,'SampleMode');
isDiscrete = strncmp(Mode,'Discrete',8);

Method = get_param(blk,'CompMethod');
isTable = strcmp(Method,'Table Lookup');

SimStatus = get_param(bdroot(gcs),'SimulationStatus');
isSimStopped = strcmp(SimStatus,'stopped');

switch action
case 'dynamic'
   
    % Update enable-status of:
    %   computation method, complex computation method,
    %   sample time, samples per frame, and re-enable:

    enables = get_param(blk,'MaskEnables');
    if isDiscrete,
        ena = 'on';
    else
        ena = 'off';
    end
    enables(6:9) = {ena};
    set_param(blk,'MaskEnables',enables);

    % Set the tunability of the Amp, Freq, and Phase.
    % These need to be "off" in Table Lookup Mode
    
    TuneVals = get_param(blk,'MaskTunableValues');
    if isTable,
        val = 'off';
    else
        val = 'on';
    end 

    % We can only change masktunablevalues when the simulation is stopped.  
    if(isSimStopped & ~strcmp(TuneVals(1),val) & ~strcmp(TuneVals(2),val) & ~strcmp(TuneVals(3),val))   
        TuneVals(1:3) = {val};
        set_param(blk,'MaskTunableValues',TuneVals);
    end
         

case 'icon'
  
   if isDiscrete,
      dx=pi/5;
      x=(0:dx:2*pi)';
      y=sin(x);
      [x,y]=stairs(x,y);   
   else
      dx=pi/22;
      x=(0:dx:2*pi)';
      y=sin(x);
   end
   
   % Axes:
   x=[x;NaN;0; 0;NaN;0;2*pi];
   y=[y;NaN;1;-1;NaN;0;0];
   varargout(1:2) = {x,y};
   
end

% [EOF] dspblksine.m