本文整理汇总了Python中interface.Interface.setChannelInterval方法的典型用法代码示例。如果您正苦于以下问题:Python Interface.setChannelInterval方法的具体用法?Python Interface.setChannelInterval怎么用?Python Interface.setChannelInterval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interface.Interface
的用法示例。
在下文中一共展示了Interface.setChannelInterval方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Controller
# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import setChannelInterval [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()