%% Use Configuration Reference to Select Code Generation Target
% This example shows how to use a configuration reference to select a code
% generation target for a model reference hierarchy without modifying
% individual models.

%% Open Example Model 
% Open the example model <matlab:slexConfigSetRefExample
% |slexConfigSetRefExample|>. 

open_system('slexConfigSetRefExample');

%%
% To open the active configuration set for the model 
% <matlab:slexConfigSetRefExample |slexConfigSetRefExample|>, on
% the *Modeling* tab, click the *Model Configuration
% Parameters* button.
%
% <<../slexConfigSetRef_config_ref_dialog2.png>>
%

%%
% Because the model is using a referenced configuration, the Configuration
% Reference dialog box opens and displays a read-only view of the
% referenced configuration set. Information at the top of the dialog box
% indicates that the model is using the configuration set, |Reference|,
% located in the data dictionary, |slexConfigSetRefData.sldd|. In this
% example, |Reference| is another configuration reference,
% |Configuration_ERT|.

%%
% In the model editor, right-click the Model block, |Amplifier|, and select
% *Open As Top Model*. 

open_system('slexConfigSetRefExample/Amplifier');

%%
% Open the active configuration set for this model. The name and location
% for the referenced configuration is the same as in
% <matlab:slexConfigSetRefExample |slexConfigSetRefExample|>.
%
% <<../slexConfigSetRef_config_ref_dialog3.png>>
%
%% Open the Referenced Configuration Set
% If you need to change and apply parameter values in the configuration
% set, open |Configuration_ERT| for edit in the Configuration Parameters
% dialog box by clicking the Model Configuration Parameters icon at the top of either of the Configuration Reference dialog
% boxes.
%
% <<../slexConfigSetRef_configparam_dialog_ert.png>>
%

%% Generate Code for ERT Target
% The referenced configuration set is customized for ERT code generation.
% To generate code, press *Ctrl+B*. 

rtwbuild('slexConfigSetRefExample');

%%
% The code generation report displays once code generation is complete.

%% Switch Targets and Generate Code for AUTOSAR Target
% For this model there is another configuration set, Configuration_AUTOSAR,
% that is customized for AUTOSAR code generation. At the top of the
% Configuration Reference dialog box, in the rightmost drop-down list,
% select Configuration_AUTOSAR. |slexConfigSetREfExample| and its
% referenced model, |slexConfigSetMdlRef|, now both use the configuration
% set, |Configuration_AUTOSAR|.
%
% <<../slexConfigSetRef_autosar2.png>>
%

%%
% Because you edited the configuration reference, the data dictionary has
% unsaved changes. The configurations are stored outside of the models so
% the models do not have unsaved changes.

%%
% If you have downloaded the AUTOSAR package, you can now generate code for an AUTOSAR target. In the model editor
% window, press *Ctrl+B*. 



%% 
% Copyright 2012 The MathWorks, Inc.