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-2023 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
    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', ''; ...
        };

    % Upgrade pre-R2023a Receiver Thermal Noise blocks to 
    % block with updated random number generator
    thermalNoiseInfo = {...
        {'ReferenceBlock', sprintf('commrflib2/Receiver\nThermal Noise'),...
        'LegacyMode','on'}, ...
      'commThermalNoiseBlockReplace', ...
      'Pre-2023a Receiver Thermal Noise block (v5 random number generator)'};

    % Concatenate the cells
    replaceInfo = [replaceInfo; commdigbbndpm2ReplaceInfo; thermalNoiseInfo];
end

% Update blocks requiring a model compilation.
if h.CheckFlags.Compiled    
    % Upgrade pre-R2023a AWGN blocks to 
    % AWGN block with var-size and updated random number generator
    awgnInfo = {...
        {'ReferenceBlock', sprintf('commchan3/AWGN\nChannel'),...
        'LegacyMode','on'}, ...
      'commAWGNBlockCompileCheck', ...
      'Pre-2023a AWGN block (v5 random number generator)'};
    
    % Concatenate the cells
    replaceInfo = [replaceInfo; awgnInfo];
end

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