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

 

Chapter

CIN Overview

1

This chapter introduces the LabVIEW Code Interface Node (CIN), a

node that links external code written in a conventional programming

language to LabVIEW.

 

Introduction

A CIN is a block diagram node associated with a section of source code written in a conventional programming language. You compile the source code first and link it to form executable code. LabVIEW calls the executable code when the node executes, passing input data from the block diagram to the executable code, and returning data from the executable code to the block diagram.

The LabVIEW compiler can usually generate code that is fast enough for most of your programming tasks. However, you can use CINs for tasks that a conventional language can accomplish more easily, such as tasks that are time-critical or require a great deal of data manipulation. CINs are also useful for tasks that you cannot perform directly from the diagram, such as calling system routines for which no corresponding LabVIEW functions exist. CINs can also link existing code to LabVIEW, although you may have to modify the code so that it uses the correct LabVIEW data types.

CINs execute synchronously. This means that while CIN code executes, no other LabVIEW processes can execute. Normally, when a VI executes, LabVIEW monitors menus and the keyboard and allows other applications to execute. LabVIEW also allows more than one VI to run simultaneously. However, when CIN object code executes, it takes control of the process, so that LabVIEW ignores keyboard events, menu clicks, and other diagrams. On the Macintosh and under Windows 3.1, CINs even prevent other applications from executing. Although you can create VIs that use CINs and behave in a more asynchronous fashion, be aware of this potential problem if you intend to write a CIN that will execute a long task and you need LabVIEW to multitask in the interim.

© National Instruments Corporation

1-1

LabVIEW Code Interface Reference Manual

Chapter 1 CIN Overview

A CIN appears on the diagram as an icon with input and output terminals. You associate this node with a piece of code you want LabVIEW to call. When it is time for the node to execute, LabVIEW calls the code associated with the CIN, passing it the specified data.

In some cases, you may want a CIN to perform additional actions at certain execution times. For instance, you may want to initialize some data structures at load time or free private data structures when the user closes the VI containing the CIN. For these situations, you can write routines that LabVIEW calls at predefined times or when the node executes. Specifically, LabVIEW calls certain routines when the VI containing the CIN is loaded, saved, closed, aborted, or compiled. You generally use these routines in CINs that perform an on-going action, such as accumulating results from call to call, so that you can allocate, initialize, and deallocate resources at the correct time. Most CINs perform a specific action at run time only.

After you have written your first CIN as described in this manual, writing new CINs is relatively easy. The work involved in writing new CINs is mostly in coding the algorithm, because the interface to LabVIEW remains the same, no matter what the development system.

Classes of External Code

LabVIEW supports code resources for CINs and external subroutines.

An external subroutine is a section of code that you can call from other external code. If you write multiple CINs that call the same subroutine, you may want to make the shared subroutine an external subroutine.

The code for an external subroutine is a separate file; when LabVIEW loads a section of external code that references an external subroutine, it also loads the appropriate external subroutine into memory. Using an external subroutine makes each section of calling code smaller, because the external subroutine does not require embedded code. Further, you need to make changes only once if you want to modify the subroutine.

Note: LabVIEW does not support code resources for external subroutines on the Power Macintosh. If you are working with a Power Macintosh, you should use shared libraries instead of external subroutines. For information on building shared libraries, consult your development environment documentation.

LabVIEW Code Interface Reference Manual

1-2

© National Instruments Corporation

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