-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate various commands with minor adjustments
- Update docs - Change member variables to be prefixed with _
- Loading branch information
Showing
8 changed files
with
108 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,44 @@ | ||
# validated: 2024-01-19 DS 6e58db398d63 NotifierCommand.java | ||
from __future__ import annotations | ||
|
||
from typing import Any, Callable | ||
|
||
from wpilib import Notifier | ||
from wpimath import units | ||
|
||
from .command import Command | ||
from .subsystem import Subsystem | ||
|
||
|
||
class NotifierCommand(Command): | ||
""" | ||
A command that starts a notifier to run the given runnable periodically in a separate thread. Has | ||
no end condition as-is; either subclass it or use Command#withTimeout(double) or {@link | ||
Command#until(java.util.function.BooleanSupplier)} to give it one. | ||
A command that starts a notifier to run the given Callable periodically in a separate thread. Has | ||
no end condition as-is; either subclass it or use :func:`commands2.Command.withTimeout` or :func:`commands2.Command.until` to give it one. | ||
WARNING: Do not use this class unless you are confident in your ability to make the executed | ||
code thread-safe. If you do not know what "thread-safe" means, that is a good sign that you | ||
should not use this class.""" | ||
.. warning:: Do not use this class unless you are confident in your ability | ||
to make the executed code thread-safe. If you do not know what | ||
"thread-safe" means, that is a good sign that you should not use | ||
this class. | ||
""" | ||
|
||
def __init__( | ||
self, toRun: Callable[[], Any], period: float, *requirements: Subsystem | ||
self, toRun: Callable[[], Any], period: units.seconds, *requirements: Subsystem | ||
): | ||
""" | ||
Creates a new NotifierCommand. | ||
:param toRun: the runnable for the notifier to run | ||
:param toRun: the Callable for the notifier to run | ||
:param period: the period at which the notifier should run, in seconds | ||
:param requirements: the subsystems required by this command""" | ||
:param requirements: the subsystems required by this command | ||
""" | ||
super().__init__() | ||
|
||
self.notifier = Notifier(toRun) | ||
self.period = period | ||
self._notifier = Notifier(toRun) | ||
self._period = period | ||
self.addRequirements(*requirements) | ||
|
||
def initialize(self): | ||
self.notifier.startPeriodic(self.period) | ||
self._notifier.startPeriodic(self._period) | ||
|
||
def end(self, interrupted: bool): | ||
self.notifier.stop() | ||
self._notifier.stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters