打开 VISA 到某器材/设备的连接。
#include <Visa.au3>
_viOpen($s_visa_address, $s_visa_secondary_address = 0)
参数
| $s_visa_address | VISA 资源描述符(descriptor)字符串(请查看 _viExecCommand 函数的注意部分以了解更多信息) 作为一个更快捷的方式,您还可以直接传递 GPIB 地址(整数) |
| $s_visa_secondary_address | 可选:“次要 GPIB 地址”。仅当传递的主地址是整数时才使用。 只有少数 GPIB 设备具有次要地址。如果有则可使用该地址来传递到此参数。 此参数的默认值是零,表示没有次要地址 |
返回值
成功: - 返回值为(正数)VISA 设备句柄
注意
所有的 VISA 函数都要求必须安装 VISA 库(您可以通过检查 WINDOWS\system32 目录下是否存在 visa32.dll 来判断)和一个 GPIB 卡(例如 National Instruments(美国国家仪器有限公司)的 NI PCI-GPIB 卡或者是 Agilent 82350B PCI 高性能 GPIB 卡)。
相关
_viClose, _viExecCommand
示例
;- 这个脚本假定您已经把 GPIB 的地址设为 1
; 本脚本演示了如何单独使用 _viExecCommand 函数以及结合
; _viOpen 和 _viClose 函数使用的方法。
; 另外还演示了 _viGTL 函数
#include <Visa.au3>
Dim $h_session = 0
; 请求设备的 GPIB 地址3 的 ID
MsgBox(0,"Step 1","Open the instrument connection with _viOpen")
Dim $h_instr = _viOpen("GPIB::3::0")
MsgBox(0,"Instrument Handle obtained", "$h_instr = " & $h_instr) ; 显示 Session 句柄
; 请求设备响应
MsgBox(0,"Step 2","Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr,"*IDN?") ; 注意,$h_instr 现在已不再是字符串了!
MsgBox(0,"GPIB QUERY result",$s_answer) ; 显示结果
; 再次请求。这时不需要再次打开连接了
MsgBox(0,"Step 3","Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr,"*IDN?")
MsgBox(0,"GPIB QUERY result",$s_answer) ; 显示结果
MsgBox(0,"Step 4","Close the instrument connection using _viClose")
_viClose($h_instr) ; 关闭设备连接
MsgBox(0,"Step 5","Open the Instrument connection using only the address number")
Dim $h_instr = _viOpen(3)
MsgBox(0,"Instrument Handle obtained", "$h_instr = " & $h_instr) ; 显示 Session 句柄
; 请求设备响应
MsgBox(0,"Step 6","Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr,"*IDN?") ; 注意,$h_instr 现在已不再是字符串了!
MsgBox(0,"GPIB QUERY result",$s_answer) ; 显示结果
; 再次请求。这时不需要再次打开连接了
MsgBox(0,"Step 7","Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr,"*IDN?")
MsgBox(0,"GPIB QUERY result",$s_answer) ; 显示结果
MsgBox(0,"Step 8","Close the instrument connection using _viClose")
_viClose($h_instr) ; 关闭设备连接