本文整理汇总了Python中pyoperant.utils.wait函数的典型用法代码示例。如果您正苦于以下问题:Python wait函数的具体用法?Python wait怎么用?Python wait使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wait函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: feed
def feed(self,dur=2.0,error_check=True):
"""Performs a feed
Parameters
---------
dur : float, optional
duration of feed in seconds
Returns
-------
(datetime, float)
Timestamp of the feed and the feed duration
Raises
------
HopperAlreadyUpError
The Hopper was already up at the beginning of the feed.
HopperWontComeUpError
The Hopper did not raise for the feed.
HopperWontDropError
The Hopper did not drop fater the feed.
"""
assert self.max_lag < dur, "max_lag (%ss) must be shorter than duration (%ss)" % (self.max_lag,dur)
try:
self.check()
except HopperActiveError as e:
self.solenoid.write(False)
raise HopperAlreadyUpError(e)
feed_time = self.up()
utils.wait(dur)
feed_over = self.down()
feed_duration = feed_over - feed_time
return (feed_time,feed_duration)
示例2: sound_then_feeder
def sound_then_feeder(self, filename="", duration=12, flash=False, flash_dur=3):
""" Pairs the sound playback with the feeder coming up.
Hit Ctrl+C to stop the sound or put the feeder down.
:param filename: path to sound file.
:param duration: duration the feeder is up (seconds)
:param flash: whether or not to flash the button at the start (default False)
"""
if not filename:
filename = self._default_sound_file
self.speaker.queue(filename)
if flash:
self.peck_port.flash(dur=flash_dur)
self.speaker.play()
try:
while self.speaker.output.interface.stream.is_active():
utils.wait(0.1)
except KeyboardInterrupt:
pass
finally:
self.speaker.stop()
try:
self.feeder.feed(duration)
except KeyboardInterrupt:
self.feeder.down()
示例3: stimulus_main
def stimulus_main(self):
## 1. present cue
if 'cue' in self.this_trial.annotations:
cue = self.this_trial.annotations["cue"]
self.log.debug("cue light turning on")
cue_start = dt.datetime.now()
if cue=="red":
self.panel.cue.red()
elif cue=="green":
self.panel.cue.green()
elif cue=="blue":
self.panel.cue.blue()
utils.wait(self.parameters["cue_duration"])
self.panel.cue.off()
cue_dur = (dt.datetime.now() - cue_start).total_seconds()
cue_time = (cue_start - self.this_trial.time).total_seconds()
cue_event = utils.Event(time=cue_time,
duration=cue_dur,
label='cue',
name=cue,
)
self.this_trial.events.append(cue_event)
utils.wait(self.parameters["cuetostim_wait"])
## 2. play stimulus
stim_start = dt.datetime.now()
self.this_trial.stimulus_event.time = (stim_start - self.this_trial.time).total_seconds()
self.panel.speaker.play() # already queued in stimulus_pre()
示例4: trial_post
def trial_post(self):
'''things to do at the end of a trial'''
self.this_trial.duration = (dt.datetime.now() - self.this_trial.time).total_seconds()
self.analyze_trial()
self.save_trial(self.this_trial)
self.write_summary()
utils.wait(self.parameters['intertrial_min'])
# determine if next trial should be a correction trial
self.do_correction = True
if len(self.trials) > 0:
if self.parameters['correction_trials']:
if self.this_trial.correct == True:
self.do_correction = False
elif self.this_trial.response == 'none':
if self.this_trial.type_ == 'normal':
self.do_correction = self.parameters['no_response_correction_trials']
else:
self.do_correction = False
else:
self.do_correction = False
if self.check_session_schedule()==False:
raise EndSession
if self._check_free_food_block(): return 'free_food_block'
示例5: temp
def temp():
if t_min == t_max:
t = t_max
else:
t = random.randrange(t_min, t_max)
utils.wait(t)
return next_state
示例6: up
def up(self):
self.solenoid.write(True)
utils.wait(self.lag)
try:
self.check()
except HopperInactiveError as e:
raise HopperWontComeUpError(e)
return True
示例7: timeout
def timeout(self,dur=10.0):
""" turn off light for a few seconds """
timeout_time = datetime.datetime.now()
self.light.write(False)
utils.wait(dur)
timeout_duration = datetime.datetime.now() - timeout_time
self.light.write(True)
return (timeout_time,timeout_duration)
示例8: trial_post
def trial_post(self):
'''things to do at the end of a trial'''
self.analyze_trial()
self.save_trial(self.this_trial)
self.write_summary()
utils.wait(self.parameters['intertrial_min'])
return None
示例9: down
def down(self):
""" drop hopper """
self.solenoid.write(False)
utils.wait(self.lag)
try:
self.check()
except HopperActiveError as e:
raise HopperWontDropError(e)
return True
示例10: sleep_main
def sleep_main(self):
""" reset expal parameters for the next day """
self.log.debug("sleeping...")
self.panel.house_light.off()
utils.wait(self.parameters["idle_poll_interval"])
if not utils.check_time(self.parameters["light_schedule"]):
return "main"
else:
return "post"
示例11: run
def run(self):
""" Checks every poll interval whether the panel should be sleeping and puts it to sleep """
while True:
logger.debug("sleeping")
self.experiment.panel.sleep()
utils.wait(self.poll_interval)
if not self.check():
break
self.experiment.panel.wake()
示例12: _run_idle
def _run_idle(self):
if self.check_light_schedule() == False:
return 'sleep'
elif self.check_session_schedule():
return 'session'
else:
self.panel_reset()
self.log.debug('idling...')
utils.wait(self.parameters['idle_poll_interval'])
return 'idle'
示例13: calibrate
def calibrate(self):
self.peck_port.off()
while True:
is_pecked = self.peck_port.status()
if is_pecked:
current_time = dt.datetime.now()
print("%s: Pecked!" % current_time.strftime("%H:%M:%S"))
self.peck_port.on()
utils.wait(0.05)
self.peck_port.off()
示例14: secondary_reinforcement
def secondary_reinforcement(self,value=1.0):
if "cue" in dir(self.panel):
self.panel.cue.red()
utils.wait(.05)
self.panel.cue.off()
self.panel.cue.red()
utils.wait(.05)
self.panel.cue.off()
return
else:
return self.panel.center.flash(dur=value)
示例15: flash
def flash(self,dur=1.0,isi=0.1):
""" flash the LED """
LED_state = self.LED.read()
flash_time = datetime.datetime.now()
flash_duration = datetime.datetime.now() - flash_time
while flash_duration < datetime.timedelta(seconds=dur):
self.LED.toggle()
utils.wait(isi)
flash_duration = datetime.datetime.now() - flash_time
self.LED.write(LED_state)
return (flash_time,flash_duration)