www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@sweepsetfilter/getStorage.m
function s = getStorage(ssf,vars) %getStorage get storage cache items for a sweepsetfilter % s = getStorage(ssf,vars) % Copyright 2015-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargin<2 % assume all variables are ok vars = get(ssf,'name'); end pSS = getOriginal(ssf); if any(ismember(get(info(pSS),'name'),vars)) % all variables and sweep variables from current ssf as valid inputs to % expressions v = get(ssf,'variables'); sv = get(ssf,'sweepVariables'); vars = unique([ vars ; {v.varName sv.varName}']); % exclude validation selector variable vars = setdiff(vars,'mbcValSelector'); typesList = {'variable', 'filter', 'sweepfilter', 'sweepnote', 'sweepvariable'}; namesList = {'Variables', 'Filters', 'Test Filters', 'Test Notes', 'Test Variables'}; s = cell(length(typesList)+1,1); for i=1:length(typesList) s{i} = extractStorage(ssf,typesList{i},namesList{i},vars); end % display layout displayLayout = getDisplayLayout(ssf); if iscell(displayLayout) % need to convert lyt.Layout = xregdatagui.Editor.convertStorageToStruct(displayLayout); lyt.SelectedTests = 1; displayLayout = lyt; end if ~isempty(displayLayout) % storage structure for display layout layoutNames = getDisplayNames(displayLayout.Layout); s{end} = struct('name', [get(ssf,'label') ' Editor Layout'],... 'type', 'xregdataeditorlayout',... 'data', {{displayLayout layoutNames}}); end % remove empty items s(cellfun(@isempty,s)) = []; else s = {}; end function newObject = extractStorage(ssf,type,typeName,vars) %extractStorage extract storage for expression type expr = get(ssf,type); OK = false(size(expr)); for i=1:length(expr) % select expressions where the inputs in the current data set OK(i) = expr(i).OK && all(ismember(expr(i).inlineExp.Inputs,vars)); if OK(i) && isfield(expr(i),'varName') % filter out any validation selector expression OK(i) = ~strcmp(expr(i).varName,'mbcValSelector'); end end % get serialized expressions s = get(ssf,['serialize',type]); s = s(OK,:); if ~isempty(s) % Create the new stored object newObject = struct('name', [get(ssf,'label') ' ' typeName],... 'type', type,... 'data', {s}); else newObject = []; end function names = getDisplayNames(s) %getDisplayNames recurse through layout structure if strcmp(s.Type,'split') names = [getDisplayNames(s.Left) ; getDisplayNames(s.Right)]; else % strip out & from label names = {strrep(s.ViewLabel,'&','')}; end