Target Language Compiler | ![]() ![]() |
Structure of Record Files
Real-Time Workshop compiles models into a structured form called a record file, referred to as model
.rtw
. Such compiled model files are similar in syntax and organization to source model (model.mdl
) files, in that they contain a series of (usually hierarchically nested) records of the form
Item names are alphabetic. Item values can be strings or numbers. Numeric values can be scalars, vectors, or matrices. Curly braces set off the contents of each record, which may contain one or more items, delimited by space, tab, and/or return characters.
In a model
.rtw
file, the top-level (first) record's name is CompiledModel
. Each block is represented by a subrecord within it, identified by the block's name. The TLC, however, can parse any well-formed record file, as this exercise demonstrates.
The following listing is a valid record file that the TLC can parse, although not one for which it can generate code. Comments are indicated by a pound sign (#):
# $Revision: 1.9 $ # File: guide.rtw -- Illustrative record file, which can't be used by Simulink # Note: string values MUST be in quotes Top { # Outermost Record, called Top Date "21-Aug-2008" # Name/Value pair named Top.Date Employee { # Nested record within the Top record FirstName "Arthur" # Alpha field Top.Employee.FirstName LastName "Dent" # Alpha field Top.Employee.LastName Overhead 1.78 # Numeric field Overhead PayRate 11.50 # Numeric field PayRate GrossRate 0.0 # Numeric Field GrossRate } # End of Employee record NumProject 3 # Indicates length of following list Project { # First list item, called Top.Project[0] Name "Tea" # Alpha field Name, Top.Project[0].Name Difficulty 3 # Numeric field Top.Project[0].Difficulty } # End of first list item Project { # Second list item, called Top.Project[1] Name "Gillian" # Alpha field Name, Top.Project[1].Name Difficulty 8 # Numeric field Top.Project[1].Difficulty } # End of second list item Project { # Third list item, called Top.Project[2] Name "Zaphod" # Alpha field Name, Top.Project[2].Name Difficulty 10 # Numeric field Top.Project[2].Difficulty } # End of third list item } # End of Top record and of file
As long as the programmer knows the names of records and fields, and their expected contents, he or she can compose TLC statements to read, parse, and manipulate record file data.
![]() | Reading Record Files with TLC | Interpreting Records | ![]() |