Esempio n. 1
0
    def __init__(self, machine, name):
        """Initialize Combo Switch."""
        super().__init__(machine, name)
        self.states = ['inactive', 'both', 'one']
        self._state = 'inactive'
        self._switches_1_active = False
        self._switches_2_active = False

        self.delay_registry = DelayManagerRegistry(self.machine)
        self.delay = DelayManager(self.delay_registry)
Esempio n. 2
0
    def __init__(self, mpf_path: str, machine_path: str, options: dict) -> None:
        """Initialize machine controller."""
        super().__init__()
        self.log = logging.getLogger("Machine")     # type: Logger
        self.log.info("Mission Pinball Framework Core Engine v%s", __version__)

        self.log.info("Command line arguments: %s", options)
        self.options = options
        self.config_processor = ConfigProcessor()

        self.log.info("MPF path: %s", mpf_path)
        self.mpf_path = mpf_path

        self.log.info("Machine path: %s", machine_path)
        self.machine_path = machine_path

        self.verify_system_info()
        self._exception = None      # type: Any
        self._boot_holds = set()    # type: Set[str]
        self.is_init_done = None    # type: asyncio.Event

        self._done = False
        self.monitors = dict()      # type: Dict[str, Set[Callable]]
        self.plugins = list()       # type: List[Any]
        self.scriptlets = list()    # type: List[Scriptlet]
        self.modes = DeviceCollection(self, 'modes', None)          # type: Dict[str, Mode]
        self.game = None            # type: Game
        self.machine_vars = dict()
        self.machine_var_monitor = False
        self.machine_var_data_manager = None    # type: DataManager
        self.thread_stopper = threading.Event()

        self.config = None      # type: Any

        # add some type hints
        MYPY = False    # noqa
        if MYPY:   # pragma: no cover
            # controllers
            self.events = None                          # type: EventManager
            self.switch_controller = None               # type: SwitchController
            self.mode_controller = None                 # type: ModeController
            self.settings = None                        # type: SettingsController
            self.bcp = None                             # type: Bcp
            self.asset_manager = None                   # type: BaseAssetManager
            self.ball_controller = None                 # type: BallController
            self.show_controller = None                 # type: ShowController
            self.placeholder_manager = None             # type: PlaceholderManager
            self.device_manager = None                  # type: DeviceManager
            self.auditor = None                         # type: Auditor
            self.tui = None                             # type: TextUi
            self.service = None                         # type: ServiceController

            # devices
            self.autofires = None                       # type: DeviceCollectionType[str, AutofireCoil]
            self.motors = None                          # type: DeviceCollectionType[str, Motor]
            self.digital_outputs = None                 # type: DeviceCollectionType[str, DigitalOutput]
            self.shows = None                           # type: DeviceCollectionType[str, Show]
            self.shots = None                           # type: DeviceCollectionType[str, Shot]
            self.shot_groups = None                     # type: DeviceCollectionType[str, ShotGroup]
            self.switches = None                        # type: DeviceCollectionType[str, Switch]
            self.coils = None                           # type: DeviceCollectionType[str, Driver]
            self.lights = None                          # type: DeviceCollectionType[str, Light]
            self.ball_devices = None                    # type: DeviceCollectionType[str, BallDevice]
            self.accelerometers = None                  # type: DeviceCollectionType[str, Accelerometer]
            self.playfield = None                       # type: Playfield
            self.playfields = None                      # type: DeviceCollectionType[str, Playfield]
            self.counters = None                        # type: DeviceCollectionType[str, Counter]
            self.sequences = None                       # type: DeviceCollectionType[str, Sequence]
            self.accruals = None                        # type: DeviceCollectionType[str, Accrual]
            self.drop_targets = None                    # type: DeviceCollectionType[str, DropTarget]
            self.servos = None                          # type: DeviceCollectionType[str, Servo]
            self.segment_displays = None                # type: DeviceCollectionType[str, SegmentDisplay]

        self._set_machine_path()

        self.config_validator = ConfigValidator(self)

        self._load_config()
        self.machine_config = self.config       # type: Any
        self.configure_logging(
            'Machine',
            self.config['logging']['console']['machine_controller'],
            self.config['logging']['file']['machine_controller'])

        self.delayRegistry = DelayManagerRegistry(self)
        self.delay = DelayManager(self.delayRegistry)

        self.hardware_platforms = dict()    # type: Dict[str, SmartVirtualHardwarePlatform]
        self.default_platform = None        # type: SmartVirtualHardwarePlatform

        self.clock = self._load_clock()
        self.stop_future = asyncio.Future(loop=self.clock.loop)     # type: asyncio.Future
Esempio n. 3
0
    def __init__(self, mpf_path: str, machine_path: str, options: dict):
        """Initialise machine controller."""
        self.log = logging.getLogger("Machine")
        self.log.info("Mission Pinball Framework Core Engine v%s", __version__)

        self.log.debug("Command line arguments: %s", options)
        self.options = options

        self.log.debug("MPF path: %s", mpf_path)
        self.mpf_path = mpf_path

        self.log.info("Machine path: %s", machine_path)
        self.machine_path = machine_path

        self.log.debug("Command line arguments: %s", self.options)
        self.verify_system_info()
        self._exception = None

        self._boot_holds = set()
        self.is_init_done = False
        self.register_boot_hold('init')

        self._done = False
        self.monitors = dict()
        self.plugins = list()
        self.scriptlets = list()
        self.modes = DeviceCollection(self, 'modes', None)
        self.game = None
        self.active_debugger = dict()
        self.machine_vars = CaseInsensitiveDict()
        self.machine_var_monitor = False
        self.machine_var_data_manager = None
        self.thread_stopper = threading.Event()

        self.delayRegistry = DelayManagerRegistry(self)
        self.delay = DelayManager(self.delayRegistry)

        self.crash_queue = queue.Queue()

        self.config = None
        self.events = None
        self.machine_config = None
        self._set_machine_path()

        self.config_validator = ConfigValidator(self)

        self._load_config()

        self.clock = self._load_clock()
        self._crash_queue_checker = self.clock.schedule_interval(
            self._check_crash_queue, 1)

        self.hardware_platforms = dict()
        self.default_platform = None

        self._load_hardware_platforms()

        self._initialize_credit_string()

        self._load_core_modules()
        # order is specified in mpfconfig.yaml

        # This is called so hw platforms have a chance to register for events,
        # and/or anything else they need to do with core modules since
        # they're not set up yet when the hw platforms are constructed.
        self._initialize_platforms()

        self._validate_config()

        self._register_config_players()
        self._register_system_events()
        self._load_machine_vars()
        self._run_init_phases()

        ConfigValidator.unload_config_spec()

        self.clear_boot_hold('init')