National Instruments AutoCode NI MATRIX User Manual

Page 41

Advertising
background image

Chapter 2

C Language Reference

AutoCode Reference

2-24

ni.com

point to the appropriate global variables. A pointer to this object will
be passed as argument I to the procedure.

5.

Invoke the procedure using pointers to the objects created in steps 1
through 4.

6.

Toggle the state flag of the states object of the procedure—that is, if the
value is 0 toggle it to 1, if the value is 1 toggle it to 0—before calling
the procedure again.

Several of the previous steps are exercised by the other two methods for
invoking generated procedures described in the

Linking Procedures with

Real-Time Applications or Simulator

section. Details are provided in the

Invoking Procedures Using Generated UCB Wrapper Function section and
the

Invoking Procedures Using Generated Subsystem Function

section.

Use the generated UCB wrapper and subsystem code as a guide. The UCB
wrapper is generated for the purpose of re-entrancy, thus producing extra
copy in and out of parameter and states variables and control and status
arrays, while the subsystem code is not re-entrant—that is, the states and
information data structures are declared as static such that the need to copy
in and out of variables is no longer necessary.

Invoking Procedures Using Generated UCB Wrapper
Function

As described in Chapter 1, Introduction, of the AutoCode User Guide,
when generating a reusable procedure from a Procedure SuperBlock,
a hook procedure or (UCB-style) wrapper along with the algorithmic
procedure, is automatically generated. This wrapper is used by the
SystemBuild simulator to automatically link the procedure for simulation.
The arguments to the wrapper follow the same format of the SystemBuild
explicit UserCode Block. A comment providing information about the
wrapper and its arguments is generated above the wrapper function. You
can use the wrapper directly from your application to invoke the procedure,
but remember that this function is re-entrant, thus exercising copy in and
out of variables that add extra overhead to the application.

Complete the following steps to invoke the wrapper function.

1.

Create an array of four elements of type

integer

, representing the

status and control argument

iinfo

, and initialize it properly. Refer to

the SystemBuild User Guide for an explanation of

iinfo

. Only the

first four elements of this array will be used by the generated
procedure. This array will be passed as argument

iinfo

.

2.

Create an array of four elements of type

double

, representing the

timing-related information for the called procedure, and initialize it

Advertising