本文整理汇总了Python中VISA_Driver.VISA_Driver类的典型用法代码示例。如果您正苦于以下问题:Python VISA_Driver类的具体用法?Python VISA_Driver怎么用?Python VISA_Driver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VISA_Driver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: performOpen
def performOpen(self, options={}):
"""Perform the operation of opening the instrument connection"""
# calling the generic VISA open to make sure we have a connection
VISA_Driver.performOpen(self, options=options)
# fix issue with termination for read
visa.vpp43.set_attribute(self.com.vi, visa.VI_ATTR_SUPPRESS_END_EN, visa.VI_FALSE)
self.detectedOptions = self.getOptions()
示例2: performOpen
def performOpen(self, options={}):
"""Perform the operation of opening the instrument connection"""
# calling the generic VISA open to make sure we have a connection
VISA_Driver.performOpen(self, options=options)
# fix issue with termination for read
visa.vpp43.set_attribute(self.com.vi, visa.VI_ATTR_SUPPRESS_END_EN, visa.VI_FALSE)
#Detect options: (vector) magnet and swicth heater
detectedOptions = []
rate = self.askAndLog('READ:SYS:VRM:RFMX').strip().rsplit(':',1)[1][1:-1].translate(None,string.letters+"/").split()
if float(rate[0]) > 0:
detectedOptions.append("x magnet")
if float(rate[1]) > 0:
detectedOptions.append("y magnet")
if float(rate[2]) > 0:
detectedOptions.append("z magnet")
heater = self.askAndLog('READ:SYS:VRM:SWHT').strip().rsplit(':',1)[1][1:-1].split()
if heater[0] != "NOSW" or heater[1] != "NOSW" or heater[2] != "NOSW":
detectedOptions.append("switch heater")
self.instrCfg.setInstalledOptions(detectedOptions)
# Make sure that the coordinate system matches the device
coordFunc = self.instrCfg.getQuantity('CoordSys')
v = self.performGetValue(coordFunc)
coordFunc.setValue(v)
示例3: performOpen
def performOpen(self, options={}):
"""Perform the operation of opening the instrument connection"""
# init meas param dict
self.dMeasParam = {}
self.cData=None
# calling the generic VISA open to make sure we have a connection
VISA_Driver.performOpen(self, options=options)
示例4: performOpen
def performOpen(self, options={}):
"""Perform the operation of opening the instrument connection"""
# start by calling the generic VISA open to make sure we have a connection
VISA_Driver.performOpen(self, options)
# check for strange bug by reading the status bit
try:
status = self.askAndLog('*STB?', bCheckError=False)
status = int(status)
except:
# if conversion to int failed, re-read instrument buffer to clear
sBuffer = self.read()
self.log('Extra data read from Tek: %s, %s' % (str(status), sBuffer))
# get model name and number of channels
sModel = self.getModel()
self.nCh = 4 if sModel in ('5004', '5014') else 2
# turn off run mode
self.writeAndLog(':AWGC:STOP;')
# init vectors with old values
self.bWaveUpdated = False
self.nOldSeq = -1
self.lOldU16 = [[np.array([], dtype=np.uint16) \
for n1 in range(self.nCh)] for n2 in range(1)]
# clear old waveforms
self.lInUse = [False]*self.nCh
for n in range(self.nCh):
self.createWaveformOnTek(n+1, 0, bOnlyClear=True)
示例5: performOpen
def performOpen(self, options={}):
"""Perform the operation of opening the instrument connection"""
# start by calling the generic VISA open to make sure we have a connection
VISA_Driver.performOpen(self, options=options)
#Reads out the Arduino upon start
reply = self.read()
self.log('Response at startup: ' + reply)
示例6: performOpen
def performOpen(self, options={}):
"""Perform the operation of opening the instrument connection"""
# calling the generic VISA open to make sure we have a connection
VISA_Driver.performOpen(self, options=options)
degChannels = []
self.unitFactors = [0. for i in range(8)]
for i in range(1,9):
#Check if channel can be used (left and right limit tripped indicates failure or missing device)
if int(self.askAndLog(str(i)+"MS").strip()[3].encode("hex"), 16) & 0x18 == 0x18:
continue
#Check the units
unit = self.askAndLog(str(i)+"SN?").strip()[3:]
self.unitFactors[i] = 1.
if unit == "Dg.":
degChannels.append("ch"+str(i)+"deg")
elif unit == "mm":
degChannels.append("ch"+str(i)+"mm")
self.unitFactors[i] = .001;
else:
degChannels.append("ch"+str(i)+"unknown")
#Set maximum velocity
vmax = self.askAndLog(str(i)+"VU?")[3:]
self.writeAndLog(str(i)+"VA"+vmax)
self.instrCfg.setInstalledOptions(degChannels)
示例7: performOpen
def performOpen(self, options={}):
"""Perform the operation of opening the instrument connection"""
# calling the generic VISA open to make sure we have a connection
VISA_Driver.performOpen(self, options=options)
# Check if there really is an IPS120 at the other end of the wire
if not "IPS120" in self.askAndLog("V"):
raise InstrumentDriver.CommunicationError("Could not get an identification as IPS120.")
self.writeAndLog("Q4")
示例8: performOpen
def performOpen(self, options={}):
"""Perform the operation of opening the instrument connection"""
# start by calling the generic VISA open to make sure we have a connection
VISA_Driver.performOpen(self, options=options)
self.bSweep1 = self.getValue('Channel 1 Autosweep')
self.bSweep2 = self.getValue('Channel 2 Autosweep')
self.bSweep3 = self.getValue('Channel 3 Autosweep')
self.bSweep4 = self.getValue('Channel 4 Autosweep')
示例9: performGetValue
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
# check type of quantity
if quant.name in ('Ch1 - Data', 'Ch2 - Data', 'Ch3 - Data', 'Ch4 - Data'):
# traces, get channel
channel = int(quant.name[2])
# check if channel is on
if self.getValue('Ch%d - Enabled' % channel):
# get waveform descriptor data
# sDesc = self.askAndLog('C%d:WF? DESC;' % channel)
self.write('C%d:WF? DESC;' % channel, bCheckError=False)
sDesc = self.read(ignore_termination=True)
# start by finding byte count, skip 9 bytes after
indx = sDesc.find('#9')
sDesc = sDesc[indx+2+9:]
# strip out relevant info
iFirst = struct.unpack('>i', sDesc[124:128])[0]
iLast = struct.unpack('>i', sDesc[128:132])[0]
Voffs = struct.unpack('>f', sDesc[160:164])[0]
Vgain = struct.unpack('>f', sDesc[156:160])[0]
dt = struct.unpack('>f', sDesc[176:180])[0]
nPts = struct.unpack('>i', sDesc[116:120])[0]
# print (iFirst, iLast, Voffs, Vgain, dt, nPts)
#
# do a second call to get data, convert to numpy array
self.write('C%d:WF? DAT1;' % channel, bCheckError=False)
sData = self.read(ignore_termination=True)
head = 16
vData = np.fromstring(sData[(head + iFirst*2):(head + (iLast+1)*2)],
dtype='>h', count=nPts)
value = InstrumentQuantity.getTraceDict(vData*Vgain + Voffs, dt=dt)
else:
# not enabled, return empty array
value = InstrumentQuantity.getTraceDict([])
elif quant.name == 'Trig source':
# trig source, treat seperately
sAns = self.askAndLog('TRSE?').strip()
i1 = sAns.find(',SR,') + 4
i2 = sAns.find(',HT')
# convert response to a number
value = quant.getValueFromCmdString(sAns[i1:i2])
elif quant.name == 'Trig level':
# trig options, get local trig source value
sTrig = self.getCmdStringFromValue('Trig source')
sAns = self.askAndLog('%s:TRLV?' % sTrig).strip()
i1 = sAns.find('V')
value = float(sAns[:i1])
elif quant.name == 'Trig slope':
# trig options, get local trig source value
sTrig = self.getCmdStringFromValue('Trig source')
# update visa commands
quant.set_cmd = '%s:TRSL' % sTrig
# run standard VISA case with updated commands
value = VISA_Driver.performGetValue(self, quant, options)
else:
# for all other cases, call VISA driver
value = VISA_Driver.performGetValue(self, quant, options)
return value
示例10: checkIfSweeping
def checkIfSweeping(self, quant, options={}):
#Can't create quant instances from here, can only pass name of quant
#Whereas system
if type(quant) == str:
name = quant
else:
name = quant.name
if name == 'Source Voltage Level' or name == 'Source Current Level':
#If sweeping, can't go into program edit mode
#Can't see any other way of checking if program is running
VISA_Driver.writeAndLog(self,'*CLS') #Clear any existing errors
VISA_Driver.writeAndLog(self,'PROG:EDIT:STAR') #force an error if program running
err = VISA_Driver.askAndLog(self,'SYST:ERR?') #Check if there's a 'program running' error
#Separate error code and error message
#error code = 0 -> no errors
errCode = int(err.split(',')[0])
if errCode == -284:
#There is a 'program running' error, so program must be sweeping
return True
elif errCode == 103:
#There is a 'program being edited error' for some reason. Stop editing
self.log("Program didn't stop properly")
VISA_Driver.writeAndLog(self,'PROG:EDIT:END')
return False
else:
VISA_Driver.writeAndLog(self,'PROG:EDIT:END')
return False
else:
#Not checking one of the quants that can sweep
return False
示例11: performStopSweep
def performStopSweep(self, quant, options={}):
# This command is only necessary if in ramp mode
if quant.name.startswith("Voltage"):
mode = self.getValue("Voltage Mode")
elif quant.name.startswith("Current"):
mode = self.getValue("Voltage Mode")
else:
# if it is some other quant, call default function
VISA_Driver.performStopSweep(self, quant, options)
if mode == "Ramp":
VISA_Driver.writeAndLog(self, "ABOR")
示例12: performOpen
def performOpen(self, options={}):
"""Perform the operation of opening the instrument connection"""
# calling the generic VISA open to make sure we have a connection
VISA_Driver.performOpen(self, options=options)
# This device does not respond to *IDN?, so let's check manually
id = self.askAndLog("ID")
if not id in ("7260", "7265"):
raise InstrumentDriver.CommunicationError(
"ID query did not return 7260 or 7265. Is this the right driver for the device at the right address?"
)
return
示例13: performOpen
def performOpen(self, options={}):
"""Perform the operation of opening the instrument connection"""
# start by calling the generic VISA open to make sure we have a connection
VISA_Driver.performOpen(self, options=options)
self.amplitude = 0
self.phase = 0
self.IOffset = 0
self.QOffset = 0
self.II = 1
self.IQ = 0
self.QI = 0
self.QQ = 1
示例14: clearMessages
def clearMessages(self):
#Send version request so message buffer isn't empty
VISA_Driver.writeAndLog(self,'V')
#Read message buffer in full, to clear any messages that were not previously cleared
#(Uncleared messages seem to arise from fact that device seems to be comparatively slow to reply)
reply = VISA_Driver.read(self,ignore_termination=True)
self.log("Message buffer read on initialisation: "+reply)
while not reply.startswith('IPS120'):
#There was an error or incorrect value, try to clear message buffer again
reply = VISA_Driver.read(self,ignore_termination=True)
self.wait(delayTime)
self.log("Message buffer read again: "+reply)
示例15: performOpen
def performOpen(self, options={}):
VISA_Driver.performOpen(self, options=options)
self.data = None
self.xdisp = 0
self.xincr = 1
self.f1 = 0
self.f2 = 0
self.I1 = None
self.Q1 = None
self.I2 = None
self.Q2 = None
self.P1Mean = None
self.P2Mean = None
self.psi = None
self.covar = None