www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdevtestplan/updateInputs.m

    function T= updateInputs(T,newDefaultModel,doRefit)
%UPDATEINPUTS update input information 
%
% T= updateInputs(T,mnew,doRefit)
%   newDefaultModel:   the coding and symbol information from this model is used to
%           update the testplan
%   doRefit: refit models (default= false)

%  Copyright 2006-2014 The MathWorks, Inc. 

if nargin<3
    doRefit=false;
end

m= HSModel(T.DesignDev);

% update designdev
m= updateInputs(m,newDefaultModel);
T.DesignDev= UpdateModels(T.DesignDev,m);

% update base modeldev model
if numstages(T)>1
    % two-stage model - might have no response features
    mbase= get(m,'baseglobal');
else
    mbase= m;
end
T.modeldev= model(T.modeldev,mbase);
% update dynamic copy of testplan as the previous command has updated the pointer address with the
% modeldev superclass
xregpointer(T);

for i=1:length(T.Responses)
    % Update anything in responses
    if useDefaultModel(T,newDefaultModel,T.Responses{i})
        % replace response model with default model
        %  need to update output info
        yi = yinfo(T.Responses{i});
        T.Responses{i} =  yinfo(newDefaultModel,yi);
    else
        % update model inputs of current model
        T.Responses{i}= updateInputs(T.Responses{i},newDefaultModel);
    end
end
if ~isnull(address(T))
    % tasks to be performed only if in the project tree
    xregpointer(T);
    if ~isnull(T.ConstraintData)
        % update input factors in boundary models
        cif= coninputfactor(newDefaultModel);
        setInputFactors(T.ConstraintData.info,cif);
    end
    
    xregpointer(T);
    T = info(T);
    % update all children
    Options.Title = 'Updating input information';
    Options.doGUIUpdate = doRefit && isBrowserProject(T);
    Options.doReselect = doRefit;
    % Use updateAllChildren as we will make a distributed version of this
    UpdateAllChildren(T,Options, @updateInputs,newDefaultModel,doRefit);
end


function useDefault = useDefaultModel(T,newDefaultModel,responseModel)
%useDefaultModel use default model instead of response model

% models should have the same number of inputs
reuseResponses = nfactors(newDefaultModel) == nfactors(responseModel);
if reuseResponses && numstages(T)==2
    % two-stage or point-by-point test plans
    if isa(responseModel,'localmulti')
        % localmulti saved in template for 15b/16b - use default model
        reuseResponses = false;
    else
        % check that the model has a same number of local inputs
        reuseResponses = nlfactors(newDefaultModel) == nlfactors(responseModel);
    end
end
useDefault = ~reuseResponses;