本文整理汇总了Python中VISA_Driver.VISA_Driver.performGetValue方法的典型用法代码示例。如果您正苦于以下问题:Python VISA_Driver.performGetValue方法的具体用法?Python VISA_Driver.performGetValue怎么用?Python VISA_Driver.performGetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VISA_Driver.VISA_Driver
的用法示例。
在下文中一共展示了VISA_Driver.performGetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
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
示例2: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
# do special case get value for some quantities
if quant.name == 'I Voltage':
return self.getVoltage(1)
elif quant.name == 'Q Voltage':
return self.getVoltage(2)
elif quant.name == 'I Autorange':
return self.getCommand('A', 1)
elif quant.name == 'Q Autorange':
return self.getCommand('A', 2)
elif quant.name == 'I Range':
return self.getCommand('R', 1)
elif quant.name == 'Q Range':
return self.getCommand('R', 2)
elif quant.name == 'I Offset':
return self.IOffset
elif quant.name == 'Q Offset':
return self.QOffset
elif quant.name == 'II':
return self.II
elif quant.name == 'QQ':
return self.QQ
elif quant.name == 'IQ':
return self.IQ
elif quant.name == 'QI':
return self.QI
else:
# run the generic visa driver case
return VISA_Driver.performGetValue(self, quant, options=options)
示例3: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
# perform special getValue for reading complex value
name = str(quant.name)
if name == 'Value':
# get complex value in one instrument reading
sCmd = 'SNAP?1,2'
sAns = self.askAndLog(sCmd).strip()
lData = sAns.split(',')
#Sometimes, we receive the value twice
#(0.12e-3,4.56e-70.12e-3,4.56e-7 instead of 0.12e-3,4.56e-7)
#This is a simple fix:
if len(lData) > 2:
lData = sAns[:len(sAns)/2].split(',')
#Also, sometimes we receive an additional "-" at the end of a value
#(0.12e-3,4.56e-7- instead of 0.12e-3,4.56e-7)
#Hence, another simple fix:
if lData[1][-1] == "-":
lData[1] = ldata[1][:-1]
# return complex values
return complex(float(lData[0].strip()), float(lData[1].strip()))
else:
# run the generic visa driver case
return VISA_Driver.performGetValue(self, quant, options=options)
示例4: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
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):
# select channel and set # of bytes to send
self.write(':DATA:SOU CH%d;:WFMO:BYT_N 2;' % channel, bCheckError=False)
# query range and offset
sRange = self.ask(':WFMO:XZE?;:WFMO:XIN?;:WFMO:YMU?;:WFMO:YOF?;:WFMO:YZE?;', bCheckError=False)
lRange = sRange.split(';')
(t0, dt, gain, ioffset, offset) = [float(s) for s in lRange]
# get data as i16, convert to numpy array
self.write('CURV?', bCheckError=False)
sData = self.read(ignore_termination=True)
# strip header to find # of points
i0 = sData.find('#')
nDig = int(sData[i0+1])
nByte = int(sData[i0+2:i0+2+nDig])
nData = nByte/2
# get data to numpy array
vData = np.frombuffer(sData[(i0+2+nDig):(i0+2+nDig+nByte)],
dtype='>h', count=nData)
value = InstrumentQuantity.getTraceDict( \
gain*(vData - ioffset) + offset, dt=dt)
else:
# not enabled, return empty array
value = InstrumentQuantity.getTraceDict([])
else:
# for all other cases, call VISA driver
value = VISA_Driver.performGetValue(self, quant, options)
return value
示例5: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
if (quant.datatype == quant.DOUBLE):
value = self.askAndLog(quant.set_cmd+"?")
value = value.replace(" ", "")
for i,c in enumerate(value):
if not c in "0123456789.-eE":
break
number=float(value[:i])
unit=value[i:]
factor = 1
cfactor = unit[:1]
if (cfactor == "G"):
factor = 1e9
elif (cfactor == "M"):
factor = 1e6
elif (cfactor == "k"):
factor = 1e3
elif (cfactor == "m"):
factor = 1e-3
elif (cfactor == "u"):
factor = 1e-6
elif (cfactor == "n"):
factor = 1e-9
elif (cfactor == "p"):
factor = 1e-12
v = float(number)*factor
return v
else:
value = VISA_Driver.performGetValue(self, quant, options)
return value
示例6: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
# check type of quantity
# check quantity
if quant.name == 'Magnetic Field':
reply = self.askAndLog('R7')
# strip first character
value = float(reply[1:])
else:
# for all other cases, call VISA driver
value = VISA_Driver.performGetValue(self, quant, options)
return value
示例7: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
# do special case get value for some quantities
if quant.name in ("Time", "Amplitude"):
if self.AvgTrace[quant.name] == None:
self.sample_tV()
value = self.AvgTrace[quant.name]
self.AvgTrace[quant.name] = None
else:
# run the generic visa driver case
value = VISA_Driver.performGetValue(self, quant, options=options)
return value
示例8: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
# do special case get value for some quantities
if quant.name in ('Current', 'Resistance'):
# check if charge/discharge
discharge = self.getValue('Discharge/charge before measuring')
if discharge:
delay_time = self.getValue('Delay between charging/measuring')
# start by discharging, then charging
self.writeAndLog('MD2')
self.writeAndLog('OT1')
self.writeAndLog('MD1')
# wait some time
self.wait(delay_time)
# turn on measurement mode
self.writeAndLog('MD0')
# after charging/discharing, run the visa driver case to get value
return VISA_Driver.performGetValue(self, quant, options=options)
else:
# run the generic visa driver case
return VISA_Driver.performGetValue(self, quant, options=options)
示例9: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
# perform special getValue for amplitude command
if quant.name == 'Amplitude':
# get voltage string from instrument
sAns = self.askAndLog('AMPL? VP').strip()
# strip "VP" from string
sData = sAns.split('VP')[0]
# return float
return float(sData)
else:
# for all other cases, just run the generic visa driver
return VISA_Driver.performGetValue(self, quant, options=options)
示例10: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
# perform special getValue for reading complex value
name = str(quant.name)
if name == 'Value':
# get complex value in one instrument reading
sCmd = 'SNAP?1,2'
sAns = self.askAndLog(sCmd).strip()
lData = sAns.split(',')
# return complex values
return complex(float(lData[0].strip()), float(lData[1].strip()))
else:
# run the generic visa driver case
return VISA_Driver.performGetValue(self, quant, options=options)
示例11: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
# check type of quantity
if quant.name in ('Ch 1', 'Ch 2', 'Ch 3', 'Ch 4',
'Ch 1 - Marker 1', 'Ch 1 - Marker 2',
'Ch 2 - Marker 1', 'Ch 2 - Marker 2',
'Ch 3 - Marker 1', 'Ch 3 - Marker 2',
'Ch 4 - Marker 1', 'Ch 4 - Marker 2'):
# do nothing here
value = quant.getValue()
else:
# for all other cases, call VISA driver
value = VISA_Driver.performGetValue(self, quant, options)
return value
示例12: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
# check type of quantity
if quant.name[3:] in ('Position', 'Rotation', 'Value'):
sAns = self.askAndLog(quant.get_cmd).strip()
# Remove the query string from the response
value = self.unitFactors[int(quant.name[2])]*float(sAns[len(quant.get_cmd):])
elif quant.name[3:] in ('Name'):
sAns = self.askAndLog(quant.get_cmd).strip()
# Remove the query string from the response (-1 as the query contains a question mark)
value = sAns[len(quant.get_cmd)-1:]
else:
# for all other cases, call VISA driver
value = VISA_Driver.performGetValue(self, quant, options)
return value
示例13: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
# check type of quantity
if quant.name == 'Ch1 - Data':
if self.data is None:
self.sample()
value = InstrumentQuantity.getTraceDict(self.data, t0=self.xdisp, dt=self.xincr)
self.log(str(self.data))
self.log(str(self.xdisp))
self.log(str(self.xincr))
self.data = None
elif quant.name == 'Power1Mean':
if self.P1Mean is None:
self.Psi()
value = self.P1Mean
self.P1Mean = None
elif quant.name == 'Power2Mean':
if self.P2Mean is None:
self.Psi()
value = self.P2Mean
self.P2Mean = None
elif quant.name == 'RF Frequency 1':
value = self.f1
elif quant.name == 'RF Frequency 2':
value = self.f2
elif quant.name == 'Psi':
if self.psi is None:
self.IQ_demodulate()
value = self.psi
self.psi = None
elif quant.name == 'Covar':
if self.covar is None:
self.Psi()
value = self.covar.reshape([1, -1])[0]
self.covar = None
else:
value = VISA_Driver.performGetValue(self, quant, options=options)
return value
示例14: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
# check type of quantity
# check quantity
if quant.name == 'Magnetic Field':
self.wait(delayTime)
# conversion from mT -> T
reply = self.askAndLog('R7')
# strip first character
reply = reply[1:]
# convert to float, scale from mT to T
value = 1E-3 * float(reply)
else:
# for all other cases, call VISA driver
value = VISA_Driver.performGetValue(self, quant, options)
return value
示例15: performGetValue
# 需要导入模块: from VISA_Driver import VISA_Driver [as 别名]
# 或者: from VISA_Driver.VISA_Driver import performGetValue [as 别名]
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
if quant.name in ('Time', 'Amplitude'): #for time and amplitude, call the special acquisition function
if self.AvgTrace[quant.name]==None:
self.sample_tV()
value=self.AvgTrace[quant.name]
self.AvgTrace[quant.name]=None
elif quant.name in ('RollAvg Time', 'RollAvg Amplitude'):
if self.AvgTrace[quant.name]==None:
self.sample_long()
value=self.AvgTrace[quant.name]
self.AvgTrace[quant.name]=None
elif quant.name=="Number of shifts":
value = self.numRep
else:
# otherwise run the generic visa driver case
value=VISA_Driver.performGetValue(self, quant, options=options)
return value