本文整理汇总了Python中MDSplus.Data.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Data.execute方法的具体用法?Python Data.execute怎么用?Python Data.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDSplus.Data
的用法示例。
在下文中一共展示了Data.execute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: store
# 需要导入模块: from MDSplus import Data [as 别名]
# 或者: from MDSplus.Data import execute [as 别名]
def store(self,arg):
"""Stores the digital input values into the tree.
Connects to the host and for each of the DIGITAL_INS nodes which are turned on, read the digital input and store the value in the node.
"""
import os
debug=os.getenv("DEBUG_DEVICES")
try:
host=str(self.node.record.data())
except:
host='local'
if Data.execute('mdsconnect($)',host) == 0:
raise Exception,"Error connecting to host: "+host
board=int(self.board.record)
for i in range(4):
di_nid=self.__getattr__('digital_ins_di%d'%(i,1))
if di_nid.on:
try:
exp='MdsValue("_lun=fopen(\\\"/sys/module/cp7452_drv/parameters/format\\\",\\\"r+\\\"); write(_lun,\\\"1\\\"); fclose(_lun);'
exp=exp+'_lun=fopen(\\\"/dev/cp7452.%d/DI%d\\\",\\\"r\\\"); _ans=read(_lun); fclose(_lun),_ans")' % (board,i)
if debug:
print exp
value=eval('0x'+str(Data.execute(exp)))
di_nid.record=value
except Exception,e:
print "Error inputting from DI%d\n\t%s" % (i,str(e),)
示例2: init
# 需要导入模块: from MDSplus import Data [as 别名]
# 或者: from MDSplus.Data import execute [as 别名]
def init(self,arg):
"""Initialize digital outputs of CP7452 cpci board.
Connects to the host and for each of the DIGITAL_OUTS nodes which are turned on, write the value to the digital output.
"""
import os
from MDSplus import Uint32
debug=os.getenv("DEBUG_DEVICES")
try:
host=str(self.node.record.data())
except:
host='local'
if Data.execute('mdsconnect($)',host) == 0:
raise Exception,"Error connecting to host: "+host
board=int(self.board.record)
for i in range(4):
do_nid=self.__getattr__('digital_outs_do%d'%(i,))
if do_nid.on:
try:
exp='MdsValue("_lun=fopen(\\\"/sys/module/cp7452_drv/parameters/format\\\",\\\"r+\\"); write(_lun,\\\"1\\\"); fclose(_lun);'
exp=exp+'_lun=fopen(\\\"/dev/cp7452.%d/DO%d\\\",\\\"r+\\\"); write(_lun,\\\"%x\\\"); fclose(_lun)")' % (board,i,int(Uint32(do_nid.record.data()).data()))
if debug:
print exp
Data.execute(exp)
except Exception,e:
print "Error outputing to DO%d\n\t%s" % (i,str(e),)
示例3: do1darray
# 需要导入模块: from MDSplus import Data [as 别名]
# 或者: from MDSplus.Data import execute [as 别名]
def do1darray(self):
if len(self.path_parts) > 2:
self.openTree(self.path_parts[1],self.path_parts[2])
expr=self.args['expr'][-1]
try:
a=makeData(Data.execute(expr).data())
except Exception:
raise Exception("Error evaluating expression: '%s', error: %s" % (expr,sys.exc_info()))
response_headers=list()
response_headers.append(('Cache-Control','no-store, no-cache, must-revalidate'))
response_headers.append(('Pragma','no-cache'))
response_headers.append(('DTYPE',a.__class__.__name__))
response_headers.append(('LENGTH',str(len(a))))
if self.tree is not None:
response_headers.append(('TREE',self.tree))
response_headers.append(('SHOT',self.shot))
output=str(a.data().data)
status = '200 OK'
return (status, response_headers, output)
示例4: str
# 需要导入模块: from MDSplus import Data [as 别名]
# 或者: from MDSplus.Data import execute [as 别名]
knots_x = [0., 1.]
if ao_nid.on:
try:
fit = str(self.__getattr__('ouput_%2.2d_fit'))
except:
fit = 'LINEAR'
try:
knots_y = ao_nid.record.data()
knots_x = ao_nid.record.getDimensionAt(0).data()
except Exception,e:
knots_y = numpy.array([ 0., 0.])
knots_x = numpy.array([ 0., 1.])
print "Error reading data for channel %d - ZEROING ZEROING\n" % i
if fit == 'SPLINE':
wave = Data.execute('SplineFit($,$,$)', knots_x, knots_y, dim)
else:
wave = Data.execute('LinFit($,$,$)', knots_x, knots_y, dim)
counts = wave.data() / 10.*2**15
counts = numpy.int16(counts[:max_samples])
self.WriteWaveform(hostname, board, i+1, counts)
if not self.first:
self.SendFiles(hostname, hostboard, board)
else:
raise Exception, 'No channels defined aborting'
try:
Dt200WriteMaster(hostboard, 'set.ao32 %d AO_MODE %s' % (board, mode), 1)
Dt200WriteMaster(hostboard, 'set.ao32 %d AO_CLK %s %d %s' % (board, clock_src, clock_div, clock_edge), 1)
Dt200WriteMaster(hostboard, 'set.ao32 %d AO_TRG %s %s' % (board, trig_src, trig_edge), 1)
示例5: doScope
# 需要导入模块: from MDSplus import Data [as 别名]
# 或者: from MDSplus.Data import execute [as 别名]
#.........这里部分代码省略.........
outStr = outStr+' xmax = "'+encodeUrl(xmax)+'" '
if(globalDefs & (1 << GLOBAL_YMIN_IDX)):
ymin = globalYMin
else:
ymin = getValue(lines, 'Scope.plot_'+str(rowIdx)+'_'+str(colIdx)+'.ymin')
if(ymin != None):
outStr = outStr+' ymin = "'+encodeUrl(ymin)+'" '
if(globalDefs & (1 << GLOBAL_YMAX_IDX)):
ymax = globalYMax
else:
ymax = getValue(lines, 'Scope.plot_'+str(rowIdx)+'_'+str(colIdx)+'.ymax')
if(ymax != None):
outStr = outStr+' ymax = "'+encodeUrl(ymax)+'" '
title = getValue(lines, 'Scope.plot_'+str(rowIdx)+'_'+str(colIdx)+'.title')
if(title != None):
title = encodeUrl(title)
title = title.replace('"', "'")
outStr = outStr+' title = "'+title+'"'
xlabel = getValue(lines,'Scope.plot_'+str(rowIdx)+'_'+str(colIdx)+'.x_label')
if (xlabel == None):
xlabel = globalXLabel
if (xlabel != None):
xlabel = encodeUrl(xlabel)
xlabel = xlabel.replace('"',"'")
outStr = outStr+' xlabel = "'+xlabel+'"'
ylabel = getValue(lines,'Scope.plot_'+str(rowIdx)+'_'+str(colIdx)+'.y_label')
if (ylabel == None):
ylabel = globalYLabel
if (ylabel != None):
ylabel = encodeUrl(ylabel)
ylabel = ylabel.replace('"',"'")
outStr = outStr+' ylabel = "'+ylabel+'"'
event = getValue(lines,'Scope.plot_'+str(rowIdx)+'_'+str(colIdx)+'.event')
if (event == None):
event = globalEvent
if (event != None):
outStr = outStr+' event = "'+event+'"'
outStr = outStr + '>'
numExprStr = getValue(lines, 'Scope.plot_'+str(rowIdx)+'_'+str(colIdx)+'.num_expr')
if(numExprStr == None):
numExpr = 1
else:
numExpr = int(numExprStr)
for exprIdx in range(1, numExpr+1):
outStr = outStr+'<signal'
color = getValue(lines, 'Scope.plot_'+str(rowIdx)+'_'+str(colIdx)+'.color_'+str(exprIdx)+'_1')
if(color != None):
if color == 'Blak':
color = 'Black' #fix old config file typo
outStr = outStr+' color="'+color+'"'
else:
outStr = outStr + ' color="Black"'
mode = getValue(lines, 'Scope.plot_'+str(rowIdx)+'_'+str(colIdx)+'.mode_1D_'+str(exprIdx)+'_1')
marker = getValue(lines, 'Scope.plot_'+str(rowIdx)+'_'+str(colIdx)+'.marker_'+str(exprIdx)+'_1')
if(mode == 'Line' and marker == '0'):
outStr = outStr+ ' mode="1"'
elif(mode == 'Line' and marker != '0'):
outStr = outStr+ ' mode="3"'
elif(mode == 'Noline' and marker != '0'):
outStr = outStr+ ' mode="2"'
outStr = outStr+'>'
yExpr = getValue(lines, 'Scope.plot_'+str(rowIdx)+'_'+str(colIdx)+'.y_expr_'+str(exprIdx))
if(yExpr == None):
yExpr = getValue(lines, 'Scope.plot_'+str(rowIdx)+'_'+str(colIdx)+'.y')
xExpr = getValue(lines, 'Scope.plot_'+str(rowIdx)+'_'+str(colIdx)+'.x_expr_'+str(exprIdx))
if(xExpr == None):
xExpr = getValue(lines, 'Scope.plot_'+str(rowIdx)+'_'+str(colIdx)+'.x')
if(xExpr == None):
outStr = outStr+encodeUrl(yExpr)+'</signal>'
else:
outStr = outStr+'BUILD_SIGNAL('+encodeUrl(yExpr)+',,'+encodeUrl(xExpr)+')</signal>'
outStr = outStr+'</panel>\n'
outStr = outStr+'</column>\n\n'
outStr = outStr+'</columns></scope>'
output=str(outStr)
status = '200 OK'
return (status, response_headers, output)
elif 'panel' in self.args:
return doScopepanel(self)
elif 'title' in self.args:
response_headers.append(('Content-type','text/text'))
try:
output = str(Data.execute(self.args['title'][0]))
except Exception:
output = str(sys.exc_info()[1])+' expression was '+self.args['title'][0]
return ('200 OK',response_headers, output)
else:
ans=('400 NOT FOUND',[('Content-type','text/text'),],'')
try:
f=open(os.path.dirname(__file__)+'/../html/scope.html',"r")
contents=f.read()
f.close()
ans = ('200 OK',[('Content-type','text/html'),],contents)
except:
pass
return ans
示例6: getStringExp
# 需要导入模块: from MDSplus import Data [as 别名]
# 或者: from MDSplus.Data import execute [as 别名]
def getStringExp(self,name,response_headers):
if name in self.args:
try:
response_headers.append((name,str(Data.execute(self.args[name][-1]).data())))
except Exception:
response_headers.append((name,str(sys.exc_info()[1])))
示例7: doScopepanel
# 需要导入模块: from MDSplus import Data [as 别名]
# 或者: from MDSplus.Data import execute [as 别名]
def doScopepanel(self):
def getStringExp(self,name,response_headers):
if name in self.args:
try:
response_headers.append((name,str(Data.execute(self.args[name][-1]).data())))
except Exception:
response_headers.append((name,str(sys.exc_info()[1])))
response_headers=list()
response_headers.append(('Cache-Control','no-store, no-cache, must-revalidate'))
response_headers.append(('Pragma','no-cache'))
if 'tree' in self.args:
Tree.usePrivateCtx()
try:
t=Tree(self.args['tree'][-1],int(self.args['shot'][-1].split(',')[0]))
except:
pass
for name in ('title','xlabel','ylabel','xmin','xmax','ymin','ymax'):
getStringExp(self,name,response_headers)
sig_idx=0
output=''
if 'tree' in self.args:
shots=self.args['shot'][-1].split(',')
for shot in shots:
y_idx=1
y_idx_s='%d' % (y_idx,)
while 'y'+y_idx_s in self.args:
x_idx_s=y_idx_s
sig_idx=sig_idx+1
sig_idx_s='%d' % (sig_idx,)
expr=self.args['y'+y_idx_s][-1]
y_idx=y_idx+1
y_idx_s='%d' % (y_idx,)
try:
t=Tree(self.args['tree'][-1],int(shot))
response_headers.append(('SHOT'+sig_idx_s,str(t.shot)))
except Exception:
response_headers.append(('ERROR'+sig_idx_s,'Error opening tree %s, shot %s, error: %s' % (self.args['tree'][-1],shot,sys.exc_info()[1])))
continue
if 'default_node' in self.args:
try:
t.setDefault(t.getNode(self.args['default_node'][-1]))
except Exception:
response_headers.append(('ERROR'+sig_idx_s,'Error setting default to %s in tree %s, shot %s, error: %s' % (self.args['default_node'][-1],
self.args['tree'][-1],shot,sys.exc_info()[1])))
continue
try:
sig=Data.execute(expr)
y=makeData(sig.data())
except Exception:
response_headers.append(('ERROR' + sig_idx_s,'Error evaluating expression: "%s", error: %s' % (expr,sys.exc_info()[1])))
continue
if 'x'+x_idx_s in self.args:
expr=self.args['x'+x_idx_s][-1]
try:
x=Data.execute(expr)
x=makeData(x.data())
except Exception:
response_headers.append(('ERROR'+sig_idx_s,'Error evaluating expression: "%s", error: %s' % (expr,sys.exc_info()[1])))
continue
else:
try:
x=makeData(sig.dim_of().data())
except Exception:
response_headers.append(('ERROR'+sig_idx_s,'Error getting x axis of %s: "%s", error: %s' % (expr,sys.exc_info()[1])))
continue
response_headers.append(('X'+sig_idx_s+'_DATATYPE',x.__class__.__name__))
response_headers.append(('Y'+sig_idx_s+'_DATATYPE',y.__class__.__name__))
response_headers.append(('X'+sig_idx_s+'_LENGTH',str(len(x))))
response_headers.append(('Y'+sig_idx_s+'_LENGTH',str(len(y))))
output=output+str(x.data().data)+str(y.data().data)
else:
y_idx=1
y_idx_s='%d' % (y_idx,)
while 'y'+y_idx_s in self.args:
x_idx_s = y_idx_s
expr=self.args['y'+y_idx_s][-1]
y_idx=y_idx+1
y_idx_s='%d' % (y_idx,)
sig_idx=sig_idx+1
sig_idx_s='%d' % (sig_idx,)
try:
sig=Data.execute(expr)
y=makeData(sig.data())
except Exception:
response_headers.append(('ERROR' + sig_idx_s,'Error evaluating expression: "%s", error: %s' % (expr,sys.exc_info()[1])))
continue
if 'x'+x_idx_s in self.args:
expr=self.args['x'+x_idx_s][-1]
try:
x=Data.execute(expr)
x=makeData(x.data())
except Exception:
response_headers.append(('ERROR'+sig_idx_s,'Error evaluating expression: "%s", error: %s' % (expr,sys.exc_info()[1])))
continue
else:
try:
x=makeData(sig.dim_of().data())
#.........这里部分代码省略.........
示例8: init
# 需要导入模块: from MDSplus import Data [as 别名]
# 或者: from MDSplus.Data import execute [as 别名]
#.........这里部分代码省略.........
print 'Error writing DAC offset'
caenLib.CAENVME_End(handle)
return 0
#states
state = TreeNode(baseNid+self.N_CHANNEL_0 + group * self.K_NODES_PER_CHANNEL + self.N_CHAN_STATE).data()
chanEnableCode = chanEnableCode | (enabledDict[state] << group)
trigState = TreeNode(baseNid+self.N_CHANNEL_0 + group * self.K_NODES_PER_CHANNEL + self.N_CHAN_TRIG_STATE).data()
trigEnableCode = trigEnableCode | (enabledDict[trigState] << group)
#endfor group in range(0,8)
trigExt = TreeNode(baseNid + self.N_TRIG_EXT).data()
trigEnableCode = trigEnableCode | (enabledDict[trigExt] << 30)
trigSoft = TreeNode(baseNid + self.N_TRIG_SOFT).data()
trigEnableCode = trigEnableCode | (enabledDict[trigSoft] << 31)
status = caenLib.CAENVME_WriteCycle(handle, c_int(vmeAddress + 0x810C), byref(c_int(trigEnableCode)), c_int(self.cvA32_S_DATA), c_int(self.cvD32))
if status != 0:
print 'Error writing trigger configuration'
caenLib.CAENVME_End(handle)
return 0
status = caenLib.CAENVME_WriteCycle(handle, c_int(vmeAddress + 0x8120), byref(c_int(chanEnableCode)), c_int(self.cvA32_S_DATA), c_int(self.cvD32))
if status != 0:
print 'Error writing channel enabling'
caenLib.CAENVME_End(handle)
return 0
#Front Panel trigger out setting set TRIG/CLK to TTL
data = 1
status = caenLib.CAENVME_WriteCycle(handle, c_int(vmeAddress + 0x811C), byref(c_int(data)), c_int(self.cvA32_S_DATA), c_int(self.cvD32))
try:
trigSource = TreeNode(baseNid + self.N_TRIG_SOURCE).data()
#if trigger is expressed as an array, consider only the first element
print 'Trigger source: ', trigSource
if len(TreeNode(baseNid + self.N_TRIG_SOURCE).getShape()) > 0:
trigSource = trigSource[0]
except:
print 'Cannot resolve Trigger source'
caenLib.CAENVME_End(handle)
return 0
#Clock source
clockMode = TreeNode(baseNid + self.N_CLOCK_MODE).data()
if clockMode == 'EXTERNAL':
try:
clockSource = TreeNode(baseNid + self.N_CLOCK_SOURCE).getData()
print 'Clock source: ', clockSource
except:
print 'Cannot resolve Clock source'
caenLib.CAENVME_End(handle)
return 0
else:
clockSource = Range(None, None, Float64(1/62.5E6))
TreeNode(baseNid + self.N_CLOCK_SOURCE).putData(clockSource)
#Post Trigger Samples
try:
pts = TreeNode(baseNid + self.N_PTS).data()
except:
print 'Cannot resolve PTS samples'
caenLib.CAENVME_End(handle)
return 0
segmentSize = 196608/nSegments
if pts > segmentSize:
print 'PTS Larger than segmentSize'
caenLib.CAENVME_End(handle)
return 0
status = caenLib.CAENVME_WriteCycle(handle, c_int(vmeAddress + 0x8114), byref(c_int(pts)), c_int(self.cvA32_S_DATA), c_int(self.cvD32))
#Time management
useTime=TreeNode(baseNid+self.N_USE_TIME).data()
if useTime == 'YES':
try:
startTime = TreeNode(baseNid+self.N_START_TIME).data()
endTime = TreeNode(baseNid+self.N_END_TIME).data()
except:
print 'Cannot Read Start or End time'
caenLib.CAENVME_End(handle)
return 0
if endTime > 0:
endIdx = Data.execute('x_to_i($1, $2)', Dimension(Window(0, None, trigSource), clockSource), endTime + trigSource)
else:
endIdx = -Data.execute('x_to_i($1,$2)', Dimension(Window(0, None, trigSource + endTime), clockSource), trigSource)
TreeNode(baseNid + self.N_END_IDX).putData(Int32(endIdx))
if startTime > 0:
startIdx = Data.execute('x_to_i($1, $2)', Dimension(Window(0, None, trigSource), clockSource), startTime + trigSource)
else:
startIdx = -Data.execute('x_to_i($1,$2)', Dimension(Window(0, None, trigSource + startTime), clockSource), trigSource)
TreeNode(baseNid + self.N_START_IDX).putData(Int32(startIdx))
# Run device
status = caenLib.CAENVME_WriteCycle(handle, c_int(vmeAddress + 0x8100), byref(c_int(4)), c_int(self.cvA32_S_DATA), c_int(self.cvD32))
caenLib.CAENVME_End(handle)
return 1
except:
print 'Generic Error'
caenLib.CAENVME_End(handle)
return 0
示例9: doPlot
# 需要导入模块: from MDSplus import Data [as 别名]
# 或者: from MDSplus.Data import execute [as 别名]
def doPlot(self):
viewbox=[0,0,10000,10000];
def scale(xmin,ymin,xmax,ymax,xmin_s,ymin_s,xmax_s,ymax_s,x,y):
px=(x-xmin)*(xmax_s-xmin_s)/(xmax-xmin)
py=(y-ymin)*(ymax_s-ymin_s)/(ymax-ymin)
return " %d %d" % (int(round(px)),int(round(py)))
def gridScaling(min_in,max_in,divisions,span):
from math import log10,pow,fabs,ceil,floor,modf
resdivlog = log10(fabs(max_in-min_in))
if resdivlog < 0:
res = pow(10,ceil(resdivlog) - 4)
else:
res = pow(10,floor(resdivlog) - 4)
divlog = log10(fabs(max_in - min_in) / divisions)
fractpart,wholepart = modf(divlog)
intinc = pow(10,fabs(fractpart))
if intinc < 1.3333333:
intinc=1
elif intinc < 2.857:
intinc=2
else:
intinc=10
if divlog < 0:
val_inc = pow(10,-log10(intinc) + wholepart)
else:
val_inc = pow(10,log10(intinc) + wholepart)
grid=ceil(min_in/val_inc) * val_inc
divs_out = floor((max_in - grid + val_inc) / val_inc)
if max_in > min_in:
first_pix = span * ((grid - min_in) / (max_in - min_in))
pix_inc = span * val_inc / (max_in - min_in);
first_val = (first_pix * ((max_in - min_in)/span)) + min_in
else:
divs_out = 2
first_pix = 0
pix_inc = span
val_inc = 0
return {"divisions":divs_out,
"first_pixel":first_pix, "pixel_increment":pix_inc,
"first_value":first_val, "value_increment":val_inc,
"resolution":res}
if len(self.path_parts) > 2:
self.openTree(self.path_parts[1],self.path_parts[2])
expr=self.args['expr'][-1]
try:
sig=Data.execute(expr)
y=makeData(sig.data()).data()
x=makeData(sig.dim_of().data()).data()
except Exception:
raise Exception("Error evaluating expression: '%s', error: %s" % (expr,sys.exc_info()[1]))
response_headers=list()
response_headers.append(('Cache-Control','no-store, no-cache, must-revalidate'))
response_headers.append(('Pragma','no-cache'))
response_headers.append(('XDTYPE',x.__class__.__name__))
response_headers.append(('YDTYPE',y.__class__.__name__))
response_headers.append(('XLENGTH',str(len(x))))
response_headers.append(('YLENGTH',str(len(y))))
response_headers.append(('Content-type','text/xml'))
if self.tree is not None:
response_headers.append(('TREE',self.tree))
response_headers.append(('SHOT',self.shot))
output="""<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg viewBox="%d %d %d %d"
xmlns="http://www.w3.org/2000/svg" version="1.1">
""" % (viewbox[0],viewbox[1],viewbox[2],viewbox[3])
output += "<title>Plot of %s </title>" % (expr,)
output += """
<path fill="none" stroke="black" stroke-width="30" d="M """
xmin=float(min(x))
xmax=float(max(x))
ymin=float(min(y))
ymax=float(max(y))
xmin_s=float(viewbox[0])
ymin_s=float(viewbox[1])
xmax_s=float(viewbox[2])
ymax_s=float(viewbox[3])
for i in range(len(x)):
output += scale(xmin-(xmax-xmin)*.1,
ymin-(ymax-ymin)*.1,
xmax+(xmax-xmin)*.1,
ymax+(ymax-ymin)*.1,xmin_s,ymin_s,xmax_s,ymax_s,x[i],y[i])
output +=""" " />
"""
scaling=gridScaling(xmin,xmax,5,viewbox[2]-viewbox[0])
for i in range(scaling['divisions']):
output +="""<text text-anchor="middle" x="%d" y="%d" font-size="300" >%g</text>
<path fill="none" stroke="black" stroke-width="5" stroke-dasharray="200,100,50,50,50,100" d="M%d %d %d %d" />
""" % (scaling["first_pixel"]+i*scaling["pixel_increment"],
viewbox[2]-200,
round(scaling['first_value']+i*scaling["value_increment"],scaling["resolution"]),
scaling["first_pixel"]+i*scaling["pixel_increment"],
viewbox[2],
scaling["first_pixel"]+i*scaling["pixel_increment"],
viewbox[0])
#.........这里部分代码省略.........