- 介绍
- 特别声明(Special Announcement)
- 安装目录结构
- 常见问题解答 (FAQ)
- 运行脚本
- 脚本编辑器
- 使用Aut2Exe编译脚本
- AutoIt 窗口信息工具
- 窗口标题与文本(基础篇)
- 窗口标题与文本(高级篇)
- Controls
- Intended Use
- AutoIt v2 用户须知
- 指南 - HelloWorld
- 指南 - 记事本(Notepad)
- 指南 - WinZip
- Language Reference
- Language Reference - Datatypes
- Language Reference - Variables
- Language Reference - Macros
- Language Reference - Operators
- Language Reference - Conditional Statements
- Language Reference - Loops Statements
- Language Reference - User Functions
- Language Reference - Comments
- GUI Reference
- GUI Reference - MessageLoop Mode
- GUI 相关 - OnEvent 模式
- Keywords
- Keyword #comments-start
- Keyword #include
- Keyword #include-once
- Keyword #NoTrayIcon
- Keyword Dim / Global / Local / Const
- Keyword ContinueLoop
- Keyword Do...Until
- Keyword Exit
- Keyword ExitLoop
- Keyword For...Next
- Keyword Func...Return...EndFunc
- Keyword If...Then
- Keyword If...ElseIf...Else...EndIf
- Keyword ReDim
- Keyword Select...Case...EndSelect
- Keyword While...WEnd
- Macros
- 宏列表-AutoIt相关
- Macro Reference - Directory
- Macro Reference - System Info
- Macro Reference - Time And Date
- 函数(Functions)
- 使用函数时的注意事项
- Function ClipGet
- Function ClipPut
- Function EnvGet
- Function EnvSet
- Function EnvUpdate
- Function MemGetStats
- Function DirCopy
- Function DirCreate
- Function DirGetSize
- Function DirMove
- Function DirRemove
- Function DriveGetDrive
- Function DriveGetFileSystem
- Function DriveGetLabel
- Function DriveGetSerial
- Function DriveGetType
- Function DriveMapAdd
- Function DriveMapDel
- Function DriveMapGet
- Function DriveSetLabel
- Function DriveSpaceFree
- Function DriveSpaceTotal
- Function DriveStatus
- Function FileChangeDir
- Function FileClose
- Function FileCopy
- Function FileCreateShortcut
- Function FileDelete
- Function FileExists
- Function FileFindFirstFile
- Function FileFindNextFile
- Function FileGetAttrib
- Function FileGetLongName
- Function FileGetShortcut
- Function FileGetShortName
- Function FileGetSize
- Function FileGetTime
- Function FileGetVersion
- Function FileInstall
- Function FileMove
- Function FileOpen
- Function FileOpenDialog
- Function FileRead
- Function FileReadLine
- Function FileRecycle
- Function FileRecycleEmpty
- Function FileSaveDialog
- Function FileSelectFolder
- Function FileSetAttrib
- Function FileSetTime
- Function FileWrite
- Function FileWriteLine
- Function IniDelete
- Function IniRead
- Function IniReadSection
- Function IniReadSectionNames
- Function IniWrite
- Function AutoItSetOption
- Function PixelChecksum
- Function PixelGetColor
- Function PixelSearch
- Function SoundPlay
- Function SoundSetWaveVolume
- GUI Reference
- Function GUICreate
- Functions
- Function GUICtrlCreateAvi
- Function GUICtrlCreateButton
- Function GUICtrlCreateCheckbox
- Function GUICtrlCreateCombo
- Function GUICtrlCreateContextMenu
- Function GUICtrlCreateDate
- Function GUICtrlCreateDummy
- Function GUICtrlCreateEdit
- Function GUICtrlCreateGroup
- Function GUICtrlCreateIcon
- Function GUICtrlCreateInput
- Function GUICtrlCreateLabel
- Function GUICtrlCreateList
- Function GUICtrlCreateListView
- Function GUICtrlCreateListViewItem
- Function GUICtrlCreateMenu
- Function GUICtrlCreateMenuitem
- Function GUICtrlCreatePic
- Function GUICtrlCreateProgress
- Function GUICtrlCreateRadio
- Function GUICtrlCreateSlider
- Function GUICtrlCreateTab
- Function GUICtrlCreateTabItem
- Function GUICtrlCreateTreeView
- Function GUICtrlCreateTreeViewItem
- Function GUICtrlCreateUpdown
- Function GUICtrlDelete
- Functions
- Function GUICtrlSetBkColor
- Function GUICtrlSetColor
- Function GUICtrlSetCursor
- Function GUICtrlSetData
- Function GUICtrlSetFont
- Function GUICtrlSetImage
- Function GUICtrlSetLimit
- Function GUICtrlSetOnEvent
- Function GUICtrlSetPos
- Function GUICtrlSetResizing
- Function GUICtrlSetState
- Function GUICtrlSetStyle
- Function GUICtrlSetTip
- Functions
- Function GUISetBkColor
- Function GUISetCoord
- Function GUISetCursor
- Function GUISetFont
- Function GUISetHelp
- Function GUISetIcon
- Function GUISetOnEvent
- Function GUISetState
- Function GUIDelete
- Function GUICtrlGetState
- Function GUICtrlRead
- Function GUICtrlRecvMsg
- Function GUICtrlSendMsg
- Function GUICtrlSendToDummy
- Function GUIGetCursorInfo
- Function GUIGetMsg
- Function GUIStartGroup
- Function GUISwitch
- Function HotKeySet
- Function Send
- Function Abs
- Function ACos
- Function ASin
- Function ATan
- Function BitAND
- Function BitNOT
- Function BitOR
- Function BitShift
- Function BitXOR
- Function Cos
- Function Exp
- Function Log
- Function Mod
- Function Random
- Function Round
- Function Sin
- Function Sqrt
- Function Tan
- Function InputBox
- Function MsgBox
- Function ProgressOff
- Function ProgressOn
- Function ProgressSet
- Function SplashImageOn
- Function SplashOff
- Function SplashTextOn
- Function ToolTip
- Function TrayTip
- Function AdlibDisable
- Function AdlibEnable
- Function AutoItSetOption
- Function AutoItWinGetTitle
- Function AutoItWinSetTitle
- Function BlockInput
- Function Break
- Function Call
- Function CDTray
- Function ConsoleWrite
- Function SetError
- Function SetExtended
- Function MouseClick
- Function MouseClickDrag
- Function MouseDown
- Function MouseGetCursor
- Function MouseGetPos
- Function MouseMove
- Function MouseUp
- Function MouseWheel
- Function FtpSetProxy
- Function HttpSetProxy
- Function InetGet
- Function InetGetSize
- Function Ping
- Function DllCall
- Function DllClose
- Function DllOpen
- Function ProcessClose
- Function ProcessExists
- Function ProcessSetPriority
- Function ProcessList
- Function ProcessWait
- Function ProcessWaitClose
- Function Run
- Function RunAsSet
- Function RunWait
- Function Shutdown
- Function RegDelete
- Function RegEnumKey
- Function RegEnumVal
- Function RegRead
- Function RegWrite
- Function StringAddCR
- Function StringInStr
- Function StringIsAlNum
- Function StringIsAlpha
- Function StringIsASCII
- Function StringIsDigit
- Function StringIsFloat
- Function StringFormat
- Function StringIsInt
- Function StringIsLower
- Function StringIsSpace
- Function StringIsUpper
- Function StringIsXDigit
- Function StringLeft
- Function StringLen
- Function StringLower
- Function StringMid
- Function StringReplace
- Function StringRight
- Function StringSplit
- Function StringStripCR
- Function StringStripWS
- Function StringTrimLeft
- Function StringTrimRight
- Function StringUpper
- Function Sleep
- Function TimerInit
- Function TimerDiff
- Function Asc
- Function Chr
- Function Assign
- Function Dec
- Function Eval
- Function Hex
- Function Int
- Function IsAdmin
- Function IsArray
- Function IsDeclared
- Function IsFloat
- Function IsInt
- Function IsNumber
- Function IsString
- Function Number
- Function String
- Function UBound
- Function ControlClick
- Function ControlCommand
- Function ControlDisable
- Function ControlEnable
- Function ControlFocus
- Function ControlGetFocus
- Function ControlGetHandle
- Function ControlGetPos
- Function ControlGetText
- Function ControlHide
- Function ControlListView
- Function ControlMove
- Function ControlSend
- Function ControlSetText
- Function ControlShow
- Function StatusbarGetText
- Function WinActivate
- Function WinActive
- Function WinClose
- Function WinExists
- Function WinGetCaretPos
- Function WinGetClassList
- Function WinGetClientSize
- Function WinGetHandle
- Function WinGetPos
- Function WinGetProcess
- Function WinGetState
- Function WinGetText
- Function WinGetTitle
- Function WinKill
- Function WinList
- Function WinMenuSelectItem
- Function WinMinimizeAll
- Function WinMinimizeAllUndo
- Function WinMove
- Function WinSetOnTop
- Function WinSetState
- Function WinSetTitle
- Function WinSetTrans
- Function WinWait
- Function WinWaitActive
- Function WinWaitClose
- Function WinWaitNotActive
- User Defined Functions
- 自定义函数的注意事项(Function Notes)
- Function _ArrayAdd
- Function _ArrayBinarySearch
- Function _ArrayCreate
- Function _ArrayDelete
- Function _ArrayDisplay
- Function _ArrayInsert
- Function _ArrayMax
- Function _ArrayMaxIndex
- Function _ArrayMin
- Function _ArrayMinIndex
- Function _ArrayPop
- Function _ArrayReverse
- Function _ArraySort
- Function _ArraySwap
- Function _ArrayToClip
- Function _ArrayToString
- Function _ArrayTrim
- Function _ColorGetBlue
- Function _ColorGetGreen
- Function _ColorGetRed
- Function _DateAdd
- Function _DateDayOfWeek
- Function _DateDaysInMonth
- Function _DateDiff
- Function _DateIsLeapYear
- Function _DateIsValid
- Function _DateTimeFormat
- Function _DateToDayValue
- Function _DateToDayOfWeek
- Function _DateToDayValue
- Function _DayValueToDate
- Function _Now
- Function _NowCalc
- Function _NowCalcDate
- Function _NowDate
- Function _NowTime
- Function _TicksToTime
- Function _TimeToTicks
- Function _FileCountLines
- Function _FileCreate
- Function _FileReadToArray
- Function _FileWriteLog
- Function _TempFile
- Function _GetIP
- Function _INetExplorerCapable
- Function _INetMail
- Function _Ceil
- Function _Floor
- Function _MathCheckDiv
- Function _Max
- Function _Min
- Function _Iif
- Function _RunDos
- Function _HexToString
- Function _StringEncrypt
- Function _StringProper
- Function _StringRepeat
- Function _StringReverse
- Function _StringToHex
- Function _viOpen
- Function _viExecCommand
- Function _viFindGpib
- Function _viGpibBusReset
- Function _viGTL
- Function _viOpen
- Function _viSetAttribute
- Function _viSetTimeout
- Language Reference
- ASCII Characters
- CLSID List
- Standard Windows Fonts
- 标准 Windows 字体
- Language Codes
- Send 命令的可用按键列表
Function _viExecCommand
通过 VISA 的接口(GPIB / TCP)向某器材/设备发送命令/请求。
#include <Visa.au3>
_viExecCommand($h_session, $s_command, $i_timeout_ms = -1)
参数
$h_session | VISA 描述符(字符串)或者 VISA session 句柄(整数)。 这个参数既可以是字符串也可以是个整数(句柄): * 字符串 -> VISA 描述符就是一个字符串,用以指定要建立通讯段的资源。 例如: "GPIB::20::0"。 本函数支持所有合法的 VISA 描述符,包括 GPIB, TCP, VXI 和串口设备(ASRL)。 关于 VISA 描述符,在下面的注意部分有详细的解释。 作为更快捷的方式,您可以使用一个包含 GPIB 设备的地址数字的字符串(比如"20") 来代替完整描述符(比如"GPIB::20::0")。 * 整数 -> VISA session 句柄,由 _viOpen 函数返回。 如果您打算经常性地和某个设备或装置通信,我们推荐您使用 _viOpen 和 VISA session 句柄 来代替描述符,否则每次要和设备联系都必须打开然后关闭通讯连接。 在完成了所有操作后切记要使用 _viClose 来关闭连接。 |
$s_command | 要执行的命令/请求(例如,"*IDN?" 或 "SOURCE:POWER -20 dBM") 请求必须含有问号(?) 如果是请求则本函数将自动等待设备响应结果(或者等到操作超时为止)。 |
$i_timeout_ms | 可选:以毫秒为单位的 VISA 操作超时时间。 |
返回值
具体的返回值取决于命令是否请求以及操作是否成功。* 一般命令,非请求:
成功: - 返回值为零
失败: - 返回值为 -1,说明无法打开 VISA DLL
否则为一个非零的数值,用以表示 VISA 错误码(请查看 VISA 编程人员指引)。
* 请求:
成功: - 返回值为请求设备的回应结果
失败: - 返回值为 -1,说明无法打开 VISA DLL
返回值为 -3,说明 VISA DLL 返回了一个未预料的结果
或返回number of results
否则为一个非零的数值,用以表示 VISA 错误码(请查看 VISA 编程人员指引)。
一旦出现错误则本函数将总是把 @error 设为 1
注意
* The VISA queries only return the 1st line of the device answerThis is not a problem in most cases, as most devices will always
answer with a single line.
* The following is a description of the MOST COMMON VISA DESCRIPTORS
Note that there are some more types. For more info please
refer to a VISA programmer's guide (available at www.ni.com)
Optional segments are shown in square brackets ([]).
Required segments that must be filled in are denoted by angle
brackets ().
接口语法
------------------------------------------------------------
GPIB INSTR GPIB[board]::primary address
[::secondary address] [::INSTR]
GPIB INTFC GPIB[board]::INTFC
TCPIP SOCKET TCPIP[board]::host address::port::SOCKET
Serial INSTR ASRL[board][::INSTR]
PXI INSTR PXI[board]::device[::function][::INSTR]
VXI INSTR VXI[board]::VXI logical address[::INSTR]
GPIB-VXI INSTR GPIB-VXI[board]::VXI logical address[::INSTR]
TCPIP INSTR TCPIP[board]::host address[::LAN device name]
[::INSTR]
关键字 GPIB 用于 GPIB 设备。
关键字 TCPIP 用于 TCP/IP 通信。
关键字 ASRL 用于串口设备。
关键字 PXI 用于 PXI 设备。
关键字 VXI 用于 VXI 设备(嵌入式或 MXIbus 控制器)
关键字 GPIB-VXI 用于 VXI 设备(GPIB-VXI 控制器)
The default values for optional parameters are shown below.
Optional Segment Default Value
---------------------------------------
board 0
secondary address none
LAN device name inst0
Example Resource Strings:
--------------------------------------------------------------
GPIB::1::0::INSTR A GPIB device at primary address 1 and
secondary address 0 in GPIB interface 0.
GPIB2::INTFC Interface or raw resource for GPIB
interface 2.
TCPIP0::1.2.3.4::999::SOCKET Raw TCP/IP access to port 999
at the specified IP address.
ASRL1::INSTR A serial device attached to interface
ASRL1. VXI::MEMACC Board-level register
access to the VXI interface.
PXI::15::INSTR PXI device number 15 on bus 0.
VXI0::1::INSTR A VXI device at logical address 1 in VXI
interface VXI0.
GPIB-VXI::9::INSTR A VXI device at logical address 9 in a
GPIB-VXI controlled system.
相关
_viFindGpib, _viOpen, _viClose, _viSetTimeout, _viGTL, _viGpibBusReset示例
;- 这个脚本假定您已经把 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) ; 关闭设备连接
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论