本文整理匯總了Python中mpf.system.tasks.DelayManager._process_delays方法的典型用法代碼示例。如果您正苦於以下問題:Python DelayManager._process_delays方法的具體用法?Python DelayManager._process_delays怎麽用?Python DelayManager._process_delays使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mpf.system.tasks.DelayManager
的用法示例。
在下文中一共展示了DelayManager._process_delays方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: HardwarePlatform
# 需要導入模塊: from mpf.system.tasks import DelayManager [as 別名]
# 或者: from mpf.system.tasks.DelayManager import _process_delays [as 別名]
class HardwarePlatform(VirtualPlatform):
"""Base class for the smart_virtual hardware platform."""
def __init__(self, machine):
super(HardwarePlatform, self).__init__(machine)
self.log = logging.getLogger("Smart Virtual Platform")
self.log.debug("Configuring smart_virtual hardware interface.")
self.delay = DelayManager()
def __repr__(self):
return '<Platform.SmartVirtual>'
def initialize(self):
self.machine.events.add_handler('machine_reset_phase_1',
self._initialize2)
def _initialize2(self):
for device in self.machine.ball_devices:
if not device.is_playfield() and device.config['eject_coil']:
device.config['eject_coil'].hw_driver.register_ball_switches(
device.config['ball_switches'])
if device.config['eject_targets'][0] is not self.machine.playfield:
device.config['eject_coil'].hw_driver.set_target_device(device.config['eject_targets'][0])
def configure_driver(self, config, device_type='coil'):
# todo should probably throw out the number that we get since it could
# be a weird string and just return an incremental int?
driver = SmartVirtualDriver(config['number'], self.machine, self)
driver.driver_settings = config
driver.driver_settings['pulse_ms'] = 30
return driver, config['number']
def write_hw_rule(self, *args, **kwargs):
pass
def clear_hw_rule(self, sw_name):
sw_num = self.machine.switches[sw_name].number
for entry in self.hw_switch_rules.keys(): # slice for copy
if entry.startswith(
self.machine.switches.number(sw_num).name):
del self.hw_switch_rules[entry]
def tick(self):
# ticks every hw loop (typically hundreds of times per sec)
self.delay._process_delays(self.machine)
def add_ball_to_device(self, device):
if device.config['entrance_switch']:
pass # todo
found_switch = False
if device.config['ball_switches']:
for switch in device.config['ball_switches']:
if self.machine.switch_controller.is_inactive(switch.name):
self.machine.switch_controller.process_switch(switch.name,
1,
True)
found_switch = True
break
if not found_switch:
raise AssertionError("KABOOM! We just added a ball to {} which"
"was already full.".format(device.name))