Справочник Пользователя для National Instruments NI-DNET

Скачать
Страница из 86
Chapter 4
NI-DNET Programming Techniques
4-12
ni.com
2.
Initialize the array to all zero.
for (I = 0; I < 4; I++)
OutputAsm [I] = 0;
3.
Assume you have two boolean variables, 
RunFwd
 and 
ResetFault
of type 
NCTYPE_BOOL
. For LabWindows/CVI, these variables could 
be accessed from front panel buttons. The following code inserts these 
boolean variables into 
OutputAsm
.
if (RunFwd)
OutputAsm [0] |= 0x01;
if (FaultReset)
OutputAsm [0] |= 0x04;
4.
Assume you have an integer variable 
SpeedRef
 of type 
NCTYPE_INT16
. For LabWindows/CVI, this variable could be 
accessed from a front panel control. The following code inserts this 
integer variable into 
OutputAsm
.
*(NCTYPE_INT16 *)(&( OutputAsm[2])) = SpeedRef;
5.
Write the output assembly to the remote device.
status = ncWriteDnetIO(objh, sizeof(OutputAsm), 
OutputAsm);
For information on NI-DNET’s C language data types and their equivalent 
DeviceNet data types, refer to Chapter 1, NI-DNET Data Types, of the 
NI-DNET Programmer Reference Manual.
Using Explicit Messaging Services
The NI-DNET Explicit Messaging Object represents an explicit messaging 
connection to a remote DeviceNet device. You use 
ncOpenDnetExplMsg
 
to configure and open an NI-DNET Explicit Messaging Object.
The following sections describe how to use the Explicit Messaging Object.
Get and Set Attributes in a Remote DeviceNet Device 
The two most commonly used DeviceNet explicit messages are the Get 
Attribute Single service and the Set Attribute Single service. These services 
are used to get or set the value of an attribute contained in a remote device. 
The easiest way to execute the Get Attribute Single service on a remote 
device is to use the NI-DNET 
ncGetDnetAttribute
 function. The