Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Using External Code in LabVIEW.pdf
Скачиваний:
48
Добавлен:
29.05.2015
Размер:
1.85 Mб
Скачать

Chapter 4 Programming Issues for CINs

Note Always use #include "extcode.h" at the beginning of your source code. If your code needs to make system calls, also use #include "hosttype.h" immediately after #include "extcode.h", and then include your system header files. hosttype.h includes only a subset of the .h files for a given operating system. If the .h file you need is not included by hosttype.h, you can include it in the .c file for your CIN after you include hosttype.h.

If you write a CIN that accepts a single 32-bit signed integer, the .c file indicates the CINRun routine is passed an int32 by reference. extcode.h typedefs an int32 to the appropriate data type for the compiler you use (if it is a supported compiler). Therefore, you can use the int32 data type in external code you write.

Passing Fixed-Size Data to CINs

As described in the Creating a CIN section in Chapter 3, CINs, you can designate terminals on the CIN as either input-output or output-only. Regardless of the designation, LabVIEW passes data by reference to the CIN. When modifying a parameter value, follow the rules for each kind of terminal in the Creating a CIN section. LabVIEW passes parameters to the CINRun routines in the same order as you wire data to the CIN—the first terminal pair corresponds to the first parameter, and the last terminal pair corresponds to the last parameter.

Refer to the following sections for information about how LabVIEW passes fixed-size parameters to CINs. Refer to the Passing Variably Sized Data to CINs section in this chapter for information about manipulating variably sized data, such as arrays and strings.

Scalar Numerics

LabVIEW passes numeric data types to CINs by passing a pointer to the data as an argument. In C, this means LabVIEW passes a pointer to the numeric data as an argument to the CIN. Arrays of numerics are described in the subsequent Arrays and Strings section in this chapter.

Scalar Booleans

LabVIEW stores Boolean data types in memory as 8-bit integers. If any bit of the integer is 1, the Boolean data type is TRUE; otherwise, it is FALSE. LabVIEW passes Boolean data types to CINs with the same conventions it uses for numerics.

Using External Code in LabVIEW

4-2

www.ni.com

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]