function parameterValues = getFlatParameterValues(testComp, flatParameterNames)
    % return inital values of all parameters from flatParameterNames and remove Value field
    % from compiled info. flatParameterNames have the leaf level names in
    % case of Bus Parameters.

%   Copyright 2022 The MathWorks, Inc.

    parameterValues = struct;
    for idx = 1:length(testComp.mdlFlatIOInfo.Parameter)
        numCompInfo = length(testComp.mdlFlatIOInfo.Parameter(idx).compiledInfo);
        for compIdx = 1:numCompInfo
            currCompiledInfo = testComp.mdlFlatIOInfo.Parameter(idx).compiledInfo(compIdx);
            paramName = replace(currCompiledInfo.paramNameStr, '.', '_');
            currentParamVal = currCompiledInfo.Value;
            if any(contains(flatParameterNames, paramName))
                    parameterValues.(paramName) = currentParamVal;
            end
        end  
    end
end

