function changeModelParameters(obj)
%

%   Copyright 2008-2021 The MathWorks, Inc.
            
    modelHsToChange = obj.ModelHsInMdlRefTree;
    modelHsToChange(1) = [];
    if isempty(modelHsToChange)
        return;
    end     
    
    paramNameValStruct.AssertControl = 'DisableAll';
    if ~strcmp(get_param(obj.ModelBlockH,'SimulationMode'),'Normal')
        obj.RequiresMexRebuild = true;
        paramNameValStruct.UpdateModelReferenceTargets = 'AssumeUpToDate';
    else
        paramNameValStruct.UpdateModelReferenceTargets = 'IfOutOfDate';
    end
    paramNameValStruct.RecordCoverage = 'off';
    paramNameValStruct.SFSimEnableDebug = 'off';
    
    for idx=1:length(modelHsToChange)
        modelH = modelHsToChange(idx);
        modelName = get_param(modelH,'Name');
        currentParamNameValStruct = paramNameValStruct;
        if ~obj.MdlParametersMap.isKey(modelName)
            origDirty = get_param(modelH,'Dirty');
            
            currenConfigSet = getActiveConfigSet(modelH);
            % Parameters will be changed remove the current ones
            Sldv.utils.replaceConfigSetRefWithCopy(modelH);
            
            % Change model parameters and store the existing ones
            modelInfo = ...
                Sldv.SimModel.changeMdlParams(modelH, currentParamNameValStruct);
            
            % OldConfigSet should be the last element in the struct filed list
            modelInfo.OldConfigSet = currenConfigSet;
            
            obj.MdlParametersMap(modelName) = modelInfo;
            
            set_param(modelH,'Dirty',origDirty);
        end
    end
end
