function pfcblock_callbackSpacingCtrl(blk)
% Callback function of the "Enable spacing control" checkbox in the Path
% Following Control System block dialog.
%
% The checkbox is located in Tab Parameters -> Panel Spacing Control.

%   Author: Meng Xia, Rong Chen
%   Copyright 2017-2018 The MathWorks, Inc.

% this parameter is not tunable.
if any(strcmpi(get_param(bdroot(blk),'SimulationStatus'),{'external','running'}))
    return
end
% enable/disable of using suboptimal solutions for MPC optimization
maskObj = Simulink.Mask.get(blk);
selection = get_param(blk,'spaceCtrl'); % do not use "object.Value'
object = maskObj.getDialogControl('SpacingCtrlPanel');
if strcmp(selection,'on')
    object.Enabled = 'on';
else
    object.Enabled = 'off';
end
