classdef (Hidden) ModelWrapper < handle & matlab.mixin.Copyable
    % Data class for each Model in Model workspace
    
    % Copyright 2015 The MathWorks, Inc.
    
    properties(GetAccess = public, SetAccess = public, SetObservable)
        % Label to be displayed in the browser
        Label
        % Store the Model
        LTI
    end
    properties (Access = public, Dependent)
       System
       Name
    end
    
    methods
        
        %% constructor
        function this = ModelWrapper(label, sys)
            % set label
            this.Label = label;
            % set data
            this.setData(sys);
        end
        
        function setData(this, sys)
            % set system
            this.LTI = sys;
        end
        
        function sys = getModel(this)
            sys = this.LTI;
        end
        
        function hText = getDisplayPreviewText(this)
            [ny,nu]=iosize(this.System);             
            Order= order(this.System);
            if length(Order)>1
                OrderLabel = getString(message('Control:mrtool:Orders'));
                OrderText = strrep(strrep(strrep(mat2str(Order'),'[',''),']',''),' ',',');
            else
                OrderLabel = getString(message('Control:mrtool:Order'));
                OrderText = int2str(order(this.System));
            end
            OrderText = sprintf('%s: %s\n',OrderLabel,OrderText);
            
            strType = mrtool.util.getSystemType(this.System);
                                    
            % REVISIT: put a link for system data
            str = [sprintf('%s: %s\n',getString(message('Control:mrtool:Name')),this.Name) ...
                   sprintf('%s: %s\n',getString(message('Control:mrtool:Type')),strType) ...
                   OrderText ...
                   sprintf('%s: %s\n',getString(message('Control:mrtool:Inputs')),int2str(nu)) ...
                   sprintf('%s: %s\n',getString(message('Control:mrtool:Outputs')),int2str(ny)) ...
                   sprintf('\n') ...
                   %% sprintf('%s',getString(message('Control:mrtool:ViewData')))
                  ];
            
            % display LTI
%             str = sprintf('%s = this.LTI;',this.Label);
            %eval(str);
            %str = sprintf('display(%s)',this.Label);
            hText = str; %evalc(str);
            
            
            
            
        end
        function System = get.System(this)
            System = this.LTI;
        end
        function Name = get.Name(this)
            Name = this.Label;            
        end       
    end 
end