function mpcblocks_callbackPM(blk)
% Callback function of the "online p/m" checkbox in the MPC/Adaptive MPC.

%   Author: Rong Chen
%   Copyright 2018 The MathWorks, Inc.

% this parameter is not tunable.
if strcmpi(get_param(bdroot(blk),'SimulationStatus'),'stopped')
    % enable/disable of using suboptimal solutions for MPC optimization
    maskObj = Simulink.Mask.get(blk);
    selection = get_param(blk,'pm_inport'); % do not use "object.Value'
    object = maskObj.Parameters.findobj('Name','MaximumP');
    if strcmp(selection,'on')
        object.Enabled = 'on';
    else
        object.Enabled = 'off';
    end
end