Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bus player for MPF 0.80 (replaces Track player from MPF 0.57) #1806

Merged
merged 4 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions mpf/config_players/bus_player.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Bus player plugin for MPF to support GMC."""

from functools import partial
from mpf.config_players.plugin_player import PluginPlayer


class BusPlayer(PluginPlayer):

"""Base class for part of the bus player which runs as part of MPF.

Note: This class is loaded by MPF and everything in it is in the context of
MPF, not the mc.
"""

config_file_section = 'bus_player'
show_section = 'buses'

def _validate_config_item(self, device, device_settings):
# device is bus name, device_settings is configuration

device_settings = self.machine.config_validator.validate_config(
'bus_player', device_settings)

return_dict = dict()
return_dict[device] = device_settings

return return_dict

def _register_trigger(self, event, **kwargs):
"""Register trigger via BCP for MC."""
del kwargs
client = self.machine.bcp.transport.get_named_client("local_display")
if client:
self.machine.bcp.interface.add_registered_trigger_event_for_client(client, event)
else:
self.machine.events.add_handler("bcp_clients_connected", partial(self._register_trigger, event))
5 changes: 5 additions & 0 deletions mpf/config_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ bonus_entries:
player_score_entry: single|str|None
skip_if_zero: single|bool|true
skip_if_negative: single|bool|false
bus_player:
__valid_in__: machine, mode, show
__type__: config_player
action: single|enum(pause,stop,unpause)|
fade: single|secs|0.1sec
coils:
__valid_in__: machine
__type__: device
Expand Down
1 change: 1 addition & 0 deletions mpf/mpfconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mpf:
coil: mpf.config_players.coil_player.CoilPlayer
event: mpf.config_players.event_player.EventPlayer
blocking: mpf.config_players.block_event_player.BlockEventPlayer
bus_player: mpf.config_players.bus_player.BusPlayer
queue_event: mpf.config_players.queue_event_player.QueueEventPlayer
queue_relay: mpf.config_players.queue_relay_player.QueueRelayPlayer
flasher: mpf.config_players.flasher_player.FlasherPlayer
Expand Down
Loading