NI VISA, pyVISA, python
在windows PC上安装:
1. 最新 NI-VISA程序包http://www.ni.com/visa/。RF设备使用VISA协议。
2. python 2x (3x以上不好用)
3. PyVisa package. http://pyvisa.sourceforge.net/
测试。
例子, (和帖子TERA TERM中, 子script相同功能):
#!C:\Python27\python.exe
import sys, os, visa, threading, time
PM = visa.instrument("TCPIP0::192.168.1.70::inst0::INSTR")
def check_read():
#currentdir = os.curdir
#fullname = os.path.join(currentdir, "read_pm.txt")
#fullname = os.path.join(".", "read_pm.txt")
if os.path.isfile("read_pm.txt"):
read_pm()
os.remove("read_pm.txt")
return
def read_pm():
PM.write("FETCh:CW:POWer?")
# Write file
fpm_read = open("pm_read_ok.txt","w")
fpm_read.write(PM.read())
fpm_read.close()
return
def main():
# Display ID
print PM.ask("*IDN?")
# Init PM
PM.write("*CLS")
# Main loop
while 1:
time.sleep(1)
check_read()
if __name__ == '__main__':
main()