%% SYSTLC: Real-Time Workshop Embedded Coder (no auto configuration) TMF: ert_default_tmf MAKE: make_rtw \
%%    EXTMODE: ext_comm
%% SYSTLC: Real-Time Workshop Embedded Coder (auto configures for optimized fixed-point code) TMF: ert_default_tmf MAKE: make_rtw optimized_fixed_point=1\
%%    EXTMODE: ext_comm
%% SYSTLC: Real-Time Workshop Embedded Coder (auto configures for optimized floating-point code) TMF: ert_default_tmf MAKE: make_rtw optimized_floating_point=1\
%%    EXTMODE: ext_comm
%% SYSTLC: Visual C/C++ Project Makefile only for the Real-Time Workshop Embedded Coder\
%%    TMF: ert_msvc.tmf MAKE: make_rtw EXTMODE: ext_comm
%%
%% $RCSfile: ert.tlc,v $
%% $Revision: 1.57.4.11 $
%%
%% Copyright 1994-2004 The MathWorks, Inc.
%% Abstract: Embedded real-time system target file.
%%
%selectfile NULL_FILE

%assign CodeFormat = "Embedded-C"

%assign TargetType = "RT"
%assign Language   = "C"
%assign AutoBuildProcedure = !GenerateSampleERTMain

%% The model_SetEventsForThisBaseRate function is not required for the
%% VxWorks environment, i.e., when using an operating system.
%assign SuppressSetEventsForThisBaseRateFcn = (TargetOS == "VxWorksExample") 

%include "codegenentry.tlc"

%% The contents between 'BEGIN_RTW_OPTIONS' and 'END_RTW_OPTIONS' in this file
%% are used to maintain backward compatibility to R13 and preR13 custom target 
%% file only.  If you want to use this file as a template to develop your
%% own system target file, you need to remove the 'CONFIGSET_TARGET_COMPONENT'
%% section at the end of this file.
%%
/%
  BEGIN_RTW_OPTIONS

  oIdx = 1;

  rtwoptions(oIdx).prompt         = 'ERT code generation options (1)';
  rtwoptions(oIdx).type           = 'Category';
  rtwoptions(oIdx).enable         = 'on';  
  rtwoptions(oIdx).default        = 7;   % number of items under this category
                                      % excluding this one.
  rtwoptions(oIdx).popupstrings  = '';
  rtwoptions(oIdx).tlcvariable   = '';
  rtwoptions(oIdx).tooltip       = '';
  rtwoptions(oIdx).callback      = '';
  rtwoptions(oIdx).opencallback  = '';
  rtwoptions(oIdx).closecallback = '';
  rtwoptions(oIdx).makevariable  = '';

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'MAT-file logging';
  rtwoptions(oIdx).type           = 'Checkbox';
  rtwoptions(oIdx).default        = 'off';
  rtwoptions(oIdx).tlcvariable    = 'MatFileLogging';
  rtwoptions(oIdx).makevariable   = 'MAT_FILE';
  rtwoptions(oIdx).callback       = 'ert_callback_handler';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'Instrument the generated code to log data to a MATLAB .mat\n',...
    'file.  Deselect this option to reduce ROM.']);

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Integer code only';
  rtwoptions(oIdx).type           = 'Checkbox';
  rtwoptions(oIdx).default        = 'off';
  rtwoptions(oIdx).tlcvariable    = 'PurelyIntegerCode';
  rtwoptions(oIdx).makevariable   = 'INTEGER_CODE';
  rtwoptions(oIdx).callback       = 'ert_callback_handler';
  rtwoptions(oIdx).tooltip = sprintf([...
    'Selected, raise an error if the generated code contains\n',...
    'floating point data types, and do not include floating\n',...
    'point utilities the RTW runtime libsrc library.']);

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Initialize internal data';
  rtwoptions(oIdx).type           = 'Checkbox';
  rtwoptions(oIdx).default        = 'on';
  rtwoptions(oIdx).tlcvariable    = 'ZeroInternalMemoryAtStartup';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'Initialize internal data structures to zero during model\n', ...
    'registration.  Deselecting this option reduces ROM.']);
		       
  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Initialize external I/O data';
  rtwoptions(oIdx).type           = 'Checkbox';
  rtwoptions(oIdx).default        = 'on';
  rtwoptions(oIdx).tlcvariable    = 'ZeroExternalMemoryAtStartup';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'Initialize root I/O data structures to zero during model\n',...
    'registration.  Deselecting this option reduces ROM.']);
		       
  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Terminate function required';
  rtwoptions(oIdx).type           = 'Checkbox';
  rtwoptions(oIdx).default        = 'on';
  rtwoptions(oIdx).tlcvariable    = 'IncludeMdlTerminateFcn';
  rtwoptions(oIdx).makevariable   = 'INCLUDE_MDL_TERMINATE_FCN';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'Include a model terminate function.']);

  oIdx = oIdx + 1;

  % WARNING!
  %
  % NEVER REMOVE THE OPTION CombineOutputUpdateFcns FROM THE UI!
  %
  % REMOVING THE OPTION FROM THE UI RESULTS IN INEFFICIENT GENERATED CODE.
  
  rtwoptions(oIdx).prompt         = 'Single output/update function';
  rtwoptions(oIdx).type           = 'Checkbox';
  rtwoptions(oIdx).default        = 'on';
  rtwoptions(oIdx).tlcvariable    = 'CombineOutputUpdateFcns';
  rtwoptions(oIdx).makevariable   = 'COMBINE_OUTPUT_UPDATE_FCNS';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'Generate the model output and update routines into a\n',...
    'single step function.']);

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt       = 'Insert block descriptions in code';
  rtwoptions(oIdx).type         = 'Checkbox';
  rtwoptions(oIdx).default      = 'off';
  rtwoptions(oIdx).tlcvariable  = 'InsertBlockDesc';
  rtwoptions(oIdx).tooltip      = sprintf([...
    'Insert the Description field from the Block Properties dialog into the\n', ...
    'generated C code as a comment. Note that virtual blocks and blocks\n', ...
    'involved in block reduction optimizations are not included.']);

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'ERT code generation options (2)';
  rtwoptions(oIdx).type           = 'Category';
  rtwoptions(oIdx).enable         = 'on';  
  rtwoptions(oIdx).default        = 7;   % number of items under this category
  
  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt       = 'Create Simulink (S-Function) block';
  rtwoptions(oIdx).type         = 'Checkbox';
  rtwoptions(oIdx).default      = 'off';
  rtwoptions(oIdx).tlcvariable  = 'GenerateErtSFunction';
  rtwoptions(oIdx).makevariable = 'GENERATE_ERT_S_FUNCTION';
  rtwoptions(oIdx).tooltip      = sprintf([...
    'Wrap the generated code inside an S-Function block.\n', ...
    'This allows you to validate the generated code in\n', ...
    'Simulink.']);
			      
  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt       = 'Generate ASAP2 file';
  rtwoptions(oIdx).type         = 'Checkbox';
  rtwoptions(oIdx).default      = 'off';
  rtwoptions(oIdx).tlcvariable  = 'GenerateASAP2';
  rtwoptions(oIdx).makevariable = 'GENERATE_ASAP2';
  rtwoptions(oIdx).tooltip      = sprintf([...
    'Create a ASAM compliant ASAP2 data definition file for the\n',...
    'generated C code.  ASAP2 is a standard interface to production\n',...
    'systems.  The file is used by calibration tools which support\n',...
    'the standard.']);

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt       = 'Initialize floats and doubles to 0.0';
  rtwoptions(oIdx).type         = 'Checkbox';
  rtwoptions(oIdx).default      = 'on';
  rtwoptions(oIdx).tlcvariable  = 'InitFltsAndDblsToZero';
  rtwoptions(oIdx).tooltip      = sprintf([...
    'Control how internal storage for floats and doubles is initialized.\n', ...
    'When selected, additional code is generated to set float and double\n', ...
    'storage explicitly to the value 0.0. Otherwise, all internal\n', ...
    'storage is cleared to the integer bit pattern 0 (that is, all bits\n', ...
    'are off). If the representation of floating point zero used by your\n', ...
    'compiler and target CPU is identical to the the integer bit pattern\n', ...
    '0, you can gain efficiency (i.e., less ROM) by not selecting this\n', ...
    'option.']);

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt       = 'Ignore custom storage classes';
  rtwoptions(oIdx).type         = 'Checkbox';
  rtwoptions(oIdx).default      = 'off';
  rtwoptions(oIdx).tlcvariable  = 'IgnoreCustomStorageClasses';
  rtwoptions(oIdx).tooltip      = sprintf([...
    'Treat custom storage classes as ''Auto'' storage class.']);

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'External mode';
  rtwoptions(oIdx).type           = 'Checkbox';
  rtwoptions(oIdx).default        = 'off';
  rtwoptions(oIdx).tlcvariable    = 'ExtMode';
  rtwoptions(oIdx).makevariable   = 'EXT_MODE';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'Adds TCP/IP communication support for use with\n',...
    'Simulink external mode.']);

  oIdx = oIdx + 1;

  % Reserved for MathWorks internal testing
  rtwoptions(oIdx).prompt         = 'External mode testing';
  rtwoptions(oIdx).type           = 'NonUI';
  rtwoptions(oIdx).default        = '0';
  rtwoptions(oIdx).tlcvariable    = 'ExtModeTesting';
  rtwoptions(oIdx).makevariable   = 'TMW_EXTMODE_TESTING';

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Suppress error status in real-time model data structure';
  rtwoptions(oIdx).type           = 'Checkbox';
  rtwoptions(oIdx).default        = 'off';
  rtwoptions(oIdx).tlcvariable    = 'SuppressErrorStatus';
  rtwoptions(oIdx).tooltip        = sprintf( ...
    ['By default, the real-time model data structure (rtM)\n', ...
     'includes an error status field (data type string). This\n', ...
     'field lets you log and monitor error messages via macros\n', ...
     'provided for this purpose (see model.h). The error\n', ...
     'status field is initialized to NULL. If this option is\n', ...
     'selected, the error status field is not included in rtM.\n', ...
     'Selecting this option may also cause the real-time\n', ...
     'object to disappear completely from the generated code.\n', ...
     'If you do not need to log or monitor error status, select\n', ... 
     'this option.']);  

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Parameter structure';
  rtwoptions(oIdx).type           = 'Popup';
  rtwoptions(oIdx).popupstrings   = 'Hierarchical|NonHierarchical';
  rtwoptions(oIdx).default        = 'Hierarchical';
  rtwoptions(oIdx).tlcvariable    = 'InlinedParameterPlacement';
  rtwoptions(oIdx).enable         = 'on';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'Hierarchical: Where possible, generate independent\n', ...
    'parameter data structures for reusable subsystems. \n', ...
    'NonHierarchical: Generate a single parameter data structure\n', ...
    'including reusable subsystem level parameters']);
  rtwoptions(oIdx).opencallback   = [ ...
    'obj0Tag = ''Parameter structure_PopupFieldTag'';', ...
    'obj0 = findobj(DialogFig,''Tag'',obj0Tag);', ...
    'val = get_param(model, ''RTWInlineParameters'');', ...
    'set(obj0, ''Enable'', val);', ...
    ];
  
  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'ERT code generation options (3)';
  rtwoptions(oIdx).type           = 'Category';
  rtwoptions(oIdx).enable         = 'on';  
  rtwoptions(oIdx).default        = 6;   % number of items under this category
  
  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Generate an example main program';
  rtwoptions(oIdx).type           = 'Checkbox';
  rtwoptions(oIdx).default        = 'on';
  rtwoptions(oIdx).tlcvariable    = 'GenerateSampleERTMain';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'Generate an example main program demonstrating\n', ...
    'how to deploy the generated code.  The program is\n', ...
    'generated into ert_main.c.']);

  % Enable/disable file name (edit lable and edit field)
  rtwoptions(oIdx).callback       = [ ...
    'DialogFig = get(gcbo,''Parent'');',...
    'obj0Tag = ''Generate an example main program_CheckboxTag'';', ...
    'obj1Tag = ''Target operating system_PopupFieldTag'';', ...
    'obj0 = findobj(DialogFig,''Tag'',obj0Tag);', ...
    'obj1 = findobj(DialogFig,''Tag'',obj1Tag);', ...
    'val = get(obj0,''Value'');', ...
    'if val == 1;val=''on'';else;val=''off'';end;', ...
    'set(obj1, ''Enable'', val);', ...
    ];

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Target operating system';
  rtwoptions(oIdx).type           = 'Popup';
  rtwoptions(oIdx).popupstrings   = 'BareBoardExample|VxWorksExample';
  rtwoptions(oIdx).default        = 'BareBoardExample';
  rtwoptions(oIdx).tlcvariable    = 'TargetOS';
  rtwoptions(oIdx).enable         = 'on';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'Specify the target operating system.  When "BareBoardExample"\n', ...
    'is selected, the generated ert_main.c contains an example\n', ...
    'main program, demonstrating how to deploy the generated algorithm\n', ...
    'code on a bare board (no operating system) real-time target.\n', ...
    'When "VxWorksExample" is selected, the ert_main.c contains an\n', ...
    'example main program, demonstrating how to deploy the generated\n', ...
    'algorithm code on the VxWorks real-time operating system.']);
  % Synchronize with "generating an example main program" option
  rtwoptions(oIdx).opencallback   = [ ...
    'obj0Tag = ''Generate an example main program_CheckboxTag'';', ...
    'obj1Tag = ''Target operating system_PopupFieldTag'';', ...
    'obj0 = findobj(DialogFig,''Tag'',obj0Tag);', ...
    'obj1 = findobj(DialogFig,''Tag'',obj1Tag);', ...
    'val = get(obj0,''Value'');', ...
    'if val == 1;val=''on'';else;val=''off'';end;', ...
    'set(obj1, ''Enable'', val);', ...
    ];
				
  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Generate reusable code';
  rtwoptions(oIdx).type           = 'Checkbox';
  rtwoptions(oIdx).default        = 'off';
  rtwoptions(oIdx).tlcvariable    = 'MultiInstanceERTCode';
  rtwoptions(oIdx).makevariable   = 'MULTI_INSTANCE_CODE';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'Generate reusable/reentrant code.  Not selected, the\n',...
    'generated code statically allocates all necessary\n',...
    'data and accesses it directly, creating non-reusable\n',...
    'and non-reentrant code.  Selected, non-constant data\n',...
    'is not allocated for the generated code; rather this\n',...
    'data must be allocated externally and passed into\n',...
    'the generated code via function arguments, creating\n',...
    'reusable and reentrant code.']);
  rtwoptions(oIdx).callback       = [ ...
    'DialogFig = get(gcbo,''Parent'');',...
    'obj0Tag = ''Generate reusable code_CheckboxTag'';', ...
    'obj1Tag = ''Reusable code error diagnostic_PopupFieldTag'';', ...
    'obj2Tag = ''Pass model I/O arguments as structure reference_CheckboxTag'';', ...
    'obj0 = findobj(DialogFig,''Tag'',obj0Tag);', ...
    'obj1 = findobj(DialogFig,''Tag'',obj1Tag);', ...
    'obj2 = findobj(DialogFig,''Tag'',obj2Tag);', ...
    'val = get(obj0,''Value'');', ...
    'if val == 1;val=''on'';else;val=''off'';end;', ...
    'set(obj1, ''Enable'', val);', ...
    'set(obj2, ''Enable'', val);', ...
    ];

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt       = 'Pass model I/O arguments as structure reference';
  rtwoptions(oIdx).type         = 'Checkbox';
  rtwoptions(oIdx).default      = 'off';
  rtwoptions(oIdx).tlcvariable  = 'RootIOStructures';
  rtwoptions(oIdx).enable       = 'on';
  rtwoptions(oIdx).tooltip      = sprintf([...
    'Specify how the model inputs and outputs are passed\n',...
    'to the model step functions.  Passing by structure\n',...
    'reference reduces the number of function arguments.\n',...
    'Selected, the model I/O is passed by structure reference.\n',...
    'Otherwise, it''s passed as individual arguments.']);
  rtwoptions(oIdx).opencallback   = [ ...
    'obj0Tag = ''Generate reusable code_CheckboxTag'';', ...
    'obj1Tag = ''Pass model I/O arguments as structure reference_CheckboxTag'';', ...
    'obj0 = findobj(DialogFig,''Tag'',obj0Tag);', ...
    'obj1 = findobj(DialogFig,''Tag'',obj1Tag);', ...
    'val = get(obj0,''Value'');', ...
    'if val == 1;val=''on'';else;val=''off'';end;', ...
    'set(obj1, ''Enable'', val);', ...
    ];
  
  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Reusable code error diagnostic';
  rtwoptions(oIdx).type           = 'Popup';
  rtwoptions(oIdx).popupstrings   = 'None|Warning|Error';
  rtwoptions(oIdx).default        = 'Error';
  rtwoptions(oIdx).tlcvariable    = 'MultiInstanceErrorCode';
  rtwoptions(oIdx).enable         = 'on';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'Specify the error diagnostic behavior for when\n',...
    'data defined in the model violates the ability\n',...
    'to reuse the code.']);
  rtwoptions(oIdx).opencallback   = [ ...
    'obj0Tag = ''Generate reusable code_CheckboxTag'';', ...
    'obj1Tag = ''Reusable code error diagnostic_PopupFieldTag'';', ...
    'obj0 = findobj(DialogFig,''Tag'',obj0Tag);', ...
    'obj1 = findobj(DialogFig,''Tag'',obj1Tag);', ...
    'val = get(obj0,''Value'');', ...
    'if val == 1;val=''on'';else;val=''off'';end;', ...
    'set(obj1, ''Enable'', val);', ...
    ];
  
  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Target floating point math environment';
  rtwoptions(oIdx).type           = 'Popup';
  rtwoptions(oIdx).popupstrings   = 'ANSI_C|ISO_C';
  rtwoptions(oIdx).default        = 'ANSI_C';
  rtwoptions(oIdx).tlcvariable    = 'GenFloatMathFcnCalls';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'If your target compiler supports the ISO C (ISO/IEC 9899:1999)\n', ...
    'math library, we recommend selecting the ISO C option and \n', ...
    'setting your compiler''s ISO C flags. This will generate calls \n', ...
    'to the ISO C functions wherever possible (for example, sqrtf()\n', ...
    'instead of sqrt() for single precision data) and ensure that\n', ...
    'you obtain the best performance your target compiler offers. \n', ...
    'If your target compiler does not support ISO C math library \n', ...
    'functions, use the ANSI C (ANSI X3.159-1989) option \n', ...
    '(the default).']);
  
  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'ERT code templates';
  rtwoptions(oIdx).type           = 'Category';
  rtwoptions(oIdx).enable         = 'on';  
  rtwoptions(oIdx).default        = 5;   % number of items under this category

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Enable custom file banners';
  rtwoptions(oIdx).type           = 'NonUI';
  rtwoptions(oIdx).default        = '1';
  rtwoptions(oIdx).tlcvariable    = 'ERTCustomFileBanners';

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Source file (.c) banner template';
  rtwoptions(oIdx).type           = 'Edit';
  rtwoptions(oIdx).default        = 'example_banner.tlc';
  rtwoptions(oIdx).tlcvariable    = 'ERTSrcFileBannerTemplate';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'Name of source file (*.c) banner template.  The location\n',...
    'of the specified file must be on the TLC include path. See\n',...
    'example file MATLAB/rtw/c/tlc/mw/example_banner.tlc.']);

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Header file (.h) banner template';
  rtwoptions(oIdx).type           = 'Edit';
  rtwoptions(oIdx).default        = 'example_banner.tlc';
  rtwoptions(oIdx).tlcvariable    = 'ERTHdrFileBannerTemplate';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'Name of header file (*.h) banner template.  The location\n',...
    'of the specified file must be on the TLC include path. See\n',...
    'example file MATLAB/rtw/c/tlc/mw/example_banner.tlc.']);

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'Customize and create source files';
  rtwoptions(oIdx).type           = 'NonUI';
  rtwoptions(oIdx).default        = '1';
  rtwoptions(oIdx).tlcvariable    = 'ERTCreateCustomFiles';

  oIdx = oIdx + 1;

  rtwoptions(oIdx).prompt         = 'File customization template';
  rtwoptions(oIdx).type           = 'Edit';
  rtwoptions(oIdx).default        = 'example_file_process.tlc';
  rtwoptions(oIdx).tlcvariable    = 'ERTCustomFileTemplate';
  rtwoptions(oIdx).tooltip        = sprintf([...
    'Name of template file to create additional and customize\n',...
    'existing source files.  The location of the specified\n',...
    'file must be on the TLC include path.  See example file\n',...
    'MATLAB/rtw/c/tlc/mw/example_file_process.tlc.']);

  %----------------------------------------%
  % Configure RTW code generation settings %
  %----------------------------------------%
  
  rtwgensettings.BuildDirSuffix = '_ert_rtw';

  END_RTW_OPTIONS 
 %/

%% The content between 'BEGIN_CONFIGSET_TARGET_COMPONENT' and 
%% 'END_CONFIGSET_TARGET_COMPONENT' is for the MathWorks internal use
%% only.  You must remove this section if you intend to use this file
%% as a template for your own system target development.
/%
  BEGIN_CONFIGSET_TARGET_COMPONENT
 
  targetComponentClass = 'Simulink.ERTTargetCC';
  
  END_CONFIGSET_TARGET_COMPONENT
 %/