当前位置: 首页>>代码示例>>Python>>正文


Python CAClient.camonitor方法代码示例

本文整理汇总了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
            
开发者ID:fajinyuan,项目名称:gda-dls-beamline-i11,代码行数:40,代码来源:gdaScriptDose.py

示例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
开发者ID:openGDA,项目名称:gda-epics,代码行数:81,代码来源:threadedMonitor.py


注:本文中的gda.epics.CAClient.camonitor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。