function nodeNamesList = dcfGetNodeNamesList(modelName)
%dcfGetNodeNamesList Get the list of nodes in the model
% 
%   NODENAMESLIST = dcfGetNodeNamesList(MODELNAME) returns a cell array,
%   where each element consists of a complete path to a node configured by
%   the user. The size of the cell array is the same as the number of nodes
%   configured by the user in the given MODELNAME.
% 
%   MODELNAME is a simulink model name.

%   Copyright 2019 The MathWorks, Inc.

% Extract the list of block names in the model.
data = find_system(modelName, 'SearchDepth',1);
% Count the number of node subsystems in the list.
count = 1;
% Loop over each block name in the model and checks whether it is a node
% subsystem or not.
nodeNamesList = {};
for i = 1:length(data)
    % Extract the initial part of block path.
    blockPath = strsplit(data{i}, '/');
    % Check whether that block is from model or a library.
    if (strcmp(blockPath{1}, modelName)) && (numel(blockPath) == 2)
        try
            % If that block is from model, check whether it has nodeId
            % property or not.
            set_param(data{i}, 'NodeID', num2str(count));
            nodeNamesList{count} = data{i};
            count = count + 1;
        catch
        end
    end
end