Esempio n. 1
0
 def _enable_main_coil_eos_cutoff_rule(self):
     if self.config['hold_coil']:
         self.debug_log('Enabling main coil EOS cutoff rule w/o hold')
         rule = self.machine.platform_controller.set_pulse_on_hit_and_release_and_disable_rule(
             SwitchRuleSettings(switch=self.config['activation_switch'],
                                debounce=False,
                                invert=False),
             SwitchRuleSettings(switch=self.config['eos_switch'],
                                debounce=False,
                                invert=False),
             DriverRuleSettings(driver=self.config['main_coil'],
                                recycle=False),
             PulseRuleSettings(duration=self._get_hold_pulse_ms(),
                               power=self._get_hold_pulse_power()),
             EosRuleSettings(
                 enable_repulse=self.config["repulse_on_eos_open"]))
         self._active_rules.append(rule)
     else:
         self.debug_log('Enabling main coil EOS cutoff rule w/ hold')
         rule = self.machine.platform_controller.set_pulse_on_hit_and_enable_and_release_and_disable_rule(
             SwitchRuleSettings(switch=self.config['activation_switch'],
                                debounce=False,
                                invert=False),
             SwitchRuleSettings(switch=self.config['eos_switch'],
                                debounce=False,
                                invert=False),
             DriverRuleSettings(driver=self.config['main_coil'],
                                recycle=False),
             PulseRuleSettings(duration=self._get_hold_pulse_ms(),
                               power=self._get_hold_pulse_power()),
             HoldRuleSettings(power=self._get_hold_power()),
             EosRuleSettings(
                 enable_repulse=self.config["repulse_on_eos_open"]))
         self._active_rules.append(rule)
Esempio n. 2
0
 def _test_hw_rule_hold_no_allow_enable(self):
     # enable coil which does not have allow_enable
     with self.assertRaises(AssertionError):
         self.machine.platform_controller.set_pulse_on_hit_and_enable_and_release_rule(
             SwitchRuleSettings(switch=self.machine.switches.s_test, debounce=True, invert=False),
             DriverRuleSettings(driver=self.machine.coils.c_test, recycle=False),
             PulseRuleSettings(duration=23, power=1.0))
Esempio n. 3
0
    def _test_hw_rule_pulse_disable_on_release(self):
        coil_number = self.machine.coils["c_test"].hw_driver.number
        self.pinproc.switch_update_rule = MagicMock(return_value=True)
        self.wait_for_platform()
        rule = self.machine.platform_controller.set_pulse_on_hit_and_release_rule(
            SwitchRuleSettings(switch=self.machine.switches.s_test, debounce=True, invert=False),
            DriverRuleSettings(driver=self.machine.coils.c_test, recycle=False),
            PulseRuleSettings(duration=23, power=1.0))
        self.wait_for_platform()

        self.pinproc.switch_update_rule.assert_has_calls([
            call(23, 'closed_nondebounced', {'reloadActive': False, 'notifyHost': False}, [], False),
            call(23, 'open_nondebounced', {'reloadActive': False, 'notifyHost': False}, [], False),
            call(23, 'open_debounced', {'reloadActive': False, 'notifyHost': True}, [
                {'patterOnTime': 0, 'driverNum': coil_number, 'waitForFirstTimeSlot': False, 'patterOffTime': 0,
                 'polarity': True,
                 'timeslots': 0, 'state': 0, 'patterEnable': False, 'outputDriveTime': 0, 'futureEnable': False}],
                 False),
            call(23, 'closed_debounced', {'reloadActive': False, 'notifyHost': True}, [
                {'patterOnTime': 0, 'driverNum': coil_number, 'waitForFirstTimeSlot': False, 'patterOffTime': 0,
                 'polarity': True,
                 'timeslots': 0, 'state': 1, 'patterEnable': False, 'outputDriveTime': 23, 'futureEnable': False}],
                 False),
        ], any_order=True)

        self.pinproc.switch_update_rule = MagicMock(return_value=True)
        self.machine.platform_controller.clear_hw_rule(rule)
        self.wait_for_platform()

        self.pinproc.switch_update_rule.assert_has_calls([
            call(23, 'closed_nondebounced', {'reloadActive': False, 'notifyHost': False}, []),
            call(23, 'open_nondebounced', {'reloadActive': False, 'notifyHost': False}, []),
            call(23, 'open_debounced', {'reloadActive': False, 'notifyHost': True}, []),
            call(23, 'closed_debounced', {'reloadActive': False, 'notifyHost': True}, []),
        ], any_order=True)
Esempio n. 4
0
    def enable(self, **kwargs):
        """Enable the autofire device.

        This causes the coil to respond to the switch hits. This is typically
        called when a ball starts to enable the slingshots, pops, etc.

        Note that there are several options for both the coil and the switch
        which can be incorporated into this rule, including recycle times,
        switch debounce, reversing the switch (fire the coil when the switch
        goes inactive), etc. These rules vary by hardware platform. See the
        user documentation for the hardware platform for details.

        Args:
            **kwargs: Not used, just included so this method can be used as an
                event callback.

        """
        del kwargs

        if self._enabled:
            return
        self._enabled = True

        self.debug_log("Enabling")

        recycle = True if self.config['coil_overwrite'].get('recycle', None) in (True, None) else False
        debounce = False if self.config['switch_overwrite'].get('debounce', None) in (None, "quick") else True

        self._rule = self.machine.platform_controller.set_pulse_on_hit_rule(
            SwitchRuleSettings(switch=self.config['switch'], debounce=debounce,
                               invert=self.config['reverse_switch']),
            DriverRuleSettings(driver=self.config['coil'], recycle=recycle),
            PulseRuleSettings(duration=self.config['coil_overwrite'].get('pulse_ms', None),
                              power=self.config['coil_overwrite'].get('pulse_power', None))
        )
Esempio n. 5
0
    def _enable_main_coil_pulse_rule(self):
        self.debug_log('Enabling main coil pulse rule')

        rule = self.machine.platform_controller.set_pulse_on_hit_and_release_rule(
            SwitchRuleSettings(switch=self.config['activation_switch'], debounce=False, invert=False),
            DriverRuleSettings(driver=self.config['main_coil'], recycle=False),
            PulseRuleSettings(duration=self._get_pulse_ms(), power=self._get_pulse_power())
        )
        self._active_rules.append(rule)
Esempio n. 6
0
    def _test_hw_rule_hold_allow_enable(self):
        self.machine.coils.c_test_allow_enable.hw_driver.state = MagicMock(
            return_value=8)
        rule = self.machine.platform_controller.set_pulse_on_hit_and_enable_and_release_rule(
            SwitchRuleSettings(switch=self.machine.switches.s_test,
                               debounce=True,
                               invert=False),
            DriverRuleSettings(driver=self.machine.coils.c_test_allow_enable,
                               recycle=False),
            PulseRuleSettings(duration=23, power=1.0))

        self.machine.default_platform.proc.switch_update_rule.assert_has_calls(
            [
                call(23, 'closed_debounced', {
                    'notifyHost': True,
                    'reloadActive': False
                }, [{
                    'patterEnable': False,
                    'patterOnTime': 0,
                    'timeslots': 0,
                    'futureEnable': False,
                    'state': False,
                    'patterOffTime': 0,
                    'outputDriveTime': 0,
                    'driverNum': 8,
                    'polarity': True,
                    'waitForFirstTimeSlot': False
                }], False),
                call(23, 'open_debounced', {
                    'notifyHost': True,
                    'reloadActive': False
                }, [{
                    'patterEnable': False,
                    'patterOnTime': 0,
                    'timeslots': 0,
                    'futureEnable': False,
                    'state': False,
                    'patterOffTime': 0,
                    'outputDriveTime': 0,
                    'driverNum': 10,
                    'polarity': True,
                    'waitForFirstTimeSlot': False
                }], False),
            ],
            any_order=True)

        p_roc_common.pinproc.driver_state_pulse.assert_called_with(8, 0)
        p_roc_common.pinproc.driver_state_disable.assert_called_with(8)
        self.machine.platform_controller.clear_hw_rule(rule)
Esempio n. 7
0
    def enable(self):
        """Enable the autofire device.

        This causes the coil to respond to the switch hits. This is typically
        called when a ball starts to enable the slingshots, pops, etc.

        Note that there are several options for both the coil and the switch
        which can be incorporated into this rule, including recycle times,
        switch debounce, reversing the switch (fire the coil when the switch
        goes inactive), etc. These rules vary by hardware platform. See the
        user documentation for the hardware platform for details.

        Args:
        ----
            **kwargs: Not used, just included so this method can be used as an
                event callback.

        """
        if self._enabled:
            return
        self._enabled = True

        self.debug_log("Enabling")

        if self.config['coil_overwrite'].get('recycle', None) is not None:
            # if coil_overwrite is set use it
            recycle = self.config['coil_overwrite']['recycle']
        else:
            # otherwise load the default from the coil and turn None to True
            recycle = self.config['coil'].config['default_recycle'] in (True,
                                                                        None)

        if self.config['switch_overwrite'].get('debounce', None) is not None:
            # if switch_overwrite is set use it
            debounce = self.config['switch_overwrite']['debounce'] == "normal"
        else:
            # otherwise load the default from the switch and turn auto into False
            debounce = self.config['switch'].config['debounce'] == "normal"

        if not self.config['coil_pulse_delay']:
            self._rule = self.machine.platform_controller.set_pulse_on_hit_rule(
                SwitchRuleSettings(switch=self.config['switch'],
                                   debounce=debounce,
                                   invert=self.config['reverse_switch']),
                DriverRuleSettings(driver=self.config['coil'],
                                   recycle=recycle),
                PulseRuleSettings(duration=self.config['coil_overwrite'].get(
                    'pulse_ms', None),
                                  power=self.config['coil_overwrite'].get(
                                      'pulse_power', None)))
        else:
            self._rule = self.machine.platform_controller.set_delayed_pulse_on_hit_rule(
                SwitchRuleSettings(switch=self.config['switch'],
                                   debounce=debounce,
                                   invert=self.config['reverse_switch']),
                DriverRuleSettings(driver=self.config['coil'],
                                   recycle=recycle),
                self.config['coil_pulse_delay'],
                PulseRuleSettings(duration=self.config['coil_overwrite'].get(
                    'pulse_ms', None),
                                  power=self.config['coil_overwrite'].get(
                                      'pulse_power', None)))
Esempio n. 8
0
    def _test_hw_rule_multiple_pulse(self):
        self.machine.coils.c_test.hw_driver.state = MagicMock(return_value=8)
        self.machine.platform_controller.set_pulse_on_hit_rule(
            SwitchRuleSettings(switch=self.machine.switches.s_test,
                               debounce=True,
                               invert=False),
            DriverRuleSettings(driver=self.machine.coils.c_test,
                               recycle=False),
            PulseRuleSettings(duration=23, power=1.0))

        self.wait_for_platform()
        self.pinproc.switch_update_rule.assert_has_calls([
            call(23, 'closed_debounced', {
                'notifyHost': True,
                'reloadActive': False
            }, [{
                'patterEnable': False,
                'patterOnTime': 0,
                'timeslots': 0,
                'futureEnable': False,
                'state': False,
                'patterOffTime': 0,
                'outputDriveTime': 0,
                'driverNum': 8,
                'polarity': True,
                'waitForFirstTimeSlot': False
            }], False),
        ],
                                                         any_order=True)

        p_roc_common.pinproc.driver_state_pulse.assert_called_with(8, 23)

        p_roc_common.pinproc.driver_state_pulse.assert_called_with = MagicMock(
            return_value=True)
        self.pinproc.switch_update_rule = MagicMock(return_value=True)

        # test setting the same rule again
        self.machine.coils.c_test.hw_driver.state = MagicMock(return_value=8)
        self.machine.platform_controller.set_pulse_on_hit_rule(
            SwitchRuleSettings(switch=self.machine.switches.s_test,
                               debounce=True,
                               invert=False),
            DriverRuleSettings(driver=self.machine.coils.c_test,
                               recycle=False),
            PulseRuleSettings(duration=23, power=1.0))
        self.wait_for_platform()

        self.pinproc.switch_update_rule.assert_has_calls([
            call(23, 'closed_debounced', {
                'notifyHost': True,
                'reloadActive': False
            }, [{
                'patterEnable': False,
                'patterOnTime': 0,
                'timeslots': 0,
                'futureEnable': False,
                'state': False,
                'patterOffTime': 0,
                'outputDriveTime': 0,
                'driverNum': 8,
                'polarity': True,
                'waitForFirstTimeSlot': False
            }], False),
        ],
                                                         any_order=True)

        self.machine.coils.c_coil_pwm_test.hw_driver.state = MagicMock(
            return_value=9)
        self.machine.platform_controller.set_pulse_on_hit_rule(
            SwitchRuleSettings(switch=self.machine.switches.s_test,
                               debounce=True,
                               invert=False),
            DriverRuleSettings(driver=self.machine.coils.c_coil_pwm_test,
                               recycle=False),
            PulseRuleSettings(duration=23, power=1.0))

        self.wait_for_platform()

        self.pinproc.switch_update_rule.assert_has_calls([
            call(23, 'closed_debounced', {
                'notifyHost': True,
                'reloadActive': False
            }, [
                {
                    'patterEnable': False,
                    'patterOnTime': 0,
                    'timeslots': 0,
                    'futureEnable': False,
                    'state': False,
                    'patterOffTime': 0,
                    'outputDriveTime': 0,
                    'driverNum': 8,
                    'polarity': True,
                    'waitForFirstTimeSlot': False
                },
                {
                    'patterEnable': False,
                    'patterOnTime': 0,
                    'timeslots': 0,
                    'futureEnable': False,
                    'state': False,
                    'patterOffTime': 0,
                    'outputDriveTime': 0,
                    'driverNum': 8,
                    'polarity': True,
                    'waitForFirstTimeSlot': False
                },
            ], False),
        ],
                                                         any_order=False)

        p_roc_common.pinproc.driver_state_pulse.assert_called_with(9, 23)