Home > classes > @ao > attachmdl.m

attachmdl

PURPOSE ^

ATTACHMDL attach an mdl file to the analysis object.

SYNOPSIS ^

function varargout = attachmdl(varargin)

DESCRIPTION ^

 ATTACHMDL attach an mdl file to the analysis object.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: ATTACHMDL attach an mdl file to the analysis object.

 CALL:        a = attachmdl(a)

 M-FILE INFO: Get information about this methods by calling
              >> ao.getInfo('attachmdl')

              Get information about a specified set-plist by calling:
              >> ao.getInfo('attachmdl', 'None')

 VERSION:     $Id: attachmdl.m,v 1.14 2008/09/05 11:05:28 ingo Exp $

 HISTORY: 31-03-07 M Hewitson
             Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % ATTACHMDL attach an mdl file to the analysis object.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: ATTACHMDL attach an mdl file to the analysis object.
0005 %
0006 % CALL:        a = attachmdl(a)
0007 %
0008 % M-FILE INFO: Get information about this methods by calling
0009 %              >> ao.getInfo('attachmdl')
0010 %
0011 %              Get information about a specified set-plist by calling:
0012 %              >> ao.getInfo('attachmdl', 'None')
0013 %
0014 % VERSION:     $Id: attachmdl.m,v 1.14 2008/09/05 11:05:28 ingo Exp $
0015 %
0016 % HISTORY: 31-03-07 M Hewitson
0017 %             Creation
0018 %
0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0020 
0021 function varargout = attachmdl(varargin)
0022 
0023   % Check if this is a call for parameters
0024   if utils.helper.isinfocall(varargin{:})
0025     varargout{1} = getInfo(varargin{3});
0026     return
0027   end
0028 
0029   import utils.const.*
0030   utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename);
0031   
0032   % Collect input variable names
0033   in_names = cell(size(varargin));
0034   for ii = 1:nargin,in_names{ii} = inputname(ii);end
0035 
0036   % Collect all AOs and plists
0037   as = utils.helper.collect_objects(varargin(:), 'ao', in_names);
0038 
0039   % Decide on a deep copy or a modify
0040   bs = copy(as, nargout);
0041 
0042   % get the current mdl file
0043   mdlfile = bdroot(gcb);
0044 
0045   % Check its status
0046   dirty = get_param(bdroot,'Dirty');
0047   if strcmp(dirty, 'on')
0048     errordlg('The current Simulink model is unsaved. As such, it can not be attached to the requested AO. Please save the model and run it again.', 'Unsaved Model');
0049   end
0050 
0051   % read it
0052   [pathstr,name,ext] = fileparts(mdlfile);
0053   if isempty(ext)
0054     mdlfile = [mdlfile '.mdl'];
0055   end
0056 
0057   mdlfilein = textread(mdlfile,'%s','delimiter','\n','whitespace','');
0058   mdlout = '';
0059   for j=1:length(mdlfilein)
0060     mdlout = [mdlout '\n' mdlfilein{j}];
0061   end
0062 
0063   % Now attach it to each input AO
0064   for jj=1:numel(bs)
0065     bs(jj).mdlfile = strrep(mdlout, '''', '`');
0066     bs(jj).mdlfilename = mdlfile;
0067   end
0068 
0069   % Set outputs
0070   if nargout > 0
0071     varargout{1} = bs;
0072   end
0073 end
0074 
0075 %--------------------------------------------------------------------------
0076 % Get Info Object
0077 %--------------------------------------------------------------------------
0078 function ii = getInfo(varargin)
0079   if nargin == 1 && strcmpi(varargin{1}, 'None')
0080     sets = {};
0081     pl   = [];
0082   else
0083     sets = {'Default'};
0084     pl   = getDefaultPlist;
0085   end
0086   % Build info object
0087   ii = minfo(mfilename, 'ao', '', utils.const.categories.helper, '$Id: attachmdl.m,v 1.14 2008/09/05 11:05:28 ingo Exp $', sets, pl);
0088 end
0089 
0090 %--------------------------------------------------------------------------
0091 % Get Default Plist
0092 %--------------------------------------------------------------------------
0093 function pl_default = getDefaultPlist()
0094   pl_default = plist();
0095 end
0096

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003