Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
LabVIEW-Measurements.pdf
Скачиваний:
61
Добавлен:
29.05.2015
Размер:
3.37 Mб
Скачать

Chapter 20 VISA in LabVIEW

Figure 20-5. VISA Open Function

Closing a VISA Session

An open session to a VISA resource uses system resources within the computer. To properly end a VISA program, all of the opened

VISA sessions should be closed. To do this, use the VISA Close VI, shown in Figure 20-6.

Figure 20-6. VISA Close VI

The VISA session input to the VISA Close VI is the session to be closed. This session originally comes from the output session terminal of the VISA Open VI or any other VISA VI. If a session is not closed when a VI is run, it remains open.

Note If a VI is aborted when you are debugging a VI, the VISA session is not closed automatically. You can use the Open VISA Session Monitor VI, available in vi.lib\Utility, to assist in closing such sessions.

Locking

VISA introduces locks for access control of resources. With VISA, applications can simultaneously open multiple sessions to the same resource and can access the resource through these different sessions concurrently. In some cases, applications accessing a resource must restrict other sessions from accessing that resource. For example, an application may need to execute a write and a read operation as a single step so that no other operations take place between the write and read operations. The application can lock the resource before invoking the write operation and unlock it after the read operation, to execute them as a single step.

© National Instruments Corporation

20-7

LabVIEW Measurements Manual

Chapter 20 VISA in LabVIEW

The VISA locking mechanism enforces arbitration of accesses to resources on an individual basis. If a session locks a resource, operations invoked by other sessions are serviced or returned with a locking error, depending on the operation and the type of lock used.

Figure 20-7. VISA Lock Async VI

The VISA Lock Async VI, shown in Figure 20-7 and available on the

Functions»Instrument I/O»VISA»VISA Advanced palette, opens two sessions to the same resource and performs a query on each of them. This example uses a lock to guarantee that the write/read pairs happen in the expected order and are not interleaved. The lock is released after the write/read sequence is complete, thus allowing the other session's execution path to continue. There is no guarantee as to which session will receive the lock first. Locking is useful in cases where more than one application may be accessing the same resource, or where multiple modules may open multiple sessions to the same resource even within a single application.

LabVIEW Measurements Manual

20-8

www.ni.com

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