function commblksSlupdateHelper(h)
% Function commblksSlupdateHelper is a helper function to be called as part of
% slupdate.  It is not intended to be called directly from the command line.

%   Copyright 2007-2019 The MathWorks, Inc.

replaceInfo = getReplaceInfo(h);
replaceBlocks(h, replaceInfo);
end

% This function sets up replacement information for the blocks
function replaceInfo = getReplaceInfo(h)
% Abstract - Create the list of blocks that require slupdate.
%
% Input args:
%   h - model updater object

replaceInfo = {};  % init value

% Add block wise information for blocks that have replacements (for obsolete blocks)
% For code samples on how to do this, refer to the R2010B version of this file
% @ matlabroot/toolbox/commblks/commblks/commmblksSlupdateHelper.m
if h.CheckFlags.BlockReplace
    % Replace equalizer blocks in commeq2 with commeq3
    replaceBlockReasonStr = 'update to new library block';
    commeq2ReplaceInfo = { ...
        {'MaskType','LMS Linear Equalizer', ...
        'ReferenceBlock', sprintf('commeq2/LMS Linear \nEqualizer')}, ...
        'ReplaceEqualizer', ...
        replaceBlockReasonStr; ...
        {'MaskType','LMS Decision Feedback Equalizer', ...
        'ReferenceBlock', sprintf('commeq2/LMS Decision \nFeedback Equalizer')}, ...
        'ReplaceEqualizer', ...
        replaceBlockReasonStr; ...
        {'MaskType','RLS Linear Equalizer', ...
        'ReferenceBlock', sprintf('commeq2/RLS Linear \nEqualizer')}, ...
        'ReplaceEqualizer', ...
        replaceBlockReasonStr; ...
        {'MaskType','RLS Decision Feedback Equalizer', ...
        'ReferenceBlock', sprintf('commeq2/RLS Decision \nFeedback Equalizer')}, ...
        'ReplaceEqualizer', ...
        replaceBlockReasonStr; ...
        {'MaskType','Sign LMS Linear Equalizer', ...
        'ReferenceBlock', sprintf('commeq2/Sign LMS Linear \nEqualizer')}, ...
        'ReplaceEqualizer', ...
        replaceBlockReasonStr; ...
        {'MaskType','Sign LMS Decision Feedback Equalizer', ...
        'ReferenceBlock', sprintf('commeq2/Sign LMS Decision \nFeedback Equalizer')}, ...
        'ReplaceEqualizer', ...
        replaceBlockReasonStr; ...
        {'MaskType','Normalized LMS Linear Equalizer', ...
        'ReferenceBlock', sprintf('commeq2/Normalized LMS \nLinear Equalizer')}, ...
        'ReplaceEqualizer', ...
        replaceBlockReasonStr; ...
        {'MaskType','Normalized LMS Decision Feedback Equalizer', ...
        'ReferenceBlock', sprintf('commeq2/Normalized LMS \nDecision Feedback Equalizer')}, ...
        'ReplaceEqualizer', ...
        replaceBlockReasonStr; ...
        {'MaskType','Variable Step LMS Linear Equalizer', ...
        'ReferenceBlock', sprintf('commeq2/Variable Step LMS \nLinear Equalizer')}, ...
        'ReplaceEqualizer', ...
        replaceBlockReasonStr; ...
        {'MaskType','Variable Step LMS Decision Feedback Equalizer', ...
        'ReferenceBlock', sprintf('commeq2/Variable Step LMS \nDecision Feedback Equalizer')}, ...
        'ReplaceEqualizer', ...
        replaceBlockReasonStr; ...
        {'MaskType','CMA Equalizer', ...
        'ReferenceBlock', sprintf('commeq2/CMA Equalizer')}, ...
        'ReplaceEqualizer', ...
        replaceBlockReasonStr; ...
        };
    
    commdigbbndpm2ReplaceInfo = { ...
        {'SourceBlock', sprintf('commdigbbndpm2/BPSK\nModulator\nBaseband')}, ...
        'commdigbbndpm2ReplaceBlocks', ''; ...
        {'SourceBlock', sprintf('commdigbbndpm2/BPSK\nDemodulator\nBaseband')}, ...
        'commdigbbndpm2ReplaceBlocks', ''; ...
        {'SourceBlock', sprintf('commdigbbndpm2/QPSK\nModulator\nBaseband')}, ...
        'commdigbbndpm2ReplaceBlocks', ''; ...
        {'SourceBlock', sprintf('commdigbbndpm2/QPSK\nDemodulator\nBaseband')}, ...
        'commdigbbndpm2ReplaceBlocks', ''; ...
        {'SourceBlock', sprintf('commdigbbndpm2/M-PSK\nModulator\nBaseband')}, ...
        'commdigbbndpm2ReplaceBlocks', ''; ...
        {'SourceBlock', sprintf('commdigbbndpm2/M-PSK\nDemodulator\nBaseband')}, ...
        'commdigbbndpm2ReplaceBlocks', ''; ...
        {'SourceBlock', sprintf('commdigbbndpm2/OQPSK\nModulator\nBaseband')}, ...
        'commdigbbndpm2ReplaceBlocks', ''; ...
        {'SourceBlock', sprintf('commdigbbndpm2/OQPSK\nDemodulator\nBaseband')}, ...
        'commdigbbndpm2ReplaceBlocks', ''; ...
        {'SourceBlock', sprintf('commdigbbndpm2/DBPSK\nModulator\nBaseband')}, ...
        'commdigbbndpm2ReplaceBlocks', ''; ...
        {'SourceBlock', sprintf('commdigbbndpm2/DBPSK\nDemodulator\nBaseband')}, ...
        'commdigbbndpm2ReplaceBlocks', ''; ...
        {'SourceBlock', sprintf('commdigbbndpm2/DQPSK\nModulator\nBaseband')}, ...
        'commdigbbndpm2ReplaceBlocks', ''; ...
        {'SourceBlock', sprintf('commdigbbndpm2/DQPSK\nDemodulator\nBaseband')}, ...
        'commdigbbndpm2ReplaceBlocks', ''; ...
        {'SourceBlock', sprintf('commdigbbndpm2/M-DPSK\nModulator\nBaseband')}, ...
        'commdigbbndpm2ReplaceBlocks', ''; ...
        {'SourceBlock', sprintf('commdigbbndpm2/M-DPSK\nDemodulator\nBaseband')}, ...
        'commdigbbndpm2ReplaceBlocks', ''; ...
        };
    
    % Concatenate the cells
    replaceInfo = [replaceInfo; commeq2ReplaceInfo;commdigbbndpm2ReplaceInfo];
end

% Update blocks requiring a model compilation.
if h.CheckFlags.Compiled
    % Source blocks with frame output option
    fu_SourceWithFrameList = { ...
        sprintf('commrandsrc2/Random Integer\nGenerator'), ...
        sprintf('commrandsrc2/Bernoulli Binary\nGenerator'), ...
        };
    reasonStrFUSrcWFrame = ...
        'Source outputs a frame-based or 1-D signal.';
    numBlksFUSrcWFrame = length(fu_SourceWithFrameList);
    repInfo_FU_SourceWithFrame = cell(numBlksFUSrcWFrame, 3);
    for p=1:numBlksFUSrcWFrame
        repInfo_FU_SourceWithFrame(p, :) = ...
            {{'ReferenceBlock', fu_SourceWithFrameList{p}}, ...
            'commFrameSourceRegisterCompileCheck', reasonStrFUSrcWFrame};
    end
    
    % Concatenate the cells
    replaceInfo = [replaceInfo; repInfo_FU_SourceWithFrame];
end

replaceInfo = cell2struct(replaceInfo, ...
    { 'BlockDesc', 'ReplaceFcn', 'ReplaceBlockReasonStr'}, 2);
end
