<commit_before>"""Contains the base classes for drop targets and drop target banks."""
from enum import Enum
from typing import List, Optional
from typing import Set

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
    from mpf.core.machine import MachineController  # 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: Optional[Driver]
        self.knockdown_coil = None          # type: Optional[Driver]
        self.banks = set()                  # type: Set[DropTargetBank]
        super().__init__(machine, name)

        self._in_ball_search = False
        self.complete = False
        self.delay = DelayManager(machine)

        self._ignore_switch_hits = False

    async def _initialize(self):
        await super()._initialize()
        self.reset_coil = self.config['reset_coil']
        self.knockdown_coil = self.config['knockdown_coil']

        # can't read the switch until the switch controller is set up
        self.machine.events.add_handler('init_phase_4',
                                        self._update_state_from_switch, priority=2)
        self.machine.events.add_handler('init_phase_4',
                                        self._register_switch_handlers, priority=1)
<commit_msg>Reconcile drop target states on init<commit_after>"""Contains the base classes for drop targets and drop target banks."""
from enum import Enum
from typing import List, Optional
from typing import Set

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
    from mpf.core.machine import MachineController  # 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: Optional[Driver]
        self.knockdown_coil = None          # type: Optional[Driver]
        self.banks = set()                  # type: Set[DropTargetBank]
        super().__init__(machine, name)

        self._in_ball_search = False
        self.complete = False
        self.delay = DelayManager(machine)

        self._ignore_switch_hits = False

    async def _initialize(self):
        await super()._initialize()
        self.reset_coil = self.config['reset_coil']
        self.knockdown_coil = self.config['knockdown_coil']

        # can't read the switch until the switch controller is set up
        self.machine.events.add_handler('init_phase_4',
                                        self._update_state_from_switch, priority=2, reconcile=True)
        self.machine.events.add_handler('init_phase_4',
                                        self._register_switch_handlers, priority=1)

{'fraction_non_alphanumeric': 0.09006140550375256, 'fraction_numerical': 0.0018194223334091425, 'mean_word_length': 3.0164383561643837, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2457563', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1215, 'n_words': 330}