From a07d18f25628a515ecf7fecc71a2a39082b480e7 Mon Sep 17 00:00:00 2001 From: Anthony van Winkle Date: Mon, 3 Jun 2024 10:51:58 -0700 Subject: [PATCH] Include trigger in playfield_active events, prospector fixes --- mpf/devices/autofire.py | 2 +- mpf/devices/drop_target.py | 10 +++++----- mpf/devices/magnet.py | 2 +- mpf/devices/playfield.py | 12 ++++++------ mpf/devices/sequence_shot.py | 2 +- mpf/devices/shot.py | 2 +- mpf/devices/switch.py | 1 + 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/mpf/devices/autofire.py b/mpf/devices/autofire.py index 81ec1bd35..02fdf2430 100644 --- a/mpf/devices/autofire.py +++ b/mpf/devices/autofire.py @@ -169,7 +169,7 @@ def _hit(self): if not self._enabled: return if not self._ball_search_in_progress: - self.config['playfield'].mark_playfield_active_from_device_action() + self.config['playfield'].mark_playfield_active_from_device_action(self.name) if self._timeout_watch_time: current_time = self.machine.clock.get_time() self._timeout_hits = [t for t in self._timeout_hits if t > current_time - self._timeout_watch_time / 1000.0] diff --git a/mpf/devices/drop_target.py b/mpf/devices/drop_target.py index daefe4d03..86ab44461 100644 --- a/mpf/devices/drop_target.py +++ b/mpf/devices/drop_target.py @@ -99,7 +99,7 @@ def _ball_search_phase1(self): self.reset_coil.pulse() return True # if down. knock down again - elif self.complete and self.knockdown_coil: + if self.complete and self.knockdown_coil: self.info_log(" - complete, firing knockdown coil") self.knockdown_coil.pulse() return True @@ -221,16 +221,16 @@ def _update_state_from_switch(self, reconcile=False, **kwargs): is_complete = self.machine.switch_controller.is_active( self.config['switch']) - self.info_log("Drop target %s switch %s has active value %s compared to drop complete %s", - self.name, self.config['switch'].name, is_complete, self.complete) + self.debug_log("Drop target %s switch %s has active value %s compared to drop complete %s", + self.name, self.config['switch'].name, is_complete, self.complete) if self._in_ball_search or self._ignore_switch_hits: self.debug_log("Ignoring state change in drop target %s due to being in ball search " "or ignoring switch hits", self.name) return if not reconcile: - self.info_log("Hit without reconciling, marking playfield as active") - self.config['playfield'].mark_playfield_active_from_device_action() + self.debug_log("Hit without reconciling, marking playfield as active") + self.config['playfield'].mark_playfield_active_from_device_action(self.name) if is_complete != self.complete: diff --git a/mpf/devices/magnet.py b/mpf/devices/magnet.py index 14fd44752..c0129b15a 100644 --- a/mpf/devices/magnet.py +++ b/mpf/devices/magnet.py @@ -62,7 +62,7 @@ def event_grab_ball(self, **kwargs): def grab_ball(self): """Grab a ball.""" # mark the playfield active no matter what - self.config['playfield'].mark_playfield_active_from_device_action() + self.config['playfield'].mark_playfield_active_from_device_action(self.name) # check if magnet is enabled or already active if not self.enabled or self._active or self._release_in_progress: return diff --git a/mpf/devices/playfield.py b/mpf/devices/playfield.py index 2a9cde441..58cdda226 100644 --- a/mpf/devices/playfield.py +++ b/mpf/devices/playfield.py @@ -261,19 +261,19 @@ def ball_arrived(self): incoming_ball.ball_arrived() break - def _mark_playfield_active(self): + def _mark_playfield_active(self, source=None): self.ball_arrived() - self.machine.events.post_boolean(self.name + "_active") + self.machine.events.post_boolean(self.name + "_active", source=source) '''event: (name)_active desc: The playfield called (name) is now active, meaning there's at least one loose ball on it. ''' - def mark_playfield_active_from_device_action(self): + def mark_playfield_active_from_device_action(self, device_name=None): """Mark playfield active because a device on the playfield detected activity.""" - self._playfield_switch_hit() + self._playfield_switch_hit(source=device_name) - def _playfield_switch_hit(self, **kwargs): + def _playfield_switch_hit(self, source=None, **kwargs): """Playfield switch was hit. A switch tagged with '_active' was just hit, @@ -281,7 +281,7 @@ def _playfield_switch_hit(self, **kwargs): """ if self.balls <= 0 or (kwargs.get('balls') and self.balls - kwargs['balls'] < 0): - self._mark_playfield_active() + self._mark_playfield_active(source) if not self.num_balls_requested: self.debug_log("Playfield was activated with no balls expected.") diff --git a/mpf/devices/sequence_shot.py b/mpf/devices/sequence_shot.py index f9e94a44c..05203b927 100644 --- a/mpf/devices/sequence_shot.py +++ b/mpf/devices/sequence_shot.py @@ -102,7 +102,7 @@ def _sequence_advance(self, event_name, **kwargs): # mark playfield active if self.config['playfield']: - self.config['playfield'].mark_playfield_active_from_device_action() + self.config['playfield'].mark_playfield_active_from_device_action(self.name) self.debug_log("Sequence advance: %s", event_name) diff --git a/mpf/devices/shot.py b/mpf/devices/shot.py index 9849e1f41..ec43d4960 100644 --- a/mpf/devices/shot.py +++ b/mpf/devices/shot.py @@ -55,7 +55,7 @@ def _mark_active(self, **kwargs): """Mark playfield active.""" del kwargs if self.config['mark_playfield_active']: - self.config['playfield'].mark_playfield_active_from_device_action() + self.config['playfield'].mark_playfield_active_from_device_action(self.name) def device_loaded_in_mode(self, mode: Mode, player: Player): """Add device to a mode that was already started. diff --git a/mpf/devices/switch.py b/mpf/devices/switch.py index 100668bfe..34836d16f 100644 --- a/mpf/devices/switch.py +++ b/mpf/devices/switch.py @@ -264,4 +264,5 @@ def unmute(self, **kwargs): @property def is_muted(self): + """True if this switch is currently muted.""" return self._mutes > 0