www.gusucode.com > sloptim工具箱matlab源码程序 > sloptim/sloptguis/@srogui/@SimProjectForm/load.m
function Warn = load(this,Proj,SilentFlag) % Import settings from another project (R14 only) % Copyright 1986-2008 The MathWorks, Inc. Warn = ''; if isa(Proj,'struct') % old ncdStruct this.loadNCDStruct(Proj) else % Check model name consistency (in case model has been renamed) if ~strcmp(this.Model,Proj.Model) s1 = ctrlMsgUtils.message('Sloptim:srogui:warnProjectForDifferentModel',Proj.Model); s2 = 'Proceed anyway?'; s3 = 'Note: Resave your project to eliminate this warning.'; Q = sprintf('%s. %s\n\n%s',s1,s2,s3); if nargin==3 || strcmp(questdlg(Q,'Load Warning'),'Yes') % RE: Always go ahead at model load time Proj.renameModel(this.Model) else return end end this.Parameters = Proj.Parameters; this.OptimOptions = Proj.OptimOptions; % Create/ remove uncertainty test if necessary if length(Proj.Tests)>length(this.Tests) t = copy(this.Tests(1)); t.Specs = this.Tests(1).Specs; this.Tests(2,1) = t; elseif length(Proj.Tests)<length(this.Tests) %Need to remove some of the tests from current project this.Tests = this.Tests(1:length(Proj.Tests)); end for ct=1:length(this.Tests) this.Tests(ct).Enable = Proj.Tests(ct).Enable; this.Tests(ct).Optimized = Proj.Tests(ct).Optimized; this.Tests(ct).Runs = Proj.Tests(ct).Runs; end % REVISIT: Current options dialog requires shared sim options set(this.Tests,'SimOptions',Proj.Tests(1).SimOptions) % Loop over each constraint/block in current project % and look for loaded constraint with matching path Warn = ''; CurrentC = this.Tests(1).Specs; for ct=1:length(CurrentC) % Find matching loaded constraint C = Proj.Tests(1).findspec(CurrentC(ct).SignalSource.LogID); if isempty(C) % No matching constraint in loaded project BlockName = find_system(this.Model,'FollowLinks','on','LookUnderMasks','all',... 'BlockType','SubSystem','LogID',CurrentC(ct).SignalSource.LogID); if isempty(Warn) Warn = ctrlMsgUtils.message('Sloptim:srogui:warnNoBlockSettings',BlockName{1}); else Warn = sprintf('%s\n%s',Warn,ctrlMsgUtils.message('Sloptim:srogui:warnNoBlockSettings',BlockName{1})); end else %Copy constraint data, but don't override block handle C.SignalSource.hBlock = CurrentC(ct).SignalSource.hBlock; CurrentC(ct) = C; end end set(this.Tests,'Specs',CurrentC) Warn = char(Warn); end