Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Labview Code Interface Reference Manual.pdf
Скачиваний:
35
Добавлен:
29.05.2015
Размер:
1.13 Mб
Скачать

Chapter 1 CIN Overview

the same directory, you need either manually, or to create two separate the lvmkmf script) and use make CIN or external subroutine.

to combine the two makefiles makefiles (using the -o option to

-f <makefile> to create the

6. Load the CIN Object Code

Load the code resource by choosing Load Code Resource from the CIN pop-up menu. Select the .lsb file you created in step 5, Compile the CIN Source Code.

This command loads your object code into memory and links the code to the current front panel/block diagram. After you save the VI, the file containing the object code does not need to be resident on the computer running LabVIEW for the VI to execute.

If you make modifications to the source code, you can load the new version of the object code using the Load Code Resource option. The file containing the object code for the CIN must have an extension of

.lsb.

There is no limit to the number of CINs per block diagram.

LabVIEW Manager Routines

LabVIEW has a suite of routines that can be called from CINs and external subroutines. This suite of routines performs user-specified

LabVIEW Code Interface Reference Manual

1-36

© National Instruments Corporation

Chapter 1 CIN Overview

routines using the appropriate instructions for a given platform. These routines, which manage the functions of a specific operating system, are grouped into three categories, the memory manager, the file manager, and the support manager.

External code written using the managers is portable–you can compile it without modification on any platform that supports LabVIEW. This portability has two advantages. First, the LabVIEW application is built on top of the managers; except for the managers, the source code for LabVIEW is identical across platforms. Second, the analysis VIs are built mainly from CINs; the source code for these CINs is the same for all platforms.

For general information about the memory manager, the file manager, and the support manager, see Chapter 5, Manager Overview.

Online Reference

For desciptions of the functions, or of the file manager data structures, select Online Reference from LabVIEW’s Help menu. Click on the topic, Function and VI Reference, and then the relevant subtopic. Or see the Code Interface Node Reference online manual.

Pointers as Parameters

Some manager functions have a parameter that is a pointer. These parameter type descriptions are identified by a trailing asterisk (such as the hp parameter of the AZHandToHand memory manager function documented in the Online Reference) or are type defined as such (such as the name parameter of the FNamePtr function documented in the Online Reference). In most cases, this means the manager function will write a value to pre-allocated memory. In some cases, such as FStrFitsPath or GetALong, the function reads a value from the memory location, so you don’t have to pre-allocate memory for a return value.

© National Instruments Corporation

1-37

LabVIEW Code Interface Reference Manual

Chapter 1 CIN Overview

Table 1-1 lists the functions with parameters that return a value for which you must pre-allocate memory.

Table 1-1. Functions with Parameters Needing Pre-allocated Memory

AZHandToHand

FGetInfo

FPathToDString

 

 

 

AZMemStats

FGetPathType

FPathToPath

 

 

 

AZPtrToHand

FGetVolInfo

FRefNumToFD

 

 

 

DateToSecs

FMOpen

FStringToPath

 

 

 

DSHandToHand

FMRead

FTextToPath

 

 

 

DSMemStats

FMTell

FUnflattenPath

 

 

 

DSPtrToHand

FMWrite

GetAlong

 

 

 

FCreate

FNamePtr

NumericArrayResize

 

 

 

FCreateAlways

FNewRefNum

RandomGen

 

 

 

FFlattenPath

FPathToArr

SecsToDate

 

 

 

FGetAccessRights

FPathToAZString

SetALong

 

 

 

FGetEOF

 

 

 

 

 

It is important to actually allocate space for this return value. The following examples illustrate correct and incorrect ways to call one of these functions from within a generic function foo:

Correct example:

foo(Path path) {

Str255 buf; /* allocated buffer of 256 chars */

File fd;

MgErr err;

err = FNamePtr(path, buf);

err = FMOpen(&fd, path, openReadOnly, denyWriteOnly);

}

LabVIEW Code Interface Reference Manual

1-38

© National Instruments Corporation

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