| |
- builtins.object
-
- Game
- MotorParameters
- VibeRequest
- threading.Thread(builtins.object)
-
- Player
- ThreadedDispenser
class Game(builtins.object) |
|
Game(local_config_file: str = '~/.skeezballrc')
This class brings together players, motor, motor parameters, sensors,
ticket dispenser and various other controls into one coherent object
that represents all the stuff controllable in or attached to the
Skeezball cabinet. |
|
Methods defined here:
- __del__(self)
- __init__(self, local_config_file: str = '~/.skeezballrc')
Initialize the game controller.
• Initializes the class
• Configures all inputs and outputs and sets them into a sane condition.
• Starts the player vibe threads.
• local_config_file : A file with configuration overrides.
- dispense(self, count: int) -> None
- getConfiguration(self) -> dict[str, typing.Any]
- shutdown(self)
Data descriptors defined here:
- __dict__
dictionary for instance variables (if defined)
- __weakref__
list of weak references to the object (if defined)
|
class MotorParameters(builtins.object) |
|
MotorParameters(name: str, short_name: str, minimum: float, maximum: float, start: float)
This class manages motor parameters.
The class manages different sets of motor parameters for different uses.
Instances contains parameters for devices connected to specific outputs. |
|
Methods defined here:
- __init__(self, name: str, short_name: str, minimum: float, maximum: float, start: float)
Construct motor parameters.
• minimum : is the minimal PWM portion which will keep the motor running.
• maximum : is the maximum PWM portion to drive the motor with.
• start : is the starting PWM portion. This may exceed maximum .
To overcome the intertia of a fully-stopped motor,
the start value is momentarily applied.
Static methods defined here:
- default()
Get some default motor parameters.
- fromConfig(config: dict)
Construct a motor parameters instance from a section of configuration file.
- getMotorParameterSets() -> list[typing.Any]
Retrieve the list of motor parameter sets.
- setMotorParameterSets(params: list[dict]) -> None
Load several parameter sets into the class for future use.
Data descriptors defined here:
- __dict__
dictionary for instance variables (if defined)
- __weakref__
list of weak references to the object (if defined)
Data and other attributes defined here:
- __annotations__ = {'_parameter_sets': list[typing.Any]}
|
class Player(threading.Thread) |
|
Player(player_number: int, consent_pin: int, motor1_number: int, motor2_number: int)
|
|
- Method resolution order:
- Player
- threading.Thread
- builtins.object
Methods defined here:
- __del__(self)
- __init__(self, player_number: int, consent_pin: int, motor1_number: int, motor2_number: int)
Construct a player instance, including initializing their I/O
pins and related motors.
- allStop(self) -> None
Stop all the player's motors.
- clearStimulation(self, shutdown: bool = False) -> None
Cancel any ongoing or pending stimulation for the player.
- consent(self) -> bool
Read user's consent.
This function returns True when consent is given.
Note: HIGH=no consent; pin is pulled to ground to give consent.
Thus, we must invert the value read.
- getMotorParameters(self, motor: int) -> hwcontrol.MotorParameters
Retrieve the motor parameters.
- getThrottle(self, motor_number: int) -> int
Retrieve the current throttle level for a given motor.
Return value: Throttle position, 0-100.
- run(self) -> None
This function runs as a background thread to process stimulation
for the player.
- setMotorParameters(self, motor: int, settings: hwcontrol.MotorParameters) -> bool
Set user's motor parameters.
• motor : The motor number to set parameters for.
Motor numbering starts at 0.
• settings : The parameter parameter set.
Return value: True on success, False on set not found.
In this case, existing parameters are unchanged.
- stimulate(self, duration: float, left_vibe: waveform.Waveform | None, right_vibe: waveform.Waveform | None) -> None
Provide stimulation to the player.
If the player is already being stimulated, the request is queued.
- stopStimulation(self) -> None
Shut down the stimulation thread and ensure all motors are stopped.
- testRequest(self, name: str)
- throttle(self, motor_number: int, rate: int) -> bool
Set a rate for a motor. Also checks consent; if not given,
stops all motors and returns False.
• At 0, motor stops. Higher values are scaled into the motor
parameter range currently set for the motor.
• If a motor is off, low values will be momentarily substituted
with the start value to "give the motor a starting push".
• motor_number : The motor number to set rate on.
Motor numbering starts at 0.
• rate : The drive intensity of the motor, 0-100.
Return value: True on success, False if consent removed.
Static methods defined here:
- fromConfig(player_number: int, player_config)
Construct a player instance using parameters
from a configuration file section.
Data and other attributes defined here:
- SAMPLE_RATE = 30
- __annotations__ = {'_motors': <class 'motorsim.MotorKit'>}
Methods inherited from threading.Thread:
- __repr__(self)
Return repr(self).
- getName(self)
Return a string used for identification purposes only.
This method is deprecated, use the name attribute instead.
- isDaemon(self)
Return whether this thread is a daemon.
This method is deprecated, use the daemon attribute instead.
- is_alive(self)
Return whether the thread is alive.
This method returns True just before the run() method starts until just
after the run() method terminates. See also the module function
enumerate().
- join(self, timeout=None)
Wait until the thread terminates.
This blocks the calling thread until the thread whose join() method is
called terminates -- either normally or through an unhandled exception
or until the optional timeout occurs.
When the timeout argument is present and not None, it should be a
floating point number specifying a timeout for the operation in seconds
(or fractions thereof). As join() always returns None, you must call
is_alive() after join() to decide whether a timeout happened -- if the
thread is still alive, the join() call timed out.
When the timeout argument is not present or None, the operation will
block until the thread terminates.
A thread can be join()ed many times.
join() raises a RuntimeError if an attempt is made to join the current
thread as that would cause a deadlock. It is also an error to join() a
thread before it has been started and attempts to do so raises the same
exception.
- setDaemon(self, daemonic)
Set whether this thread is a daemon.
This method is deprecated, use the .daemon property instead.
- setName(self, name)
Set the name string for this thread.
This method is deprecated, use the name attribute instead.
- start(self)
Start the thread's activity.
It must be called at most once per thread object. It arranges for the
object's run() method to be invoked in a separate thread of control.
This method will raise a RuntimeError if called more than once on the
same thread object.
Readonly properties inherited from threading.Thread:
- ident
Thread identifier of this thread or None if it has not been started.
This is a nonzero integer. See the get_ident() function. Thread
identifiers may be recycled when a thread exits and another thread is
created. The identifier is available even after the thread has exited.
- native_id
Native integral thread ID of this thread, or None if it has not been started.
This is a non-negative integer. See the get_native_id() function.
This represents the Thread ID as reported by the kernel.
Data descriptors inherited from threading.Thread:
- __dict__
dictionary for instance variables (if defined)
- __weakref__
list of weak references to the object (if defined)
- daemon
A boolean value indicating whether this thread is a daemon thread.
This must be set before start() is called, otherwise RuntimeError is
raised. Its initial value is inherited from the creating thread; the
main thread is not a daemon thread and therefore all threads created in
the main thread default to daemon = False.
The entire Python program exits when only daemon threads are left.
- name
A string used for identification purposes only.
It has no semantics. Multiple threads may be given the same name. The
initial name is set by the constructor.
|
class ThreadedDispenser(threading.Thread) |
|
ThreadedDispenser(dispenser: dispense.Dispenser)
Threaded wrapper for a ticket dispenser.
Provides the same interface as the underlying ticket dispenser,
except it does not wait for dispensing to complete or return the
number of tickets dispensed. |
|
- Method resolution order:
- ThreadedDispenser
- threading.Thread
- builtins.object
Methods defined here:
- __del__(self)
- __init__(self, dispenser: dispense.Dispenser)
This constructor should always be called with keyword arguments. Arguments are:
*group* should be None; reserved for future extension when a ThreadGroup
class is implemented.
*target* is the callable object to be invoked by the run()
method. Defaults to None, meaning nothing is called.
*name* is the thread name. By default, a unique name is constructed of
the form "Thread-N" where N is a small decimal number.
*args* is the argument tuple for the target invocation. Defaults to ().
*kwargs* is a dictionary of keyword arguments for the target
invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke
the base class constructor (Thread.__init__()) before doing anything
else to the thread.
- dispense(self, count: int) -> None
Dispense a number of tickets.
If dispensing is not complete, why is lost.
- empty(self) -> bool
- jammed(self) -> bool
- run(self) -> None
Thread to process dispensing requests.
- stop(self) -> None
Data and other attributes defined here:
- __annotations__ = {}
Methods inherited from threading.Thread:
- __repr__(self)
Return repr(self).
- getName(self)
Return a string used for identification purposes only.
This method is deprecated, use the name attribute instead.
- isDaemon(self)
Return whether this thread is a daemon.
This method is deprecated, use the daemon attribute instead.
- is_alive(self)
Return whether the thread is alive.
This method returns True just before the run() method starts until just
after the run() method terminates. See also the module function
enumerate().
- join(self, timeout=None)
Wait until the thread terminates.
This blocks the calling thread until the thread whose join() method is
called terminates -- either normally or through an unhandled exception
or until the optional timeout occurs.
When the timeout argument is present and not None, it should be a
floating point number specifying a timeout for the operation in seconds
(or fractions thereof). As join() always returns None, you must call
is_alive() after join() to decide whether a timeout happened -- if the
thread is still alive, the join() call timed out.
When the timeout argument is not present or None, the operation will
block until the thread terminates.
A thread can be join()ed many times.
join() raises a RuntimeError if an attempt is made to join the current
thread as that would cause a deadlock. It is also an error to join() a
thread before it has been started and attempts to do so raises the same
exception.
- setDaemon(self, daemonic)
Set whether this thread is a daemon.
This method is deprecated, use the .daemon property instead.
- setName(self, name)
Set the name string for this thread.
This method is deprecated, use the name attribute instead.
- start(self)
Start the thread's activity.
It must be called at most once per thread object. It arranges for the
object's run() method to be invoked in a separate thread of control.
This method will raise a RuntimeError if called more than once on the
same thread object.
Readonly properties inherited from threading.Thread:
- ident
Thread identifier of this thread or None if it has not been started.
This is a nonzero integer. See the get_ident() function. Thread
identifiers may be recycled when a thread exits and another thread is
created. The identifier is available even after the thread has exited.
- native_id
Native integral thread ID of this thread, or None if it has not been started.
This is a non-negative integer. See the get_native_id() function.
This represents the Thread ID as reported by the kernel.
Data descriptors inherited from threading.Thread:
- __dict__
dictionary for instance variables (if defined)
- __weakref__
list of weak references to the object (if defined)
- daemon
A boolean value indicating whether this thread is a daemon thread.
This must be set before start() is called, otherwise RuntimeError is
raised. Its initial value is inherited from the creating thread; the
main thread is not a daemon thread and therefore all threads created in
the main thread default to daemon = False.
The entire Python program exits when only daemon threads are left.
- name
A string used for identification purposes only.
It has no semantics. Multiple threads may be given the same name. The
initial name is set by the constructor.
|
class VibeRequest(builtins.object) |
|
VibeRequest(duration: float, left: waveform.Waveform | None, right: waveform.Waveform | None, shutdown: bool = False)
VibeRequest(duration: float, left: waveform.Waveform | None, right: waveform.Waveform | None, shutdown: bool = False) |
|
Methods defined here:
- __eq__(self, other)
Return self==value.
- __init__(self, duration: float, left: waveform.Waveform | None, right: waveform.Waveform | None, shutdown: bool = False)
Initialize self. See help(type(self)) for accurate signature.
- __repr__(self)
Return repr(self).
Data descriptors defined here:
- __dict__
dictionary for instance variables (if defined)
- __weakref__
list of weak references to the object (if defined)
Data and other attributes defined here:
- __annotations__ = {'duration': <class 'float'>, 'stop': <class 'bool'>, 'vibration': tuple[waveform.Waveform, waveform.Waveform]}
- __dataclass_fields__ = {'duration': Field(name='duration',type=<class 'float'>,defau...appingproxy({}),kw_only=False,_field_type=_FIELD), 'stop': Field(name='stop',type=<class 'bool'>,default=<d...appingproxy({}),kw_only=False,_field_type=_FIELD), 'vibration': Field(name='vibration',type=tuple[waveform.Wavef...appingproxy({}),kw_only=False,_field_type=_FIELD)}
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)
- __hash__ = None
- __match_args__ = ('stop', 'duration', 'vibration')
| |