This documentation is for an unreleased version of MPF!
This is the developer documentation for MPF 0.54, which is the “dev” (next) release of MPF that is a work-in-progress. Use the “Read the Docs” link in the lower left corner to view the developer docs for the version of MPF you’re using.
Base class for a ‘Ball Device’ in a pinball machine.
A ball device is anything that can hold one or more balls, such as a trough, an eject hole, a VUK, a catapult, etc.
Args: Same as Device.
Accessing ball_devices in code
The device collection which contains the ball_devices in your machine is available via
self.machine.ball_devices. For example, to access one called “foo”, you would use
self.machine.ball_devices.foo. You can also access ball_devices in dictionary form, e.g.
You can also get devices by tag or hardware number. See the DeviceCollection documentation for details.
Methods & Attributes
Ball_devices have the following methods & attributes available. Note that methods & attributes inherited from base classes are not included here.
Notify this device that there is a ball heading its way.
Number of balls that are available to be ejected. This differs from balls since it’s possible that this device could have balls that are being used for some other eject, and thus not available.
Return the number of balls we expect in the near future.
Check if the ball is going to a certain target and cancel the path in that case.
Return the ball capacity.
eject(balls=1, target=None) → int¶
Eject balls to target.
Return the number of balls found for eject. The remaining balls are queued for eject when available.
eject_all(target=None) → bool¶
Eject all the balls from this device.
- target – The string or BallDevice target for this eject. Default of None means playfield.
- **kwargs – unused
Returns True if there are balls to eject. False if this device is empty.
event_eject(balls=1, target=None, **kwargs)¶
Handle eject control event.
Handle eject_all control event.
Event handler for entrance events.
Handle request_ball control event.
Handle an expected ball.
Try to remove available ball at the end of the path.
Find next trough after device.
Find a path to a source device which has at least one available ball.
Find a path to this target.
format_log_line(msg, context, error_no) → str¶
Return a formatted log line with log link and context.
Get the value of a placeholder.
Handle mechanical eject.
Return True if this ball device is a Playfield-type device, False if it’s a regular ball device.
Handle an outgoing lost ball.
Lost an ball while the device was idle.
Handle lost ball which was confirmed to have left source.
raise_config_error(msg, error_no, *, context=None) → NoReturn¶
Raise a ConfigFileError exception.
Remove a ball from the incoming balls queue.
Request that one or more balls is added to this device.
- balls – Integer of the number of balls that should be added to this device. A value of -1 will cause this device to try to fill itself.
- **kwargs – unused
Return the number of requested balls.
desc: A ball (or balls) have just entered the ball device called “name”.
Note that this is a relay event based on the “unclaimed_balls” arg. Any unclaimed balls in the relay will be processed as new balls entering this device.
Please be aware that we did not add those balls to balls or available_balls of the device during this event.
unclaimed_balls: The number of balls that have not yet been claimed. device: A reference to the ball device object that is posting this event.
Set the current device state.
Set up an eject chain.
Set up one hop of the eject chain.
Set up a player controlled eject.
Return the device state.
Subscribe to an attribute.
Handle an unexpected ball.
Wait until this device is ready to receive a ball.