mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[robotpy] Mirror robotpy's commands-v2 (#8369)
Project import generated by Copybara. GitOrigin-RevId: 715c8e8372d936f447f2937aab6b1a22dc619126
This commit is contained in:
31
commandsv2/src/main/python/commands2/schedulecommand.py
Normal file
31
commandsv2/src/main/python/commands2/schedulecommand.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# validated: 2024-01-19 DS aaea85ff1656 ScheduleCommand.java
|
||||
from __future__ import annotations
|
||||
|
||||
from .command import Command
|
||||
|
||||
|
||||
class ScheduleCommand(Command):
|
||||
"""
|
||||
Schedules the given commands when this command is initialized. Useful for forking off from
|
||||
CommandGroups. Note that if run from a composition, the composition will not know about the
|
||||
status of the scheduled commands, and will treat this command as finishing instantly.
|
||||
"""
|
||||
|
||||
def __init__(self, *commands: Command):
|
||||
"""
|
||||
Creates a new ScheduleCommand that schedules the given commands when initialized.
|
||||
|
||||
:param toSchedule: the commands to schedule
|
||||
"""
|
||||
super().__init__()
|
||||
self._toSchedule = set(commands)
|
||||
|
||||
def initialize(self):
|
||||
for command in self._toSchedule:
|
||||
command.schedule()
|
||||
|
||||
def isFinished(self) -> bool:
|
||||
return True
|
||||
|
||||
def runsWhenDisabled(self) -> bool:
|
||||
return True
|
||||
Reference in New Issue
Block a user