function readInfoFromSLBlk(this, slbh, deprInfo)
%  takes info from the model and applies it onto dialog source

%   Copyright 2007-2023 The MathWorks, Inc.

% If no HDL specific data on the simulink block, do nothing here;
hd = get_param(slbh, 'HDLData');
if isempty(hd)    
    return;
end

% get stored data on the block
archSelection = hd.getCurrentArch;
archImplParams = hd.getCurrentArchImplParams;
% get possible arch selections for block
archImplList = this.archInfo.keys;
defArchSelection = this.defArchSelection;

if ~isempty(deprInfo) && strcmpi(archSelection, deprInfo.oldName)
    archSelection = deprInfo.newName;    
end

if ~isempty(archSelection)
    if any(strcmp(archSelection, archImplList))
        % update the display archSelection based on block storage
        this.archSelection = archSelection;
    else
        if any(strcmp(defArchSelection, archImplList))
            % revert to default if present in list
            hd.archSelection = defArchSelection;
            this.archSelection = defArchSelection;
        elseif ~isempty(archImplList)
            % default to first arch selection otherwise
            hd.archSelection = archImplList{1};
            this.archSelection = archImplList{1};
        end
        set_param(slbh, 'HDLData', hd);
    end
end

% add mapped impl params to preserve forward compatibility when running 
% hdlget_param or opening up block config GUI 
archImplParams = this.addMapImplParams(archImplParams);

if ~isempty(archImplParams)
    % get implementation param info structure for the current architecture selection
    if iscell(archImplParams)
        if mod(length(archImplParams), 2) == 0
            implInfo = this.getCurrentArchImplParams;
            % now loop over all params to be applied
            for ii=1:2:length(archImplParams)
                paramName = lower(archImplParams{ii});
                newParamValue = archImplParams{ii+1};
                
                if isKey(implInfo, paramName)
                    currParamInfo = implInfo(paramName);
                    currParamInfo.Value = newParamValue;
                    
                    % update the implementation param with new value
                    implInfo(paramName) = currParamInfo;
                end
            end
            % now update the implementation param info structure    
            this.setCurrentArchImplParams(implInfo);
        else
            fprintf('invalid implementation params on: %s', getfullname(slbh));
            % TBD: Error?
        end
    else
        % archImplParams is corrupted. This is protection against a base save to
        % previous version. See g1392598/g1413414.
        hd.archImplInfo = [];
        set_param(slbh, 'HDLData', hd);
    end
end
end

% LocalWords:  impl hdlget
