function h = compdata
%COMPDATA  Constructor for compensator data repository.

%   Author(s): P. Gahinet
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.5 $ $Date: 2000/08/02 16:06:19 $

if nargout==0
    % Register class 
    c = schema.class(findpackage('sisodata'),'compdata');
    
    % Public properties
    schema.prop(c,'Name','String');      % Compensator name
    schema.prop(c,'Format','String');    % Compensator format
    schema.prop(c,'PZGroup','handle vector');   % Pole/zero groups
    schema.prop(c,'Gain','mxArray');     % Gain (sign + mag)
    schema.prop(c,'Ts','double');        % Sample time 
 
    % Private properties
    p = schema.prop(c,'Listeners','handle vector');  % Listeners
    set(p,'AccessFlags.PublicGet','off','AccessFlags.PublicSet','off');
    
else
    % Create class instance
    h = sisodata.compdata;
    
    h.Listeners = handle.listener(h,findprop(h,'Format'),...
        'PropertyPreSet',@LocalUpdateGain);

end


%-------------------------Listeners-------------------------


%%%%%%%%%%%%%%%%%%%%%%%
%%% LocalUpdateGain %%%
%%%%%%%%%%%%%%%%%%%%%%%
function LocalUpdateGain(hProp,event)
% Updates gain magnitude when switching format
% REVISIT: using PreSet because both old and new value needed
CompData = event.AffectedObject;
CompData.Gain = convertgain(CompData,CompData.Format,event.NewValue);
