% Copyright (C) 2013 Czech Technical University in Prague
%
% Authors:
%     - Carlos Jenkins <carlos@jenkins.co.cr>
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program.  If not, see <http://www.gnu.org/licenses/>.
%
% File : rpp_select_callback_handler.m
% Abstract:
%     Custom callback funtion for rtwgensettings.SelectCallback event.
%     Default values of Simulation configurations parameters are set.
%     Some options are disabled if it is not allowed to be changed by user.
%
% References:
%     rtw_ug.pdf p. 1211?


function rpp_select_callback_handler(hDlg, hSrc)

    % Setup the hardware configuration
    %slConfigUISetVal(hDlg, hSrc, 'ProdHWDeviceType', 'Texas Instruments->TMS570');

    % The target is model reference compliant
    slConfigUISetVal(hDlg, hSrc, 'ModelReferenceCompliant', 'on');
    slConfigUISetEnabled(hDlg, hSrc, 'ModelReferenceCompliant', false);

    % Set the target language to C and disable modification
    slConfigUISetVal(hDlg, hSrc, 'TargetLang', 'C');
    slConfigUISetEnabled(hDlg, hSrc, 'TargetLang', false);

    % Configure solver
    slConfigUISetVal(hDlg, hSrc, 'SolverType', 'Fixed-step');
    slConfigUISetVal(hDlg, hSrc, 'Solver', 'FixedStepDiscrete');

    % Hardware being used is the production hardware
    slConfigUISetVal(hDlg, hSrc, 'ProdEqTarget', 'on');

    % For real-time builds, we must generate ert_main.c
    slConfigUISetVal(hDlg, hSrc, 'ERTCustomFileTemplate', 'rpp_file_process.tlc');
    slConfigUISetVal(hDlg, hSrc, 'GenerateSampleERTMain', 'off');
    slConfigUISetEnabled(hDlg, hSrc, 'GenerateSampleERTMain', false);

    % Set the TargetLibSuffix
    slConfigUISetVal(hDlg, hSrc, 'TargetLibSuffix', '.a');

    % Configure PostCodeGen Command to execute (library code inclusion for compilation)
    slConfigUISetVal(hDlg, hSrc, 'PostCodeGenCommand', ...
        'rpp_lib_support(modelName, buildInfo)');

end

