本文整理汇总了Python中pyoperant.utils.run_state_machine函数的典型用法代码示例。如果您正苦于以下问题:Python run_state_machine函数的具体用法?Python run_state_machine怎么用?Python run_state_machine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_state_machine函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: temp
def temp():
self.recent_state = block_num
self.log.info("Starting %s" % (self.block_name(block_num)))
utils.run_state_machine(
start_in="init",
error_state="check",
error_callback=self.error_callback,
init=self._block_init("check"),
check=self._check_block("poll_mid", reps, revert_timeout),
poll_mid=self._poll(self.panel.center, 10, "check", "coin_flip"),
coin_flip=self._rand_state(("check_right", "check_center", "check_left")),
check_right=self._check_block("audio_right", reps, revert_timeout),
audio_right=self._play_audio("poll_right", "R"),
poll_right=self._flash_poll(self.panel.right, 10, "check_right", "close_audio"),
check_center=self._check_block("audio_center", reps, revert_timeout),
audio_center=self._play_audio("poll_center", "C"),
poll_center=self._flash_poll(self.panel.center, 10, "check_center", "close_audio"),
check_left=self._check_block("audio_left", reps, revert_timeout),
audio_left=self._play_audio("poll_left", "L"),
poll_left=self._flash_poll(self.panel.left, 10, "check_left", "close_audio"),
close_audio=self._close_audio("pre_reward"),
pre_reward=self._pre_reward("reward"),
reward=self.reward(2.5, "check"),
)
if not utils.check_time(self.parameters["light_schedule"]):
return "sleep_block"
if self.responded_block:
return self.block_name(block_num + 1)
else:
return self.block_name(block_num - 1)
示例2: temp
def temp():
self.recent_state = block_num
self.log.warning('Starting %s'%(self.block_name(block_num)))
if 'free_food_schedule' in self.parameters:
if utils.check_time(self.parameters['free_food_schedule']):
return 'free_food_block'
utils.run_state_machine( start_in='init',
error_state='wait',
error_callback=self.error_callback,
init=self._block_init('wait'),
wait=self._wait_block(10, 40,'check'),
check=self._check_block('flash_mid', 1, float('inf')),
flash_mid=self._flash_poll(self.panel.center, 5, 'reward', 'pre_reward'),
pre_reward=self._pre_reward('reward'),
reward=self.reward(5, 'check2'),
check2=self._check_block('wait', 1, float('inf')))
# check if its time for free food
if 'free_food_schedule' in self.parameters:
if utils.check_time(self.parameters['free_food_schedule']):
return 'free_food_block'
if not utils.check_time(self.parameters['light_schedule']):
return 'sleep_block'
return self.block_name(block_num + 1)
示例3: temp
def temp():
self.recent_state = block_num
self.log.info('Starting %s'%(self.block_name(block_num)))
utils.run_state_machine( start_in='init',
error_state='check',
error_callback=self.error_callback,
init=self._block_init('check'),
check=self._check_block('poll_mid', reps, revert_timeout),
poll_mid=self._poll(self.panel.center, 10, 'check', 'coin_flip'),
coin_flip=self._rand_state(('check_right', 'check_center', 'check_left')),
check_right=self._check_block('audio_right', reps, revert_timeout),
audio_right=self._play_audio('poll_right', 'R'),
poll_right=self._flash_poll(self.panel.right, 10, 'check_right', 'close_audio'),
check_center=self._check_block('audio_center', reps, revert_timeout),
audio_center=self._play_audio('poll_center', 'C'),
poll_center=self._flash_poll(self.panel.center, 10, 'check_center', 'close_audio'),
check_left=self._check_block('audio_left', reps, revert_timeout),
audio_left=self._play_audio('poll_left', 'L'),
poll_left=self._flash_poll(self.panel.left, 10, 'check_left', 'close_audio'),
close_audio=self._close_audio('pre_reward'),
pre_reward=self._pre_reward('reward'),
reward=self.reward(2.5, 'check'))
if not utils.check_time(self.parameters['light_schedule']):
return 'sleep_block'
if self.responded_block:
return self.block_name(block_num + 1)
else:
return self.block_name(block_num - 1)
示例4: _run_sleep
def _run_sleep(self):
utils.run_state_machine(start_in='pre',
error_state='post',
error_callback=self.error_callback,
pre=self.sleep_pre,
main=self.sleep_main,
post=self.sleep_post)
return self.block_name(self.recent_state)
示例5: _run_session
def _run_session(self):
utils.run_state_machine(start_in='pre',
error_state='post',
error_callback=self.log_error_callback,
pre=self.session_pre,
main=self.session_main,
post=self.session_post)
return 'idle'
示例6: _free_food
def _free_food(self):
self.log.debug('Starting _free_food')
utils.run_state_machine(start_in='pre',
error_state='post',
error_callback=self.log_error_callback,
pre=self.free_food_pre,
main=self.free_food_main,
post=self.free_food_post)
return 'idle'
示例7: _run_trial
def _run_trial(self):
self.log.debug('running trial')
self.log.debug("number of open file descriptors: %d" %(utils.get_num_open_fds()))
utils.run_state_machine(start_in='pre',
error_state='post',
error_callback=self.log_error_callback,
pre=self.trial_pre,
main=self.trial_main,
post=self.trial_post)
示例8: run_shape
def run_shape(self, start_state='block1'):
self.log.info('Starting shaping procedure')
utils.run_state_machine( start_in=start_state,
error_state='block1',
error_callback=self.error_callback,
block1=self.block1,
block2=self.block2,
block3=self.block3,
block4=self.block4,
block5=self.block5,
sleep_block=self._run_sleep)
self.log.info('Shaping procedure complete')
示例9: free_food_main
def free_food_main(self):
""" reset expal parameters for the next day """
self.log.debug('Starting Free Food main.')
utils.run_state_machine(start_in='wait',
error_state='wait',
error_callback=self.log_error_callback,
wait=self._wait_block(5, 5, 'food'),
food=self.deliver_free_food(10, 'checker'),
checker=self.food_checker('wait')
)
if not utils.check_time(self.parameters['free_food_schedule']):
return 'post'
else:
return 'main'
示例10: run
def run(self):
for attr in self.req_panel_attr:
assert hasattr(self.panel,attr)
self.panel_reset()
self.save()
self.init_summary()
self.log.info('%s: running %s with parameters in %s' % (self.name,
self.__class__.__name__,
self.snapshot_f,
)
)
if self.parameters['shape']:
self.shaper.run_shape(self.parameters['shape'])
while True: #is this while necessary
utils.run_state_machine(start_in='idle',
error_state='idle',
error_callback=self.log_error_callback,
idle=self._run_idle,
sleep=self._run_sleep,
session=self._run_session)
示例11: _run_stimulus
def _run_stimulus(self):
utils.run_state_machine(start_in='pre',
error_callback=self.log_error_callback,
pre=self.stimulus_pre,
main=self.stimulus_main,
post=self.stimulus_post)
示例12: _run_punish
def _run_punish(self):
utils.run_state_machine(start_in='pre',
error_callback=self.log_error_callback,
pre=self.punish_pre,
main=self.punish_main,
post=self.punish_post)
示例13: _run_consequence
def _run_consequence(self):
utils.run_state_machine(start_in='pre',
error_callback=self.log_error_callback,
pre=self.consequence_pre,
main=self.consequence_main,
post=self.consequence_post)
示例14: _run_correction_reward
def _run_correction_reward(self):
utils.run_state_machine(start_in='pre',
error_callback=self.log_error_callback,
pre=self.correction_reward_pre,
main=self.correction_reward_main,
post=self.correction_reward_post)