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


Python DelayManager._process_delays方法代码示例

本文整理汇总了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))
开发者ID:HarryXS,项目名称:mpf,代码行数:73,代码来源:smart_virtual.py


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