Code Configuration Functions
LibAddSourceFileCustomSection
(file, builtInSection, newSection)
Adds a custom section to a source file. You must associate a custom
section with one of the built-in sections: Includes, Defines, Types,
Enums, Definitions, Declarations, Functions, or Documentation. Nothing
happens if the section already exists, except to report an error if an
inconsistent built-in section association is attempted.
LibAddSourceFileCustomSection is available only
with the Embedded Coder® product.
Arguments
file — Source file reference
builtInSection — Name of the associated built-in
section
newSection — Name of the new (custom) section
See LibAddSourceFileCustomSection in codetemplatelib.tlc.
LibAddToCommonIncludes(incFileName)
Adds items to a list of #include /package specification items. Each
member of the list is unique. Attempting to add a duplicate member does nothing.
LibAddToCommonIncludes should be called from block TLC methods to
specify generation of #include statements in
. Specify the names of files on the
include path inside angle brackets, e.g., model.h<sysinclude.h>. Specify
the names of local files without angle brackets, e.g., myinclude.h. Each
call to LibAddToCommonIncludes adds the specified file to the list only
if it is not already there. Filenames with and without angle brackets (e.g.,
<math.h> and math.h) are considered different.
The #include statements are placed inside
.model.h
Example
LibAddToCommonIncludes("tpu332lib.h")See LibAddToCommonIncludes in cachelib.tlc.
LibAddToModelSources(newFile)
LibAddToModelSources serves two purposes:
To notify the build process that it must build with the specified source file
To update the
SOURCES: file1.c file2.c ...comment in the generated code.
For inlined S-functions, LibAddToModelSources is generally called
from BlockTypeSetup. LibAddToModelSources adds a
filename to the list of sources for building this model.
LibAddToModelSources returns 1 if the filename
passed in was a duplicate (i.e., it was already in the sources list) and
0 if it was not a duplicate.
You can use the LibAddToModelSources function for other purposes in
TLC aside from writing S-functions. If you write your own S-functions, use the
SFunctionModules block parameter instead of
LibAddToModelSources. See LibAddToModelSources in
utils_api.tlc.
LibCacheDefine(buffer)
Each call to LibCacheDefine appends your buffer to the existing cache
buffer. For blocks, LibCacheDefine is generally called from
BlockTypeSetup.
LibCacheDefine caches #define statements for
inclusion in or
model_private.h. Call
model.cLibCacheDefine from inside BlockTypeSetup to cache a
#define statement. Each call to LibCacheDefine
appends your buffer to the existing cache buffer. The #define statements
are placed inside or
model_private.h.model.c
Example
%openfile buffer #define INTERP(x,x1,x2,y1,y2) ( y1+((y2 - y1)/(x2 - x1))*(x-x1)) #define this that %closefile buffer %<LibCacheDefine(buffer)>
See LibCacheDefine in codecache_api.tlc.
LibCacheExtern(buffer)
LibCacheExtern should be called from inside
BlockTypeSetup to cache an extern statement. Each
call to LibCacheExtern appends your buffer to the existing cache buffer.
The extern statements are placed in
.model_private.h
Example
%openfile buffer extern real_T mydata; %closefile buffer %<LibCacheExtern(buffer)>
See LibCacheExtern in codecache_api.tlc.
LibCacheFunctionPrototype(buffer)
LibCacheFunctionPrototype should be called from inside
BlockTypeSetup to cache a function prototype. Each call to
LibCacheFunctionPrototype appends your buffer to the existing cache
buffer. The prototypes are placed inside
.model_private.h
Example
%openfile buffer extern int_T fun1(real_T x); extern real_T fun2(real_T y, int_T i); %closefile buffer %<LibCacheFunctionPrototype(buffer)>
See LibCacheFunctionPrototype in codecache_api.tlc.
LibCacheTypedefs(buffer)
LibCacheTypedefs should be called from inside
BlockTypeSetup to cache typedef declarations. Each
call to LibCacheTypedefs appends your buffer to the existing cache
buffer. The typedef statements are placed inside
(or
model.h).model_common.h
Example
%openfile buffer typedef foo bar; %closefile buffer %<LibCacheTypedefs(buffer)>
See LibCacheTypedefs in codecache_api.tlc.
LibCallModelInitialize()
Returns code for calling the model's initialize function (valid for ERT only).
See LibCallModelInitialize in .codetemplatelib.tlc
LibCallModelStep(tid)
Returns code for calling the model's step function (valid for ERT only).
See LibCallModelStep in codetemplatelib.tlc.
LibCallModelTerminate()
Returns code for calling the model's terminate function (valid for ERT only).
See LibCallModelTerminate in codetemplatelib.tlc.
LibCallSetEventForThisBaseStep(buffername)
Returns code for calling the model's set events function (valid for ERT only).
Argument
buffername — Name of the variable used to buffer the events.
For the example ert_main.c, this is
eventFlags.
See LibCallSetEventForThisBaseStep in codetemplatelib.tlc.
LibClearFileSectionContents(fileIdx, attrib)
Before writing file to disk, clear file sections with custom values.
Arguments
fileIdx (scope or number) — File index
attrib (string) — Name of model attribute
See LibGetSourceFileAttribute in codetemplatelib.tlc.
LibCreateSourceFile(type, creator, name)
Creates a new C or C++ file and returns its reference. If the file already exists,
LibCreateSourceFile returns the existing file's reference.
Syntax
%assign fileH = LibCreateSourceFile
("Source", "Custom", "foofile")Arguments
type (string) — Valid values are "Source"
and "Header" for .c and .h files,
respectively.
creator (string) — Who is creating the file? An error is
reported if different creators attempt to create the same file.
name (string) — Base name of the file (i.e., without the
extension). Note that files are not written to disk if they are empty.
Returns
Reference to the model file (scope).
See LibCreateSourceFile in codetemplatelib.tlc.
LibGetFileRecordName (file)
Returns model file name (including the path) without the file extension. To retrieve the
file name (including the path) with the file extension, use
LibGetSourceFileSection.
Arguments
file — Source file reference
See LibGetFileRecordName in codetemplatelib.tlc.
LibGetMdlPrvHdrBaseName()
Returns the base name of the model's private header file, for example,
.model_private.h
See LibGetMdlPrvHdrBaseName in codetemplatelib.tlc.
LibGetMdlPubHdrBaseName()
Returns the base name of the model's public header file, for example,
.model.h
See LibGetMdlPubHdrBaseName in codetemplatelib.tlc.
LibGetMdlSrcBaseName()
Returns the base name of the model's main source file, for example,
.model.c
See LibGetMdlSrcBaseName in codetemplatelib.tlc.
LibGetMdlDataSrcBaseName()
Returns the base name of the model's data file, for example,
.model_data.c
See LibGetMdlDataSrcBaseName in codetemplatelib.tlc.
LibGetMdlTypesHdrBaseName()
Returns the base name of the model types file, for example,
.model_types.h
See LibGetMdlTypesHdrBaseName in codetemplatelib.tlc.
LibGetMdlCapiHdrBaseName()
Returns the base name of the model capi header file, for example,
.model_capi.h
See LibGetMdlCapiHdrBaseName in codetemplatelib.tlc.
LibGetMdlCapiSrcBaseName()
Returns the base name of the model capi source file, for example,
.model_capi.c
See LibGetMdlCapiSrcBaseName in codetemplatelib.tlc.
LibGetMdlCapiHostHdrBaseName()
Returns the base name of the model capi host header file, for example,
.model_host_capi.h
See LibGetMdlCapiHostHdrBaseName in codetemplatelib.tlc.
LibGetMdlTestIfHdrBaseName()
Returns the base name of the model testinterface header file, for example,
.model_testinterface.h
See LibGetMdlTestIfHdrBaseName in codetemplatelib.tlc.
LibGetMdlTestIfSrcBaseName()
Returns the base name of the model testinterface source file, for example,
.model_testinterface.c
See LibGetMdlTestIfSrcBaseName in codetemplatelib.tlc.
LibGetDataTypeTransHdrBaseName()
Returns the base name of the data type transition file, for example,
for code generation's Real-Time
and Embedded-C code formats.model_dt.h
See LibGetDataTypeTransHdrBaseName in codetemplatelib.tlc.
LibGetModelDotCFile()
Returns a reference to the or
model.c.cpp source file. You can then cache additional code using
LibSetSourceFileSection.
Syntax
%assign srcFile = LibGetModelDotCFile() %<LibSetSourceFileSection(srcFile, "Functions", mybuf)>
Returns
Returns a reference to the or
model.c.cpp source file.
See LibGetModelDotCFile in codetemplatelib.tlc.
LibGetModelDotHFile()
Returns a reference to the source
file. You can then cache additional code using
model.hLibSetSourceFileSection.
Syntax
%assign hdrFile = LibGetModelDotHFile() %<LibSetSourceFileSection(hdrFile, "Functions", mybuf)>
Returns
Returns a reference to the
source file.model.h
See LibGetModelDotHFile in codetemplatelib.tlc.
LibGetModelName()
Returns the name of the model (without an extension).
See LibGetModelName in codetemplatelib.tlc.
LibGetNumSourceFiles()
Returns the number of source files (.c or .cpp and
.h) that have been created.
Syntax
%assign numFiles = LibGetNumSourceFiles()
Returns
Returns the number of files (number).
See LibGetNumSourceFiles in codetemplatelib.tlc.
LibGetRTModelErrorStatus()
Returns the code required to get the model error status.
Syntax
%<LibGetRTModelErrorStatus()>;
See LibGetRTModelErrorStatus in codetemplatelib.tlc.
LibGetSourceFileAttribute(fileIdx, attrib)
Returns the specified attribute of a file. The table lists the valid attributes.
| Attribute | |||
|---|---|---|---|
| Name (with file extension) | SystemsInFile | IsEmpty | SharedType |
| BaseName | RequiredIncludes | Indent | CodeTemplate |
| Type | UtilityIncludes | WrittenToDisk | OutputDirectory |
| Creator | Filter | Shared | Group |
Arguments
fileIdx (scope or number) — File index
attrib (string) — Name of model attribute
See LibGetSourceFileAttribute in codetemplatelib.tlc.
LibGetSourceFileFromIdx(fileIdx)
Returns a model file reference based on its index. This reference can be useful for a common operation on all files, for example, to set the leading file banner of all files.
Syntax
%assign fileH = LibGetSourceFileFromIdx(fileIdx)
Argument
fileIdx (number) — Index of model file
Returns
Reference (scope) to the model file.
See LibGetSourceFileFromIdx in .codetemplatelib.tlc
LibGetSourceFileSection(fileIdx, section)
Returns the contents of a file. See LibSetSourceFileSection(fileH, section, value) for a list of valid sections.
Arguments
fileIdx (scope or number) — File index
section (string) — File section of interest
See LibGetSourceFileSection in codetemplatelib.tlc.
LibGetSourceFileTag(fileIdx)
Returns and
fileName_h for header and source files,
respectively, where fileName_c is the name of
the model file.fileName
Syntax
%assign tag = LibGetSourceFileTag(fileIdx)
Argument
fileIndex (number) — File index
Returns
Returns the tag (string).
See LibGetSourceFileTag in .codetemplatelib.tlc
LibMdlRegCustomCode(buffer, location)
Places declaration statements and executable code inside the
function.model_initialize
Arguments
buffer — String buffer containing text to append to the internal
cache buffer.
location — String specifying where to place the buffer's
contents. Possible values are
"header"— Place buffer at top of function"declaration"— Place buffer at top of function"execution"— Place buffer at top of function, but after header"trailer"— Place buffer at bottom of function
Returns
Nothing
See LibMdlRegCustomCode in hookslib.tlc.
LibMdlStartCustomCode(buffer, location)
Places declaration statements and executable code inside the start function. Start code is executed once, during the model initialization phase.
Syntax
LibMdlStartCustomCode(buffer, location)
Arguments
buffer — String buffer containing text to append to the
internal cache buffer.
location — String specifying where to place the buffer's
contents. Possible values are
"header"— Place buffer at top of function"declaration"— Place buffer at top of function"execution"— Place buffer at top of function, but after header"trailer"— Place buffer at bottom of function
Returns
Nothing
Description
LibMdlStartCustomCode places declaration statements and executable
code inside the start function. This code is output into the following functions,
depending on the current value for the CodeFormat TLC variable:
| Function Name | Value of CodeFormat TLC variable |
|---|---|
|
|
|
|
|
|
|
|
Each call to LibMdlStartCustomCode appends your buffer to the
internal cache buffer.
See LibMdlStartCustomCode in hookslib.tlc.
LibMdlTerminateCustomCode(buffer, location)
Purpose
Places declaration statements and executable code inside the terminate function.
Syntax
LibMdlTerminateCustomCode(buffer, location)
Arguments
buffer — String buffer containing text to append to the
internal cache buffer.
location — String specifying where to place the buffer's
contents. Possible values are
"header"— Place buffer at top of function"declaration"— Place buffer at top of function"execution"— Place buffer at top of function, but after header"trailer"— Place buffer at bottom of function
Returns
Nothing
Description
LibMdlTerminateCustomCode places declaration statements and
executable code inside the terminate function. This code is output into the following
functions, depending on the current value of the CodeFormat TLC
variable:
| Function Name | Value of CodeFormat TLC variable |
|---|---|
|
|
|
|
|
|
Each call to LibMdlTerminateCustomCode appends your buffer to the
internal cache buffer.
Note
Do not use the LibMdlTerminateCustomCode outside of the
"case 'content' " section of the TLC code of a
custom storage class.
See LibMdlTerminateCustomCode in hookslib.tlc.
LibNotifySymbolExportedFromFile
Notifies the code generation infrastructure that the symbol is being exported from the file.
This function is recommended for custom user symbols such as variable, type, macro, and function declarations. The function signals the code generation infrastructure to include appropriate headers when the passed symbol is used in auto generated files.
Arguments
symbol — Macro, variable, type, or function name, specified
as a string.
fileNameWithExtension — File name with language extension,
specified as a string. For example, <modelName>.h.
Example
%openfile myFcnDecl
extern real_T myCustomFcn(void);
%closefile myFcnDecl
%<LibCacheFunctionPrototype(myFcnDecl)>
%assign modelPrivateFile = "%<LibGetMdlPrvHdrBaseName()>.h
%<LibNotifySymbolExportedFromFile("myCustomFcn",modelPrivateFile)>
LibNotifySymbolUsedByFile
Notifies the code generation infrastructure that the symbol is being used by the file.
This function is recommended for custom user symbols such as variable, type, macro, and function declarations. The function signals the code generation infrastructure to include headers for the symbol passed to the function.
Arguments
symbol — Macro, variable, type, or function name, specified
as a string.
fileNameWithExtension — File name with language extension,
specified as a string. For example, <modelName>.h.
Example
%% The following line is expanded and placed in <model>.c
%<y> = myCustomFcn();
%assign modelSrcFile = LibGetModelDotCFile()
%<LibNotifySymbolUsedByFile("myCustomFcn",modelSrcFile)>LibSetRTModelErrorStatus(str)
Returns the code required to set the model error status.
Syntax
LibSetRTModelErrorStatus("\"Overrun\"")Argument
str (string) — char * to a C string
See LibSetRTModelErrorStatus in .codetemplatelib.tlc
LibSetSourceFileCodeTemplate(opFile, name)
By default, *.c and *.h files are generated with
the code templates specified in the Code Generation > Templates pane
of the Configuration Parameters dialog box. LibSetSourceFileCodeTemplate
allows you to change the template for a file.
Note
Custom templates are a feature of the Embedded Coder product.
Syntax
%assign tag = LibSetSourceFileCodeTemplate(opFile,name)
Arguments
opFile (scope) — Reference to file
name (string) — Name of the desired template
Returns
Nothing
See LibSetSourceFileCodeTemplate in .codetemplatelib.tlc
LibSetSourceFileCustomSection(file, attrib, value)
Adds to the contents of a custom section previously created with
LibAddSourceFileCustomSection. Available only with Embedded Coder software.
Arguments
file (scope or number) — Source file reference or
index
attrib (string) — Name of custom section
value (string) — Value to be appended to section
See LibSetSourceFileCustomSection in codetemplatelib.tlc.
LibSetSourceFileOutputDirectory(opFile, name)
By default, *.c and *.h files are generated into a
build folder at the current location. LibSetSourceFileOutputDirectory
allows you to change the folder into which a specified source file is to be generated. Note
that the caller is responsible for specifying a valid folder.
Syntax
%assign tag = LibSetSourceFileOutputDirectory(opFile,dirName)
Arguments
opFile (scope) — Reference to file
dirName (string) — Name of the desired output folder
Returns
Nothing
See LibSetSourceFileOutputDirectory in codetemplatelib.tlc.
LibSetSourceFileSection(fileH, section, value)
Adds to the contents of a specified section within a specified file. Valid file sections include
File Section | Description |
|---|---|
| Set the file banner (comment) at the top of the file. |
| Append to the |
| Append to the |
| Append to the intrinsic |
| Append to the primitive |
| Append to the User Top section. |
| Append to the |
| Append to the enumerated types section. |
| Append to the data definition section. |
| (Reserved) Code generator |
| (Reserved) Code generator |
| (Reserved) Code generator function prototypes. |
| Append to the data declaration section. |
| Append to the C functions section. |
| Append to the |
| Append to the |
| Append to the documentation (comment) section. |
| Append to the User Bottom section. |
The code generator orders the code as listed above.
Syntax
Example (iterating over the files):
%openfile tmpBuf
whatever
%closefile tmpBuf
%foreach fileIdx = LibGetNumSourceFiles()
%assign fileH = LibGetSourceFileFromIdx(fileIdx)
%<LibSetSourceFileSection(fileH,"SectionOfInterest",tmpBuf)>
%endforeach
%assign fileH = LibCreateSourceFile("Header","Custom","foofile")
%<LibSetSourceFileSection(fileH,"Defines","#define FOO 5.0\n")>Arguments
fileH (scope or number) — Reference or index to a file
section (string) — File section of interest
value (string) — Value
See LibSetSourceFileSection in codetemplatelib.tlc.
LibSystemDerivativeCustomCode
(system, buffer, location)
Purpose
Places declaration statements and executable code inside a subsystem's derivative function.
Syntax
LibSystemDerivativeCustomCode(system, buffer, location)
Arguments
system — Reference to the subsystem whose derivative
function is to be modified.
buffer — String buffer containing text to append to the
internal cache buffer.
location — String specifying where to place the buffer's
contents. Possible values are
"header"— Place buffer at top of function"declaration"— Place buffer at top of function"execution"— Place buffer at top of function, but after header"trailer"— Place buffer at bottom of function
Returns
Nothing
Description
LibSystemDerivativeCustomCode places declaration statements and
executable code inside the derivative function for the subsystem specified by
system. This code is output into the following functions, depending
on the current value of the CodeFormat TLC variable:
| Function Name | Value of CodeFormat TLC variable |
|---|---|
|
|
|
|
LibSystemDerivativeCustomCode is not relevant when the value of the
CodeFormat TLC variable is Embedded-C, because
blocks with continuous states cannot be used.
Each call to LibSystemDerivativeCustomCode appends your buffer to
the internal cache buffer. An error is generated if you attempt to add code to a subsystem
that does not have continuous states.
See LibSystemDerivativeCustomCode in hookslib.tlc.
Note
To avoid a potential mismatch between simulation and code generation results, do not
use LibSystemDerivativeCustomCode to read from and write to global
Simulink data (signals, states, and block parameters). Instead, use the proper modeling
pattern (for example, Data Store Read, Data Store Write, State Reader, and State Writer blocks.)
LibSystemDisableCustomCode
(system, buffer, location)
Purpose
Places declaration statements and executable code inside a subsystem's disable function.
Syntax
LibSystemDisableCustomCode(system, buffer, location)
Arguments
system — Reference to the subsystem whose disable function
is to be modified.
buffer — String buffer containing text to append to the
internal cache buffer.
location — String specifying where to place the buffer's
contents. Possible values are
"header"— Place buffer at top of function"declaration"— Place buffer at top of function"execution"— Place buffer at top of function, but after header"trailer"— Place buffer at bottom of function
Returns
Nothing
Description
LibSystemDisableCustomCode places declaration statements and
executable code inside the disable function for the subsystem specified by
system. Each call to LibSystemDisableCustomCode
appends your buffer to the internal cache buffer.
An error is generated if you attempt to add code to a subsystem that does not have a disable function.
See LibSystemDisableCustomCode in hookslib.tlc.
Note
To avoid a potential mismatch between simulation and code generation results, do not
use LibSystemDisableCustomCode to read from and write to global
Simulink data (signals, states, and block parameters). Instead, use the proper modeling
pattern (for example, Data Store Read, Data Store Write, State Reader, and State Writer blocks.)
LibSystemEnableCustomCode
(system, buffer, location)
Purpose
Places declaration statements and executable code inside a subsystem's enable function.
Syntax
LibSystemEnableCustomCode(system, buffer, location)
Arguments
system — Reference to the subsystem whose enable function is
to be modified.
buffer — String buffer containing text to append to the
internal cache buffer.
location — String specifying where to place the buffer's
contents. Possible values are
"header"— Place buffer at top of function"declaration"— Place buffer at top of function"execution"— Place buffer at top of function, but after header"trailer"— Place buffer at bottom of function
Returns
Nothing
Description
LibSystemEnableCustomCode places declaration statements and
executable code inside the enable function for the subsystem specified by
system. Each call to LibSystemEnableCustomCode
appends your buffer to the internal cache buffer.
An error is generated if you attempt to add code to a subsystem that does not have an enable function.
See LibSystemEnableCustomCode in hookslib.tlc.
Note
To avoid a potential mismatch between simulation and code generation results, do not
use LibSystemEnableCustomCode to read from and write to global
Simulink data (signals, states, and block parameters). Instead, use the proper modeling
pattern (for example, Data Store Read, Data Store Write, State Reader, and State Writer blocks.)
LibSystemInitializeCustomCode
(system, buffer, location)
Purpose
Places declaration statements and executable code inside a subsystem's initialize function.
Syntax
LibSystemInitializeCustomCode(system, buffer, location)
Arguments
system — Reference to the subsystem whose initialize
function is to be modified.
buffer — String buffer containing text to append to the
internal cache buffer.
location — String specifying where to place the buffer's
contents. Possible values are
"header"— Place buffer at top of function"declaration"— Place buffer at top of function"execution"— Place buffer at top of function, but after header"trailer"— Place buffer at bottom of function
Returns
Nothing
Description
LibSystemInitializeCustomCode places declaration statements and
executable code inside the initialize function for the subsystem specified by
system. This code is output into the following functions, depending
on the current value of the CodeFormat TLC variable:
| Function Name | Value of CodeFormat TLC variable |
|---|---|
|
|
|
|
|
|
Code for a subsystem is output into the subsystem's initialization function. Each call
to LibSystemInitializeCustomCode appends your buffer to the internal
cache buffer.
Note
Enable systems that are not configured to reset on enable are inlined into
MdlStart. For this case, the subsystem's custom code is found in
MdlStart above and below the enable subsystem's initialization
code.
See LibSystemInitializeCustomCode in hookslib.tlc.
Note
To avoid a potential mismatch between simulation and code generation results, do not
use LibSystemInitializeCustomCode to read from and write to global
Simulink data (signals, states, and block parameters). Instead, use the proper modeling
pattern (for example, Data Store Read, Data Store Write, State Reader, and State Writer blocks.)
LibSystemOutputCustomCode
(system, buffer, location)
Purpose
Places declaration statements and executable code inside a subsystem's output function.
Syntax
LibSystemOutputCustomCode(system, buffer, location)
Arguments
system — Reference to the subsystem whose output function is
to be modified.
buffer — String buffer containing text to append to the
internal cache buffer.
location — String specifying where to place the buffer's
contents. Possible values are
"header"— Place buffer at top of function"declaration"— Place buffer at top of function"execution"— Place buffer at top of function, but after header"trailer"— Place buffer at bottom of function
Returns
Nothing
Description
LibSystemOutputCustomCode places declaration statements and
executable code inside the output function for the subsystem specified by
system. This code is output into the following functions, depending
on the current value of the CodeFormat TLC variable:
| Function Name | Value of CodeFormat TLC variable |
|---|---|
|
|
|
|
|
|
|
|
Each call to LibSystemOutputCustomCode appends your buffer to the
internal cache buffer.
See LibSystemOutputCustomCode in .hookslib.tlc
Note
To avoid a potential mismatch between simulation and code generation results, do not
use LibSystemOutputCustomCode to read from and write to global
Simulink data (signals, states, and block parameters). Instead, use the proper modeling
pattern (for example, Data Store Read, Data Store Write, State Reader, and State Writer blocks.)
LibSystemUpdateCustomCode
(system, buffer, location)
Purpose
Places code inside a subsystem's update function.
Syntax
LibSystemUpdateCustomCode(system, buffer, location)
Arguments
system — Reference to the subsystem whose update function is
to be modified.
buffer — String buffer containing text to append to the
internal cache buffer.
location — String specifying where to place the buffer's
contents. Possible values are
"header"— Place buffer at top of function"declaration"— Place buffer at top of function"execution"— Place buffer at top of function, but after header"trailer"— Place buffer at bottom of function
Returns
Nothing
Description
LibSystemUpdateCustomCode places declaration statements and
executable code inside the update function for the subsystem specified by
system. This code is output into the following functions, depending
on the current value of the CodeFormat TLC variable:
| Function Name | Value of CodeFormat TLC variable |
|---|---|
|
|
| Embedded-C ( |
|
|
| RealTime |
Each call to LibSystemUpdateCustomCode appends your buffer to the
internal cache buffer.
See LibSystemUpdateCustomCode in hookslib.tlc.
Note
To avoid a potential mismatch between simulation and code generation results, do not
use LibSystemUpdateCustomCode to read from and write to global
Simulink data (signals, states, and block parameters). Instead, use the proper modeling
pattern (for example, Data Store Read, Data Store Write, State Reader, and State Writer blocks.)
LibWriteModelData()
Returns data for the model (valid for ERT only).
See LibWriteModelData in codetemplatelib.tlc.
LibWriteModelInput(tid, rollThreshold)
Returns the code for writing to a specified root input (that is, a model inport block). This function is valid for ERT only, and not valid for referenced models.
Arguments
tid (number) — Task identifier (0 is
fastest rate and n is the slowest)
rollThreshold — Width of signal before wrapping in a
for loop.
See LibWriteModelInput in codetemplatelib.tlc.
LibWriteModelInputs()
Returns code that writes to all root inputs (that is, the model inport blocks). This function is valid for ERT only, and is not valid for referenced models.
See LibWriteModelInputs in codetemplatelib.tlc.
LibWriteModelOutput(tid, rollThreshold)
Returns code that writes to a specified root output (that is, a model outport block). This function is valid for ERT only, and not valid for referenced models.
Arguments
tid (number) — Task identifier (0 is
fastest rate and n is the slowest)
rollThreshold — Width of signal before wrapping in a
for loop.
See LibWriteModelOutput in codetemplatelib.tlc.
LibWriteModelOutputs()
Returns code that writes to all root outputs (that is, the model outport blocks). This function is valid for ERT only, and not valid for referenced models.
See LibWriteModelOutputs in codetemplatelib.tlc.