User`s guide

Rapid Prototyping Program Framework
6-27
modules that implement the functions carried out by the system dependent,
system independent, and application components.
Rapid Prototyping System Dependent Components
These components contain the program’s main function, which controls
program timing, creates tasks, installs interrupt handlers, enables data
logging, and performs error checking.
The way in which application modules implement these operations depends on
the type of computer. This means that, for example, the components used for a
DOS-based program perform the same operations, but differ in method of
implementation from components designed to run under Tornado on a VME
target.
The main Function
The main function in a C program is the point where execution begins. In
Real-Time Workshop application programs, the
main function must perform
certain operations. These operations can be grouped into three categories
initialization, model execution, and program termination.
Initialization
Initialize special numeric parameters: rtInf, rtMinusInf,andrtNaN.These
are variables that the model code can use.
Call the model registration function to get a pointer to the
SimStruct.The
model registration function has the same name as your model. It is
responsible for initializing
SimStruct fields and any S-functions in your
model.
Initialize the model size information in the
SimStruct. This is done by calling
MdlInitializeSizes.
Initialize a vector of sample times and offsets (for systems with multiple
sample rates). This is done by calling
MdlInitializeSampleTimes.
Get the model ready for execution by calling
MdlStart, which initializes
states and similar items.
Set up the timer to control execution of the model.
Define background tasks and enable data logging, if selected.