本文整理汇总了Python中gda.epics.CAClient.camonitor方法的典型用法代码示例。如果您正苦于以下问题:Python CAClient.camonitor方法的具体用法?Python CAClient.camonitor怎么用?Python CAClient.camonitor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gda.epics.CAClient
的用法示例。
在下文中一共展示了CAClient.camonitor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DoseControl
# 需要导入模块: from gda.epics import CAClient [as 别名]
# 或者: from gda.epics.CAClient import camonitor [as 别名]
class DoseControl(MonitorListener):
def __init__(self, name,pv):
self.name=name
self.currentpressure=0.0
self.outcli=CAClient(pv)
self.outcli.configure()
sleep(1)
self.monitor=self.outcli.camonitor(self)
def waitForGreaterThan(self, target):
while (self.getCurrentPressure() <= target):
sleep(0.1)
def getCurrentPressure(self):
return self.currentpressure
def setSystemPressure(self, sysP,target,flow):
#SET STARTING SAMPLE PRESSURE
caput("BL11I-EA-GIR-01:DVPC:SETPOINT:WR", sysP)
caput("BL11I-EA-GIR-01:MFC1:SETPOINT:WR", flow)
caput("BL11I-EA-GIR-01:BPR:SETPOINT:WR", target)
self.waitForGreaterThan(target)
caput("BL11I-EA-GIR-01:MFC1:SETPOINT:WR", 0)
def setSamplePressure(self,SampleP, target, increment):
# SET FINAL SAMPLE PRESSURE AND INCREMENTS
while SampleP <= target: #final sample pressure in bar
SampleP += increment #increments in bar
caput("BL11I-EA-GIR-01:DVPC:SETPOINT:WR", SampleP)
sleep(5) #wait time in seconds
def monitorChanged(self, mevent):
try:
self.currentpressure = float(mevent.getDBR().getDoubleValue()[0])
except:
#do nothing
print
示例2: EpicsPVWithMonitorListener
# 需要导入模块: from gda.epics import CAClient [as 别名]
# 或者: from gda.epics.CAClient import camonitor [as 别名]
class EpicsPVWithMonitorListener(PseudoDevice, MonitorListener, Runnable):
'''create a scannable that monitors the EPICS PV value changes and update its value passively.
This value is used by a running thread to control the scan processing this object participates in.
'''
def __init__(self, name, pvstring, unitstring, formatstring):
self.setName(name)
self.setInputNames([name])
self.Units=[unitstring]
self.setOutputFormat([formatstring])
self.setLevel(5)
self.outcli=CAClient(pvstring)
self.currenttemp=float(self.rawGetPosition())
self.monitor=None
self.thread=None
self.runThread=False
def atScanStart(self):
'''prepare to start scan: creating channel, monitor, and start control thread'''
if not self.outcli.isConfigured():
self.outcli.configure()
self.monitor=self.outcli.camonitor(self)
self.thread=Thread(self,"Thread: "+self.getName())
self.runThread=True
self.thread.start()
def atScanEnd(self):
'''clean up after scan finished successfully: remove monitor, destroy channel, and stop control thread'''
if self.outcli.isConfigured():
self.outcli.removeMonitor(self.monitor)
self.monitor=None
self.outcli.clearup()
self.runThread=False
self.thread=None
def rawGetPosition(self):
''' return current position.'''
output=0.0
if not self.outcli.isConfigured():
self.outcli.configure()
output=float(self.outcli.caget())
self.outcli.clearup()
else:
output=float(self.outcli.caget())
return float(output)
def rawAsynchronousMoveTo(self,position):
'''Not implemented, this is only a monitoring object'''
print "object " + self.getName()+" cannot be moved."
return
def rawIsBusy(self):
'''monitoring object never busy'''
return 0
def monitorChanged(self, mevent):
self.currenttemp = float(mevent.getDBR().getDoubleValue()[0])
def run(self):
# print "Thread: " + self.getName() + " started"
while (self.runThread):
if (JythonServerFacade.getInstance().getScanStatus() == JythonStatus.RUNNING and self.currenttemp >= float(MAXTEMP)):
JythonServerFacade.getInstance().pauseCurrentScan()
print "Scan paused as temperature " + self.getName() +" returns: "+str(self.currenttemp)
elif (JythonServerFacade.getInstance().getScanStatus() == JythonStatus.PAUSED and self.currenttemp <= float(MINTEMP)):
print "Scan resumed as temperature " + self.getName() +" returns: "+str(self.currenttemp)
JythonServerFacade.getInstance().resumeCurrentScan()
sleep(10)
def stop(self):
'''clean up after scan finished successfully: remove monitor, destroy channel,
and stop control thread on emergence stop or unexpected crash. If required, can be used to manually clean up the object.'''
if not self.monitor == None:
self.outcli.removeMonitor(self.monitor)
self.monitor=None
if self.outcli.isConfigured():
self.outcli.clearup()
if not self.thread == None:
self.runThread=False
self.thread=None