function output = utilBlockLocations(varargin)
% These are the library locations for the PID Controller blocks in Simulink
% If no input argument is given then the enture structure array is returned

% Copyright 2020-2021 The MathWorks, Inc.

if nargin > 0
    maskType = varargin{1};
else
    maskType = [];
end

if nargin > 1
    field = varargin{2};
else
    field = [];
end

libLocations = {...
    'PID 1dof', ...
        'SubSystem', ...
        'simulink/Continuous/PID Controller', ...
        'slpidlib/PID Controller', ...
        {}, ...
        ''; ...
    'PID 2dof', ...
        'SubSystem', ...
        'simulink/Continuous/PID Controller (2DOF)', ...
        'slpidlib/PID Controller (2DOF)', ...
        {}, ...
        ''};

libLocations = cell2struct( ...
    libLocations, { ...
    'maskType', ...
    'blockType', ...
    'libLocation', ...
    'refBlock', ...
    'MaskNames', ...
    'SFunctionName' }, ...
    2);

% Get desired output
if isempty(maskType)
    output = libLocations;
else
    tmpCell = {libLocations.maskType};
    idx = strcmp(tmpCell,maskType);
    output = libLocations(idx);
end

if ~isempty(field)
    output = output.(field);
end