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


Python Interface.setChannelDuration方法代码示例

本文整理汇总了Python中interface.Interface.setChannelDuration方法的典型用法代码示例。如果您正苦于以下问题:Python Interface.setChannelDuration方法的具体用法?Python Interface.setChannelDuration怎么用?Python Interface.setChannelDuration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在interface.Interface的用法示例。


在下文中一共展示了Interface.setChannelDuration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Controller

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import setChannelDuration [as 别名]
class Controller(object):

	def __init__(self, **kwargs):
		"Configure and create/store an underlying interface instance."
		settings = {
				'active' : False,
				'channel' : 1,
				'paradigm' : {},
				'triggerInterval' : None
				}
		settings.update(kwargs)
		for k,v in settings.items():
			setattr(self, k, v)

		self.interface = Interface()

	def turnOn(self):
		"""Run the paradigm on the configured channel and start the clock."""
		self.active = True
		self.runParadigm(self.paradigm)
		if self.triggerInterval:
			self.clockedTrigger()
	
	def turnOff(self):
		"""Turn off the configured channel and stop the clock."""
		self.active = False
		self.interface.changeChannelMode(self.channel, 'OFF')
		if self.triggerInterval:
			self.nextTrigger.cancel()

	def runParadigm(self, name):
		"""Send signals to program the Master 8 with the configured paradigm."""
		self.interface.clearParadigm()
		time.sleep(0.1)
		self.interface.changeChannelMode(self.channel, self.paradigm['mode'])
		if self.paradigm.has_key('DURA'):
			self.interface.setChannelDuration(self.channel, self.paradigm['DURA'])
		if self.paradigm.has_key('INTER'):
			self.interface.setChannelInterval(self.channel, self.paradigm['INTER'])
		if self.paradigm.has_key('M'):
			self.interface.setChannelM(self.channel, self.paradigm['M'])

	def sendTrigger(self):
		"""If active, send a triggre signal to the Master 8."""
		if self.active:
			self.interface.trigger(self.channel)
	
	def clockedTrigger(self):
		"""Create a trigger timer in a separate thread.

		This function calls itself; in this way, we can have regular, repeated
		signalling, since each time the function is called it starts a timer for
		calling the function again.
		"""
		self.nextTrigger = threading.Timer(
				self.triggerInterval, self.clockedTrigger)
		self.nextTrigger.start()
		self.sendTrigger()
开发者ID:smackesey,项目名称:master8,代码行数:60,代码来源:controller.py


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