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.
Parent class for a mode timer.
- machine – The main MPF MachineController object.
- name – The string name of this timer.
Accessing timers in code
The device collection which contains the timers in your machine is available via
self.machine.timers. For example, to access one called “foo”, you would use
self.machine.timers.foo. You can also access timers in dictionary form, e.g.
You can also get devices by tag or hardware number. See the DeviceCollection documentation for details.
Methods & Attributes
Timers have the following methods & attributes available. Note that methods & attributes inherited from base classes are not included here.
Add ticks to this timer.
- timer_value – The number of ticks you want to add to this timer’s current value.
- kwargs – Not used in this method. Only exists since this method is often registered as an event handler which may contain additional keyword arguments.
Change the interval for each “tick” of this timer.
- change – Float or int of the change you want to make to this timer’s tick rate. Note this value is multiplied by the current tick interval: >1 will increase the tick interval (slow the timer) and <1 will decrease the tick interval (accelerate the timer). To set an absolute value, use the set_tick_interval() method.
- **kwargs – Not used in this method. Only exists since this method is often registered as an event handler which may contain additional keyword arguments.
enable() → None¶
Event handler for enable event.
format_log_line(msg, context, error_no) → str¶
Return a formatted log line with log link and context.
Get the value of a placeholder.
Set the current amount of time of this timer.
This value is expressed in “ticks” since the interval per tick can be something other than 1 second).
- timer_value – Integer of the current value you want this timer to be.
Pause the timer and posts the ‘timer_<name>_paused’ event.
- timer_value – How many seconds you want to pause the timer for. Note that this pause time is real-world seconds and does not take into consideration this timer’s tick interval.
raise_config_error(msg, error_no, *, context=None) → NoReturn¶
Raise a ConfigFileError exception.
Reset this timer based to the starting value that’s already been configured.
Does not start or stop the timer.
Restart the timer by resetting it and then starting it.
Essentially this is just a reset() then a start().
Set the number of seconds between ticks for this timer.
This is an absolute setting. To apply a change to the current value, use the change_tick_interval() method.
- timer_value – The new number of seconds between each tick of this timer. This value should always be positive.
Start this timer based on the starting value that’s already been configured.
Use jump() if you want to set the starting time value.
Stop the timer and posts the ‘timer_<name>_stopped’ event.
Subscribe to an attribute.
Subtract ticks from this timer.
- timer_value – The number of ticks you want to subtract from this timer’s current value.
Automatically called when this timer completes.
Posts the ‘timer_<name>_complete’ event. Can be manually called to mark this timer as complete.