本文整理汇总了Python中Detector.Detector.start方法的典型用法代码示例。如果您正苦于以下问题:Python Detector.start方法的具体用法?Python Detector.start怎么用?Python Detector.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Detector.Detector
的用法示例。
在下文中一共展示了Detector.start方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from Detector import Detector [as 别名]
# 或者: from Detector.Detector import start [as 别名]
def get(self):
link_open = urllib2.build_opener( urllib2.HTTPCookieProcessor() )
urllib2.install_opener( link_open )
login_params = "data={\"username\":\"Spring\", \"password\":\"[email protected]\", \"mechanism\":\"plain\"}"
login_result = link_open.open( config.base_url + config.login_url, login_params )
login_data = login_result.read()
logging.info("Receive data " + login_data)
print login_data
login_json = json.loads(login_data)
login_result.close()
self.response.headers['Content-Type'] = 'text/plain'
#save sessionid for this connection
sessionid = login_json["sessionid"]
fetchor = Detector( 5, sessionid, login_json['deviceid'] )
fetchor.start()
fetchor.run()
fetchor.join()
示例2: Detector
# 需要导入模块: from Detector import Detector [as 别名]
# 或者: from Detector.Detector import start [as 别名]
login_json = json.loads(login_data)
login_result.close()
#save sessionid for this connection
sessionid = login_json["sessionid"]
print sessionid
'''
# get devices
device_params = "data={\"sessionid\":\"" + login_json["sessionid"] + "\"}"
device_result = link_open.open( base_url + device_url, device_params );
device_data = device_result.read()
device_result.close()
device_json = json.loads(device_data)
'''
# save deviceids
boundbox = (100, 100, 150, 150)
fetchor = Detector( 5, sessionid, content['deviceid'], boundbox )
fetchor.start()
fetchor.join()
#fetchor.run()
#threadone = myTimer(1,1)
#threadtow = myTimer(2,3)
#threadone.start()
#threadtow.start()
print 'OK'
finally:
print 'Finished'
示例3: DetectorThunk
# 需要导入模块: from Detector import Detector [as 别名]
# 或者: from Detector.Detector import start [as 别名]
def DetectorThunk(conn,dir='C:/PAPA Control/',datacount=1000):
"""An infinite loop for controlling the detector
Keyword arguments:
conn -- a connection stream for communicating with the main process
dir -- the directory in which to save data
datacount -- the number of data points to attempts to read at a time
The function loops through, either sleeping or recording data. It polls
its communication stream and expects a two element tuple. The first
element is an event code and the second is a tuple with the arguments for
the event.
"""
det = Detector() #detector object
running = False
paused = False
runnumber = -1
stream = None
count = 0
while True:
if (not running) and (not conn.poll()):
sleep(0.01)
continue
if conn.poll():
cmd,args=conn.recv()
if cmd==QUIT:
break
elif cmd==START:
if runnumber<=0:
logging.error("Error: Invalid Run #")
continue
if not running:
stream = open(dir+("%04d"%runnumber)+'.pel','wb')
stream.write(det.makeHeader())
det.start()
running = True
count=0
elif cmd==STOP:
if running:
det.stop()
det.clear()
running = False
stream.close()
stream=None
continue
elif cmd==PAUSE:
logging.info("Pausing Detector")
det.stop()#Do NOT clear
running = False
paused = True
elif cmd==RESUME:
if paused:
logging.info("Resuming")
det.start()
running = True
else:
logging.warning("Cannot resume: detector not paused")
elif cmd==RUNNUMBER:
runnumber = args[0]
conn.send("Run # set to %d"%runnumber)
elif cmd==DIRECTORY:
dir = args[0]
elif cmd == N_COUNT:
conn.send(count/2)#Correction Needed for 64 Bit Mode
elif cmd==PARAM:
opt,val=args
det.setParam(opt,val)
elif cmd == QUERY:
conn.send(det.status[args[0]])
#print det.status[args[0]]
else:
logging.warning("Did not recognize command %d"%cmd)
if running:
if stream is None: continue
try:
#Get the number of data points and the data
#note that num is the number of 32 bit data
#points given by the detector, which may or
#may not be the actual number of neutrons,
#depending on if the detector is in 32 or
#64 bit mode
(num,data)=det.read(datacount)
except RuntimeError,(err):
logging.error(err)
break
count += num
#Pull only the actual data from the buffer
if num < datacount:
data=data[:num]
stream.write(data.tostring())
if num < datacount:
stream.flush()
sleep(0.01)