def run(self): """Run test1.test() function""" Tree.usePrivateCtx() stream = StringIO() try: self.result = TextTestRunner(stream=stream,verbosity=2).run(self.test) finally: stream.seek(0) self.stream = stream.read() stream.close()
def openTree(self,tree,shot): Tree.usePrivateCtx() try: shot=int(shot) except Exception: raise Exception("Invalid shot specified, must be an integer value: %s<br /><br />Error: %s" % (shot,sys.exc_info())) try: t=Tree(tree,shot) self.tree=t.tree self.shot=str(t.shot) self.treeObj=t except Exception: raise Exception("Error opening tree named %s for shot %d<br /><br />Error: %s" % (tree,shot,sys.exc_info()))
def interface(self): with Tree(self.tree,self.shot,'new') as pytree: Device.PyDevice('TestDevice').Add(pytree,'TESTDEVICE_I') Device.PyDevice('TestDevice').Add(pytree,'TESTDEVICE_S') pytree.write() pytree.normal() self.assertEqual(pytree.TESTDEVICE_S.check_source(),"No source stored in record.") pytree.TESTDEVICE_S._update_source() self.assertEqual(pytree.TESTDEVICE_S.check_source(),"") pytree.close() # needed for windows to release file lock self.assertEqual(dcl('help set verify',1,1,0)[1],None) self.assertEqual(tcl('help set tree',1,1,0)[1],None) self.assertEqual(ccl('help set xandq',1,1,0)[1],None) self.assertEqual(cts('help addcrate',1,1,0)[1],None) """ tcl commands """ self._doTCLTest('type test','test\n') if self.inThread: Tree.usePrivateCtx(1) self._doTCLTest('close/all') self._doTCLTest('show db','\n') self._doTCLTest('set tree pytree/shot=%d'%(self.shot,)) self._doTCLTest('show db','000 PYTREE shot: %d [\\PYTREE::TOP] \n\n'%self.shot) self._doTCLTest('edit PYTREE/shot=%d'%(self.shot,)) self._doTCLTest('add node TCL_NUM/usage=numeric') self._doTCLTest('add node TCL_PY_DEV/model=TESTDEVICE') self._doTCLTest('do TESTDEVICE_I:TASK_TEST') self._doTCLTest('do TESTDEVICE_S:TASK_TEST') self._doTCLTest('do TESTDEVICE_S:ACTIONSERVER:MANUAL') self._doExceptionTest('do TESTDEVICE_I:TASK_ERROR1',Exc.DevUNKOWN_STATE) # w/o timeout self._doExceptionTest('do TESTDEVICE_S:TASK_ERROR1',Exc.DevUNKOWN_STATE) # w/o timeout self._doExceptionTest('do TESTDEVICE_I:TASK_ERROR2',Exc.DevUNKOWN_STATE) # w/ timeout self._doExceptionTest('do TESTDEVICE_S:TASK_ERROR2',Exc.DevUNKOWN_STATE) # w/ timeout self._doExceptionTest('close',Exc.TreeWRITEFIRST) self._doTCLTest('write') self._doTCLTest('close') self._doTCLTest('show db','\n') """ context """ self._doTCLTest('set tree pytree/shot=%d'%(self.shot,)) pytree = Tree() self.assertEqual(str(pytree),'Tree("PYTREE",%d,"Normal")'%self.shot) self._doTCLTest('close pytree/shot=%d'%(self.shot,)) self.assertEqual(str(pytree),'Tree("?",?,"Closed")') if self.inThread: Tree.usePrivateCtx(0) """ tcl exceptions """ self._doExceptionTest('close',Exc.TreeNOT_OPEN) self._doExceptionTest('dispatch/command/server=xXxXxXx type test',Exc.ServerPATH_DOWN) self._doExceptionTest('dispatch/command/server type test',Exc.MdsdclIVVERB)
def test(): Tree('pytree', -1, 'ReadOnly').createPulse(self.shot) self.assertEqual(dcl('help set verify', 1, 1, 0)[1], None) self.assertEqual(tcl('help set tree', 1, 1, 0)[1], None) self.assertEqual(ccl('help set xandq', 1, 1, 0)[1], None) self.assertEqual(cts('help addcrate', 1, 1, 0)[1], None) """ tcl commands """ self._doTCLTest('type test', 'test\n') if self.inThread: Tree.usePrivateCtx(1) self._doTCLTest('close/all') self._doTCLTest('show db', '\n') self._doTCLTest('set tree pytree/shot=%d' % (self.shot, )) self._doTCLTest( 'show db', '000 PYTREE shot: %d [\\PYTREE::TOP] \n\n' % self.shot) self._doTCLTest('edit PYTREE/shot=%d' % (self.shot, )) self._doTCLTest('add node TCL_NUM/usage=numeric') self._doTCLTest('add node TCL_PY_DEV/model=TESTDEVICE') self._doTCLTest('do TESTDEVICE:TASK_TEST') self._doExceptionTest('do TESTDEVICE:TASK_ERROR1', Exc.DevUNKOWN_STATE) self._doExceptionTest('do TESTDEVICE:TASK_ERROR2', Exc.DevUNKOWN_STATE) self._doExceptionTest('close', Exc.TreeWRITEFIRST) self._doTCLTest('write') self._doTCLTest('close') self._doTCLTest('show db', '\n') """ context """ self._doTCLTest('set tree pytree') pytree = Tree() self.assertEqual(str(pytree), 'Tree("PYTREE",-1,"Normal")') self._doTCLTest('close pytree') self.assertEqual(str(pytree), 'Tree("PYTREE",-1,"Closed")') if self.inThread: Tree.usePrivateCtx(0) """ tcl exceptions """ self._doExceptionTest('close', Exc.TreeNOT_OPEN) self._doExceptionTest('dispatch/command/server=xXxXxXx type test', Exc.ServerPATH_DOWN) self._doExceptionTest('dispatch/command/server type test', Exc.MdsdclIVVERB)
def doFrame(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()))) response_headers = list() response_headers.append( ('Cache-Control', 'no-store, no-cache, must-revalidate')) response_headers.append(('Pragma', 'no-cache')) response_headers.append(('Content-Type', 'application/octet-stream')) if 'tree' in self.args: Tree.usePrivateCtx() try: t = Tree(self.args['tree'][-1], int(self.args['shot'][-1].split(',')[0])) except: response_headers.append(('ERROR', 'Error opening tree')) for name in ('title', 'xlabel', 'ylabel'): getStringExp(self, name, response_headers) if 'frame_idx' in self.args: frame_idx = self.args['frame_idx'][-1] else: frame_idx = '0' expr = self.args['y'][-1] try: sig = Data.execute('GetSegment(' + expr + ',' + frame_idx + ')') frame_data = makeData(sig.data()) except Exception: response_headers.append( ('ERROR', 'Error evaluating expression: "%s", error: %s' % (expr, sys.exc_info()))) if 'init' in self.args: if 'x' in self.args: expr = self.args['x'][-1] try: times = Data.execute(expr) times = makeData(times.data()) except Exception: response_headers.append( ('ERROR', 'Error evaluating expression: "%s", error: %s' % (expr, sys.exc_info()))) else: try: #times = Data.execute('dim_of(' + expr + ')') times = list() numSegments = Data.execute('GetNumSegments(' + expr + ')').data() for i in range(0, numSegments): times.append( Data.execute('GetSegmentLimits(' + expr + ',' + str(i) + ')').data()[0]) times = Float64Array(times) except Exception: response_headers.append( ('ERROR', 'Error getting x axis of: "%s", error: %s' % (expr, sys.exc_info()))) response_headers.append(('FRAME_WIDTH', str(sig.getShape()[0]))) response_headers.append(('FRAME_HEIGHT', str(sig.getShape()[1]))) response_headers.append( ('FRAME_BYTES_PER_PIXEL', str(frame_data.data().itemsize))) response_headers.append(('FRAME_LENGTH', str(len(frame_data)))) output = str(frame_data.data().data) if 'init' in self.args: response_headers.append(('TIMES_DATATYPE', times.__class__.__name__)) response_headers.append(('TIMES_LENGTH', str(len(times)))) output = output + str(times.data().data) status = '200 OK' return (status, response_headers, output)
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 + '_error:', str(sys.exc_info()))) def manageContinuousUpdate(self, x): if x.getShape().size == 1: new_max_x = x.data()[-1] else: new_max_x = x.data()[0][-1] curr_max_x = float(self.args['curr_max_x' + x_idx_s][-1]) displayed_width = float(self.args['displayed_width'][-1]) default_num_samples = float(self.args['default_num_samples'][-1]) num_samples = int( (new_max_x - curr_max_x) * default_num_samples / displayed_width) if new_max_x > curr_max_x and num_samples > 1: if issubclass(x.dtype.type, integer): min_req_x = floor(curr_max_x + 1) else: min_req_x = curr_max_x + finfo(new_max_x).eps update_function = 'MdsMisc->GetXYWave:DSC' infinity = sys.float_info.max if x.__class__.__name__ == 'Uint64Array' or x.__class__.__name__ == 'Int64Array': update_function = 'MdsMisc->GetXYWaveLongTimes:DSC' min_req_x = str(int(min_req_x)) + 'QU' infinity = str((1 << 63) - 1) + 'QU' sig = Data.execute( update_function + '(\'' + expr.replace('\\', '\\\\').replace('\'', '\\\'') + '\',' + str(min_req_x) + ',' + str(infinity) + ',' + str(num_samples) + ')') return makeData(sig.dim_of().data()), makeData(sig.data()) else: return Float64Array([]), Float64Array([]) 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) continuous_update = 'continuous_update' in self.args 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()))) 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()))) continue try: sig = Data.execute(expr) if not continuous_update: y = makeData(sig.data()) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error evaluating expression: "%s", error: %s' % (expr, sys.exc_info()))) 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()) if continuous_update: x, y = manageContinuousUpdate(self, x) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error evaluating expression: "%s", error: %s' % (expr, sys.exc_info()))) continue else: try: x = makeData(sig.dim_of().data()) if continuous_update: x, y = manageContinuousUpdate(self, x) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error getting x axis of %s:, error: %s' % (expr, sys.exc_info()))) continue if x.__class__.__name__ == 'Uint64Array' or x.__class__.__name__ == 'Int64Array': x = Float64Array( x) # Javascript doesn't support 64 bit integers response_headers.append(('X_IS_DATETIME', 'true')) 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) if not continuous_update: y = makeData(sig.data()) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error evaluating expression: "%s", error: %s' % (expr, sys.exc_info()))) 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()) if continuous_update: x, y = manageContinuousUpdate(self, x) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error evaluating expression: "%s", error: %s' % (expr, sys.exc_info()))) continue else: try: x = makeData(sig.dim_of().data()) if continuous_update: x, y = manageContinuousUpdate(self, x) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error getting x axis of %s: "%s", error: %s' % (expr, sys.exc_info()))) continue if x.__class__.__name__ == 'Uint64Array' or x.__class__.__name__ == 'Int64Array': x = Float64Array( x) # Javascript doesn't support 64 bit integers response_headers.append(('X_IS_DATETIME', 'true')) 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) return ('200 OK', response_headers, output)
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()) 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) return ('200 OK', response_headers, output)
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()) 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) return ('200 OK', response_headers, output)
def run(self): Tree.usePrivateCtx(True) try: # test open Nodes tree = Tree(self.tree, self.shot) try: tree.getNode(self.pcb) except Exception as exc: error(exc) self.pcb = None try: tree.getNode(self.cmos) except Exception as exc: error(exc) self.cmos = None except Exception as exc: error(exc) error( 'Cannot access trend tree. Check TREND:TREE and TREND_SHOT.' ) raise mdsExceptions.TreeTNF if self.pcb is None and self.cmos is None: error( 'Cannot access any node for trend. Check TREND:PCB, TREND:CMOS on. Nodes must exist on %s.' % repr(tree)) raise mdsExceptions.TreeNNF if self.pcb is None: error( 'Cannot access node for pcb trend. Check TREND:PCB. Continue with cmos trend.' ) elif self.cmos is None: error( 'Cannot access node for cmos trend. Check TREND:CMOS. Continue with pcb trend.' ) print('started trend writing to %s - %s and %s every %fs' % (self.tree, self.pcb, self.cmos, self.period)) self.running = True while (not self.stopReq): timeTillNextMeasurement = self.period - (time() % self.period) if timeTillNextMeasurement > 0.6: sleep(.5) # listen to stopReq else: sleep(timeTillNextMeasurement) # wait remaining period unit self.period currTime = int( int(time() / self.period + .1) * self.period * 1000) # currTime in steps of self.period if self.ns: currTime *= 1000000 # time in nano seconds try: if self.shot == 0: if Tree.getCurrent(self.tree) != tree.shot: tree = Tree(self.tree, self.shot) if self.pcb is not None: pcbTemp = CYGNET4K.xclib.getPcbTemp() tree.getNode(self.pcb).makeSegment( currTime, currTime, Dimension(None, Uint64Array(currTime)), Float32Array(pcbTemp).setUnits('oC'), -1) if self.cmos is not None: cmosTemp = CYGNET4K.xclib.getCmosTemp() tree.getNode(self.cmos).makeSegment( currTime, currTime, Dimension(None, Uint64Array(currTime)), Uint16Array(cmosTemp), -1) if Device.debug: print(tree.tree, tree.shot, currTime, pcbTemp, cmosTemp) except Exception: error(exc_info()[1]) error('failure during temperature readout') sleep(0.01) self.running = False print('done')
ERRORn """ 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,e: response_headers.append((name,str(e))) 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,)