Chapter 4 NI-DNET Programming Techniques
© National Instruments Corporation 4-15 NI-DNET User Manual
For the C programming language, you can declare a structure typedef to
store the parameters of ncOpenDnetIO, similar to the following:
typedef struct {
NCTYPE_UINT32DeviceMacId;
NCTYPE_CONN_TYPEConnectionType;
NCTYPE_UINT32InputLength;
NCTYPE_UINT32OutputLength;
NCTYPE_UINT32ExpPacketRate;
} OpenDnetIO_Struct;
For LabVIEW, a cluster that contains these parameters is already defined
for use with ncOpenDnetIO.
You can use this structure/cluster to declare an array that contains one entry
for each call you make to ncOpenDnetIO. In LabVIEW and
LabWindows/CVI, you can use front panel controls to index through this
array and update configurations as needed.
In your code, write a For loop to index through the array and call
ncOpenDnetIO once for each array entry. This simplifies your code
because it does not contain a long list of sequential open calls, but instead
all open calls are combined into a concise loop.
Object Handles
If you use an array to store configuration parameters for
ncOpenDnetIO
,
you can use this same scheme to store the
ObjHandle
returned by
ncOpenDnetIO
. Within the For loop used for
ncOpenDnetIO
, you can store
the resulting
ObjHandle
into an array of object handles. Throughout your
code, you can index into this array to obtain the appropriate object handle.
Using an array of object handles is particularly useful in the LabVIEW
programming environment because it eliminates confusing routing of
individual object handle wires.
For applications with only a few object handles, another useful technique
for LabVIEW is to store each object handle in an indicator, then create a
local variable for each call that uses the handle. To create the indicator,
right-click on the ObjHandle out terminal and select Create Indicator.
To create a local variable, right-click on the indicator, select Create»Local
Variable, right-click on the local variable, and select Change To Read
Local. For more information on local variables, refer to the LabVIEW
online reference.