Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""A kickback device which will fire a ball back into the playfield."""
from mpf.core.device_monitor import DeviceMonitor
from mpf.devices.autofire import AutofireCoil
@DeviceMonitor(_enabled="enabled")
class Kickback(AutofireCoil):
"""A kickback device which will fire a ball back into the playfield."""
config_section = 'kickbacks'
collection = 'kickbacks'
class_label = 'kickback'
__slots__ = []
def _hit(self):
"""Post fired event."""
super()._hit()
if self._enabled:
self.machine.events.post("kickback_{}_fired".format(self.name))
'''event: kickback_(name)_fired
"""Contains the Led class."""
from operator import itemgetter
from mpf.core.device_monitor import DeviceMonitor
from mpf.core.machine import MachineController
from mpf.core.mode import Mode
from mpf.core.rgb_color import RGBColor
from mpf.core.rgb_color import RGBColorCorrectionProfile
from mpf.core.settings_controller import SettingEntry
from mpf.core.system_wide_device import SystemWideDevice
@DeviceMonitor(_color="color", _corrected_color="corrected_color")
class Led(SystemWideDevice):
"""An RGB LED in a pinball machine."""
config_section = 'leds'
collection = 'leds'
class_label = 'led'
machine = None
leds_to_update = set()
leds_to_fade = set()
_updater_task = None
@classmethod
def device_class_init(cls, machine: MachineController):
"""Initialise all LEDs.
from mpf.core.device_monitor import DeviceMonitor
from mpf.core.delays import DelayManager
from mpf.core.mode_device import ModeDevice
from mpf.core.player import Player
from mpf.core.mode import Mode
MYPY = False
if MYPY: # pragma: no cover
from mpf.core.machine import MachineController # pylint: disable-msg=cyclic-import,unused-import
from mpf.core.clock import PeriodicTask # pylint: disable-msg=cyclic-import,unused-import
from mpf.core.events import EventHandlerKey # pylint: disable-msg=cyclic-import,unused-import
# pylint: disable-msg=too-many-instance-attributes
@DeviceMonitor("running", "ticks", "end_value", "max_value", "start_value")
class Timer(ModeDevice):
"""Parent class for a mode timer.
Args:
machine: The main MPF MachineController object.
name: The string name of this timer.
"""
config_section = 'timers'
collection = 'timers'
class_label = 'timer'
def __init__(self, machine: "MachineController", name: str) -> None:
"""Initialise mode timer."""
super().__init__(machine, name)
"""Contains the BallLock device class."""
from collections import deque
from mpf.core.events import event_handler
from mpf.core.device_monitor import DeviceMonitor
from mpf.core.mode_device import ModeDevice
from mpf.core.system_wide_device import SystemWideDevice
@DeviceMonitor("balls_locked", "enabled", "lock_queue")
class BallLock(SystemWideDevice, ModeDevice):
"""Ball lock device which can be used to keep balls in ball devices and control their eject later on."""
config_section = 'ball_locks'
collection = 'ball_locks'
class_label = 'ball_lock'
__slots__ = ["lock_devices", "source_playfield", "balls_locked", "enabled", "_released_balls", "_release_lock",
"lock_queue"]
def __init__(self, machine, name):
"""Initialise ball lock."""
self.lock_devices = None
self.source_playfield = None
super().__init__(machine, name)
"""Implements a servo in MPF."""
import asyncio
from typing import Optional
from mpf.platforms.interfaces.stepper_platform_interface import StepperPlatformInterface
from mpf.core.delays import DelayManager
from mpf.core.device_monitor import DeviceMonitor
from mpf.core.events import event_handler
from mpf.core.system_wide_device import SystemWideDevice
@DeviceMonitor(_current_position="position", _target_position="target_position", _is_homed="is_homed")
class Stepper(SystemWideDevice):
"""Represents an stepper motor based axis in a pinball machine.
Args: Same as the Device parent class.
"""
config_section = 'steppers'
collection = 'steppers'
class_label = 'stepper'
__slots__ = ["hw_stepper", "platform", "_target_position", "_current_position", "_ball_search_started",
"_ball_search_old_target", "_is_homed", "_is_moving", "_move_task", "delay"]
def __init__(self, machine, name):
"""Initialise stepper."""
# pylint: disable-msg=too-many-arguments
def __init__(self, priority, key, start_time, start_color, dest_time, dest_color):
"""Initialize light stack entry."""
self.priority = priority
self.key = key
self.start_time = start_time
self.start_color = start_color
self.dest_time = dest_time
self.dest_color = dest_color
def __gt__(self, other):
"""Compare two stack entries."""
return self.priority > other.priority or (self.priority == other.priority and self.key > other.key)
@DeviceMonitor(_color="color", _do_not_overwrite_setter=True)
class Light(SystemWideDevice, DevicePositionMixin):
"""A light in a pinball machine."""
config_section = 'lights'
collection = 'lights'
class_label = 'light'
__slots__ = ["hw_drivers", "platforms", "delay", "default_fade_ms", "_color_correction_profile", "stack",
"hw_driver_functions", "_off_color"]
def __init__(self, machine, name):
"""Initialise light."""
self.hw_drivers = {} # type: Dict[str, List[LightPlatformInterface]]
self.hw_driver_functions = []
self.platforms = set() # type: Set[LightsPlatform]
"""Contains the GI (General Illumination) parent classes."""
from mpf.core.device_monitor import DeviceMonitor
from mpf.core.system_wide_device import SystemWideDevice
@DeviceMonitor(_brightness="brightness")
class Gi(SystemWideDevice):
"""Represents a light connected to a traditional lamp matrix in a pinball machine.
This light could be an incandescent lamp or a replacement single-color
LED. The key is that they're connected up to a lamp matrix.
"""
config_section = 'gis'
collection = 'gis'
class_label = 'gi'
def __init__(self, machine, name):
"""Initialise GI."""
self.hw_driver = None
super().__init__(machine, name)
from mpf.core.machine import MachineController
from mpf.core.mode import Mode
from mpf.core.player import Player
from mpf.core.delays import DelayManager
from mpf.core.device_monitor import DeviceMonitor
from mpf.core.events import event_handler
from mpf.core.mode_device import ModeDevice
from mpf.core.system_wide_device import SystemWideDevice
MYPY = False
if MYPY: # pragma: no cover
from mpf.devices.driver import Driver # pylint: disable-msg=cyclic-import,unused-import
@DeviceMonitor("complete")
class DropTarget(SystemWideDevice):
"""Represents a single drop target in a pinball machine.
Args: Same as the `Target` parent class
"""
config_section = 'drop_targets'
collection = 'drop_targets'
class_label = 'drop_target'
__slots__ = ["reset_coil", "knockdown_coil", "banks", "_in_ball_search", "complete", "delay", "_ignore_switch_hits"]
def __init__(self, machine: "MachineController", name: str) -> None:
"""Initialise drop target."""
self.reset_coil = None # type: Driver
"""Contains the Playfield device class which represents the actual playfield in a pinball machine."""
import asyncio
from mpf.core.device_monitor import DeviceMonitor
from mpf.core.system_wide_device import SystemWideDevice
from mpf.core.ball_search import BallSearch
from mpf.core.delays import DelayManager
from mpf.devices.ball_device.incoming_balls_handler import IncomingBall
@DeviceMonitor("available_balls", "balls",
num_balls_requested="balls_requested")
class Playfield(SystemWideDevice):
"""One playfield in a pinball machine."""
config_section = 'playfields'
collection = 'playfields'
class_label = 'playfield'
def __init__(self, machine, name):
"""Create the playfield."""
super().__init__(machine, name)
self.ball_search = BallSearch(self.machine, self)
"""An instance of :class:`mpf.core.ball_search.BallSearch` which
handles ball search for this playfield."""
"""Contains the Timed Switch device class."""
from mpf.core.device_monitor import DeviceMonitor
from mpf.core.mode_device import ModeDevice
from mpf.core.system_wide_device import SystemWideDevice
@DeviceMonitor("active_switches")
class TimedSwitch(SystemWideDevice, ModeDevice):
"""Timed Switch device."""
config_section = 'timed_switches'
collection = 'timed_switches'
class_label = 'timed_switch'
def __init__(self, machine, name):
"""Initialize Timed Switch."""
super().__init__(machine, name)
self.active_switches = set()
def validate_and_parse_config(self, config: dict, is_mode_config: bool, debug_prefix: str = None) -> dict:
"""Validate and parse config."""
config = super().validate_and_parse_config(config, is_mode_config, debug_prefix)