| ert_make_rtw_hook(hookMethod,modelName,rtwroot,templateMakefile,buildOpts,buildArgs)
|
function ert_make_rtw_hook(hookMethod,modelName,rtwroot,templateMakefile,buildOpts,buildArgs)
% ERT_MAKE_RTW_HOOK - ERT hook file for the RTW build process (make_rtw).
%
% <<Includes multiple configuration options using buildArgs>>
%
% Called by RTW for system target file ert.tlc for strategic stages of the RTW
% process.
%
% ert_make_rtw_hook(hookMethod, modelName, rtwroot, templateMakefile,
% buildOpts, buildArgs)
%
% hookMethod:
% Specifies the stage of the RTW build process. Possible values are
% entry, before_tlc, before_make, and exit.
%
% modelName:
% Name of model. Valid for all stages.
%
% rtwroot:
% Reserved.
%
% templateMakefile:
% Name of template makefile. Valid for stages 'before_make' and 'exit'.
%
% buildOpts:
% Valid for stages 'before_make' and 'exit', a MATLAB structure
% containing fields
%
% modules:
% Char array specifying list of generated C files: model.c, model_data.c,
% etc.
%
% codeFormat:
% Char array containing code format: 'RealTime', 'RealTimeMalloc',
% 'Embedded-C', and 'S-Function'
%
% noninlinedSFcns:
% Cell array specifying list of non-inlined S-Functions.
%
% compilerEnvVal:
% String specifying compiler environment variable value, e.g.,
% D:\Applications\Microsoft Visual
%
% buildArgs:
% Char array containing the argument to make_rtw. When pressing the build
% button through the simulation parameter dialog, buildArgs is taken
% verbatim from whatever follows make_rtw in the make command edit field.
% <<inludes options for -opt, -debug, -model>>
% Copyright 1996-2003 The MathWorks, Inc.
% $Revision: $ $Date: $
switch hookMethod
case 'entry'
% Called at start of code generation process (before anything happens.)
% Valid arguments at this stage are hookMethod, modelName, and buildArgs.
disp('Auto configuring model for ERT target based on ert_make_rtw_hook.m file.')
uset_param(modelName,'BackupSettings');
try
if strcmpi(buildArgs, '-opt')
disp('Configuration based on optimized code efficiency (-opt)');
ConfigurationOptimized(modelName);
elseif strcmpi(buildArgs, '-debug')
disp('Configuation based on maximum clarity and traceability (-debug)');
ConfigurationDebug(modelName);
elseif strcmpi(buildArgs, '-model')
disp('Configuration based on current model settings (-model)');
return;
else
disp('Configuration based on default autoconfig values');
EntryConfiguration(modelName);
end
disp('To change setings use -opt/-debug/-model as args for make_rtw');
catch
uset_param(modelName,'RestoreSettings');
error(lasterr)
end
case 'before_tlc'
% Called just prior to invoking TLC Compiler (actual code generation.)
% Valid arguments at this stage are hookMethod, modelName, and
% buildArgs
case 'before_make'
% Called after code generation is complete, and just prior to kicking
% off make process (assuming code generation only is not selected.) All
% arguments are valid at this stage.
case 'exit'
% Called at the end of the RTW build process. All arguments are valid
% at this stage.
% disp('Restoring model configuration.');
% uset_param(modelName,'RestoreSettings');
end
function EntryConfiguration(model)
% Options related to code efficiency (set for maximum efficiency)
uset_param(model,'InlineParams','on');
uset_param(model,'BlockReduction','on');
uset_param(model,'ConditionalExecOptimization','on');
uset_param(model,'ParameterPooling','on');
uset_param(model,'OptimizeBlockIOStorage','on');
uset_param(model,'ExpressionFolding','on');
uset_param(model,'FoldNonRolledExpr','on');
uset_param(model,'EnforceIntegerDowncast','off');
uset_param(model,'InlineInvariantSignals','on');
uset_param(model,'LocalBlockOutputs','on');
uset_param(model,'BufferReuse','on');
uset_param(model,'RollThreshold',5);
uset_param(model,'ZeroExternalMemoryAtStartup','off');
uset_param(model,'ZeroInternalMemoryAtStartup','off');
uset_param(model,'CombineOutputUpdateFcns','on');
uset_param(model,'InitFltsAndDblsToZero','off');
uset_param(model,'StateBitSets','on');
uset_param(model,'DataBitSets','on');
% It is very important to configure to use boolean data types, but
% may cause a model to fail to update diagram.
uset_param(model,'BooleanDataType','on');
% Target Environment
% Note: Target word lengths should be set inside ert_rtw_info_hook.m, and
% extracted as follows. For details on setting up the C implemenation
% details for RTW, type
%
% >> type example_rtw_info_hook
%
% This code synchronizes the model word sizes to the target word sizes.
targetwordlenghts = struct2cell(rtwwordlengths(model));
wordlengths = [] ; comma = '';
for idx = 1 : length(targetwordlenghts)
str = num2str(double(targetwordlenghts{idx}));
wordlengths = [wordlengths,sprintf('%s%s',comma,str)];
comma = ',';
end
uset_param(model,'Solver','FixedStepDiscrete');
uset_param(model,'SolverMode','Auto');
uset_param(model,'GenerateSampleERTMain','on');
uset_param(model,'TargetOS','BareBoardExample');
uset_param(model,'PurelyIntegerCode','off');
uset_param(model,'ProdHWDeviceType','Microprocessor');
uset_param(model,'ProdHWWordLengths', wordlengths);
uset_param(model,'GenFloatMathFcnCalls','ANSI_C');
% Identifiers
uset_param(model,'PrefixModelToSubsysFcnNames','on');
uset_param(model,'IncHierarchyInIds','on');
uset_param(model,'IncDataTypeInIds','on');
uset_param(model,'MaxIdLength',31);
uset_param(model,'InlinedPrmAccess','Literals');
uset_param(model,'IgnoreCustomStorageClasses','off');
% Traceability
uset_param(model,'GenerateComments','on');
uset_param(model,'InsertBlockDesc','on');
uset_param(model,'ShowEliminatedStatement','off');
% Interfaces
uset_param(model,'MultiInstanced','off');
uset_param(model,'MultiInstanceErrorCode','Error');
uset_param(model,'RootIOStructures','off');
uset_param(model,'SuppressErrorStatus','off');
uset_param(model,'IgnoreCustomStorageClasses','off');
uset_param(model,'ParameterTuning','off');
uset_param(model,'BlockIOSignals','off');
uset_param(model,'ExtMode','off');
uset_param(model,'IncludeMdlTerminateFcn','off');
uset_param(model,'GenerateASAP2','off');
% Build environment
uset_param(model,'RTWVerbose','off');
uset_param(model,'GenerateReport','off');
uset_param(model,'GenerateErtSFunction','off');
% Workspace I/O
uset_param(model,'MatFileLogging','off');
uset_param(model,'SaveTime','off');
uset_param(model,'SaveOutput','off');
uset_param(model,'SaveState','off');
uset_param(model,'SaveFinalState','off');
|
|