function freblkCallbackExperimentMode(blk)
%   Callback function of FRE block

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

maskObj = Simulink.Mask.get(blk);
if strcmpi(get_param(blk,'ExperimentMode'),slsvInternal('slsvGetEnStringFromCatalog','Slcontrol:onlinefre:rbtnElementSS'))
    InputSignalType = 'Sinestream';
elseif strcmpi(get_param(blk,'ExperimentMode'),slsvInternal('slsvGetEnStringFromCatalog','Slcontrol:onlinefre:rbtnElementSI'))
    InputSignalType = 'Superposition';
else
    InputSignalType = 'PRBS';
end
IsHz = strcmpi(get_param(blk,'FreqUnits'),'hz');
% switch experiment settings panel depending on mode selection
objectSS = maskObj.getDialogControl('SSPanel');
objectSI = maskObj.getDialogControl('SIPanel');
objectPRBS = maskObj.getDialogControl('PRBSPanel');
IsExternalSource = strcmpi(get_param(blk,'SineSource'),slsvInternal('slsvGetEnStringFromCatalog','Slcontrol:onlinefre:rbtnElementPort'));
if strcmp(InputSignalType,'Sinestream')
    objectSI.Visible = 'off';
    objectSS.Visible = 'on';
    objectPRBS.Visible = 'off';
elseif strcmp(InputSignalType,'Superposition')
    objectSI.Visible = 'on';
    objectSS.Visible = 'off';
    objectPRBS.Visible = 'off';
else
    objectSI.Visible = 'off';
    objectSS.Visible = 'off';
    objectPRBS.Visible = 'on';    
    freblkUpdateAutogenPRBSParamsCheckboxes(blk);
end
% update bode plot setting
freblkCallbackBodePlot(blk);
% update experiment length display
wksp = getWorkspaceVariables(maskObj);
if ~isempty(wksp) % Needed for PLC Codegen
    W = wksp(strcmp('Frequencies',{wksp.Name})).Value;
    EP = wksp(strcmp('NumOfEstPeriod',{wksp.Name})).Value;
    SP = wksp(strcmp('NumOfSetPeriod',{wksp.Name})).Value;
    Ts = wksp(strcmp('DiscreteTs',{wksp.Name})).Value;
    NP = wksp(strcmp('NumOfPRBSPeriod',{wksp.Name})).Value;
    SO = wksp(strcmp('PRBSSignalOrder',{wksp.Name})).Value;
    freblkUpdateLength(blk,IsExternalSource,InputSignalType,IsHz,W,EP,SP,NP,SO,Ts);
end